]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Add relay_(de)activate entity, make trigger_push and func_rotating work with it.
authorJakob MG <jakob_mg@hotmail.com>
Tue, 10 Aug 2010 14:59:21 +0000 (16:59 +0200)
committerJakob MG <jakob_mg@hotmail.com>
Tue, 10 Aug 2010 14:59:21 +0000 (16:59 +0200)
qcsrc/server/defs.qh
qcsrc/server/g_triggers.qc
qcsrc/server/t_jumppads.qc
qcsrc/server/t_plats.qc

index 74b4ecea88c17683996b4b65aacca357f00b10fb..26e7075d3c3943ca5b3033a90eeb4ea9bd5ad0e0 100644 (file)
@@ -635,3 +635,11 @@ string deathmessage;
 .float selectweapon; // last selected weapon of the player
 
 .float ballistics_density; // wall piercing factor, larger = bullet can pass through more
+
+#define ACTIVE_NOT             0
+#define ACTIVE_ACTIVE  1
+#define ACTIVE_IDLE    2
+#define ACTIVE_BUSY    2
+#define ACTIVE_TOGGLE  3
+.float active;
+.float (float act_state) setactive;
\ No newline at end of file
index c31352ed5dec0e3f517d30198211d143db2cdcba..2ed219ac26062eda36be23050d0104ff041eefe2 100644 (file)
@@ -1931,3 +1931,46 @@ void spawnfunc_trigger_magicear()
        // target:
        //   what to trigger
 }
+
+void relay_activateors_use()
+{
+       entity trg, os;
+       
+       os = self;
+       
+       for(trg = world; (trg = find(trg, targetname, os.target)); )
+       {
+               self = trg;
+               if (trg.setactive)
+                       trg.setactive(os.cnt);
+               else
+               {
+                       if(os.cnt == ACTIVE_TOGGLE)
+                               if(trg.active)
+                                       trg.active = ACTIVE_NOT;
+                               else    
+                                       trg.active = ACTIVE_ACTIVE;
+                       else
+                               trg.active = os.cnt;
+               }               
+       }
+       self = os;
+}
+
+void spawnfunc_relay_activate()
+{
+       self.cnt = ACTIVE_ACTIVE;
+       self.use = relay_activateors_use;
+}
+
+void spawnfunc_relay_deactivate()
+{
+       self.cnt = ACTIVE_NOT;
+       self.use = relay_activateors_use;       
+}
+
+void spawnfunc_relay_activatetoggle()
+{
+       self.cnt = ACTIVE_TOGGLE;
+       self.use = relay_activateors_use;       
+}
index 9bb8f7c92034d88e0de65ba2f88e0039ed4f53f5..606f3b3dec4ce63d70b35ffecf4b259672a0a9cc 100644 (file)
@@ -127,6 +127,9 @@ vector trigger_push_calculatevelocity(vector org, entity tgt, float ht)
 
 void trigger_push_touch()
 {
+       if (self.active == ACTIVE_NOT) 
+               return;         
+               
        // FIXME: add a .float for whether an entity should be tossed by jumppads
        if (!other.iscreature)
        if (other.classname != "corpse")
@@ -228,8 +231,26 @@ void trigger_push_touch()
        }
 };
 
-.vector dest;
+void trigger_push_setactive(float astate)
+{
+       self.active = astate;
+               
+       if(astate == ACTIVE_NOT)
+               self.touch = SUB_Null;
+       else if (astate == ACTIVE_TOGGLE)
+       {
+               if(self.active)
+                       self.active = ACTIVE_NOT;
+               else
+                       self.active = ACTIVE_ACTIVE;
+       }
+       else
+               self.touch = trigger_push_touch;
+}
+
 
+
+.vector dest;
 void trigger_push_findtarget()
 {
        local entity e;
@@ -287,7 +308,9 @@ void spawnfunc_trigger_push()
                SetMovedir ();
 
        EXACTTRIGGER_INIT;
-
+       
+       self.active = ACTIVE_ACTIVE;    
+       self.setactive = trigger_push_setactive;
        self.use = trigger_push_use;
        self.touch = trigger_push_touch;
 
index ad80e7f9998ef08d2507e2f11bbf4fe4c0d11c88..8dac99e41c6079fa50f2aebc4e6026357c399985 100644 (file)
@@ -327,6 +327,25 @@ void spawnfunc_func_train()
        // TODO make a reset function for this one
 };
 
+void func_rotating_setactive(float astate)
+{
+       
+       if (astate == ACTIVE_TOGGLE)
+       {
+               if(self.active)
+                       self.active = ACTIVE_NOT;
+               else
+                       self.active = ACTIVE_ACTIVE;
+       }
+       else
+               self.active = astate;
+               
+       if(astate == ACTIVE_NOT)                
+               self.avelocity = '0 0 0';
+       else
+               self.avelocity = self.pos1;
+}
+
 /*QUAKED spawnfunc_func_rotating (0 .5 .8) ? - - X_AXIS Y_AXIS
 Brush model that spins in place on one axis (default Z).
 speed   : speed to rotate (in degrees per second)
@@ -342,6 +361,10 @@ void spawnfunc_func_rotating()
                precache_sound(self.noise);
                ambientsound(self.origin, self.noise, VOL_BASE, ATTN_IDLE);
        }
+       
+       self.active = ACTIVE_ACTIVE;
+       self.setactive = func_rotating_setactive;
+       
        if (!self.speed)
                self.speed = 100;
        // FIXME: test if this turns the right way, then remove this comment (negate as needed)
@@ -353,7 +376,9 @@ void spawnfunc_func_rotating()
        // FIXME: test if this turns the right way, then remove this comment (negate as needed)
        else // Z
                self.avelocity = '0 1 0' * self.speed;
-
+       
+       self.pos1 = self.avelocity;
+    
     if(self.dmg & (!self.message))
         self.message = " was squished";
     if(self.dmg && (!self.message2))