From: Mario Date: Thu, 9 Jun 2016 13:05:41 +0000 (+1000) Subject: Purify PlayerDamage_Calculate X-Git-Tag: xonotic-v0.8.2~872 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=640749c392e1312c4b43b8fbc0a7c9ee2acf9041;p=xonotic%2Fxonotic-data.pk3dir.git Purify PlayerDamage_Calculate --- diff --git a/qcsrc/common/mutators/mutator/breakablehook/breakablehook.qc b/qcsrc/common/mutators/mutator/breakablehook/breakablehook.qc index 3719001a4..e0cf91b35 100644 --- a/qcsrc/common/mutators/mutator/breakablehook/breakablehook.qc +++ b/qcsrc/common/mutators/mutator/breakablehook/breakablehook.qc @@ -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)) diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index 731b10ce9..d15f18feb 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -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; } diff --git a/qcsrc/common/mutators/mutator/campcheck/campcheck.qc b/qcsrc/common/mutators/mutator/campcheck/campcheck.qc index 0036bbaf3..067fa1895 100644 --- a/qcsrc/common/mutators/mutator/campcheck/campcheck.qc +++ b/qcsrc/common/mutators/mutator/campcheck/campcheck.qc @@ -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) diff --git a/qcsrc/common/mutators/mutator/instagib/instagib.qc b/qcsrc/common/mutators/mutator/instagib/instagib.qc index fe3304667..8b1b3bf40 100644 --- a/qcsrc/common/mutators/mutator/instagib/instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/instagib.qc @@ -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; } diff --git a/qcsrc/common/mutators/mutator/midair/midair.qc b/qcsrc/common/mutators/mutator/midair/midair.qc index c02642dab..adf3c3a1f 100644 --- a/qcsrc/common/mutators/mutator/midair/midair.qc +++ b/qcsrc/common/mutators/mutator/midair/midair.qc @@ -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) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index d2f90091f..699a83d3a 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc index c5c876742..611dc6e0a 100644 --- a/qcsrc/common/mutators/mutator/overkill/overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -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; diff --git a/qcsrc/common/mutators/mutator/rocketminsta/rocketminsta.qc b/qcsrc/common/mutators/mutator/rocketminsta/rocketminsta.qc index eee3fef02..b6264647c 100644 --- a/qcsrc/common/mutators/mutator/rocketminsta/rocketminsta.qc +++ b/qcsrc/common/mutators/mutator/rocketminsta/rocketminsta.qc @@ -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; } diff --git a/qcsrc/common/notifications/all.qc b/qcsrc/common/notifications/all.qc index 3d3c78629..7d093f619 100644 --- a/qcsrc/common/notifications/all.qc +++ b/qcsrc/common/notifications/all.qc @@ -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], diff --git a/qcsrc/common/notifications/all.qh b/qcsrc/common/notifications/all.qh index 48bd44af5..8ba86ee5f 100644 --- a/qcsrc/common/notifications/all.qh +++ b/qcsrc/common/notifications/all.qh @@ -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; diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 4eef9e788..24ae60c3d 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -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); } diff --git a/qcsrc/common/weapons/weapon.qh b/qcsrc/common/weapons/weapon.qh index 99ff42367..4de39db17 100644 --- a/qcsrc/common/weapons/weapon.qh +++ b/qcsrc/common/weapons/weapon.qh @@ -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); diff --git a/qcsrc/server/g_damage.qc b/qcsrc/server/g_damage.qc index 730dad620..92710cc58 100644 --- a/qcsrc/server/g_damage.qc +++ b/qcsrc/server/g_damage.qc @@ -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) diff --git a/qcsrc/server/miscfunctions.qh b/qcsrc/server/miscfunctions.qh index de42eda51..4ce33b198 100644 --- a/qcsrc/server/miscfunctions.qh +++ b/qcsrc/server/miscfunctions.qh @@ -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); diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 7221bcb4c..b5240fd14 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -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) \ diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 8835d11a9..c49bfa218 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -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; } diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 84a80a786..ed9dc1fbd 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -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 { diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 158493306..88464a934 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -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; } diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index d3e40465c..6fcfc1913 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -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; diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index 22ae10f7c..b12ddb4b3 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -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;