From e9c9fda4a8d7356d101316ea3050c84b0daf9b47 Mon Sep 17 00:00:00 2001 From: Mario Date: Fri, 28 Aug 2015 21:04:10 +1000 Subject: [PATCH] Add some more hooks and fix a particle effect call --- qcsrc/common/triggers/func/breakable.qc | 4 ++-- qcsrc/common/turrets/sv_turrets.qc | 20 ++++++++++++++++---- qcsrc/common/turrets/unit/fusionreactor.qc | 20 ++++++++++---------- qcsrc/server/mutators/events.qh | 14 ++++++++++++++ 4 files changed, 42 insertions(+), 16 deletions(-) diff --git a/qcsrc/common/triggers/func/breakable.qc b/qcsrc/common/triggers/func/breakable.qc index 12a225ad9..444b99b35 100644 --- a/qcsrc/common/triggers/func/breakable.qc +++ b/qcsrc/common/triggers/func/breakable.qc @@ -211,8 +211,8 @@ void func_breakable_destroy() { if(self.dmg) RadiusDamage(self, activator, self.dmg, self.dmg_edge, self.dmg_radius, self, world, self.dmg_force, DEATH_HURTTRIGGER, world); - if(self.cnt) - Send_Effect((effects_ent[self.cnt - 1]).eent_eff_name, self.absmin * 0.5 + self.absmax * 0.5, '0 0 0', self.count); + if(self.cnt) // TODO + pointparticles(self.cnt, self.absmin * 0.5 + self.absmax * 0.5, '0 0 0', self.count); if(self.respawntime) { diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index fa5318dc2..4595d6789 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -974,11 +974,23 @@ float turret_firecheck() return 1; } +bool turret_checkfire() +{ + bool ret = false; // dummy + if(MUTATOR_CALLHOOK(Turret_CheckFire, ret)) + return ret_bool; + + return self.turret_firecheckfunc(); +} + void turret_fire() { if (autocvar_g_turrets_nofire != 0) return; + if(MUTATOR_CALLHOOK(TurretFire, self)) + return; + TUR_ACTION(self.turretid, TR_ATTACK); self.attack_finished_single = time + self.shot_refire; @@ -1060,7 +1072,7 @@ void turret_think() turret_do_updates(self); - if (self.turret_firecheckfunc()) + if (turret_checkfire()) turret_fire(); } } @@ -1084,7 +1096,7 @@ void turret_think() turret_do_updates(self); // Fire? - if (self.turret_firecheckfunc()) + if (turret_checkfire()) turret_fire(); } else @@ -1104,7 +1116,7 @@ void turret_think() turret_do_updates(self); // Fire! - if (self.turret_firecheckfunc() != 0) + if (turret_checkfire()) turret_fire(); TUR_ACTION(self.turretid, TR_THINK); @@ -1164,7 +1176,7 @@ void turret_think() turret_do_updates(self); // Fire? - if (self.turret_firecheckfunc()) + if (turret_checkfire()) turret_fire(); } diff --git a/qcsrc/common/turrets/unit/fusionreactor.qc b/qcsrc/common/turrets/unit/fusionreactor.qc index 459c1263a..ca4c3e2de 100644 --- a/qcsrc/common/turrets/unit/fusionreactor.qc +++ b/qcsrc/common/turrets/unit/fusionreactor.qc @@ -11,33 +11,33 @@ REGISTER_TURRET( ); #else #ifdef SVQC -float turret_fusionreactor_firecheck() +bool turret_fusionreactor_firecheck() { if (self.attack_finished_single > time) - return 0; + return false; if (self.enemy.deadflag != DEAD_NO) - return 0; + return false; if (self.enemy == world) - return 0; + return false; if (self.ammo < self.shot_dmg) - return 0; + return false; if (self.enemy.ammo >= self.enemy.ammo_max) - return 0; + return false; if (vlen(self.enemy.origin - self.origin) > self.target_range) - return 0; + return false; if(self.team != self.enemy.team) - return 0; + return false; if(!(self.enemy.ammo_flags & TFL_AMMO_ENERGY)) - return 0; + return false; - return 1; + return true; } void spawnfunc_turret_fusionreactor() { if(!turret_initialize(TUR_FUSIONREACTOR)) remove(self); } diff --git a/qcsrc/server/mutators/events.qh b/qcsrc/server/mutators/events.qh index 2d10ee01c..ad493f4f6 100644 --- a/qcsrc/server/mutators/events.qh +++ b/qcsrc/server/mutators/events.qh @@ -182,6 +182,20 @@ MUTATOR_HOOKABLE(FilterItem, EV_NO_ARGS); /**/ MUTATOR_HOOKABLE(TurretSpawn, EV_TurretSpawn); +/** return error to not attack */ +#define EV_TurretFire(i, o) \ + /** turret */ i(entity, self) \ + /**/ +MUTATOR_HOOKABLE(TurretFire, EV_TurretFire); + +/** return error to not attack */ +#define EV_Turret_CheckFire(i, o) \ + /**/ i(bool, ret_bool) \ + /**/ o(bool, ret_bool) \ + /**/ +bool ret_bool; +MUTATOR_HOOKABLE(Turret_CheckFire, EV_Turret_CheckFire); + /** return error to prevent entity spawn, or modify the entity */ MUTATOR_HOOKABLE(OnEntityPreSpawn, EV_NO_ARGS); -- 2.39.2