From cf0cdfcbd8d876244d768c00f94c3160545ae5e7 Mon Sep 17 00:00:00 2001 From: Mattia Basaglia Date: Fri, 24 Mar 2017 10:36:53 +0000 Subject: [PATCH] Allow activating turrets from triggers --- qcsrc/common/turrets/sv_turrets.qc | 25 +++++++++++++++++++------ qcsrc/common/turrets/turret.qh | 2 ++ 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/qcsrc/common/turrets/sv_turrets.qc b/qcsrc/common/turrets/sv_turrets.qc index 231117d24..2f5a24e8d 100644 --- a/qcsrc/common/turrets/sv_turrets.qc +++ b/qcsrc/common/turrets/sv_turrets.qc @@ -1198,13 +1198,22 @@ void turret_use(entity this, entity actor, entity trigger) { LOG_TRACE("Turret ",this.netname, " used by ", actor.classname); - this.team = actor.team; + if ( !(this.spawnflags & TSF_KEEPTEAM) ) + { + this.team = actor.team; - if(this.team == 0) - this.active = ACTIVE_NOT; + if(this.team == 0) + this.active = ACTIVE_NOT; + else + this.active = ACTIVE_ACTIVE; + } else - this.active = ACTIVE_ACTIVE; - + { + if ( this.active == ACTIVE_NOT ) + this.active = ACTIVE_ACTIVE; + else + this.active = ACTIVE_NOT; + } } void turret_link(entity this) @@ -1342,9 +1351,13 @@ bool turret_initialize(entity this, Turret tur) _setmodel(this, tur.model); setsize(this, tur.mins, tur.maxs); + if ( this.spawnflags & TSF_INACTIVE ) + this.active = ACTIVE_NOT; + else + this.active = ACTIVE_ACTIVE; + this.m_id = tur.m_id; this.classname = "turret_main"; - this.active = ACTIVE_ACTIVE; this.effects = EF_NODRAW; this.netname = tur.turret_name; this.ticrate = bound(sys_frametime, this.ticrate, 60); diff --git a/qcsrc/common/turrets/turret.qh b/qcsrc/common/turrets/turret.qh index 8e5239702..23d8923dd 100644 --- a/qcsrc/common/turrets/turret.qh +++ b/qcsrc/common/turrets/turret.qh @@ -163,6 +163,8 @@ const int TSF_NO_AMMO_REGEN = 4; // disable builtin ammo regeneration const int TSF_NO_PATHBREAK = 8; // don't break path to chase enemies, will still fire at them if possible const int TSL_NO_RESPAWN = 16; // don't re-spawn const int TSL_ROAM = 32; // roam while idle +const int TSF_INACTIVE = 64; // start deactivated +const int TSF_KEEPTEAM = 128; // when used, don't switch teams // send flags const int TNSF_UPDATE = 2; -- 2.39.2