From dd2b9a194fa4b844241392bfc136b953abf94a7a Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 10 Jun 2016 16:19:27 +1000 Subject: [PATCH] Cleanse more of the mutator hooks --- .../gamemodes/gamemode/nexball/nexball.qc | 25 ++-- .../gamemodes/gamemode/onslaught/onslaught.qc | 28 +++-- qcsrc/common/items/all.qc | 2 +- qcsrc/common/mutators/mutator/buffs/buffs.qc | 36 +++--- .../mutators/mutator/instagib/instagib.qc | 7 +- qcsrc/common/mutators/mutator/itemstime.qc | 6 +- qcsrc/common/mutators/mutator/nades/nades.qc | 47 ++++---- qcsrc/common/mutators/mutator/overkill/hmg.qc | 2 +- .../mutators/mutator/overkill/overkill.qc | 11 +- .../mutators/mutator/superspec/superspec.qc | 5 +- qcsrc/common/stats.qh | 4 +- qcsrc/common/turrets/sv_turrets.qc | 2 +- qcsrc/common/weapons/all.qc | 2 +- qcsrc/common/weapons/weapon/arc.qc | 4 +- qcsrc/common/weapons/weapon/devastator.qc | 4 +- qcsrc/common/weapons/weapon/electro.qc | 2 +- qcsrc/common/weapons/weapon/fireball.qc | 2 +- qcsrc/common/weapons/weapon/hagar.qc | 10 +- qcsrc/common/weapons/weapon/hlac.qc | 2 +- qcsrc/common/weapons/weapon/hook.qc | 4 +- qcsrc/common/weapons/weapon/machinegun.qc | 6 +- qcsrc/common/weapons/weapon/seeker.qc | 2 +- qcsrc/common/weapons/weapon/shockwave.qc | 6 +- qcsrc/common/weapons/weapon/shotgun.qc | 8 +- qcsrc/common/weapons/weapon/tuba.qc | 2 +- qcsrc/common/weapons/weapon/vaporizer.qc | 6 +- qcsrc/server/bot/aim.qc | 4 +- qcsrc/server/cl_client.qc | 4 +- qcsrc/server/cl_impulse.qc | 2 +- qcsrc/server/g_world.qc | 2 +- qcsrc/server/miscfunctions.qc | 6 +- qcsrc/server/mutators/events.qh | 110 ++++++++---------- .../mutators/mutator/gamemode_assault.qc | 4 +- qcsrc/server/mutators/mutator/gamemode_ca.qc | 27 +++-- qcsrc/server/mutators/mutator/gamemode_ctf.qc | 29 +++-- qcsrc/server/mutators/mutator/gamemode_cts.qc | 37 +++--- .../mutators/mutator/gamemode_domination.qc | 6 +- .../mutators/mutator/gamemode_freezetag.qc | 23 ++-- .../mutators/mutator/gamemode_invasion.qc | 3 +- .../mutators/mutator/gamemode_keepaway.qc | 13 ++- .../mutators/mutator/gamemode_keyhunt.qc | 29 ++--- qcsrc/server/mutators/mutator/gamemode_lms.qc | 19 +-- .../server/mutators/mutator/gamemode_race.qc | 31 ++--- qcsrc/server/mutators/mutator/gamemode_tdm.qc | 2 +- qcsrc/server/scores.qc | 4 +- qcsrc/server/teamplay.qc | 4 +- qcsrc/server/weapons/tracing.qc | 6 +- qcsrc/server/weapons/tracing.qh | 2 +- qcsrc/server/weapons/weaponsystem.qc | 16 +-- qcsrc/server/weapons/weaponsystem.qh | 4 +- 50 files changed, 330 insertions(+), 292 deletions(-) diff --git a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc index 7d10f5d47..2889b182c 100644 --- a/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc +++ b/qcsrc/common/gamemodes/gamemode/nexball/nexball.qc @@ -791,7 +791,7 @@ void W_Nexball_Attack(entity actor, float t) mul = mi + (ma - mi) * mul; // range from the minimal power to the maximal power } - DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(actor.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false)); + DropBall(ball, w_shotorg, W_CalculateProjectileVelocity(actor, actor.velocity, w_shotdir * autocvar_g_balance_nexball_primary_speed * mul, false)); //TODO: use the speed_up cvar too ?? @@ -922,9 +922,10 @@ void nb_DropBall(entity player) } MUTATOR_HOOKFUNCTION(nb, ClientDisconnect) -{SELFPARAM(); - nb_DropBall(self); - return false; +{ + entity player = M_ARGV(0, entity); + + nb_DropBall(player); } MUTATOR_HOOKFUNCTION(nb, PlayerDies) @@ -935,8 +936,10 @@ MUTATOR_HOOKFUNCTION(nb, PlayerDies) } MUTATOR_HOOKFUNCTION(nb, MakePlayerObserver) -{SELFPARAM(); - nb_DropBall(self); +{ + entity player = M_ARGV(0, entity); + + nb_DropBall(player); return false; } @@ -1009,8 +1012,10 @@ MUTATOR_HOOKFUNCTION(nb, PlayerPreThink) MUTATOR_HOOKFUNCTION(nb, SpectateCopy) { - SELFPARAM(); - this.metertime = other.metertime; + entity spectatee = M_ARGV(0, entity); + entity client = M_ARGV(1, entity); + + client.metertime = spectatee.metertime; } MUTATOR_HOOKFUNCTION(nb, PlayerSpawn) @@ -1063,13 +1068,13 @@ MUTATOR_HOOKFUNCTION(nb, FilterItem) MUTATOR_HOOKFUNCTION(nb, GetTeamCount) { - ret_string = "nexball_team"; + M_ARGV(1, string) = "nexball_team"; return true; } MUTATOR_HOOKFUNCTION(nb, WantWeapon) { - ret_float = 0; // weapon is set a few lines later, apparently + M_ARGV(1, float) = 0; // weapon is set a few lines later, apparently return true; } diff --git a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc index 1f9c88780..d7a615b87 100644 --- a/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc +++ b/qcsrc/common/gamemodes/gamemode/onslaught/onslaught.qc @@ -1765,15 +1765,17 @@ MUTATOR_HOOKFUNCTION(ons, reset_map_global) } MUTATOR_HOOKFUNCTION(ons, ClientDisconnect) -{SELFPARAM(); - self.ons_deathloc = '0 0 0'; - return false; +{ + entity player = M_ARGV(0, entity); + + player.ons_deathloc = '0 0 0'; } MUTATOR_HOOKFUNCTION(ons, MakePlayerObserver) -{SELFPARAM(); - self.ons_deathloc = '0 0 0'; - return false; +{ + entity player = M_ARGV(0, entity); + + player.ons_deathloc = '0 0 0'; } MUTATOR_HOOKFUNCTION(ons, PlayerSpawn) @@ -2022,9 +2024,11 @@ MUTATOR_HOOKFUNCTION(ons, GetTeamCount) } MUTATOR_HOOKFUNCTION(ons, SpectateCopy) -{SELFPARAM(); - self.ons_roundlost = other.ons_roundlost; // make spectators see it too - return false; +{ + entity spectatee = M_ARGV(0, entity); + entity client = M_ARGV(1, entity); + + client.ons_roundlost = spectatee.ons_roundlost; // make spectators see it too } MUTATOR_HOOKFUNCTION(ons, SV_ParseClientCommand) @@ -2114,6 +2118,8 @@ MUTATOR_HOOKFUNCTION(ons, PlayerUseKey) MUTATOR_HOOKFUNCTION(ons, PlayHitsound) { + entity frag_victim = M_ARGV(0, entity); + return (frag_victim.classname == "onslaught_generator" && !frag_victim.isshielded) || (frag_victim.classname == "onslaught_controlpoint_icon" && !frag_victim.owner.isshielded); } @@ -2143,9 +2149,11 @@ MUTATOR_HOOKFUNCTION(ons, SendWaypoint) MUTATOR_HOOKFUNCTION(ons, TurretValidateTarget) { + entity turret_target = M_ARGV(1, entity); + if(substring(turret_target.classname, 0, 10) == "onslaught_") // don't attack onslaught targets, that's the player's job! { - ret_float = -3; + M_ARGV(3, float) = -3; return true; } diff --git a/qcsrc/common/items/all.qc b/qcsrc/common/items/all.qc index 9d7cfa8d3..7a3e50046 100644 --- a/qcsrc/common/items/all.qc +++ b/qcsrc/common/items/all.qc @@ -14,7 +14,7 @@ string Item_Model(string item_mdl) string output = strcat("models/items/", item_mdl); #ifdef SVQC MUTATOR_CALLHOOK(ItemModel, item_mdl, output); - output = item_model_output; + output = M_ARGV(1, string); #endif return output; } diff --git a/qcsrc/common/mutators/mutator/buffs/buffs.qc b/qcsrc/common/mutators/mutator/buffs/buffs.qc index 01e7f31bb..134971766 100644 --- a/qcsrc/common/mutators/mutator/buffs/buffs.qc +++ b/qcsrc/common/mutators/mutator/buffs/buffs.qc @@ -799,8 +799,8 @@ bool buffs_RemovePlayer(entity player) return false; } -MUTATOR_HOOKFUNCTION(buffs, MakePlayerObserver) { SELFPARAM(); return buffs_RemovePlayer(self); } -MUTATOR_HOOKFUNCTION(buffs, ClientDisconnect) { SELFPARAM(); return buffs_RemovePlayer(self); } +MUTATOR_HOOKFUNCTION(buffs, MakePlayerObserver) { entity player = M_ARGV(0, entity); return buffs_RemovePlayer(player); } +MUTATOR_HOOKFUNCTION(buffs, ClientDisconnect) { entity player = M_ARGV(0, entity); return buffs_RemovePlayer(player); } MUTATOR_HOOKFUNCTION(buffs, CustomizeWaypoint) {SELFPARAM(); @@ -832,25 +832,25 @@ MUTATOR_HOOKFUNCTION(buffs, OnEntityPreSpawn, CBC_ORDER_LAST) } MUTATOR_HOOKFUNCTION(buffs, WeaponRateFactor) -{SELFPARAM(); - if(self.buffs & BUFF_SPEED.m_itemid) - weapon_rate *= autocvar_g_buffs_speed_rate; +{ + entity player = M_ARGV(1, entity); - if(time < self.buff_disability_time) - weapon_rate *= autocvar_g_buffs_disability_rate; + if(player.buffs & BUFF_SPEED.m_itemid) + M_ARGV(0, float) *= autocvar_g_buffs_speed_rate; - return false; + if(time < player.buff_disability_time) + M_ARGV(0, float) *= autocvar_g_buffs_disability_rate; } MUTATOR_HOOKFUNCTION(buffs, WeaponSpeedFactor) -{SELFPARAM(); - if(self.buffs & BUFF_SPEED.m_itemid) - ret_float *= autocvar_g_buffs_speed_weaponspeed; +{ + entity player = M_ARGV(1, entity); - if(time < self.buff_disability_time) - ret_float *= autocvar_g_buffs_disability_weaponspeed; + if(player.buffs & BUFF_SPEED.m_itemid) + M_ARGV(0, float) *= autocvar_g_buffs_speed_weaponspeed; - return false; + if(time < player.buff_disability_time) + M_ARGV(0, float) *= autocvar_g_buffs_disability_weaponspeed; } MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) @@ -1006,9 +1006,11 @@ MUTATOR_HOOKFUNCTION(buffs, PlayerPreThink) } MUTATOR_HOOKFUNCTION(buffs, SpectateCopy) -{SELFPARAM(); - self.buffs = other.buffs; - return false; +{ + entity spectatee = M_ARGV(0, entity); + entity client = M_ARGV(1, entity); + + client.buffs = spectatee.buffs; } MUTATOR_HOOKFUNCTION(buffs, VehicleEnter) diff --git a/qcsrc/common/mutators/mutator/instagib/instagib.qc b/qcsrc/common/mutators/mutator/instagib/instagib.qc index 34836ab3d..89f98ade7 100644 --- a/qcsrc/common/mutators/mutator/instagib/instagib.qc +++ b/qcsrc/common/mutators/mutator/instagib/instagib.qc @@ -170,9 +170,10 @@ MUTATOR_HOOKFUNCTION(mutator_instagib, BotShouldAttack) } MUTATOR_HOOKFUNCTION(mutator_instagib, MakePlayerObserver) -{SELFPARAM(); - instagib_stop_countdown(self); - return false; +{ + entity player = M_ARGV(0, entity); + + instagib_stop_countdown(player); } MUTATOR_HOOKFUNCTION(mutator_instagib, PlayerSpawn) diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc index 089f03abb..16e181908 100644 --- a/qcsrc/common/mutators/mutator/itemstime.qc +++ b/qcsrc/common/mutators/mutator/itemstime.qc @@ -160,8 +160,10 @@ MUTATOR_HOOKFUNCTION(itemstime, reset_map_global) } MUTATOR_HOOKFUNCTION(itemstime, MakePlayerObserver) -{SELFPARAM(); - Item_ItemsTime_SetTimesForPlayer(self); +{ + entity player = M_ARGV(0, entity); + + Item_ItemsTime_SetTimesForPlayer(player); } MUTATOR_HOOKFUNCTION(itemstime, ClientConnect, CBC_ORDER_LAST) diff --git a/qcsrc/common/mutators/mutator/nades/nades.qc b/qcsrc/common/mutators/mutator/nades/nades.qc index 999bd4ada..112b2ca01 100644 --- a/qcsrc/common/mutators/mutator/nades/nades.qc +++ b/qcsrc/common/mutators/mutator/nades/nades.qc @@ -813,7 +813,7 @@ void nade_damage(entity this, entity inflictor, entity attacker, float damage, i } void toss_nade(entity e, bool set_owner, vector _velocity, float _time) -{SELFPARAM(); +{ if(e.nade == world) return; @@ -849,14 +849,14 @@ void toss_nade(entity e, bool set_owner, vector _velocity, float _time) if (trace_startsolid) setorigin(_nade, e.origin); - if(self.v_angle.x >= 70 && self.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(self)) + if(e.v_angle.x >= 70 && e.v_angle.x <= 110 && PHYS_INPUT_BUTTON_CROUCH(e)) _nade.velocity = '0 0 100'; else if(autocvar_g_nades_nade_newton_style == 1) _nade.velocity = e.velocity + _velocity; else if(autocvar_g_nades_nade_newton_style == 2) _nade.velocity = _velocity; else - _nade.velocity = W_CalculateProjectileVelocity(e.velocity, _velocity, true); + _nade.velocity = W_CalculateProjectileVelocity(e, e.velocity, _velocity, true); if(set_owner) _nade.realowner = e; @@ -1351,27 +1351,34 @@ MUTATOR_HOOKFUNCTION(nades, DropSpecialItems) return false; } -bool nades_RemovePlayer() -{SELFPARAM(); - nades_Clear(self); - nades_RemoveBonus(self); - return false; +void nades_RemovePlayer(entity this) +{ + nades_Clear(this); + nades_RemoveBonus(this); } -MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { nades_RemovePlayer(); } -MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { nades_RemovePlayer(); } -MUTATOR_HOOKFUNCTION(nades, reset_map_global) { nades_RemovePlayer(); } +MUTATOR_HOOKFUNCTION(nades, MakePlayerObserver) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); } +MUTATOR_HOOKFUNCTION(nades, ClientDisconnect) { entity player = M_ARGV(0, entity); nades_RemovePlayer(player); } +MUTATOR_HOOKFUNCTION(nades, reset_map_global) +{ + FOREACH_CLIENT(IS_PLAYER(it), + { + nades_RemovePlayer(it); + }); +} MUTATOR_HOOKFUNCTION(nades, SpectateCopy) -{SELFPARAM(); - self.nade_timer = other.nade_timer; - self.nade_type = other.nade_type; - self.pokenade_type = other.pokenade_type; - self.bonus_nades = other.bonus_nades; - self.bonus_nade_score = other.bonus_nade_score; - self.stat_healing_orb = other.stat_healing_orb; - self.stat_healing_orb_alpha = other.stat_healing_orb_alpha; - return false; +{ + entity spectatee = M_ARGV(0, entity); + entity client = M_ARGV(1, entity); + + client.nade_timer = spectatee.nade_timer; + client.nade_type = spectatee.nade_type; + client.pokenade_type = spectatee.pokenade_type; + client.bonus_nades = spectatee.bonus_nades; + client.bonus_nade_score = spectatee.bonus_nade_score; + client.stat_healing_orb = spectatee.stat_healing_orb; + client.stat_healing_orb_alpha = spectatee.stat_healing_orb_alpha; } REPLICATE(cvar_cl_nade_type, int, "cl_nade_type"); diff --git a/qcsrc/common/mutators/mutator/overkill/hmg.qc b/qcsrc/common/mutators/mutator/overkill/hmg.qc index 0d14164d1..38aec81e7 100644 --- a/qcsrc/common/mutators/mutator/overkill/hmg.qc +++ b/qcsrc/common/mutators/mutator/overkill/hmg.qc @@ -96,7 +96,7 @@ void W_HeavyMachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weapone SpawnCasing (((random () * 50 + 50) * v_right) - (v_forward * (random () * 25 + 25)) - ((random () * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); int slot = weaponslot(weaponentity); - ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(hmg, refire) * W_WeaponRateFactor(); + ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(hmg, refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(hmg, refire), W_HeavyMachineGun_Attack_Auto); } diff --git a/qcsrc/common/mutators/mutator/overkill/overkill.qc b/qcsrc/common/mutators/mutator/overkill/overkill.qc index 71b111476..fc41bbc3d 100644 --- a/qcsrc/common/mutators/mutator/overkill/overkill.qc +++ b/qcsrc/common/mutators/mutator/overkill/overkill.qc @@ -222,7 +222,7 @@ MUTATOR_HOOKFUNCTION(ok, PlayerPreThink) if(!forbidWeaponUse(self) || self.weapon_blocked) // allow if weapon is blocked if(time >= self.jump_interval) { - self.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(); + self.jump_interval = time + WEP_CVAR_PRI(blaster, refire) * W_WeaponRateFactor(this); makevectors(self.v_angle); Weapon oldwep = PS(self).m_weapon; @@ -353,11 +353,12 @@ MUTATOR_HOOKFUNCTION(ok, FilterItem) } MUTATOR_HOOKFUNCTION(ok, SpectateCopy) -{SELFPARAM(); - self.ammo_charge[PS(self).m_weapon.m_id] = other.ammo_charge[PS(other).m_weapon.m_id]; - self.ok_use_ammocharge = other.ok_use_ammocharge; +{ + entity spectatee = M_ARGV(0, entity); + entity client = M_ARGV(1, entity); - return false; + client.ammo_charge[PS(client).m_weapon.m_id] = spectatee.ammo_charge[PS(spectatee).m_weapon.m_id]; + client.ok_use_ammocharge = spectatee.ok_use_ammocharge; } MUTATOR_HOOKFUNCTION(ok, SetStartItems) diff --git a/qcsrc/common/mutators/mutator/superspec/superspec.qc b/qcsrc/common/mutators/mutator/superspec/superspec.qc index c3ce2d27d..9913591af 100644 --- a/qcsrc/common/mutators/mutator/superspec/superspec.qc +++ b/qcsrc/common/mutators/mutator/superspec/superspec.qc @@ -457,7 +457,8 @@ MUTATOR_HOOKFUNCTION(superspec, PlayerDies) MUTATOR_HOOKFUNCTION(superspec, ClientDisconnect) { - superspec_save_client_conf(); - return false; + entity player = M_ARGV(0, entity); + + WITHSELF(player, superspec_save_client_conf()); } #endif diff --git a/qcsrc/common/stats.qh b/qcsrc/common/stats.qh index e9828c69e..f5eec5765 100644 --- a/qcsrc/common/stats.qh +++ b/qcsrc/common/stats.qh @@ -63,9 +63,9 @@ REGISTER_STAT(SWITCHINGWEAPON, int) REGISTER_STAT(WEAPON_NEXTTHINK, float) #ifdef SVQC SPECTATE_COPYFIELD(_STAT(WEAPON_NEXTTHINK)) -float W_WeaponRateFactor(); +float W_WeaponRateFactor(entity this); #endif -REGISTER_STAT(WEAPONRATEFACTOR, float, W_WeaponRateFactor()) +REGISTER_STAT(WEAPONRATEFACTOR, float, W_WeaponRateFactor(this)) REGISTER_STAT(GAMESTARTTIME, float) REGISTER_STAT(STRENGTH_FINISHED, float) diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index 769c0edf7..b2b1d973b 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -704,7 +704,7 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl return -1; if(MUTATOR_CALLHOOK(TurretValidateTarget, e_turret, e_target, validate_flags)) - return ret_float; + return M_ARGV(3, float); if (validate_flags & TFL_TARGETSELECT_NO) return -4; diff --git a/qcsrc/common/weapons/all.qc b/qcsrc/common/weapons/all.qc index 24ae60c3d..1e1ce3eed 100644 --- a/qcsrc/common/weapons/all.qc +++ b/qcsrc/common/weapons/all.qc @@ -262,7 +262,7 @@ string W_Sound(string w_snd) string output = strcat("weapons/", w_snd); #ifdef SVQC MUTATOR_CALLHOOK(WeaponSound, w_snd, output); - return weapon_sound_output; + return M_ARGV(1, string); #else return output; #endif diff --git a/qcsrc/common/weapons/weapon/arc.qc b/qcsrc/common/weapons/weapon/arc.qc index 5df635f77..ba75c98c5 100644 --- a/qcsrc/common/weapons/weapon/arc.qc +++ b/qcsrc/common/weapons/weapon/arc.qc @@ -805,7 +805,7 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i sound(actor, CH_WEAPON_A, SND_ARC_STOP, VOL_BASE, ATTN_NORM); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(arc, beam_animtime), w_ready); int slot = weaponslot(weaponentity); - ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(); + ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(arc, beam_refire) * W_WeaponRateFactor(actor); } actor.arc_BUTTON_ATCK_prev = false; @@ -816,7 +816,7 @@ METHOD(Arc, wr_think, void(entity thiswep, entity actor, .entity weaponentity, i W_Arc_Attack2(); actor.arc_count = autocvar_g_balance_arc_secondary_count; weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, autocvar_g_balance_arc_secondary_animtime, w_arc_checkattack); - actor.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor(); + actor.arc_secondarytime = time + autocvar_g_balance_arc_secondary_refire2 * W_WeaponRateFactor(actor); } #endif } diff --git a/qcsrc/common/weapons/weapon/devastator.qc b/qcsrc/common/weapons/weapon/devastator.qc index 772b9ea62..275c375f3 100644 --- a/qcsrc/common/weapons/weapon/devastator.qc +++ b/qcsrc/common/weapons/weapon/devastator.qc @@ -267,9 +267,9 @@ void W_Devastator_Think(entity this) // accelerate makevectors(self.angles.x * '-1 0 0' + self.angles.y * '0 1 0'); - velspeed = WEP_CVAR(devastator, speed) * W_WeaponSpeedFactor() - (self.velocity * v_forward); + velspeed = WEP_CVAR(devastator, speed) * W_WeaponSpeedFactor(self.realowner) - (self.velocity * v_forward); if(velspeed > 0) - self.velocity = self.velocity + v_forward * min(WEP_CVAR(devastator, speedaccel) * W_WeaponSpeedFactor() * frametime, velspeed); + self.velocity = self.velocity + v_forward * min(WEP_CVAR(devastator, speedaccel) * W_WeaponSpeedFactor(self.realowner) * frametime, velspeed); // laser guided, or remote detonation if(PS(self.realowner).m_weapon == WEP_DEVASTATOR) diff --git a/qcsrc/common/weapons/weapon/electro.qc b/qcsrc/common/weapons/weapon/electro.qc index 64a5e06aa..19e3ff8a8 100644 --- a/qcsrc/common/weapons/weapon/electro.qc +++ b/qcsrc/common/weapons/weapon/electro.qc @@ -492,7 +492,7 @@ METHOD(Electro, wr_think, void(entity thiswep, entity actor, .entity weaponentit W_Electro_Attack_Orb(thiswep, actor); actor.electro_count = WEP_CVAR_SEC(electro, count); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(electro, animtime), W_Electro_CheckAttack); - actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(); + actor.electro_secondarytime = time + WEP_CVAR_SEC(electro, refire2) * W_WeaponRateFactor(actor); } } } diff --git a/qcsrc/common/weapons/weapon/fireball.qc b/qcsrc/common/weapons/weapon/fireball.qc index 3ee23e8f5..d6768f9eb 100644 --- a/qcsrc/common/weapons/weapon/fireball.qc +++ b/qcsrc/common/weapons/weapon/fireball.qc @@ -386,7 +386,7 @@ METHOD(Fireball, wr_think, void(entity thiswep, entity actor, .entity weaponenti if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(fireball, refire))) { W_Fireball_Attack1_Frame0(thiswep, actor, weaponentity, fire); - actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(); + actor.fireball_primarytime = time + WEP_CVAR_PRI(fireball, refire2) * W_WeaponRateFactor(actor); } } else if(fire & 2) diff --git a/qcsrc/common/weapons/weapon/hagar.qc b/qcsrc/common/weapons/weapon/hagar.qc index 577d4cf4e..a81479869 100644 --- a/qcsrc/common/weapons/weapon/hagar.qc +++ b/qcsrc/common/weapons/weapon/hagar.qc @@ -295,7 +295,7 @@ void W_Hagar_Attack2_Load_Release(entity actor, .entity weaponentity) } weapon_thinkf(self, weaponentity, WFRAME_FIRE2, WEP_CVAR_SEC(hagar, load_animtime), w_ready); - self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor(); + self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, refire) * W_WeaponRateFactor(actor); self.hagar_load = 0; } @@ -332,7 +332,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) sound(self, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM); // pause until we can load rockets again, once we re-press the alt fire button - self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor(); + self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor(actor); // require letting go of the alt fire button before we can load again self.hagar_loadblock = true; @@ -353,7 +353,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) if(self.hagar_load >= WEP_CVAR_SEC(hagar, load_max)) stopped = true; else - self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor(); + self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_speed) * W_WeaponRateFactor(actor); } } if(stopped && !self.hagar_loadbeep && self.hagar_load) // prevents the beep from playing each frame @@ -361,7 +361,7 @@ void W_Hagar_Attack2_Load(Weapon thiswep, entity actor, .entity weaponentity) // if this is the last rocket we can load, play a beep sound to notify the player sound(self, CH_WEAPON_A, SND_HAGAR_BEEP, VOL_BASE, ATTN_NORM); self.hagar_loadbeep = true; - self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor(); + self.hagar_loadstep = time + WEP_CVAR_SEC(hagar, load_hold) * W_WeaponRateFactor(actor); } } } @@ -426,7 +426,7 @@ void W_Hagar_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity, int W_Hagar_Attack(thiswep, actor); int slot = weaponslot(weaponentity); - ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor(); + ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hagar, refire) * W_WeaponRateFactor(actor); int theframe = WFRAME_FIRE1; entity this = actor.(weaponentity); if(this) diff --git a/qcsrc/common/weapons/weapon/hlac.qc b/qcsrc/common/weapons/weapon/hlac.qc index 3fa50ff04..9d82c34f2 100644 --- a/qcsrc/common/weapons/weapon/hlac.qc +++ b/qcsrc/common/weapons/weapon/hlac.qc @@ -180,7 +180,7 @@ void W_HLAC_Attack_Frame(Weapon thiswep, entity actor, .entity weaponentity, int } int slot = weaponslot(weaponentity); - ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(); + ATTACK_FINISHED(actor, slot) = time + WEP_CVAR_PRI(hlac, refire) * W_WeaponRateFactor(actor); W_HLAC_Attack(WEP_HLAC, actor); actor.misc_bulletcounter = actor.misc_bulletcounter + 1; weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(hlac, refire), W_HLAC_Attack_Frame); diff --git a/qcsrc/common/weapons/weapon/hook.qc b/qcsrc/common/weapons/weapon/hook.qc index 7c4aabfe7..fd8fd9aef 100644 --- a/qcsrc/common/weapons/weapon/hook.qc +++ b/qcsrc/common/weapons/weapon/hook.qc @@ -215,7 +215,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, if(actor.hook) { // if hooked, no bombs, and increase the timer - actor.hook_refire = max(actor.hook_refire, time + WEP_CVAR_PRI(hook, refire) * W_WeaponRateFactor()); + actor.hook_refire = max(actor.hook_refire, time + WEP_CVAR_PRI(hook, refire) * W_WeaponRateFactor(actor)); // hook also inhibits health regeneration, but only for 1 second if(!(actor.items & IT_UNLIMITED_WEAPON_AMMO)) @@ -268,7 +268,7 @@ METHOD(Hook, wr_think, void(entity thiswep, entity actor, .entity weaponentity, RemoveGrapplingHook(actor); WITHSELF(actor, FireGrapplingHook()); actor.hook_state &= ~HOOK_FIRING; - actor.hook_refire = max(actor.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor()); + actor.hook_refire = max(actor.hook_refire, time + autocvar_g_balance_grapplehook_refire * W_WeaponRateFactor(actor)); } else if (actor.hook_state & HOOK_REMOVING) { diff --git a/qcsrc/common/weapons/weapon/machinegun.qc b/qcsrc/common/weapons/weapon/machinegun.qc index 10a8c40a1..2bf2f18bd 100644 --- a/qcsrc/common/weapons/weapon/machinegun.qc +++ b/qcsrc/common/weapons/weapon/machinegun.qc @@ -116,7 +116,7 @@ void W_MachineGun_Attack(Weapon thiswep, int deathtype, entity actor, .entity we } int slot = weaponslot(weaponentity); // this attack_finished just enforces a cooldown at the end of a burst - ATTACK_FINISHED(self, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(); + ATTACK_FINISHED(self, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor); if(self.misc_bulletcounter == 1) fireBullet(self, w_shotorg, w_shotdir, WEP_CVAR(machinegun, first_spread), WEP_CVAR(machinegun, solidpenetration), WEP_CVAR(machinegun, first_damage), WEP_CVAR(machinegun, first_force), deathtype, 0); @@ -205,7 +205,7 @@ void W_MachineGun_Attack_Auto(Weapon thiswep, entity actor, .entity weaponentity SpawnCasing(((random() * 50 + 50) * v_right) - (v_forward * (random() * 25 + 25)) - ((random() * 5 - 70) * v_up), 2, vectoangles(v_forward),'0 250 0', 100, 3, actor); int slot = weaponslot(weaponentity); - ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(); + ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, first_refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(machinegun, sustained_refire), W_MachineGun_Attack_Auto); } @@ -232,7 +232,7 @@ void W_MachineGun_Attack_Burst(Weapon thiswep, entity actor, .entity weaponentit if(actor.misc_bulletcounter == 0) { int slot = weaponslot(weaponentity); - ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(); + ATTACK_FINISHED(actor, slot) = time + WEP_CVAR(machinegun, burst_refire2) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, WEP_CVAR(machinegun, burst_animtime), w_ready); } else diff --git a/qcsrc/common/weapons/weapon/seeker.qc b/qcsrc/common/weapons/weapon/seeker.qc index 085255551..2fc642525 100644 --- a/qcsrc/common/weapons/weapon/seeker.qc +++ b/qcsrc/common/weapons/weapon/seeker.qc @@ -425,7 +425,7 @@ void W_Seeker_Vollycontroller_Think(entity this) // TODO: Merge this with W_Seek return; } - this.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor(); + this.nextthink = time + WEP_CVAR(seeker, missile_delay) * W_WeaponRateFactor(this.realowner); entity own = this.realowner; diff --git a/qcsrc/common/weapons/weapon/shockwave.qc b/qcsrc/common/weapons/weapon/shockwave.qc index a39e7697b..a138d6a68 100644 --- a/qcsrc/common/weapons/weapon/shockwave.qc +++ b/qcsrc/common/weapons/weapon/shockwave.qc @@ -137,7 +137,7 @@ void W_Shockwave_Melee_Think(entity this) makevectors(self.realowner.v_angle); // calculate swing percentage based on time - meleetime = WEP_CVAR(shockwave, melee_time) * W_WeaponRateFactor(); + meleetime = WEP_CVAR(shockwave, melee_time) * W_WeaponRateFactor(this.realowner); swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10); f = ((1 - swing) * WEP_CVAR(shockwave, melee_traces)); @@ -242,7 +242,7 @@ void W_Shockwave_Melee(Weapon thiswep, entity actor, .entity weaponentity, int f entity meleetemp = new_pure(meleetemp); meleetemp.owner = meleetemp.realowner = actor; setthink(meleetemp, W_Shockwave_Melee_Think); - meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor(); + meleetemp.nextthink = time + WEP_CVAR(shockwave, melee_delay) * W_WeaponRateFactor(actor); W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR(shockwave, melee_damage), WEP_CVAR(shockwave, melee_range)); } @@ -689,7 +689,7 @@ METHOD(Shockwave, wr_think, void(entity thiswep, entity actor, .entity weaponent if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR(shockwave, blast_animtime))) { W_Shockwave_Attack(actor); - actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor(); + actor.shockwave_blasttime = time + WEP_CVAR(shockwave, blast_refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR(shockwave, blast_animtime), w_ready); } } diff --git a/qcsrc/common/weapons/weapon/shotgun.qc b/qcsrc/common/weapons/weapon/shotgun.qc index 2440ea42e..8de7b6fb3 100644 --- a/qcsrc/common/weapons/weapon/shotgun.qc +++ b/qcsrc/common/weapons/weapon/shotgun.qc @@ -103,7 +103,7 @@ void W_Shotgun_Melee_Think(entity this) makevectors(self.realowner.v_angle); // update values for v_* vectors // calculate swing percentage based on time - meleetime = WEP_CVAR_SEC(shotgun, melee_time) * W_WeaponRateFactor(); + meleetime = WEP_CVAR_SEC(shotgun, melee_time) * W_WeaponRateFactor(this.realowner); swing = bound(0, (self.cnt + meleetime - time) / meleetime, 10); f = ((1 - swing) * WEP_CVAR_SEC(shotgun, melee_traces)); @@ -191,7 +191,7 @@ void W_Shotgun_Attack2(Weapon thiswep, entity actor, .entity weaponentity, int f entity meleetemp = new_pure(meleetemp); meleetemp.realowner = actor; setthink(meleetemp, W_Shotgun_Melee_Think); - meleetemp.nextthink = time + WEP_CVAR_SEC(shotgun, melee_delay) * W_WeaponRateFactor(); + meleetemp.nextthink = time + WEP_CVAR_SEC(shotgun, melee_delay) * W_WeaponRateFactor(actor); W_SetupShot_Range(actor, true, 0, SND_Null, 0, WEP_CVAR_SEC(shotgun, damage), WEP_CVAR_SEC(shotgun, melee_range)); } @@ -252,7 +252,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_PRI(shotgun, animtime))) { W_Shotgun_Attack(thiswep, actor, true); - actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(); + actor.shotgun_primarytime = time + WEP_CVAR_PRI(shotgun, refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_PRI(shotgun, animtime), w_ready); } } @@ -264,7 +264,7 @@ METHOD(Shotgun, wr_think, void(entity thiswep, entity actor, .entity weaponentit if(weapon_prepareattack(thiswep, actor, weaponentity, false, WEP_CVAR_SEC(shotgun, alt_animtime))) { W_Shotgun_Attack(thiswep, actor, false); - actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(); + actor.shotgun_primarytime = time + WEP_CVAR_SEC(shotgun, alt_refire) * W_WeaponRateFactor(actor); weapon_thinkf(actor, weaponentity, WFRAME_FIRE1, WEP_CVAR_SEC(shotgun, alt_animtime), W_Shotgun_Attack3_Frame1); } } diff --git a/qcsrc/common/weapons/weapon/tuba.qc b/qcsrc/common/weapons/weapon/tuba.qc index 3dd1c2628..147f2e00e 100644 --- a/qcsrc/common/weapons/weapon/tuba.qc +++ b/qcsrc/common/weapons/weapon/tuba.qc @@ -344,7 +344,7 @@ void W_Tuba_NoteOn(entity actor, float hittype) Net_LinkEntity(self.tuba_note, false, 0, W_Tuba_NoteSendEntity); } - self.tuba_note.teleport_time = time + WEP_CVAR(tuba, refire) * 2 * W_WeaponRateFactor(); // so it can get prolonged safely + self.tuba_note.teleport_time = time + WEP_CVAR(tuba, refire) * 2 * W_WeaponRateFactor(actor); // so it can get prolonged safely //sound(self, c, TUBA_NOTE(n), bound(0, VOL_BASE * cvar("g_balance_tuba_volume"), 1), autocvar_g_balance_tuba_attenuation); RadiusDamage(self, self, WEP_CVAR(tuba, damage), WEP_CVAR(tuba, edgedamage), WEP_CVAR(tuba, radius), NULL, NULL, WEP_CVAR(tuba, force), hittype | WEP_TUBA.m_id, NULL); diff --git a/qcsrc/common/weapons/weapon/vaporizer.qc b/qcsrc/common/weapons/weapon/vaporizer.qc index 3ade59d5f..ee77fc1c1 100644 --- a/qcsrc/common/weapons/weapon/vaporizer.qc +++ b/qcsrc/common/weapons/weapon/vaporizer.qc @@ -281,7 +281,7 @@ void W_RocketMinsta_Attack2(entity actor) //W_SETUPPROJECTILEVELOCITY(proj, g_balance_minstanex_laser); proj.velocity = (w_shotdir + (((counter + 0.5) / total) * 2 - 1) * v_right * (spread * (rndspread ? random() : 1))) * cvar("g_rm_laser_speed"); proj.velocity_z = proj.velocity_z + cvar("g_rm_laser_zspread") * (random() - 0.5); - proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true); + proj.velocity = W_CalculateProjectileVelocity(actor, actor.velocity, proj.velocity, true); proj.angles = vectoangles(proj.velocity); settouch(proj, W_RocketMinsta_Laser_Touch); setsize(proj, '0 0 -3', '0 0 -3'); @@ -331,7 +331,7 @@ void W_RocketMinsta_Attack3 (entity actor) proj.movetype = MOVETYPE_BOUNCEMISSILE; proj.velocity = w_shotdir * autocvar_g_rm_laser_speed; - proj.velocity = W_CalculateProjectileVelocity(proj.realowner.velocity, proj.velocity, true); + proj.velocity = W_CalculateProjectileVelocity(actor, actor.velocity, proj.velocity, true); proj.angles = vectoangles(proj.velocity); settouch(proj, W_RocketMinsta_Laser_Touch); setsize(proj, '0 0 -3', '0 0 -3'); @@ -395,7 +395,7 @@ METHOD(Vaporizer, wr_think, void(entity thiswep, entity actor, .entity weaponent else if (actor.jump_interval <= time) { // handle refire manually, so that primary and secondary can be fired without conflictions (important for instagib) - actor.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor(); + actor.jump_interval = time + WEP_CVAR_SEC(vaporizer, refire) * W_WeaponRateFactor(actor); // decrease ammo for the laser? if(WEP_CVAR_SEC(vaporizer, ammo)) diff --git a/qcsrc/server/bot/aim.qc b/qcsrc/server/bot/aim.qc index 0f138d2d5..ebbacd6b8 100644 --- a/qcsrc/server/bot/aim.qc +++ b/qcsrc/server/bot/aim.qc @@ -337,8 +337,8 @@ bool bot_aim(entity this, float shotspeed, float shotspeedupward, float maxshott hf = this.dphitcontentsmask; this.dphitcontentsmask = DPCONTENTS_SOLID | DPCONTENTS_BODY | DPCONTENTS_CORPSE; - shotspeed *= W_WeaponSpeedFactor(); - shotspeedupward *= W_WeaponSpeedFactor(); + shotspeed *= W_WeaponSpeedFactor(this); + shotspeedupward *= W_WeaponSpeedFactor(this); if (!shotspeed) { LOG_TRACE("bot_aim: WARNING: weapon ", PS(this).m_weapon.m_name, " shotspeed is zero!\n"); diff --git a/qcsrc/server/cl_client.qc b/qcsrc/server/cl_client.qc index 6f0e1d3ae..9d9d0fea2 100644 --- a/qcsrc/server/cl_client.qc +++ b/qcsrc/server/cl_client.qc @@ -187,7 +187,7 @@ void FixPlayermodel(entity player); void PutObserverInServer() { SELFPARAM(); - bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver); + bool mutator_returnvalue = MUTATOR_CALLHOOK(MakePlayerObserver, this); PlayerState_detach(this); if (IS_PLAYER(this) && this.health >= 1) { @@ -1191,7 +1191,7 @@ void ClientDisconnect() Send_Notification(NOTIF_ALL, world, MSG_INFO, INFO_QUIT_DISCONNECT, this.netname); - MUTATOR_CALLHOOK(ClientDisconnect); + MUTATOR_CALLHOOK(ClientDisconnect, this); ClientState_detach(this); diff --git a/qcsrc/server/cl_impulse.qc b/qcsrc/server/cl_impulse.qc index 251c6921e..5c1e6ea60 100644 --- a/qcsrc/server/cl_impulse.qc +++ b/qcsrc/server/cl_impulse.qc @@ -248,7 +248,7 @@ IMPULSE(weapon_drop) { if (this.vehicle) return; if (IS_DEAD(this)) return; - W_ThrowWeapon(this, W_CalculateProjectileVelocity(this.velocity, v_forward * 750, false), '0 0 0', true); + W_ThrowWeapon(this, W_CalculateProjectileVelocity(this, this.velocity, v_forward * 750, false), '0 0 0', true); } IMPULSE(weapon_reload) diff --git a/qcsrc/server/g_world.qc b/qcsrc/server/g_world.qc index 9d67d3346..5e242e48c 100644 --- a/qcsrc/server/g_world.qc +++ b/qcsrc/server/g_world.qc @@ -1928,7 +1928,7 @@ void CheckRules_World() if(checkrules_status == WINNING_YES) bprint("Hey! Someone ran out of spawns!\n"); else if(MUTATOR_CALLHOOK(CheckRules_World, checkrules_status, timelimit, fraglimit)) - checkrules_status = ret_float; + checkrules_status = M_ARGV(0, float); else checkrules_status = WinningCondition_Scores(fraglimit, leadlimit); diff --git a/qcsrc/server/miscfunctions.qc b/qcsrc/server/miscfunctions.qc index 0532feb6d..7eaf978a9 100644 --- a/qcsrc/server/miscfunctions.qc +++ b/qcsrc/server/miscfunctions.qc @@ -472,9 +472,9 @@ float want_weapon(entity weaponinfo, float allguns) // WEAPONTODO: what still ne return 0; bool mutator_returnvalue = MUTATOR_CALLHOOK(WantWeapon, weaponinfo, d, allguns, allow_mutatorblocked); - d = ret_float; - allguns = want_allguns; - allow_mutatorblocked = false; + d = M_ARGV(1, float); + allguns = M_ARGV(2, bool); + allow_mutatorblocked = M_ARGV(3, bool); if(allguns) { diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index eaef39ae8..143627180 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -6,6 +6,7 @@ /** called when a player becomes observer, after shared setup */ #define EV_MakePlayerObserver(i, o) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(MakePlayerObserver, EV_MakePlayerObserver) @@ -39,6 +40,7 @@ MUTATOR_HOOKABLE(ForbidPlayerScore_Clear, EV_ForbidPlayerScore_Clear); /** called when a player disconnects */ #define EV_ClientDisconnect(i, o) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ MUTATOR_HOOKABLE(ClientDisconnect, EV_ClientDisconnect); @@ -55,29 +57,24 @@ MUTATOR_HOOKABLE(PlayerDies, EV_PlayerDies); /** called when a player dies to e.g. remove stuff he was carrying */ #define EV_PlayHitsound(i, o) \ - /**/ i(entity, frag_victim) \ + /** victim */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ -entity frag_victim; MUTATOR_HOOKABLE(PlayHitsound, EV_PlayHitsound); /** called when a weapon sound is about to be played, allows custom paths etc. */ #define EV_WeaponSound(i, o) \ - /**/ i(string, weapon_sound) \ - /**/ i(string, weapon_sound_output) \ - /**/ o(string, weapon_sound_output) \ + /** sound */ i(string, MUTATOR_ARGV_0_string) \ + /** output */ i(string, MUTATOR_ARGV_1_string) \ + /**/ o(string, MUTATOR_ARGV_1_string) \ /**/ -string weapon_sound; -string weapon_sound_output; MUTATOR_HOOKABLE(WeaponSound, EV_WeaponSound); /** called when an item model is about to be set, allows custom paths etc. */ #define EV_ItemModel(i, o) \ - /**/ i(string, item_model) \ - /**/ i(string, item_model_output) \ - /**/ o(string, item_model_output) \ + /** model */ i(string, MUTATOR_ARGV_0_string) \ + /** output */ i(string, MUTATOR_ARGV_1_string) \ + /**/ o(string, MUTATOR_ARGV_1_string) \ /**/ -string item_model; -string item_model_output; MUTATOR_HOOKABLE(ItemModel, EV_ItemModel); /** called when someone was fragged by "self", and is expected to change frag_score to adjust scoring for the kill */ @@ -92,20 +89,19 @@ MUTATOR_HOOKABLE(GiveFragsForKill, EV_GiveFragsForKill); /** called when the match ends */ MUTATOR_HOOKABLE(MatchEnd, EV_NO_ARGS); -/** should adjust ret_float to contain the team count */ +/** should adjust number to contain the team count */ #define EV_GetTeamCount(i, o) \ - /**/ i(float, ret_float) \ - /**/ o(float, ret_float) \ - /**/ i(string, ret_string) \ - /**/ o(string, ret_string) \ + /** number of teams */ i(float, MUTATOR_ARGV_0_float) \ + /**/ o(float, MUTATOR_ARGV_0_float) \ + /** team entity name */ i(string, MUTATOR_ARGV_1_string) \ + /**/ o(string, MUTATOR_ARGV_1_string) \ /**/ -float ret_float; MUTATOR_HOOKABLE(GetTeamCount, EV_GetTeamCount); /** copies variables for spectating "other" to "self" */ #define EV_SpectateCopy(i, o) \ - /**/ i(entity, other) \ - /**/ i(entity, __self) \ + /** spectatee */ i(entity, MUTATOR_ARGV_0_entity) \ + /** client */ i(entity, MUTATOR_ARGV_1_entity) \ /**/ MUTATOR_HOOKABLE(SpectateCopy, EV_SpectateCopy); @@ -139,16 +135,17 @@ MUTATOR_HOOKABLE(SetDefaultAlpha, EV_NO_ARGS); /** allows changing attack rate */ #define EV_WeaponRateFactor(i, o) \ - /**/ i(float, weapon_rate) \ - /**/ o(float, weapon_rate) \ + /** weapon rate */ i(float, MUTATOR_ARGV_0_float) \ + /**/ o(float, MUTATOR_ARGV_0_float) \ + /** player */ i(entity, MUTATOR_ARGV_1_entity) \ /**/ -float weapon_rate; MUTATOR_HOOKABLE(WeaponRateFactor, EV_WeaponRateFactor); /** allows changing weapon speed (projectiles mostly) */ #define EV_WeaponSpeedFactor(i, o) \ - /**/ i(float, ret_float) \ - /**/ o(float, ret_float) \ + /** weapon speed */ i(float, MUTATOR_ARGV_0_float) \ + /**/ o(float, MUTATOR_ARGV_0_float) \ + /** player */ i(entity, MUTATOR_ARGV_1_entity) \ /**/ MUTATOR_HOOKABLE(WeaponSpeedFactor, EV_WeaponSpeedFactor); @@ -405,9 +402,9 @@ MUTATOR_HOOKABLE(PlayerUseKey, EV_NO_ARGS); * } */ #define EV_SV_ParseClientCommand(i, o) \ - /** client sending the command */ i(entity, MUTATOR_ARGV_0_entity) \ - /** command name */ i(string, MUTATOR_ARGV_1_string) \ - /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_2_int) \ + /** client sending the command */ i(entity, MUTATOR_ARGV_0_entity) \ + /** command name */ i(string, MUTATOR_ARGV_1_string) \ + /** argc (also, argv() can be used) */ i(int, MUTATOR_ARGV_2_int) \ /** whole command, use only if you really have to */ i(string, MUTATOR_ARGV_3_string) \ /**/ MUTATOR_HOOKABLE(SV_ParseClientCommand, EV_SV_ParseClientCommand); @@ -456,6 +453,7 @@ MUTATOR_HOOKABLE(Item_Spawn, EV_Item_Spawn); /**/ i(string, ret_string) \ /**/ o(string, ret_string) \ /**/ +//string ret_string; MUTATOR_HOOKABLE(SetWeaponreplace, EV_SetWeaponreplace); /** called when an item is about to respawn */ @@ -669,16 +667,15 @@ MUTATOR_HOOKABLE(Race_FinalCheckpoint, EV_Race_FinalCheckpoint); /** called when player triggered kill (or is changing teams), return error to not do anything */ #define EV_ClientKill(i, o) \ - /** player */ i(entity, __self) \ - /* kill delay */ i(float, ret_float) \ - /* kill delay */ o(float, ret_float) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ + /** kill delay */ i(float, MUTATOR_ARGV_1_float) \ + /**/ o(float, MUTATOR_ARGV_1_float) \ /**/ MUTATOR_HOOKABLE(ClientKill, EV_ClientKill); #define EV_FixClientCvars(i, o) \ - /**/ i(entity, fix_client) \ + /** player */ i(entity, MUTATOR_ARGV_0_entity) \ /**/ -entity fix_client; MUTATOR_HOOKABLE(FixClientCvars, EV_FixClientCvars); #define EV_SpectateSet(i, o) \ @@ -734,35 +731,30 @@ enum { }; #define EV_CheckRules_World(i, o) \ - /* status */ i(float, ret_float) \ - /* status */ o(float, ret_float) \ - /* time limit */ i(float, checkrules_timelimit) \ - /* frag limit */ i(int, checkrules_fraglimit) \ + /** status */ i(float, MUTATOR_ARGV_0_float) \ + /**/ o(float, MUTATOR_ARGV_0_float) \ + /* time limit */ i(float, MUTATOR_ARGV_1_float) \ + /* frag limit */ i(float, MUTATOR_ARGV_2_float) \ /**/ -float checkrules_timelimit; -int checkrules_fraglimit; MUTATOR_HOOKABLE(CheckRules_World, EV_CheckRules_World); #define EV_WantWeapon(i, o) \ - /**/ i(entity, want_weaponinfo) \ - /**/ i(float, ret_float) \ - /**/ o(float, ret_float) \ - /**/ i(bool, want_allguns) \ - /**/ o(bool, want_allguns) \ - /**/ i(bool, want_mutatorblocked) \ - /**/ o(bool, want_mutatorblocked) \ - /**/ -entity want_weaponinfo; -bool want_allguns; -bool want_mutatorblocked; + /** weapon info entity */ i(entity, MUTATOR_ARGV_0_entity) \ + /** do want? */ i(float, MUTATOR_ARGV_1_float) \ + /**/ o(float, MUTATOR_ARGV_1_float) \ + /** want all guns */ i(bool, MUTATOR_ARGV_2_bool) \ + /**/ o(bool, MUTATOR_ARGV_2_bool) \ + /** want mutator blocked */ i(bool, MUTATOR_ARGV_3_bool) \ + /**/ o(bool, MUTATOR_ARGV_3_bool) \ + /**/ MUTATOR_HOOKABLE(WantWeapon, EV_WantWeapon); #define EV_AddPlayerScore(i, o) \ - /**/ i(int, score_field) \ - /**/ i(float, ret_float) \ - /**/ o(float, ret_float) \ + /** score field */ i(int, MUTATOR_ARGV_0_int) \ + /** score */ i(float, MUTATOR_ARGV_1_float) \ + /**/ o(float, MUTATOR_ARGV_1_float) \ + /** player */ i(entity, MUTATOR_ARGV_2_entity) \ /**/ -int score_field; MUTATOR_HOOKABLE(AddPlayerScore, EV_AddPlayerScore); #define EV_GetPlayerStatus(i, o) \ @@ -806,13 +798,11 @@ int wp_flag; MUTATOR_HOOKABLE(SendWaypoint, EV_SendWaypoint); #define EV_TurretValidateTarget(i, o) \ - /**/ i(entity, turret_this) \ - /**/ i(entity, turret_target) \ - /**/ i(int, turret_vflags) \ + /** turret */ i(entity, MUTATOR_ARGV_0_entity) \ + /** target */ i(entity, MUTATOR_ARGV_1_entity) \ + /** validate flags */ i(int, MUTATOR_ARGV_2_int) \ + /** target score */ o(float, MUTATOR_ARGV_3_float) \ /**/ -entity turret_this; -entity turret_target; -int turret_vflags; MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget); #define EV_TurretThink(i, o) \ diff --git a/qcsrc/server/mutators/mutator/gamemode_assault.qc b/qcsrc/server/mutators/mutator/gamemode_assault.qc index c8519a76e..ca1779486 100644 --- a/qcsrc/server/mutators/mutator/gamemode_assault.qc +++ b/qcsrc/server/mutators/mutator/gamemode_assault.qc @@ -647,6 +647,8 @@ MUTATOR_HOOKFUNCTION(as, HavocBot_ChooseRole) MUTATOR_HOOKFUNCTION(as, PlayHitsound) { + entity frag_victim = M_ARGV(0, entity); + return (frag_victim.classname == "func_assault_destructible"); } @@ -659,7 +661,7 @@ MUTATOR_HOOKFUNCTION(as, GetTeamCount) MUTATOR_HOOKFUNCTION(as, CheckRules_World) { - ret_float = WinningCondition_Assault(); + M_ARGV(0, float) = WinningCondition_Assault(); return true; } diff --git a/qcsrc/server/mutators/mutator/gamemode_ca.qc b/qcsrc/server/mutators/mutator/gamemode_ca.qc index 32c69096c..ff011b59d 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ca.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ca.qc @@ -35,7 +35,6 @@ REGISTER_MUTATOR(ca, false) ca_teams = autocvar_g_ca_teams_override; if (ca_teams < 2) ca_teams = autocvar_g_ca_teams; ca_teams = bound(2, ca_teams, 4); - ret_float = ca_teams; ScoreRules_basics(ca_teams, SFL_SORT_PRIO_PRIMARY, 0, true); ScoreInfo_SetLabel_TeamScore(ST_CA_ROUNDS, "rounds", SFL_SORT_PRIO_PRIMARY); @@ -276,8 +275,7 @@ MUTATOR_HOOKFUNCTION(ca, reset_map_global) MUTATOR_HOOKFUNCTION(ca, GetTeamCount, CBC_ORDER_EXCLUSIVE) { - ret_float = ca_teams; - return false; + M_ARGV(0, float) = ca_teams; } entity ca_LastPlayerForTeam() @@ -320,10 +318,11 @@ MUTATOR_HOOKFUNCTION(ca, PlayerDies) MUTATOR_HOOKFUNCTION(ca, ClientDisconnect) { - SELFPARAM(); - if (this.caplayer == 1) + entity player = M_ARGV(0, entity); + + if (player.caplayer == 1) ca_LastPlayerForTeam_Notify(); - return 1; + return true; } MUTATOR_HOOKFUNCTION(ca, ForbidPlayerScore_Clear) @@ -333,13 +332,14 @@ MUTATOR_HOOKFUNCTION(ca, ForbidPlayerScore_Clear) MUTATOR_HOOKFUNCTION(ca, MakePlayerObserver) { - SELFPARAM(); - if (!IS_DEAD(this)) + entity player = M_ARGV(0, entity); + + if (!IS_DEAD(player)) ca_LastPlayerForTeam_Notify(); - if (this.killindicator_teamchange == -2) - this.caplayer = 0; - if (this.caplayer) - this.frags = FRAGS_LMS_LOSER; + if (player.killindicator_teamchange == -2) + player.caplayer = 0; + if (player.caplayer) + player.frags = FRAGS_LMS_LOSER; if (!warmup_stage) eliminatedPlayers.SendFlags |= 1; return true; // prevent team reset @@ -497,8 +497,7 @@ MUTATOR_HOOKFUNCTION(ca, ClientCommand_Spectate) MUTATOR_HOOKFUNCTION(ca, WantWeapon) { - want_allguns = true; - return false; + M_ARGV(2, bool) = true; // all weapons } MUTATOR_HOOKFUNCTION(ca, GetPlayerStatus) diff --git a/qcsrc/server/mutators/mutator/gamemode_ctf.qc b/qcsrc/server/mutators/mutator/gamemode_ctf.qc index 1d8ad402f..ab664794a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_ctf.qc +++ b/qcsrc/server/mutators/mutator/gamemode_ctf.qc @@ -471,7 +471,7 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype) makevectors((player.v_angle.y * '0 1 0') + (bound(autocvar_g_ctf_throw_angle_min, player.v_angle.x, autocvar_g_ctf_throw_angle_max) * '1 0 0')); flag_velocity = (('0 0 1' * autocvar_g_ctf_throw_velocity_up) + ((v_forward * autocvar_g_ctf_throw_velocity_forward) * ((player.items & ITEM_Strength.m_itemid) ? autocvar_g_ctf_throw_strengthmultiplier : 1))); - flag.velocity = W_CalculateProjectileVelocity(player.velocity, flag_velocity, false); + flag.velocity = W_CalculateProjectileVelocity(player, player.velocity, flag_velocity, false); ctf_Handle_Drop(flag, player, droptype); break; } @@ -485,7 +485,7 @@ void ctf_Handle_Throw(entity player, entity receiver, int droptype) default: case DROP_NORMAL: { - flag.velocity = W_CalculateProjectileVelocity(player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false); + flag.velocity = W_CalculateProjectileVelocity(player, player.velocity, (('0 0 1' * autocvar_g_ctf_drop_velocity_up) + ((('0 1 0' * crandom()) + ('1 0 0' * crandom())) * autocvar_g_ctf_drop_velocity_side)), false); ctf_Handle_Drop(flag, player, droptype); break; } @@ -2104,15 +2104,18 @@ void ctf_RemovePlayer(entity player) } MUTATOR_HOOKFUNCTION(ctf, MakePlayerObserver) -{SELFPARAM(); - ctf_RemovePlayer(self); +{ + entity player = M_ARGV(0, entity); + + ctf_RemovePlayer(player); return false; } MUTATOR_HOOKFUNCTION(ctf, ClientDisconnect) -{SELFPARAM(); - ctf_RemovePlayer(self); - return false; +{ + entity player = M_ARGV(0, entity); + + ctf_RemovePlayer(player); } MUTATOR_HOOKFUNCTION(ctf, PortalTeleport) @@ -2325,15 +2328,17 @@ MUTATOR_HOOKFUNCTION(ctf, HavocBot_ChooseRole) MUTATOR_HOOKFUNCTION(ctf, GetTeamCount) { - //ret_float = ctf_teams; - ret_string = "ctf_team"; + //M_ARGV(0, float) = ctf_teams; + M_ARGV(1, string) = "ctf_team"; return true; } MUTATOR_HOOKFUNCTION(ctf, SpectateCopy) -{SELFPARAM(); - self.ctf_flagstatus = other.ctf_flagstatus; - return false; +{ + entity spectatee = M_ARGV(0, entity); + entity client = M_ARGV(1, entity); + + client.ctf_flagstatus = spectatee.ctf_flagstatus; } MUTATOR_HOOKFUNCTION(ctf, GetRecords) diff --git a/qcsrc/server/mutators/mutator/gamemode_cts.qc b/qcsrc/server/mutators/mutator/gamemode_cts.qc index 65376b78d..cbe6544c4 100644 --- a/qcsrc/server/mutators/mutator/gamemode_cts.qc +++ b/qcsrc/server/mutators/mutator/gamemode_cts.qc @@ -240,14 +240,16 @@ MUTATOR_HOOKFUNCTION(cts, ClientConnect) } MUTATOR_HOOKFUNCTION(cts, MakePlayerObserver) -{SELFPARAM(); - if(PlayerScore_Add(self, SP_RACE_FASTEST, 0)) - self.frags = FRAGS_LMS_LOSER; +{ + entity player = M_ARGV(0, entity); + + if(PlayerScore_Add(player, SP_RACE_FASTEST, 0)) + player.frags = FRAGS_LMS_LOSER; else - self.frags = FRAGS_SPECTATOR; + player.frags = FRAGS_SPECTATOR; - race_PreparePlayer(this); - self.race_checkpoint = -1; + race_PreparePlayer(player); + player.race_checkpoint = -1; return false; } @@ -403,18 +405,18 @@ MUTATOR_HOOKFUNCTION(cts, GetRecords) void ClientKill_Now(); MUTATOR_HOOKFUNCTION(cts, ClientKill) { - SELFPARAM(); - ret_float = 0; + entity player = M_ARGV(0, entity); - if(self.killindicator && self.killindicator.health == 1) // self.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill + M_ARGV(1, float) = 0; // kill delay + + if(player.killindicator && player.killindicator.health == 1) // player.killindicator.health == 1 means that the kill indicator was spawned by CTS_ClientKill { - remove(self.killindicator); - self.killindicator = world; + remove(player.killindicator); + player.killindicator = world; - ClientKill_Now(); // allow instant kill in this case + WITHSELF(player, ClientKill_Now()); // allow instant kill in this case return; } - } MUTATOR_HOOKFUNCTION(cts, Race_FinalCheckpoint) @@ -427,14 +429,15 @@ MUTATOR_HOOKFUNCTION(cts, Race_FinalCheckpoint) MUTATOR_HOOKFUNCTION(cts, FixClientCvars) { - stuffcmd(fix_client, "cl_cmd settemp cl_movecliptokeyboard 2\n"); - return false; + entity player = M_ARGV(0, entity); + + stuffcmd(player, "cl_cmd settemp cl_movecliptokeyboard 2\n"); } MUTATOR_HOOKFUNCTION(cts, WantWeapon) { - ret_float = (want_weaponinfo == WEP_SHOTGUN); - want_mutatorblocked = true; + M_ARGV(1, float) = (M_ARGV(0, entity) == WEP_SHOTGUN); // want weapon = weapon info + M_ARGV(3, bool) = true; // want mutator blocked return true; } diff --git a/qcsrc/server/mutators/mutator/gamemode_domination.qc b/qcsrc/server/mutators/mutator/gamemode_domination.qc index abee018be..ea70cb61a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_domination.qc +++ b/qcsrc/server/mutators/mutator/gamemode_domination.qc @@ -468,8 +468,8 @@ void havocbot_role_dom(entity this) MUTATOR_HOOKFUNCTION(dom, GetTeamCount) { // fallback? - ret_float = domination_teams; - ret_string = "dom_team"; + M_ARGV(0, float) = domination_teams; + string ret_string = "dom_team"; entity head = find(world, classname, ret_string); while(head) @@ -488,7 +488,7 @@ MUTATOR_HOOKFUNCTION(dom, GetTeamCount) head = find(head, classname, ret_string); } - ret_string = string_null; + M_ARGV(1, string) = string_null; return true; } diff --git a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc index 86b8d1336..c10ba0b78 100644 --- a/qcsrc/server/mutators/mutator/gamemode_freezetag.qc +++ b/qcsrc/server/mutators/mutator/gamemode_freezetag.qc @@ -352,24 +352,28 @@ void havocbot_role_ft_freeing(entity this) // Hook Functions // ============== -void ft_RemovePlayer() -{SELFPARAM(); - self.health = 0; // neccessary to update correctly alive stats - if(!STAT(FROZEN, self)) +void ft_RemovePlayer(entity this) +{ + this.health = 0; // neccessary to update correctly alive stats + if(!STAT(FROZEN, this)) freezetag_LastPlayerForTeam_Notify(); - freezetag_Unfreeze(world); + WITHSELF(this, freezetag_Unfreeze(world)); freezetag_count_alive_players(); } MUTATOR_HOOKFUNCTION(ft, ClientDisconnect) { - ft_RemovePlayer(); - return 1; + entity player = M_ARGV(0, entity); + + ft_RemovePlayer(player); + return true; } MUTATOR_HOOKFUNCTION(ft, MakePlayerObserver) { - ft_RemovePlayer(); + entity player = M_ARGV(0, entity); + + ft_RemovePlayer(player); return false; } @@ -596,8 +600,7 @@ MUTATOR_HOOKFUNCTION(ft, HavocBot_ChooseRole) MUTATOR_HOOKFUNCTION(ft, GetTeamCount, CBC_ORDER_EXCLUSIVE) { - ret_float = freezetag_teams; - return false; + M_ARGV(0, float) = freezetag_teams; } MUTATOR_HOOKFUNCTION(ft, SetWeaponArena) diff --git a/qcsrc/server/mutators/mutator/gamemode_invasion.qc b/qcsrc/server/mutators/mutator/gamemode_invasion.qc index ea2ed6e1d..cfd4f9612 100644 --- a/qcsrc/server/mutators/mutator/gamemode_invasion.qc +++ b/qcsrc/server/mutators/mutator/gamemode_invasion.qc @@ -481,8 +481,7 @@ MUTATOR_HOOKFUNCTION(inv, AllowMobSpawning) MUTATOR_HOOKFUNCTION(inv, GetTeamCount, CBC_ORDER_EXCLUSIVE) { - ret_float = invasion_teams; - return false; + M_ARGV(0, float) = invasion_teams; } MUTATOR_HOOKFUNCTION(inv, AllowMobButcher) diff --git a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc index 0da0e3025..d13e62200 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keepaway.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keepaway.qc @@ -408,14 +408,17 @@ MUTATOR_HOOKFUNCTION(ka, PlayerDamage_Calculate) // for changing damage and forc } MUTATOR_HOOKFUNCTION(ka, ClientDisconnect) -{SELFPARAM(); - if(self.ballcarried) { ka_DropEvent(self); } // a player with the ball has left the match, drop it - return false; +{ + entity player = M_ARGV(0, entity); + + if(player.ballcarried) { ka_DropEvent(player); } // a player with the ball has left the match, drop it } MUTATOR_HOOKFUNCTION(ka, MakePlayerObserver) -{SELFPARAM(); - if(self.ballcarried) { ka_DropEvent(self); } // a player with the ball has left the match, drop it +{ + entity player = M_ARGV(0, entity); + + if(player.ballcarried) { ka_DropEvent(player); } // a player with the ball has left the match, drop it return false; } diff --git a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc index ef23a9109..2fb8632f8 100644 --- a/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc +++ b/qcsrc/server/mutators/mutator/gamemode_keyhunt.qc @@ -878,7 +878,7 @@ void kh_Key_DropOne(entity key) kh_Key_AssignTo(key, world); makevectors(player.v_angle); - key.velocity = W_CalculateProjectileVelocity(player.velocity, autocvar_g_balance_keyhunt_throwvelocity * v_forward, false); + key.velocity = W_CalculateProjectileVelocity(player, player.velocity, autocvar_g_balance_keyhunt_throwvelocity * v_forward, false); key.pusher = world; key.pushltime = time + autocvar_g_balance_keyhunt_protecttime; key.kh_dropperteam = key.team; @@ -903,7 +903,7 @@ void kh_Key_DropAll(entity player, float suicide) // runs whenever a player dies Send_Notification(NOTIF_ALL, world, MSG_INFO, APP_TEAM_ENT(key, INFO_KEYHUNT_LOST), player.netname); kh_Key_AssignTo(key, world); makevectors('-1 0 0' * (45 + 45 * random()) + '0 360 0' * random()); - key.velocity = W_CalculateProjectileVelocity(player.velocity, autocvar_g_balance_keyhunt_dropvelocity * v_forward, false); + key.velocity = W_CalculateProjectileVelocity(player, player.velocity, autocvar_g_balance_keyhunt_dropvelocity * v_forward, false); key.pusher = mypusher; key.pushltime = time + autocvar_g_balance_keyhunt_protecttime; if(suicide) @@ -1290,15 +1290,17 @@ void havocbot_role_kh_freelancer(entity this) // register this as a mutator MUTATOR_HOOKFUNCTION(kh, ClientDisconnect) -{SELFPARAM(); - kh_Key_DropAll(self, true); - return 0; +{ + entity player = M_ARGV(0, entity); + + kh_Key_DropAll(player, true); } MUTATOR_HOOKFUNCTION(kh, MakePlayerObserver) -{SELFPARAM(); - kh_Key_DropAll(self, true); - return 0; +{ + entity player = M_ARGV(0, entity); + + kh_Key_DropAll(player, true); } MUTATOR_HOOKFUNCTION(kh, PlayerDies) @@ -1332,14 +1334,15 @@ MUTATOR_HOOKFUNCTION(kh, MatchEnd) MUTATOR_HOOKFUNCTION(kh, GetTeamCount, CBC_ORDER_EXCLUSIVE) { - ret_float = kh_teams; - return false; + M_ARGV(0, float) = kh_teams; } MUTATOR_HOOKFUNCTION(kh, SpectateCopy) -{SELFPARAM(); - self.kh_state = other.kh_state; - return 0; +{ + entity spectatee = M_ARGV(0, entity); + entity client = M_ARGV(1, entity); + + client.kh_state = spectatee.kh_state; } MUTATOR_HOOKFUNCTION(kh, PlayerUseKey) diff --git a/qcsrc/server/mutators/mutator/gamemode_lms.qc b/qcsrc/server/mutators/mutator/gamemode_lms.qc index 8670bbbef..8ff6c190a 100644 --- a/qcsrc/server/mutators/mutator/gamemode_lms.qc +++ b/qcsrc/server/mutators/mutator/gamemode_lms.qc @@ -204,15 +204,17 @@ void lms_RemovePlayer(entity player) } MUTATOR_HOOKFUNCTION(lms, ClientDisconnect) -{SELFPARAM(); - lms_RemovePlayer(self); - return false; +{ + entity player = M_ARGV(0, entity); + + lms_RemovePlayer(player); } MUTATOR_HOOKFUNCTION(lms, MakePlayerObserver) { - SELFPARAM(); - lms_RemovePlayer(this); + entity player = M_ARGV(0, entity); + + lms_RemovePlayer(player); return true; // prevent team reset } @@ -371,14 +373,13 @@ MUTATOR_HOOKFUNCTION(lms, ClientCommand_Spectate) MUTATOR_HOOKFUNCTION(lms, CheckRules_World) { - ret_float = WinningCondition_LMS(); + M_ARGV(0, float) = WinningCondition_LMS(); return true; } MUTATOR_HOOKFUNCTION(lms, WantWeapon) { - want_allguns = true; - return false; + M_ARGV(2, bool) = true; // all weapons } MUTATOR_HOOKFUNCTION(lms, GetPlayerStatus) @@ -389,7 +390,7 @@ MUTATOR_HOOKFUNCTION(lms, GetPlayerStatus) MUTATOR_HOOKFUNCTION(lms, AddPlayerScore) { if(gameover) - if(score_field == SP_LMS_RANK) + if(M_ARGV(0, int) == SP_LMS_RANK) // score field return true; // allow writing to this field in intermission as it is needed for newly joining players return false; } diff --git a/qcsrc/server/mutators/mutator/gamemode_race.qc b/qcsrc/server/mutators/mutator/gamemode_race.qc index c3be9b247..9e41ac483 100644 --- a/qcsrc/server/mutators/mutator/gamemode_race.qc +++ b/qcsrc/server/mutators/mutator/gamemode_race.qc @@ -272,17 +272,17 @@ MUTATOR_HOOKFUNCTION(rc, ClientConnect) } MUTATOR_HOOKFUNCTION(rc, MakePlayerObserver) -{SELFPARAM(); +{ + entity player = M_ARGV(0, entity); + if(g_race_qualifying) - if(PlayerScore_Add(self, SP_RACE_FASTEST, 0)) - self.frags = FRAGS_LMS_LOSER; + if(PlayerScore_Add(player, SP_RACE_FASTEST, 0)) + player.frags = FRAGS_LMS_LOSER; else - self.frags = FRAGS_SPECTATOR; - - race_PreparePlayer(this); - self.race_checkpoint = -1; + player.frags = FRAGS_SPECTATOR; - return false; + race_PreparePlayer(player); + player.race_checkpoint = -1; } MUTATOR_HOOKFUNCTION(rc, PlayerSpawn) @@ -387,8 +387,7 @@ MUTATOR_HOOKFUNCTION(rc, ForbidPlayerScore_Clear) MUTATOR_HOOKFUNCTION(rc, GetTeamCount, CBC_ORDER_EXCLUSIVE) { - ret_float = race_teams; - return false; + M_ARGV(0, float) = race_teams; } MUTATOR_HOOKFUNCTION(rc, Scores_CountFragsRemaining) @@ -421,22 +420,26 @@ MUTATOR_HOOKFUNCTION(rc, GetRecords) MUTATOR_HOOKFUNCTION(rc, FixClientCvars) { - stuffcmd(fix_client, "cl_cmd settemp cl_movecliptokeyboard 2\n"); - return false; + entity player = M_ARGV(0, entity); + + stuffcmd(player, "cl_cmd settemp cl_movecliptokeyboard 2\n"); } MUTATOR_HOOKFUNCTION(rc, CheckRules_World) { + float checkrules_timelimit = M_ARGV(1, float); + float checkrules_fraglimit = M_ARGV(2, float); + if(checkrules_timelimit >= 0) { if(!g_race_qualifying) { - ret_float = WinningCondition_Race(checkrules_fraglimit); + M_ARGV(0, float) = WinningCondition_Race(checkrules_fraglimit); return true; } else if(g_race_qualifying == 2) { - ret_float = WinningCondition_QualifyingThenRace(checkrules_fraglimit); + M_ARGV(0, float) = WinningCondition_QualifyingThenRace(checkrules_fraglimit); return true; } } diff --git a/qcsrc/server/mutators/mutator/gamemode_tdm.qc b/qcsrc/server/mutators/mutator/gamemode_tdm.qc index d391f11b2..2eeaafa30 100644 --- a/qcsrc/server/mutators/mutator/gamemode_tdm.qc +++ b/qcsrc/server/mutators/mutator/gamemode_tdm.qc @@ -87,7 +87,7 @@ void tdm_DelayedInit(entity this) MUTATOR_HOOKFUNCTION(tdm, GetTeamCount, CBC_ORDER_EXCLUSIVE) { - ret_string = "tdm_team"; + M_ARGV(1, string) = "tdm_team"; return true; } diff --git a/qcsrc/server/scores.qc b/qcsrc/server/scores.qc index efefcd17a..e7a3aa9ab 100644 --- a/qcsrc/server/scores.qc +++ b/qcsrc/server/scores.qc @@ -333,8 +333,8 @@ void PlayerScore_Detach(entity player) float PlayerScore_Add(entity player, float scorefield, float score) { - bool mutator_returnvalue = MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score); - score = ret_float; + bool mutator_returnvalue = MUTATOR_CALLHOOK(AddPlayerScore, scorefield, score, player); + score = M_ARGV(1, float); if(gameover) if(!mutator_returnvalue) diff --git a/qcsrc/server/teamplay.qc b/qcsrc/server/teamplay.qc index 7d31de0ae..db724692b 100644 --- a/qcsrc/server/teamplay.qc +++ b/qcsrc/server/teamplay.qc @@ -214,8 +214,8 @@ void CheckAllowedTeams (entity for_whom) string teament_name = string_null; bool mutator_returnvalue = MUTATOR_CALLHOOK(GetTeamCount, dm, teament_name); - teament_name = ret_string; - dm = ret_float; + dm = M_ARGV(0, float); + teament_name = M_ARGV(1, string); if(!mutator_returnvalue) { diff --git a/qcsrc/server/weapons/tracing.qc b/qcsrc/server/weapons/tracing.qc index 81fa73d49..7bd69c9d4 100644 --- a/qcsrc/server/weapons/tracing.qc +++ b/qcsrc/server/weapons/tracing.qc @@ -146,13 +146,13 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m //if(w_shotdir != prevdir) { printf("SERVER: shotDIR differs: %s - %s\n", vtos(w_shotdir), vtos(prevdir)); } } -vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity, float forceAbsolute) +vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute) { vector mdirection; float mspeed; vector outvelocity; - mvelocity = mvelocity * W_WeaponSpeedFactor(); + mvelocity = mvelocity * W_WeaponSpeedFactor(actor); mdirection = normalize(mvelocity); mspeed = vlen(mvelocity); @@ -189,7 +189,7 @@ void W_SetupProjVelocity_Explicit(entity proj, vector dir, vector upDir, float p LOG_INFO("avg: ", ftos(mspercallcount / mspercallsum), " per sec\n"); #endif - proj.velocity = W_CalculateProjectileVelocity(proj.owner.velocity, pSpeed * dir, forceAbsolute); + proj.velocity = W_CalculateProjectileVelocity(proj.owner, proj.owner.velocity, pSpeed * dir, forceAbsolute); } diff --git a/qcsrc/server/weapons/tracing.qh b/qcsrc/server/weapons/tracing.qh index decdc39d9..52e5bd840 100644 --- a/qcsrc/server/weapons/tracing.qh +++ b/qcsrc/server/weapons/tracing.qh @@ -15,7 +15,7 @@ void W_SetupShot_Dir_ProjectileSize_Range(entity ent, vector s_forward, vector m #define W_SetupShot(ent,antilag,recoil,snd,chan,maxdamage) W_SetupShot_ProjectileSize(ent, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage) #define W_SetupShot_Range(ent,antilag,recoil,snd,chan,maxdamage,range) W_SetupShot_Dir_ProjectileSize_Range(ent, v_forward, '0 0 0', '0 0 0', antilag, recoil, snd, chan, maxdamage, range) -vector W_CalculateProjectileVelocity(vector pvelocity, vector mvelocity, float forceAbsolute); +vector W_CalculateProjectileVelocity(entity actor, vector pvelocity, vector mvelocity, float forceAbsolute); #if 0 float mspercallsum; diff --git a/qcsrc/server/weapons/weaponsystem.qc b/qcsrc/server/weapons/weaponsystem.qc index d6b155048..12b2e7daa 100644 --- a/qcsrc/server/weapons/weaponsystem.qc +++ b/qcsrc/server/weapons/weaponsystem.qc @@ -19,22 +19,22 @@ .float weapon_frametime; -float W_WeaponRateFactor() +float W_WeaponRateFactor(entity this) { float t = 1.0 / g_weaponratefactor; - MUTATOR_CALLHOOK(WeaponRateFactor, t); - t = weapon_rate; + MUTATOR_CALLHOOK(WeaponRateFactor, t, this); + t = M_ARGV(0, float); return t; } -float W_WeaponSpeedFactor() +float W_WeaponSpeedFactor(entity this) { float t = 1.0 * g_weaponspeedfactor; - MUTATOR_CALLHOOK(WeaponSpeedFactor, t); - t = ret_float; + MUTATOR_CALLHOOK(WeaponSpeedFactor, t, this); + t = M_ARGV(0, float); return t; } @@ -299,7 +299,7 @@ void weapon_prepareattack_do(entity actor, .entity weaponentity, bool secondary, ATTACK_FINISHED(actor, slot) = time; // dprint("resetting attack finished to ", ftos(time), "\n"); } - ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * W_WeaponRateFactor(); + ATTACK_FINISHED(actor, slot) = ATTACK_FINISHED(actor, slot) + attacktime * W_WeaponRateFactor(actor); } actor.bulletcounter += 1; // dprint("attack finished ", ftos(ATTACK_FINISHED(actor, slot)), "\n"); @@ -357,7 +357,7 @@ void weapon_thinkf(entity actor, .entity weaponentity, WFRAME fr, float t, void( if (this.weapon_think == w_ready && func != w_ready && this.state == WS_RAISE) backtrace( "Tried to override initial weapon think function - should this really happen?"); - t *= W_WeaponRateFactor(); + t *= W_WeaponRateFactor(actor); // VorteX: haste can be added here if (this.weapon_think == w_ready) diff --git a/qcsrc/server/weapons/weaponsystem.qh b/qcsrc/server/weapons/weaponsystem.qh index a43a40c2f..2aeca5381 100644 --- a/qcsrc/server/weapons/weaponsystem.qh +++ b/qcsrc/server/weapons/weaponsystem.qh @@ -20,9 +20,9 @@ void W_Reload(entity actor, float sent_ammo_min, Sound sent_sound); void W_WeaponFrame(Player actor); -float W_WeaponRateFactor(); +float W_WeaponRateFactor(entity this); -float W_WeaponSpeedFactor(); +float W_WeaponSpeedFactor(entity this); bool weapon_prepareattack(Weapon thiswep, entity actor, .entity weaponentity, bool secondary, float attacktime); -- 2.39.2