X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fbase.qh;h=ecec3c87c57a65c107afb09d2b02cf457526d744;hb=d9708336de4c01e81ea08bb205093b676b7cb882;hp=05a5187e508709528c16cee43e7938027fb64d5b;hpb=5a682c6eb030594b9cc2cf652dd5ab98475095db;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index 05a5187e5..ecec3c87c 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -3,6 +3,8 @@ #define CBC_ORDER_LAST 2 #define CBC_ORDER_ANY 4 +float CallbackChain_ReturnValue; // read-only field of the current return value + entity CallbackChain_New(string name); float CallbackChain_Add(entity cb, float() func, float order) float CallbackChain_Remove(entity cb, float() func); @@ -32,6 +34,7 @@ void Mutator_Remove(mutatorfunc_t func, string name); // calls error() on fail #define MUTATOR_HOOKABLE(cb) entity HOOK_##cb #define MUTATOR_CALLHOOK(cb) CallbackChain_Call(HOOK_##cb) +#define MUTATOR_RETURNVALUE CallbackChain_ReturnValue @@ -42,6 +45,7 @@ MUTATOR_HOOKABLE(MakePlayerObserver); // called when a player becomes observer, after shared setup MUTATOR_HOOKABLE(PlayerSpawn); + entity spawn_spot; // spot that was used, or world // called when a player spawns as player, after shared setup, before his weapon is chosen (so items may be changed in here) MUTATOR_HOOKABLE(ClientDisconnect); @@ -151,3 +155,49 @@ MUTATOR_HOOKABLE(PlayerPowerups); // INPUT entity self; float olditems; // also technically output, but since it is at the end of the function it's useless for that :P + +MUTATOR_HOOKABLE(PlayerUseKey); + // called when the use key is pressed + // if MUTATOR_RETURNVALUE is 1, don't do anything + // return 1 if the use key actually did something + +MUTATOR_HOOKABLE(SV_ParseClientCommand); + // called when a client command is parsed + // NOTE: hooks MUST start with if(MUTATOR_RETURNVALUE) return 0; + // NOTE: return 1 if you handled the command, return 0 to continue handling + // NOTE: THESE HOOKS MUST NEVER EVER CALL tokenize() + // INPUT + string cmd_name; // command name + float cmd_argc; // also, argv() can be used + string cmd_string; // whole command, use only if you really have to + /* + // example: + MUTATOR_HOOKFUNCTION(foo_SV_ParseClientCommand) + { + if(MUTATOR_RETURNVALUE) // command was already handled? + return 0; + if(cmd_name == "echocvar" && cmd_argc >= 2) + { + print(cvar_string(argv(1)), "\n"); + return 1; + } + if(cmd_name == "echostring" && cmd_argc >= 2) + { + print(substring(cmd_string, argv_start_index(1), argv_end_index(-1) - argv_start_index(1)), "\n"); + return 1; + } + return 0; + } + */ + +MUTATOR_HOOKABLE(Spawn_Score); + // called when a spawnpoint is being evaluated + // return 1 to make the spawnpoint unusable + // INPUT + entity self; // player wanting to spawn + entity spawn_spot; // spot to be evaluated + // IN+OUT + vector spawn_score; // _x is priority, _y is "distance" + +MUTATOR_HOOKABLE(SV_StartFrame); + // runs globally each server frame