From 7df2b70957b51529244dc2ce7c0dc68c071590bb Mon Sep 17 00:00:00 2001 From: Mario Date: Thu, 15 Oct 2015 01:29:29 +1000 Subject: [PATCH] Another 2 gamemode specific checks killed --- qcsrc/common/turrets/sv_turrets.qc | 24 +++--------------- qcsrc/server/mutators/events.qh | 15 +++++++++++ qcsrc/server/mutators/gamemode_onslaught.qc | 28 +++++++++++++++++++++ 3 files changed, 47 insertions(+), 20 deletions(-) diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index e1c23c7ab..ec7ce3711 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -708,9 +708,8 @@ float turret_validate_target(entity e_turret, entity e_target, float validate_fl if(e_target.alpha <= 0.3) return -1; - if(g_onslaught) - if (substring(e_target.classname, 0, 10) == "onslaught_") // don't attack onslaught targets, that's the player's job! - return - 3; + if(MUTATOR_CALLHOOK(TurretValidateTarget, e_turret, e_target, validate_flags)) + return ret_float; if (validate_flags & TFL_TARGETSELECT_NO) return -4; @@ -1019,24 +1018,9 @@ void turret_fire() void turret_think() {SELFPARAM(); - entity e; - self.nextthink = time + self.ticrate; - // ONS uses somewhat backwards linking. - if (teamplay) - { - if (g_onslaught) - if (self.target) - { - e = find(world, targetname,self.target); - if (e != world) - self.team = e.team; - } - - if (self.team != self.tur_head.team) - turret_respawn(); - } + MUTATOR_CALLHOOK(TurretThink, self); #ifdef TURRET_DEBUG if (self.tur_debug_tmr1 < time) @@ -1065,7 +1049,7 @@ void turret_think() if (self.shoot_flags & TFL_SHOOT_HITALLVALID) { // Do a self.turret_fire for every valid target. - e = findradius(self.origin,self.target_range); + entity e = findradius(self.origin,self.target_range); while (e) { if(e.takedamage) diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 44801a256..93861ffae 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -784,4 +784,19 @@ entity wp_sendto; int wp_sendflags; 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) \ + /**/ +entity turret_this; +entity turret_target; +int turret_vflags; +MUTATOR_HOOKABLE(TurretValidateTarget, EV_TurretValidateTarget); + +#define EV_TurretThink(i, o) \ + /**/ i(entity, __self) \ + /**/ +MUTATOR_HOOKABLE(TurretThink, EV_TurretThink); #endif diff --git a/qcsrc/server/mutators/gamemode_onslaught.qc b/qcsrc/server/mutators/gamemode_onslaught.qc index 68318f4d6..53cf0c798 100644 --- a/qcsrc/server/mutators/gamemode_onslaught.qc +++ b/qcsrc/server/mutators/gamemode_onslaught.qc @@ -2066,6 +2066,34 @@ MUTATOR_HOOKFUNCTION(ons, SendWaypoint) return false; } +MUTATOR_HOOKFUNCTION(ons, TurretValidateTarget) +{ + if(substring(turret_target.classname, 0, 10) == "onslaught_") // don't attack onslaught targets, that's the player's job! + { + ret_float = -3; + return true; + } + + return false; +} + +MUTATOR_HOOKFUNCTION(ons, TurretThink) +{ + // ONS uses somewhat backwards linking. + if(self.target) + { + entity e = find(world, targetname, self.target); + if (e != world) + self.team = e.team; + } + + if(self.team != self.tur_head.team) + turret_respawn(); + + return false; +} + + // ========== // Spawnfuncs // ========== -- 2.39.2