]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Allow activating turrets from triggers
authorMattia Basaglia <mattia.basaglia@gmail.com>
Fri, 24 Mar 2017 10:36:53 +0000 (10:36 +0000)
committerMattia Basaglia <mattia.basaglia@gmail.com>
Fri, 24 Mar 2017 10:36:53 +0000 (10:36 +0000)
qcsrc/common/turrets/sv_turrets.qc
qcsrc/common/turrets/turret.qh

index 231117d24c31abb10c2d42ecc80e328d5d3f3b3b..2f5a24e8d942151734b53f2036879f189fc2d723 100644 (file)
@@ -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);
index 8e5239702866c4c6fe4519a7c34d67f2aa00b7fd..23d8923dd260c4315dbe074bafd445b81c4852c4 100644 (file)
@@ -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;