X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Fmutators%2Fbase.qh;h=311d156304c9dbd0c99835d8ab928515e8ddc6aa;hb=4779c1bd8269aaca0d20e802c7e8e685602bb926;hp=1f42d30597128c458678b8c91d9959af58bd39bd;hpb=4ac7682d090bc3f070c4659dd719fac9569ad899;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/mutators/base.qh b/qcsrc/server/mutators/base.qh index 1f42d3059..311d15630 100644 --- a/qcsrc/server/mutators/base.qh +++ b/qcsrc/server/mutators/base.qh @@ -6,7 +6,7 @@ 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_Add(entity cb, float() func, float order); float CallbackChain_Remove(entity cb, float() func); // a callback function is like this: // float mycallback(entity me) @@ -18,6 +18,7 @@ float CallbackChain_Call(entity cb); #define MUTATOR_REMOVING 0 #define MUTATOR_ADDING 1 +#define MUTATOR_ROLLING_BACK 2 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 @@ -27,9 +28,10 @@ void Mutator_Remove(mutatorfunc_t func, string name); // calls error() on fail #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() -#define MUTATOR_HOOK(cb,func,order) do { if(mode == MUTATOR_ADDING) { if(!HOOK_##cb) HOOK_##cb = CallbackChain_New(#cb); if(!CallbackChain_Add(HOOK_##cb,HOOKFUNCTION_##func,order)) { print("HOOK FAILED: ", #func, "\n"); return 1; } } else if(mode == MUTATOR_REMOVING) { if(HOOK_##cb) CallbackChain_Remove(HOOK_##cb,HOOKFUNCTION_##func); } } while(0) +#define MUTATOR_HOOK(cb,func,order) do { if(mode == MUTATOR_ADDING) { if(!HOOK_##cb) HOOK_##cb = CallbackChain_New(#cb); if(!CallbackChain_Add(HOOK_##cb,HOOKFUNCTION_##func,order)) { print("HOOK FAILED: ", #func, "\n"); return 1; } } else if(mode == MUTATOR_REMOVING || mode == MUTATOR_ROLLING_BACK) { if(HOOK_##cb) CallbackChain_Remove(HOOK_##cb,HOOKFUNCTION_##func); } } while(0) #define MUTATOR_ONADD if(mode == MUTATOR_ADDING) #define MUTATOR_ONREMOVE if(mode == MUTATOR_REMOVING) +#define MUTATOR_ONROLLBACK_OR_REMOVE if(mode == MUTATOR_REMOVING || mode == MUTATOR_ROLLING_BACK) #define MUTATOR_HOOKABLE(cb) entity HOOK_##cb #define MUTATOR_CALLHOOK(cb) CallbackChain_Call(HOOK_##cb) @@ -44,6 +46,9 @@ void Mutator_Remove(mutatorfunc_t func, string name); // calls error() on fail MUTATOR_HOOKABLE(MakePlayerObserver); // called when a player becomes observer, after shared setup +MUTATOR_HOOKABLE(PutClientInServer); + entity self; // client wanting to spawn + 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) @@ -54,6 +59,9 @@ MUTATOR_HOOKABLE(reset_map_global); MUTATOR_HOOKABLE(reset_map_players); // called in reset_map +MUTATOR_HOOKABLE(ForbidPlayerScore_Clear); + // returns 1 if clearing player score shall not be allowed + MUTATOR_HOOKABLE(ClientDisconnect); // called when a player disconnects @@ -147,7 +155,7 @@ MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor); 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 + // called to adjust damage and force values which are applied to the player, used for e.g. strength damage/force multiplier // 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; @@ -212,6 +220,12 @@ MUTATOR_HOOKABLE(SV_StartFrame); MUTATOR_HOOKABLE(SetModname); // OUT string modname; // name of the mutator/mod if it warrants showing as such in the server browser + +MUTATOR_HOOKABLE(Item_Spawn); + // called for each item being spawned on a map, including dropped weapons + // return 1 to remove an item + // INPUT + entity self; // the item MUTATOR_HOOKABLE(SetWeaponreplace); // IN @@ -234,6 +248,10 @@ MUTATOR_HOOKABLE(HelpMePing); // INPUT entity self; // the player who pressed impulse 33 +MUTATOR_HOOKABLE(VehicleSpawn); + // called when a vehicle initializes + // return TRUE to remove the vehicle + MUTATOR_HOOKABLE(VehicleEnter); // called when a player enters a vehicle // allows mutators to set special settings in this event