#ifdef SVQC
bool turret_fusionreactor_firecheck(entity this)
{
- if (this.attack_finished_single[0] > time)
- return false;
-
- if (IS_DEAD(this.enemy))
- return false;
-
- if (this.enemy == NULL)
- return false;
-
- if (this.ammo < this.shot_dmg)
- return false;
-
- if (this.enemy.ammo >= this.enemy.ammo_max)
- return false;
-
- if(vdist(this.enemy.origin - this.origin, >, this.target_range))
- return false;
-
- if(this.team != this.enemy.team)
- return false;
-
- if(!(this.enemy.ammo_flags & TFL_AMMO_ENERGY))
- return false;
+ entity targ = this.enemy;
+
+ switch(MUTATOR_CALLHOOK(FusionReactor_ValidTarget, this, targ))
+ {
+ case MUT_FUSREAC_TARG_VALID: { return true; }
+ case MUT_FUSREAC_TARG_INVALID: { return false; }
+ }
+
+ if((this.attack_finished_single[0] > time)
+ || (!targ)
+ || (IS_DEAD(targ))
+ || (this.ammo < this.shot_dmg)
+ || (targ.ammo >= targ.ammo_max)
+ || (vdist(targ.origin - this.origin, >, this.target_range))
+ || (this.team != targ.team)
+ || (!(targ.ammo_flags & TFL_AMMO_ENERGY))
+ ) { return false; }
return true;
}
/** return true to just restart the match, for modes that don't support readyrestart */
MUTATOR_HOOKABLE(ReadyRestart_Deny, EV_NO_ARGS);
+
+/** called when a fusion reactor is validating its target */
+#define EV_FusionReactor_ValidTarget(i, o) \
+ /** turret */ i(entity, MUTATOR_ARGV_0_entity) \
+ /** target */ i(entity, MUTATOR_ARGV_1_entity) \
+ /**/
+MUTATOR_HOOKABLE(FusionReactor_ValidTarget, EV_FusionReactor_ValidTarget);
+
+enum {
+ MUT_FUSREAC_TARG_CONTINUE, // return this flag to make the function continue as normal
+ MUT_FUSREAC_TARG_VALID, // return this flag to make the function return true (valid target)
+ MUT_FUSREAC_TARG_INVALID // return this flag to make the function return false (invalid target)
+};