]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Purify PlayerDamage_Calculate
authorMario <mario@smbclan.net>
Thu, 9 Jun 2016 13:05:41 +0000 (23:05 +1000)
committerMario <mario@smbclan.net>
Thu, 9 Jun 2016 13:05:41 +0000 (23:05 +1000)
20 files changed:
qcsrc/common/mutators/mutator/breakablehook/breakablehook.qc
qcsrc/common/mutators/mutator/buffs/buffs.qc
qcsrc/common/mutators/mutator/campcheck/campcheck.qc
qcsrc/common/mutators/mutator/instagib/instagib.qc
qcsrc/common/mutators/mutator/midair/midair.qc
qcsrc/common/mutators/mutator/nades/nades.qc
qcsrc/common/mutators/mutator/overkill/overkill.qc
qcsrc/common/mutators/mutator/rocketminsta/rocketminsta.qc
qcsrc/common/notifications/all.qc
qcsrc/common/notifications/all.qh
qcsrc/common/weapons/all.qc
qcsrc/common/weapons/weapon.qh
qcsrc/server/g_damage.qc
qcsrc/server/miscfunctions.qh
qcsrc/server/mutators/events.qh
qcsrc/server/mutators/mutator/gamemode_ca.qc
qcsrc/server/mutators/mutator/gamemode_ctf.qc
qcsrc/server/mutators/mutator/gamemode_cts.qc
qcsrc/server/mutators/mutator/gamemode_invasion.qc
qcsrc/server/mutators/mutator/gamemode_keepaway.qc

index 3719001a40f9869647fb02946b08c8f962d333d0..e0cf91b35f57c809c5f130b423eb85b8eddc34eb 100644 (file)
@@ -9,11 +9,14 @@ bool autocvar_g_breakablehook_owner;
 
 MUTATOR_HOOKFUNCTION(breakablehook, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+
        if(frag_target.classname == "grapplinghook")
        {
                if((!autocvar_g_breakablehook)
                || (!autocvar_g_breakablehook_owner && frag_attacker == frag_target.realowner)
-                       ) { frag_damage = 0; }
+                       ) { M_ARGV(4, float) = 0; }
 
                // hurt the owner of the hook
                if(DIFF_TEAM(frag_attacker, frag_target.realowner))
index 731b10ce97277d50b9903bda294076205fdb350c..d15f18febcc72f288c9cec998d49f974b8a2d0ae 100644 (file)
@@ -519,6 +519,12 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_SplitHealthArmor)
 
 MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_deathtype = M_ARGV(3, float);
+       float frag_damage = M_ARGV(4, float);
+       vector frag_force = M_ARGV(6, vector);
+
        if(frag_deathtype == DEATH_BUFF.m_id) { return false; }
 
        if(frag_target.buffs & BUFF_SPEED.m_itemid)
@@ -608,6 +614,9 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerDamage_Calculate)
                        frag_attacker.armorvalue = bound(0, frag_attacker.armorvalue + bound(0, frag_damage * autocvar_g_buffs_vampire_damage_steal, frag_target.armorvalue), g_pickup_armorsmall_max);
        }
 
+       M_ARGV(4, float) = frag_damage;
+       M_ARGV(6, vector) = frag_force;
+
        return false;
 }
 
index 0036bbaf330181d2d4f7ab9f538f9556efe56313..067fa1895c92147d758376dddd275b14c447856f 100644 (file)
@@ -16,6 +16,9 @@ MUTATOR_HOOKFUNCTION(campcheck, PlayerDies)
 
 MUTATOR_HOOKFUNCTION(campcheck, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+
        if(IS_PLAYER(frag_target))
        if(IS_PLAYER(frag_attacker))
        if(frag_attacker != frag_target)
index fe33046678fa9fc1d46c47a3bd24132753b64a5a..8b1b3bf40aec178eb75312afea195e56d365f899 100644 (file)
@@ -267,6 +267,13 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, ForbidThrowCurrentWeapon)
 
 MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_deathtype = M_ARGV(3, float);
+       float frag_damage = M_ARGV(4, float);
+       float frag_mirrordamage = M_ARGV(5, float);
+       vector frag_force = M_ARGV(6, vector);
+
        if(autocvar_g_friendlyfire == 0 && SAME_TEAM(frag_target, frag_attacker) && IS_PLAYER(frag_target) && IS_PLAYER(frag_attacker))
                frag_damage = 0;
 
@@ -340,6 +347,10 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerDamage_Calculate)
        if(IS_PLAYER(frag_target))
                yoda = 1;
 
+       M_ARGV(4, float) = frag_damage;
+       M_ARGV(5, float) = frag_mirrordamage;
+       M_ARGV(6, vector) = frag_force;
+
        return false;
 }
 
index c02642dab4828cafa38262ba0742c48dba74cf73..adf3c3a1f3a9aa8f9f5ba9bbf14da86297eeae63 100644 (file)
@@ -8,6 +8,9 @@ REGISTER_MUTATOR(midair, cvar("g_midair"));
 
 MUTATOR_HOOKFUNCTION(midair, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       
        if(IS_PLAYER(frag_attacker))
        if(IS_PLAYER(frag_target))
        if(time < frag_target.midair_shieldtime)
index d2f90091fda3909848ddc2a8249a593a3cd7ec28..699a83d3a057c85ff7ad4aa9454cbfe95111ce92 100644 (file)
@@ -1299,6 +1299,12 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDies, CBC_ORDER_LAST)
 
 MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_deathtype = M_ARGV(3, float);
+       float frag_damage = M_ARGV(4, float);
+       vector frag_force = M_ARGV(6, vector);
+
        if(STAT(FROZEN, frag_target))
        if(autocvar_g_freezetag_revive_nade)
        if(frag_attacker == frag_target)
@@ -1312,6 +1318,9 @@ MUTATOR_HOOKFUNCTION(nades, PlayerDamage_Calculate)
                frag_force = '0 0 0';
                Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_FREEZETAG_REVIVED_NADE, frag_target.netname);
                Send_Notification(NOTIF_ONE, frag_target, MSG_CENTER, CENTER_FREEZETAG_REVIVE_SELF);
+
+               M_ARGV(4, float) = frag_damage;
+               M_ARGV(6, vector) = frag_force;
        }
 
        return false;
index c5c8767423596115b40243014bf700950e66a20b..611dc6e0ac508c1427f4a94860d8f4e83f53b83e 100644 (file)
@@ -94,6 +94,12 @@ float ok_CheckWeaponCharge(entity ent, int wep)
 
 MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_deathtype = M_ARGV(3, float);
+       float frag_damage = M_ARGV(4, float);
+       vector frag_force = M_ARGV(6, vector);
+
        if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target))
        if(DEATH_ISWEAPON(frag_deathtype, WEP_BLASTER))
        {
@@ -107,6 +113,9 @@ MUTATOR_HOOKFUNCTION(ok, PlayerDamage_Calculate, CBC_ORDER_LAST)
                        Send_Notification(NOTIF_ONE, frag_attacker, MSG_CENTER, CENTER_SECONDARY_NODAMAGE);
                        frag_force = '0 0 0';
                }
+
+               M_ARGV(4, float) = frag_damage;
+               M_ARGV(6, vector) = frag_force;
        }
 
        return false;
index eee3fef02f4fec1f8add5d8467c691aae671f632..b6264647c12cdcc92e61388c39bd4455db29de1d 100644 (file)
@@ -9,6 +9,11 @@ MUTATOR_HOOKFUNCTION(rm, PlayerDamage_Calculate)
        // we do it this way, so rm can be toggled during the match
        if(!autocvar_g_rm) { return false; }
 
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_deathtype = M_ARGV(3, float);
+       float frag_damage = M_ARGV(4, float);
+
        if(DEATH_ISWEAPON(frag_deathtype, WEP_DEVASTATOR))
        if(frag_attacker == frag_target || frag_target.classname == "nade")
                frag_damage = 0;
@@ -18,6 +23,8 @@ MUTATOR_HOOKFUNCTION(rm, PlayerDamage_Calculate)
        if(frag_attacker == frag_target || (round_handler_IsActive() && !round_handler_IsRoundStarted()))
                frag_damage = 0;
 
+       M_ARGV(4, float) = frag_damage;
+
        return false;
 }
 
index 3d3c786297c43cb283cd39f43449b4611c98de7b..7d093f619e3c24b0056ba598cadc12c88c59d943 100644 (file)
@@ -758,10 +758,11 @@ void Create_Notification_Entity_Choice(entity notif,
 
 // used by MSG_CHOICE to build list of choices
 #ifdef SVQC
-void Notification_GetCvars()
+void Notification_GetCvars(entity this)
 {
        FOREACH(Notifications, it.nent_type == MSG_CHOICE, {
                GetCvars_handleFloat(
+                       this,
                        get_cvars_s,
                        get_cvars_f,
                        msg_choice_choices[it.nent_choice_idx],
index 48bd44af5f59d36732995692134caf8c44a24781..8ba86ee5fd19eb15cebeca6ed09a41d743f21af1 100644 (file)
@@ -298,7 +298,7 @@ float autocvar_notification_lifetime_mapload = 10;
 
 #ifdef SVQC
 .float FRAG_VERBOSE;
-void Notification_GetCvars();
+void Notification_GetCvars(entity this);
 float autocvar_notification_server_allows_location = 1; // 0 = no, 1 = yes
 #else
 float autocvar_notification_item_centerprinttime = 1.5;
index 4eef9e788ad7be9b2570803b99c6551b2d517765..24ae60c3df039f8cd4e4ca9e2380c994c579d464 100644 (file)
@@ -181,7 +181,7 @@ string W_FixWeaponOrder_BuildImpulseList(string o)
        return substring(o, 1, -1);
 }
 
-string W_FixWeaponOrder_AllowIncomplete(string order)
+string W_FixWeaponOrder_AllowIncomplete(entity this, string order)
 {
        return W_FixWeaponOrder(order, 0);
 }
index 99ff42367fe14bbb38e330f2143425e055ea9676..4de39db1772f31ab462467f55a0b76e9f3eeb3ec 100644 (file)
@@ -201,7 +201,7 @@ string W_UndeprecateName(string s);
 string W_NameWeaponOrder(string order);
 string W_NumberWeaponOrder(string order);
 string W_FixWeaponOrder_BuildImpulseList(string o);
-string W_FixWeaponOrder_AllowIncomplete(string order);
+string W_FixWeaponOrder_AllowIncomplete(entity this, string order);
 string W_FixWeaponOrder_ForceComplete(string order);
 void W_RandomWeapons(entity e, float n);
 
index 730dad620b2d8818eec2ad8ba7a8bd00eeebd504..92710cc58264c14e1958297604cb0c32a9b3790b 100644 (file)
@@ -697,9 +697,9 @@ void Damage (entity targ, entity inflictor, entity attacker, float damage, int d
 
                // should this be changed at all? If so, in what way?
                MUTATOR_CALLHOOK(PlayerDamage_Calculate, inflictor, attacker, targ, deathtype, damage, mirrordamage, force);
-               damage = frag_damage;
-               mirrordamage = frag_mirrordamage;
-               force = frag_force;
+               damage = M_ARGV(4, float);
+               mirrordamage = M_ARGV(5, float);
+               force = M_ARGV(6, vector);
 
                if(STAT(FROZEN, targ))
                if(deathtype != DEATH_HURTTRIGGER.m_id && deathtype != DEATH_TEAMCHANGE.m_id && deathtype != DEATH_AUTOTEAMCHANGE.m_id)
index de42eda5196ee3875f521af11d253b527f0d8d36..4ce33b198442141e7aba03e783c01787c7de5bf4 100644 (file)
@@ -40,11 +40,11 @@ void play2all(string samp);
 
 void play2team(float t, string filename);
 
-void GetCvars_handleFloat(string thisname, float f, .float field, string name);
+void GetCvars_handleFloat(entity this, string thisname, float f, .float field, string name);
 
 float spamsound(entity e, float chan, string samp, float vol, float _atten);
 
-void GetCvars_handleString(string thisname, float f, .string field, string name);
+void GetCvars_handleString(entity this, string thisname, float f, .string field, string name);
 
 void precache_all_playermodels(string pattern);
 
index 7221bcb4ce57b0ef87e4246e43bb57f578a08a6e..b5240fd1474bcdb65e11d4c582fe31c3f398aba1 100644 (file)
@@ -310,20 +310,17 @@ MUTATOR_HOOKABLE(PlayerDamage_SplitHealthArmor, EV_PlayerDamage_SplitHealthArmor
  * i'm not sure if I should change this around slightly (Naming of the entities, and also how they're done in g_damage).
  */
 #define EV_PlayerDamage_Calculate(i, o) \
-    /**/ i(entity, frag_inflictor) \
-    /**/ i(entity, frag_attacker) \
-    /**/ i(entity, frag_target) \
-    /**/ i(float, frag_deathtype) \
-       /**/ i(float, frag_damage) \
-    /**/ o(float, frag_damage) \
-       /**/ i(float, frag_mirrordamage) \
-    /**/ o(float, frag_mirrordamage) \
-    /**/ i(vector, frag_force) \
-    /**/ o(vector, frag_force) \
+    /** inflictor              */ i(entity, MUTATOR_ARGV_0_entity) \
+    /** attacker       */ i(entity, MUTATOR_ARGV_1_entity) \
+    /** target                 */ i(entity, MUTATOR_ARGV_2_entity) \
+    /** deathtype      */ i(float,  MUTATOR_ARGV_3_float) \
+    /** damage          */ i(float,  MUTATOR_ARGV_4_float) \
+    /** damage                 */ o(float,  MUTATOR_ARGV_4_float) \
+    /** mirrordamage    */ i(float,  MUTATOR_ARGV_5_float) \
+    /** mirrordamage   */ o(float,  MUTATOR_ARGV_5_float) \
+    /** force           */ i(vector, MUTATOR_ARGV_6_vector) \
+    /** force                  */ o(vector, MUTATOR_ARGV_6_vector) \
     /**/
-float frag_damage;
-float frag_mirrordamage;
-vector frag_force;
 MUTATOR_HOOKABLE(PlayerDamage_Calculate, EV_PlayerDamage_Calculate);
 
 /**
@@ -615,7 +612,7 @@ entity bullet_hit;
 //vector bullet_hitloc; // the end pos matches the hit location, apparently
 vector bullet_startpos;
 vector bullet_endpos;
-//float frag_damage;
+float frag_damage;
 MUTATOR_HOOKABLE(FireBullet_Hit, EV_FireBullet_Hit);
 
 #define EV_FixPlayermodel(i, o) \
index 8835d11a9cdaac326642cb9811bfb2986dd699af..c49bfa2188ec68b545a86d74d11c334dfc103dda 100644 (file)
@@ -369,6 +369,12 @@ MUTATOR_HOOKFUNCTION(ca, SetStartItems)
 
 MUTATOR_HOOKFUNCTION(ca, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_deathtype = M_ARGV(3, float);
+       float frag_damage = M_ARGV(4, float);
+       float frag_mirrordamage = M_ARGV(5, float);
+
        if (IS_PLAYER(frag_target))
        if (!IS_DEAD(frag_target))
        if (frag_target == frag_attacker || SAME_TEAM(frag_target, frag_attacker) || frag_deathtype == DEATH_FALL.m_id)
@@ -376,6 +382,9 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDamage_Calculate)
 
        frag_mirrordamage = 0;
 
+       M_ARGV(4, float) = frag_damage;
+       M_ARGV(5, float) = frag_mirrordamage;
+
        return false;
 }
 
index 84a80a7860d03f12d832f8168d11994af14be40d..ed9dc1fbd3a5ac55fe0d038ab8ee97d58348e5d9 100644 (file)
@@ -2029,6 +2029,11 @@ MUTATOR_HOOKFUNCTION(ctf, PlayerPreThink)
 
 MUTATOR_HOOKFUNCTION(ctf, PlayerDamage_Calculate) // for changing damage and force values that are applied to players in g_damage.qc
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_damage = M_ARGV(4, float);
+       vector frag_force = M_ARGV(6, vector);
+
        if(frag_attacker.flagcarried) // if the attacker is a flagcarrier
        {
                if(frag_target == frag_attacker) // damage done to yourself
@@ -2041,6 +2046,9 @@ MUTATOR_HOOKFUNCTION(ctf, PlayerDamage_Calculate) // for changing damage and for
                        frag_damage *= autocvar_g_ctf_flagcarrier_damagefactor;
                        frag_force *= autocvar_g_ctf_flagcarrier_forcefactor;
                }
+
+               M_ARGV(4, float) = frag_damage;
+               M_ARGV(6, vector) = frag_force;
        }
        else if(frag_target.flagcarried && !IS_DEAD(frag_target) && CTF_DIFFTEAM(frag_target, frag_attacker)) // if the target is a flagcarrier
        {
index 1584933063e2386780479cc319f9252fcaed254c..88464a9344ce7ad4705863031a965096c9bc0817 100644 (file)
@@ -354,9 +354,17 @@ MUTATOR_HOOKFUNCTION(cts, FilterItem)
 
 MUTATOR_HOOKFUNCTION(cts, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_deathtype = M_ARGV(3, float);
+       float frag_damage = M_ARGV(4, float);
+
        if(frag_target == frag_attacker || frag_deathtype == DEATH_FALL.m_id)
        if(!autocvar_g_cts_selfdamage)
+       {
                frag_damage = 0;
+               M_ARGV(4, float) = frag_damage;
+       }
 
        return false;
 }
index d3e40465c1376323c526c52193c83b8ecee32445..6fcfc1913d694acb43a62bf1f10e04939fcd67a8 100644 (file)
@@ -403,10 +403,18 @@ MUTATOR_HOOKFUNCTION(inv, PlayerSpawn)
 
 MUTATOR_HOOKFUNCTION(inv, PlayerDamage_Calculate)
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_damage = M_ARGV(4, float);
+       vector frag_force = M_ARGV(6, vector);
+
        if(IS_PLAYER(frag_attacker) && IS_PLAYER(frag_target) && frag_attacker != frag_target)
        {
                frag_damage = 0;
                frag_force = '0 0 0';
+
+               M_ARGV(4, float) = frag_damage;
+               M_ARGV(6, vector) = frag_force;
        }
 
        return false;
index 22ae10f7c46810c17120a9ef73ba3b72ea61ca8e..b12ddb4b38ead884cc11f488a98479ac2de725be 100644 (file)
@@ -26,7 +26,7 @@ REGISTER_MUTATOR(ka, false)
                return -1;
        }
 
-       return 0;
+       return false;
 }
 
 
@@ -332,7 +332,7 @@ MUTATOR_HOOKFUNCTION(ka, PlayerDies)
        }
 
        if(frag_target.ballcarried) { ka_DropEvent(frag_target); } // a player with the ball has died, drop it
-       return 0;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(ka, GiveFragsForKill)
@@ -350,7 +350,7 @@ MUTATOR_HOOKFUNCTION(ka, PlayerPreThink)
        if(self.ballcarried)
                self.items |= IT_KEY1;
 
-       return 0;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(ka, PlayerUseKey)
@@ -361,11 +361,16 @@ MUTATOR_HOOKFUNCTION(ka, PlayerUseKey)
                ka_DropEvent(self);
                return 1;
        }
-       return 0;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(ka, PlayerDamage_Calculate) // for changing damage and force values that are applied to players in g_damage.qc
 {
+       entity frag_attacker = M_ARGV(1, entity);
+       entity frag_target = M_ARGV(2, entity);
+       float frag_damage = M_ARGV(4, float);
+       vector frag_force = M_ARGV(6, vector);
+
        if(frag_attacker.ballcarried) // if the attacker is a ballcarrier
        {
                if(frag_target == frag_attacker) // damage done to yourself
@@ -392,19 +397,23 @@ MUTATOR_HOOKFUNCTION(ka, PlayerDamage_Calculate) // for changing damage and forc
                        frag_force *= autocvar_g_keepaway_noncarrier_force;
                }
        }
-       return 0;
+
+       M_ARGV(4, float) = frag_damage;
+       M_ARGV(6, vector) = frag_force;
+
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(ka, ClientDisconnect)
 {SELFPARAM();
        if(self.ballcarried) { ka_DropEvent(self); } // a player with the ball has left the match, drop it
-       return 0;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(ka, MakePlayerObserver)
 {SELFPARAM();
        if(self.ballcarried) { ka_DropEvent(self); } // a player with the ball has left the match, drop it
-       return 0;
+       return false;
 }
 
 MUTATOR_HOOKFUNCTION(ka, PlayerPowerups)
@@ -417,7 +426,7 @@ MUTATOR_HOOKFUNCTION(ka, PlayerPowerups)
        if(self.ballcarried)
                self.effects |= autocvar_g_keepaway_ballcarrier_effects;
 
-       return 0;
+       return false;
 }
 
 .float stat_sv_airspeedlimit_nonqw;