]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_triggers.qc
trigger_impulse: update csqc projectiles
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_triggers.qc
index cecca06d2e030fe96375326099fdedb9f3948472..1f50a1b818099fdceccc925e5d33a23976b52eea 100644 (file)
@@ -413,6 +413,9 @@ void spawnfunc_trigger_counter()
 .float triggerhurttime;
 void trigger_hurt_touch()
 {
+       if (self.active != ACTIVE_ACTIVE) 
+               return;
+
        // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
        if (other.iscreature)
        {
@@ -455,6 +458,7 @@ entity trigger_hurt_first;
 void spawnfunc_trigger_hurt()
 {
        EXACTTRIGGER_INIT;
+       self.active = ACTIVE_ACTIVE;
        self.touch = trigger_hurt_touch;
        if (!self.dmg)
                self.dmg = 1000;
@@ -493,6 +497,9 @@ float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end)
 .float triggerhealtime;
 void trigger_heal_touch()
 {
+       if (self.active != ACTIVE_ACTIVE) 
+               return;
+       
        // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
        if (other.iscreature)
        {
@@ -514,6 +521,8 @@ void trigger_heal_touch()
 
 void spawnfunc_trigger_heal()
 {
+       self.active = ACTIVE_ACTIVE;
+       
        EXACTTRIGGER_INIT;
        self.touch = trigger_heal_touch;
        if (!self.health)
@@ -1207,6 +1216,9 @@ void trigger_impulse_touch1()
     float pushdeltatime;
     float str;
 
+       if (self.active != ACTIVE_ACTIVE) 
+               return;
+
        // FIXME: Better checking for what to push and not.
        if not(other.iscreature)
        if (other.classname != "corpse")
@@ -1250,7 +1262,8 @@ void trigger_impulse_touch1()
     if(!pushdeltatime) return;
 
     other.velocity = other.velocity + normalize(targ.origin - self.origin) * str * pushdeltatime;
-       other.flags &~= FL_ONGROUND;
+    other.flags &~= FL_ONGROUND;
+    UpdateCSQCProjectile(other);
 }
 
 // Directionless (accelerator/decelerator) mode
@@ -1258,6 +1271,9 @@ void trigger_impulse_touch2()
 {
     float pushdeltatime;
 
+       if (self.active != ACTIVE_ACTIVE) 
+               return;
+
        // FIXME: Better checking for what to push and not.
        if not(other.iscreature)
        if (other.classname != "corpse")
@@ -1287,6 +1303,7 @@ void trigger_impulse_touch2()
 
     // div0: ticrate independent, 1 = identity (not 20)
     other.velocity = other.velocity * pow(self.strength, pushdeltatime);
+    UpdateCSQCProjectile(other);
 }
 
 // Spherical (gravity/repulsor) mode
@@ -1295,6 +1312,9 @@ void trigger_impulse_touch3()
     float pushdeltatime;
     float str;
 
+       if (self.active != ACTIVE_ACTIVE) 
+               return;
+
        // FIXME: Better checking for what to push and not.
        if not(other.iscreature)
        if (other.classname != "corpse")
@@ -1334,6 +1354,7 @@ void trigger_impulse_touch3()
         str = self.strength;
 
     other.velocity = other.velocity + normalize(other.origin - self.origin) * str * pushdeltatime;
+    UpdateCSQCProjectile(other);
 }
 
 /*QUAKED spawnfunc_trigger_impulse (.5 .5 .5) ?
@@ -1356,6 +1377,8 @@ in directional and sperical mode. For damper/accelerator mode this is not nesses
 
 void spawnfunc_trigger_impulse()
 {
+       self.active = ACTIVE_ACTIVE;
+
        EXACTTRIGGER_INIT;
     if(self.radius)
     {
@@ -1933,7 +1956,7 @@ void spawnfunc_trigger_magicear()
        //   what to trigger
 }
 
-void relay_activateors_use()
+void relay_activators_use()
 {
        entity trg, os;
        
@@ -1946,8 +1969,9 @@ void relay_activateors_use()
                        trg.setactive(os.cnt);
                else
                {
+                       //bprint("Not using setactive\n");
                        if(os.cnt == ACTIVE_TOGGLE)
-                               if(trg.active)
+                               if(trg.active == ACTIVE_ACTIVE)
                                        trg.active = ACTIVE_NOT;
                                else    
                                        trg.active = ACTIVE_ACTIVE;
@@ -1961,17 +1985,34 @@ void relay_activateors_use()
 void spawnfunc_relay_activate()
 {
        self.cnt = ACTIVE_ACTIVE;
-       self.use = relay_activateors_use;
+       self.use = relay_activators_use;
 }
 
 void spawnfunc_relay_deactivate()
 {
        self.cnt = ACTIVE_NOT;
-       self.use = relay_activateors_use;       
+       self.use = relay_activators_use;        
 }
 
 void spawnfunc_relay_activatetoggle()
 {
        self.cnt = ACTIVE_TOGGLE;
-       self.use = relay_activateors_use;       
+       self.use = relay_activators_use;        
 }
+
+.string chmap, gametype;
+void spawnfunc_target_changelevel_use()
+{
+       if(self.gametype != "")
+               MapInfo_SwitchGameType(MapInfo_Type_FromString(self.gametype));
+
+       if (self.chmap == "")
+               localcmd("endmatch\n");
+       else
+               localcmd(strcat("changelevel ", self.chmap, "\n"));
+};
+
+void spawnfunc_target_changelevel()
+{
+       self.use = spawnfunc_target_changelevel_use;
+};