X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fbase.qh;h=73b23bbd3f224201ecffa53725fe544a3b225573;hb=3075f859f31fc7f9a7b2bcac4f2c42b96796a28a;hp=9ed316ee1574a00bdbfe517894c6c2c259e86be6;hpb=f59a071b441a5467f71532fbace066ccae9137a4;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index 9ed316ee1..73b23bbd3 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); @@ -16,11 +18,12 @@ float CallbackChain_Call(entity cb); #define MUTATOR_REMOVING 0 #define MUTATOR_ADDING 1 -float Mutator_Add(float(float) func); -void Mutator_Remove(float(float) func); // calls error() on fail +typedef float(float) mutatorfunc_t; +float Mutator_Add(mutatorfunc_t func, string name); +void Mutator_Remove(mutatorfunc_t func, string name); // calls error() on fail -#define MUTATOR_ADD(name) Mutator_Add(MUTATOR_##name) -#define MUTATOR_REMOVE(name) Mutator_Remove(MUTATOR_##name) +#define MUTATOR_ADD(name) Mutator_Add(MUTATOR_##name, #name) +#define MUTATOR_REMOVE(name) Mutator_Remove(MUTATOR_##name, #name) #define MUTATOR_DEFINITION(name) float MUTATOR_##name(float mode) #define MUTATOR_DECLARATION(name) float MUTATOR_##name(float mode) #define MUTATOR_HOOKFUNCTION(name) float HOOKFUNCTION_##name() @@ -31,6 +34,7 @@ void Mutator_Remove(float(float) func); // calls error() on fail #define MUTATOR_HOOKABLE(cb) entity HOOK_##cb #define MUTATOR_CALLHOOK(cb) CallbackChain_Call(HOOK_##cb) +#define MUTATOR_RETURNVALUE CallbackChain_ReturnValue @@ -51,10 +55,12 @@ MUTATOR_HOOKABLE(PlayerDies); // INPUT: entity frag_inflictor; entity frag_attacker; + entity frag_target; // same as self MUTATOR_HOOKABLE(GiveFragsForKill); // called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill // INPUT: + entity frag_attacker; // same as self entity frag_target; // INPUT, OUTPUT: float frag_score; @@ -92,6 +98,10 @@ MUTATOR_HOOKABLE(FilterItem); // checks if the current item may be spawned (self.items and self.weapons may be read and written to, as well as the ammo_ fields) // return error to request removal +MUTATOR_HOOKABLE(TurretSpawn); + // return error to request removal + // INPUT: self - turret + MUTATOR_HOOKABLE(OnEntityPreSpawn); // return error to prevent entity spawn, or modify the entity @@ -110,3 +120,71 @@ MUTATOR_HOOKABLE(GetCvars); // INPUT: float get_cvars_f; string get_cvars_s; + +MUTATOR_HOOKABLE(EditProjectile); + // can edit any "just fired" projectile + // INPUT: + entity self; + entity other; + +MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor); + // called when a player gets damaged to e.g. remove stuff he was carrying. + // INPUT: + entity frag_inflictor; + entity frag_attacker; + entity frag_target; // same as self + vector damage_force; // NOTE: this force already HAS been applied + // INPUT, OUTPUT: + float damage_take; + float damage_save; + +MUTATOR_HOOKABLE(PlayerDamage_Calculate); + // called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier or runematch runes + // i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage). + // INPUT: + entity frag_attacker; + entity frag_target; + float frag_deathtype; + // INPUT, OUTPUT: + float frag_damage; + vector frag_force; + +MUTATOR_HOOKABLE(PlayerPowerups); + // called at the end of player_powerups() in cl_client.qc, used for manipulating the values which are set by powerup items. + // 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; + } + */