]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Port client mutator hooks to new arguments system
authorMario <mario@smbclan.net>
Fri, 10 Jun 2016 02:08:14 +0000 (12:08 +1000)
committerMario <mario@smbclan.net>
Fri, 10 Jun 2016 02:08:14 +0000 (12:08 +1000)
qcsrc/client/mutators/events.qh
qcsrc/common/mutators/mutator/invincibleproj/invincibleproj.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/rocketflying/rocketflying.qc
qcsrc/server/mutators/events.qh

index 4cdba48cfa8f9f0df42c481ed81425a42908a219..58ed12952a2a1a4f247a22339028a97f837af6ae 100644 (file)
@@ -2,12 +2,6 @@
 
 #include <common/mutators/base.qh>
 
-// globals
-
-string cmd_name;
-int cmd_argc;
-string cmd_string;
-
 /**
  * Called when a client command is parsed
  * NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
@@ -16,6 +10,8 @@ string cmd_string;
  * // example:
  * MUTATOR_HOOKFUNCTION(foo, CSQC_ConsoleCommand) {
  *     if (MUTATOR_RETURNVALUE) return false; // command was already handled
+ *     string cmd_name = M_ARGV(0, string);
+ *     int cmd_argc = M_ARGV(1, int);
  *     if (cmd_name == "echocvar" && cmd_argc >= 2) {
  *         print(cvar_string(argv(1)), "\n");
  *         return true;
@@ -28,9 +24,9 @@ string cmd_string;
  * }
  */
 #define EV_CSQC_ConsoleCommand(i, o) \
-       /** command name */ i(string, cmd_name) \
-       /** also, argv() can be used */ i(int, cmd_argc) \
-       /** whole command, use only if you really have to */ i(string, cmd_string) \
+       /** command name */ i(string, MUTATOR_ARGV_0_string) \
+       /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_1_int) \
+       /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_2_string) \
        /**/
 MUTATOR_HOOKABLE(CSQC_ConsoleCommand, EV_CSQC_ConsoleCommand);
 
@@ -39,13 +35,13 @@ MUTATOR_HOOKABLE(UpdateCrosshair, EV_NO_ARGS);
 
 /** Called when a projectile is linked with CSQC */
 #define EV_Ent_Projectile(i, o) \
-       /** entity id */ i(entity, __self) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
        /**/
 MUTATOR_HOOKABLE(Ent_Projectile, EV_Ent_Projectile);
 
 /** Called when a projectile's properties are being modified */
 #define EV_EditProjectile(i, o) \
-       /** entity id */ i(entity, __self) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
        /**/
 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);
 
@@ -54,25 +50,25 @@ MUTATOR_HOOKABLE(PrecacheProjectiles, EV_NO_ARGS);
 
 /** Called when updating the attached tags index */
 #define EV_TagIndex_Update(i, o) \
-       /** entity id */ i(entity, __self) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
        /**/
 MUTATOR_HOOKABLE(TagIndex_Update, EV_TagIndex_Update);
 
 /** Called when setting the attached tags */
 #define EV_TagIndex_Apply(i, o) \
-       /** entity id */ i(entity, __self) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
        /**/
 MUTATOR_HOOKABLE(TagIndex_Apply, EV_TagIndex_Apply);
 
 /** Called when setting up skeleton bones */
 #define EV_Skeleton_CheckBones(i, o) \
-       /** entity id */ i(entity, __self) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
        /**/
 MUTATOR_HOOKABLE(Skeleton_CheckBones, EV_Skeleton_CheckBones);
 
 /** Called when setting up bones from the loaded model */
 #define EV_Skeleton_CheckModel(i, o) \
-       /** entity id */ i(entity, __self) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
        /**/
 MUTATOR_HOOKABLE(Skeleton_CheckModel, EV_Skeleton_CheckModel);
 
@@ -81,21 +77,20 @@ MUTATOR_HOOKABLE(ClearModelParams, EV_NO_ARGS);
 
 /** Called when getting the global parameters for a model */
 #define EV_GetModelParams(i, o) \
-       /** entity id */ i(string, checkmodel_input) \
-       /** entity id */ i(string, checkmodel_command) \
+       /** input */  i(string, MUTATOR_ARGV_0_string) \
+       /** command */  i(string, MUTATOR_ARGV_1_string) \
        /**/
-string checkmodel_input, checkmodel_command;
 MUTATOR_HOOKABLE(GetModelParams, EV_GetModelParams);
 
 /** Called checking if 3rd person mode should be forced on */
 #define EV_WantEventchase(i, o) \
-       /** entity id */ i(entity, __self) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
        /**/
 MUTATOR_HOOKABLE(WantEventchase, EV_WantEventchase);
 
 #define EV_AnnouncerOption(i, o) \
-       /**/ i(string, ret_string) \
-       /**/ o(string, ret_string) \
+       /** announcer string */  i(string, MUTATOR_ARGV_0_string) \
+       /** announcer string */ o(string, MUTATOR_ARGV_0_string) \
        /**/
 MUTATOR_HOOKABLE(AnnouncerOption, EV_AnnouncerOption);
 
@@ -111,23 +106,20 @@ MUTATOR_HOOKABLE(HUD_Powerups_add, EV_NO_ARGS);
 
 /** Return true to not draw any vortex beam */
 #define EV_Particles_VortexBeam(i, o) \
-       /**/ i(vector, vbeam_shotorg) \
-       /**/ i(vector, vbeam_endpos) \
+       /** beam shot origin */  i(vector, MUTATOR_ARGV_0_vector) \
+       /** beam end position */ i(vector, MUTATOR_ARGV_1_vector) \
        /**/
-vector vbeam_shotorg;
-vector vbeam_endpos;
 MUTATOR_HOOKABLE(Particles_VortexBeam, EV_Particles_VortexBeam);
 
 /** Return true to not draw any impact effect */
 #define EV_Weapon_ImpactEffect(i, o) \
-       /**/ i(entity, w_hitwep) \
+       /** entity id */ i(entity, MUTATOR_ARGV_0_entity) \
        /**/
-entity w_hitwep;
 MUTATOR_HOOKABLE(Weapon_ImpactEffect, EV_Weapon_ImpactEffect);
 
 /* NOTE: hooks MUST start with if (MUTATOR_RETURNVALUE) return false;
 */
 #define EV_HUD_Command(i, o) \
-       /** also, argv() can be used */ i(int, cmd_argc) \
+       /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_0_int) \
        /**/
 MUTATOR_HOOKABLE(HUD_Command, EV_HUD_Command);
index 5a781a8812f3e0a9ca8381928488e568c1feaa67..df8c181b21c841f20c40d785f3a446643e0f5354 100644 (file)
@@ -3,23 +3,25 @@ REGISTER_MUTATOR(invincibleprojectiles, cvar("g_invincible_projectiles"));
 
 MUTATOR_HOOKFUNCTION(invincibleprojectiles, EditProjectile)
 {
-       if(other.health)
+       entity proj = M_ARGV(1, entity);
+
+       if(proj.health)
        {
                // disable health which in effect disables damage calculations
-               other.health = 0;
+               proj.health = 0;
        }
-       return 0;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(invincibleprojectiles, BuildMutatorsString)
 {
        ret_string = strcat(ret_string, ":InvincibleProjectiles");
-       return 0;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(invincibleprojectiles, BuildMutatorsPrettyString)
 {
        ret_string = strcat(ret_string, ", Invincible Projectiles");
-       return 0;
+       return false;
 }
 #endif
index 699a83d3a057c85ff7ad4aa9454cbfe95111ce92..e1efa8e0680f5b8e098ecb1971dc1b795013716b 100644 (file)
@@ -45,53 +45,55 @@ MUTATOR_HOOKFUNCTION(cl_nades, HUD_Draw_overlay)
 }
 MUTATOR_HOOKFUNCTION(cl_nades, Ent_Projectile)
 {
-    SELFPARAM();
-       if (self.cnt == PROJECTILE_NAPALM_FOUNTAIN)
+       entity proj = M_ARGV(0, entity);
+
+       if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
        {
-               self.modelindex = 0;
-               self.traileffect = EFFECT_FIREBALL.m_id;
+               proj.modelindex = 0;
+               proj.traileffect = EFFECT_FIREBALL.m_id;
                return true;
        }
-       if (Nade_FromProjectile(self.cnt) != NADE_TYPE_Null)
+       if (Nade_FromProjectile(proj.cnt) != NADE_TYPE_Null)
        {
-               setmodel(self, MDL_PROJECTILE_NADE);
-               entity trail = Nade_TrailEffect(self.cnt, self.team);
-               if (trail.eent_eff_name) self.traileffect = trail.m_id;
+               setmodel(proj, MDL_PROJECTILE_NADE);
+               entity trail = Nade_TrailEffect(proj.cnt, proj.team);
+               if (trail.eent_eff_name) proj.traileffect = trail.m_id;
                return true;
        }
 }
 MUTATOR_HOOKFUNCTION(cl_nades, EditProjectile)
 {
-    SELFPARAM();
-       if (self.cnt == PROJECTILE_NAPALM_FOUNTAIN)
+       entity proj = M_ARGV(0, entity);
+
+       if (proj.cnt == PROJECTILE_NAPALM_FOUNTAIN)
        {
-               loopsound(self, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
-               self.mins = '-16 -16 -16';
-               self.maxs = '16 16 16';
+               loopsound(proj, CH_SHOTS_SINGLE, SND(FIREBALL_FLY2), VOL_BASE, ATTEN_NORM);
+               proj.mins = '-16 -16 -16';
+               proj.maxs = '16 16 16';
        }
 
-       entity nade_type = Nade_FromProjectile(self.cnt);
+       entity nade_type = Nade_FromProjectile(proj.cnt);
        if (nade_type == NADE_TYPE_Null) return;
        if(STAT(NADES_SMALL, NULL))
        {
-               self.mins = '-8 -8 -8';
-               self.maxs = '8 8 8';
+               proj.mins = '-8 -8 -8';
+               proj.maxs = '8 8 8';
        }
        else
        {
-               self.mins = '-16 -16 -16';
-               self.maxs = '16 16 16';
+               proj.mins = '-16 -16 -16';
+               proj.maxs = '16 16 16';
        }
-       self.colormod = nade_type.m_color;
-       self.move_movetype = MOVETYPE_BOUNCE;
-       settouch(self, func_null);
-       self.scale = 1.5;
-       self.avelocity = randomvec() * 720;
+       proj.colormod = nade_type.m_color;
+       proj.move_movetype = MOVETYPE_BOUNCE;
+       settouch(proj, func_null);
+       proj.scale = 1.5;
+       proj.avelocity = randomvec() * 720;
 
        if (nade_type == NADE_TYPE_TRANSLOCATE || nade_type == NADE_TYPE_SPAWN)
-               self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
+               proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_PLAYERCLIP | DPCONTENTS_BOTCLIP;
        else
-               self.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
+               proj.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY;
 }
 bool Projectile_isnade(int p)
 {
index f23d9918bdc9642293246d084b171ec556629311..ed3e9c6f617068fe2b9a9fdcb5fb42f7ec74245a 100644 (file)
@@ -3,10 +3,12 @@ REGISTER_MUTATOR(rocketflying, cvar("g_rocket_flying"));
 
 MUTATOR_HOOKFUNCTION(rocketflying, EditProjectile)
 {
-       if(other.classname == "rocket" || other.classname == "mine")
+       entity proj = M_ARGV(1, entity);
+
+       if(proj.classname == "rocket" || proj.classname == "mine")
        {
                // kill detonate delay of rockets
-               other.spawnshieldtime = time;
+               proj.spawnshieldtime = time;
        }
        return 0;
 }
index b5240fd1474bcdb65e11d4c582fe31c3f398aba1..05adcf17314b4466c34bb63b9f5fd37dfac296b4 100644 (file)
@@ -218,8 +218,8 @@ MUTATOR_HOOKABLE(GetCvars, EV_NO_ARGS); // NOTE: Can't use EV_GetCvars because o
 
 /** can edit any "just fired" projectile */
 #define EV_EditProjectile(i, o) \
-    /**/ i(entity, __self) \
-    /**/ i(entity, other) \
+    /** projectile owner */ i(entity, MUTATOR_ARGV_0_entity) \
+    /** projectile */ i(entity, MUTATOR_ARGV_1_entity) \
     /**/
 MUTATOR_HOOKABLE(EditProjectile, EV_EditProjectile);