]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_triggers.qc
#include this
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_triggers.qc
index 4c24ed60650bd574283744814918241081eb07a2..cacb434d3d76cd00e04d8e0728272b7b68349eca 100644 (file)
@@ -1,3 +1,22 @@
+#if defined(CSQC)
+#elif defined(MENUQC)
+#elif defined(SVQC)
+       #include "../dpdefs/progsdefs.qc"
+    #include "../dpdefs/dpextensions.qc"
+    #include "../warpzonelib/util_server.qh"
+    #include "../common/constants.qh"
+    #include "../common/util.qh"
+    #include "../common/monsters/monsters.qh"
+    #include "../common/weapons/weapons.qh"
+    #include "weapons/csqcprojectile.qh"
+    #include "autocvars.qh"
+    #include "constants.qh"
+    #include "defs.qh"
+    #include "../common/notifications.qh"
+    #include "../common/deathtypes.qh"
+    #include "../common/mapinfo.qh"
+#endif
+
 void SUB_DontUseTargets()
 {
 }
@@ -61,6 +80,7 @@ void SUB_UseTargets()
 //
 // print the message
 //
+       if(self)
        if(IS_PLAYER(activator) && self.message != "")
        if(IS_REAL_CLIENT(activator))
        {
@@ -162,7 +182,7 @@ void multi_trigger()
 
        if (self.classname == "trigger_secret")
        {
-               if not(IS_PLAYER(self.enemy))
+               if (!IS_PLAYER(self.enemy))
                        return;
                found_secrets = found_secrets + 1;
                WriteByte (MSG_ALL, SVC_FOUNDSECRET);
@@ -203,8 +223,8 @@ void multi_use()
 
 void multi_touch()
 {
-       if not(self.spawnflags & 2)
-               if not(other.iscreature)
+       if(!(self.spawnflags & 2))
+       if(!other.iscreature)
                        return;
 
        if(self.team)
@@ -384,7 +404,7 @@ void counter_use()
        {
                if(IS_PLAYER(activator) && (self.spawnflags & SPAWNFLAG_NOMESSAGE) == 0)
                        Send_Notification(NOTIF_ONE, activator, MSG_CENTER, CENTER_SEQUENCE_COMPLETED);
-                       
+
                self.enemy = activator;
                multi_trigger ();
        }
@@ -433,7 +453,7 @@ void trigger_hurt_use()
 .float triggerhurttime;
 void trigger_hurt_touch()
 {
-       if (self.active != ACTIVE_ACTIVE) 
+       if (self.active != ACTIVE_ACTIVE)
                return;
 
        if(self.team)
@@ -451,7 +471,7 @@ void trigger_hurt_touch()
 
                        entity own;
                        own = self.enemy;
-                       if not(IS_PLAYER(own))
+                       if (!IS_PLAYER(own))
                        {
                                own = self;
                                self.enemy = world; // I still hate you all
@@ -508,9 +528,9 @@ float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end)
 
        for(th = trigger_hurt_first; th; th = th.trigger_hurt_next)
                if(tracebox_hits_box(start, mi, ma, end, th.absmin, th.absmax))
-                       return TRUE;
+                       return true;
 
-       return FALSE;
+       return false;
 }
 
 //////////////////////////////////////////////////////////////
@@ -524,9 +544,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) 
+       if (self.active != ACTIVE_ACTIVE)
                return;
-       
+
        // only do the EXACTTRIGGER_TOUCH checks when really needed (saves some cpu)
        if (other.iscreature)
        {
@@ -536,7 +556,7 @@ void trigger_heal_touch()
                {
                        EXACTTRIGGER_TOUCH;
                        other.triggerhealtime = time + 1;
-                       
+
                        if (other.health < self.max_health)
                        {
                                other.health = min(other.health + self.health, self.max_health);
@@ -550,7 +570,7 @@ void trigger_heal_touch()
 void spawnfunc_trigger_heal()
 {
        self.active = ACTIVE_ACTIVE;
-       
+
        EXACTTRIGGER_INIT;
        self.touch = trigger_heal_touch;
        if (!self.health)
@@ -613,14 +633,14 @@ void trigger_gravity_touch()
 {
        float g;
 
-       if(self.state != TRUE)
+       if(self.state != true)
                return;
 
        EXACTTRIGGER_TOUCH;
 
        g = self.gravity;
 
-       if not(self.spawnflags & 1)
+       if (!(self.spawnflags & 1))
        {
                if(other.trigger_gravity_check)
                {
@@ -667,12 +687,12 @@ void spawnfunc_trigger_gravity()
        if(self.noise != "")
                precache_sound(self.noise);
 
-       self.state = TRUE;
+       self.state = true;
        IFTARGETED
        {
                self.use = trigger_gravity_use;
                if(self.spawnflags & 2)
-                       self.state = FALSE;
+                       self.state = false;
        }
 }
 
@@ -683,7 +703,7 @@ void spawnfunc_trigger_gravity()
 void target_speaker_use_off();
 void target_speaker_use_activator()
 {
-       if not(IS_REAL_CLIENT(activator))
+       if (!IS_REAL_CLIENT(activator))
                return;
        string snd;
        if(substring(self.noise, 0, 1) == "*")
@@ -846,9 +866,9 @@ float pointparticles_SendEntity(entity to, float fl)
        }
        if(fl & 4)
        {
-               WriteCoord(MSG_ENTITY, self.origin_x);
-               WriteCoord(MSG_ENTITY, self.origin_y);
-               WriteCoord(MSG_ENTITY, self.origin_z);
+               WriteCoord(MSG_ENTITY, self.origin.x);
+               WriteCoord(MSG_ENTITY, self.origin.y);
+               WriteCoord(MSG_ENTITY, self.origin.z);
        }
        if(fl & 1)
        {
@@ -857,12 +877,12 @@ float pointparticles_SendEntity(entity to, float fl)
                        WriteShort(MSG_ENTITY, self.modelindex);
                        if(fl & 0x80)
                        {
-                               WriteCoord(MSG_ENTITY, self.mins_x);
-                               WriteCoord(MSG_ENTITY, self.mins_y);
-                               WriteCoord(MSG_ENTITY, self.mins_z);
-                               WriteCoord(MSG_ENTITY, self.maxs_x);
-                               WriteCoord(MSG_ENTITY, self.maxs_y);
-                               WriteCoord(MSG_ENTITY, self.maxs_z);
+                               WriteCoord(MSG_ENTITY, self.mins.x);
+                               WriteCoord(MSG_ENTITY, self.mins.y);
+                               WriteCoord(MSG_ENTITY, self.mins.z);
+                               WriteCoord(MSG_ENTITY, self.maxs.x);
+                               WriteCoord(MSG_ENTITY, self.maxs.y);
+                               WriteCoord(MSG_ENTITY, self.maxs.z);
                        }
                }
                else
@@ -870,9 +890,9 @@ float pointparticles_SendEntity(entity to, float fl)
                        WriteShort(MSG_ENTITY, 0);
                        if(fl & 0x80)
                        {
-                               WriteCoord(MSG_ENTITY, self.maxs_x);
-                               WriteCoord(MSG_ENTITY, self.maxs_y);
-                               WriteCoord(MSG_ENTITY, self.maxs_z);
+                               WriteCoord(MSG_ENTITY, self.maxs.x);
+                               WriteCoord(MSG_ENTITY, self.maxs.y);
+                               WriteCoord(MSG_ENTITY, self.maxs.z);
                        }
                }
                WriteShort(MSG_ENTITY, self.cnt);
@@ -934,7 +954,7 @@ void spawnfunc_func_pointparticles()
                setmodel(self, self.model);
        if(self.noise != "")
                precache_sound (self.noise);
-       
+
        if(!self.bgmscriptsustain)
                self.bgmscriptsustain = 1;
        else if(self.bgmscriptsustain < 0)
@@ -1002,12 +1022,12 @@ float rainsnow_SendEntity(entity to, float sf)
 {
        WriteByte(MSG_ENTITY, ENT_CLIENT_RAINSNOW);
        WriteByte(MSG_ENTITY, self.state);
-       WriteCoord(MSG_ENTITY, self.origin_x + self.mins_x);
-       WriteCoord(MSG_ENTITY, self.origin_y + self.mins_y);
-       WriteCoord(MSG_ENTITY, self.origin_z + self.mins_z);
-       WriteCoord(MSG_ENTITY, self.maxs_x - self.mins_x);
-       WriteCoord(MSG_ENTITY, self.maxs_y - self.mins_y);
-       WriteCoord(MSG_ENTITY, self.maxs_z - self.mins_z);
+       WriteCoord(MSG_ENTITY, self.origin.x + self.mins.x);
+       WriteCoord(MSG_ENTITY, self.origin.y + self.mins.y);
+       WriteCoord(MSG_ENTITY, self.origin.z + self.mins.z);
+       WriteCoord(MSG_ENTITY, self.maxs.x - self.mins.x);
+       WriteCoord(MSG_ENTITY, self.maxs.y - self.mins.y);
+       WriteCoord(MSG_ENTITY, self.maxs.z - self.mins.z);
        WriteShort(MSG_ENTITY, compressShortVector(self.dest));
        WriteShort(MSG_ENTITY, self.count);
        WriteByte(MSG_ENTITY, self.cnt);
@@ -1039,7 +1059,7 @@ void spawnfunc_func_rain()
                self.cnt = 12;
        if (!self.count)
                self.count = 2000;
-       self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024);
+       self.count = 0.01 * self.count * (self.size.x / 1024) * (self.size.y / 1024);
        if (self.count < 1)
                self.count = 1;
        if(self.count > 65535)
@@ -1048,7 +1068,7 @@ void spawnfunc_func_rain()
        self.state = 1; // 1 is rain, 0 is snow
        self.Version = 1;
 
-       Net_LinkEntity(self, FALSE, 0, rainsnow_SendEntity);
+       Net_LinkEntity(self, false, 0, rainsnow_SendEntity);
 }
 
 
@@ -1077,7 +1097,7 @@ void spawnfunc_func_snow()
                self.cnt = 12;
        if (!self.count)
                self.count = 2000;
-       self.count = 0.01 * self.count * (self.size_x / 1024) * (self.size_y / 1024);
+       self.count = 0.01 * self.count * (self.size.x / 1024) * (self.size.y / 1024);
        if (self.count < 1)
                self.count = 1;
        if(self.count > 65535)
@@ -1086,12 +1106,9 @@ void spawnfunc_func_snow()
        self.state = 0; // 1 is rain, 0 is snow
        self.Version = 1;
 
-       Net_LinkEntity(self, FALSE, 0, rainsnow_SendEntity);
+       Net_LinkEntity(self, false, 0, rainsnow_SendEntity);
 }
 
-
-void FireRailgunBullet (vector start, vector end, float bdamage, float bforce, float mindist, float maxdist, float halflifedist, float forcehalflifedist, float deathtype);
-
 .float modelscale;
 void misc_laser_aim()
 {
@@ -1109,7 +1126,7 @@ void misc_laser_aim()
                else
                {
                        a = vectoangles(self.enemy.origin - self.origin);
-                       a_x = -a_x;
+                       a_x = -a.x;
                        if(a != self.mangle)
                        {
                                self.mangle = a;
@@ -1156,7 +1173,7 @@ void misc_laser_think()
        if(self.enemy)
        {
                o = self.enemy.origin;
-               if not(self.spawnflags & 2)
+               if (!(self.spawnflags & 2))
                        o = self.origin + normalize(o - self.origin) * 32768;
        }
        else
@@ -1228,15 +1245,15 @@ float laser_SendEntity(entity to, float fl)
        WriteByte(MSG_ENTITY, fl);
        if(fl & 1)
        {
-               WriteCoord(MSG_ENTITY, self.origin_x);
-               WriteCoord(MSG_ENTITY, self.origin_y);
-               WriteCoord(MSG_ENTITY, self.origin_z);
+               WriteCoord(MSG_ENTITY, self.origin.x);
+               WriteCoord(MSG_ENTITY, self.origin.y);
+               WriteCoord(MSG_ENTITY, self.origin.z);
        }
        if(fl & 8)
        {
-               WriteByte(MSG_ENTITY, self.colormod_x * 255.0);
-               WriteByte(MSG_ENTITY, self.colormod_y * 255.0);
-               WriteByte(MSG_ENTITY, self.colormod_z * 255.0);
+               WriteByte(MSG_ENTITY, self.colormod.x * 255.0);
+               WriteByte(MSG_ENTITY, self.colormod.y * 255.0);
+               WriteByte(MSG_ENTITY, self.colormod.z * 255.0);
                if(fl & 0x40)
                        WriteByte(MSG_ENTITY, self.alpha * 255.0);
                if(fl & 0x20)
@@ -1251,14 +1268,14 @@ float laser_SendEntity(entity to, float fl)
        {
                if(fl & 0x80)
                {
-                       WriteCoord(MSG_ENTITY, self.enemy.origin_x);
-                       WriteCoord(MSG_ENTITY, self.enemy.origin_y);
-                       WriteCoord(MSG_ENTITY, self.enemy.origin_z);
+                       WriteCoord(MSG_ENTITY, self.enemy.origin.x);
+                       WriteCoord(MSG_ENTITY, self.enemy.origin.y);
+                       WriteCoord(MSG_ENTITY, self.enemy.origin.z);
                }
                else
                {
-                       WriteAngle(MSG_ENTITY, self.mangle_x);
-                       WriteAngle(MSG_ENTITY, self.mangle_y);
+                       WriteAngle(MSG_ENTITY, self.mangle.x);
+                       WriteAngle(MSG_ENTITY, self.mangle.y);
                }
        }
        if(fl & 4)
@@ -1336,7 +1353,7 @@ void spawnfunc_misc_laser()
 
        self.mangle = self.angles;
 
-       Net_LinkEntity(self, FALSE, 0, laser_SendEntity);
+       Net_LinkEntity(self, false, 0, laser_SendEntity);
 
        IFTARGETED
        {
@@ -1361,7 +1378,7 @@ void trigger_impulse_touch1()
     float pushdeltatime;
     float str;
 
-       if (self.active != ACTIVE_ACTIVE) 
+       if (self.active != ACTIVE_ACTIVE)
                return;
 
        if (!isPushable(other))
@@ -1401,7 +1418,7 @@ void trigger_impulse_touch2()
 {
     float pushdeltatime;
 
-       if (self.active != ACTIVE_ACTIVE) 
+       if (self.active != ACTIVE_ACTIVE)
                return;
 
        if (!isPushable(other))
@@ -1425,7 +1442,7 @@ void trigger_impulse_touch3()
     float pushdeltatime;
     float str;
 
-       if (self.active != ACTIVE_ACTIVE) 
+       if (self.active != ACTIVE_ACTIVE)
                return;
 
        if (!isPushable(other))
@@ -1758,7 +1775,7 @@ void target_voicescript_next(entity pl)
                return;
        if(vs.message == "")
                return;
-       if not(IS_PLAYER(pl))
+       if (!IS_PLAYER(pl))
                return;
        if(gameover)
                return;
@@ -1773,7 +1790,7 @@ void target_voicescript_next(entity pl)
                        if(pl.voicescript_index < vs.cnt)
                                i = pl.voicescript_index * 2;
                        else if(n > vs.cnt * 2)
-                               i = mod(pl.voicescript_index - vs.cnt, (n - vs.cnt * 2 - 1) / 2) * 2 + vs.cnt * 2 + 1;
+                               i = ((pl.voicescript_index - vs.cnt) % ((n - vs.cnt * 2 - 1) / 2)) * 2 + vs.cnt * 2 + 1;
                        else
                                i = -1;
 
@@ -1811,7 +1828,7 @@ void spawnfunc_target_voicescript()
        //          added after this message
        // wait: average time between messages
        // delay: initial delay before the first message
-       
+
        float i, n;
        self.use = target_voicescript_use;
 
@@ -1905,24 +1922,24 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
        entity oldself;
        string savemessage;
 
-       magicear_matched = FALSE;
+       magicear_matched = false;
 
        dotrigger = ((IS_PLAYER(source)) && (source.deadflag == DEAD_NO) && ((ear.radius == 0) || (vlen(source.origin - ear.origin) <= ear.radius)));
        domatch = ((ear.spawnflags & 32) || dotrigger);
 
-       if not(domatch)
+       if (!domatch)
                return msgin;
 
-       if not(msgin)
+       if (!msgin)
        {
                // we are in TUBA mode!
-               if not(ear.spawnflags & 256)
+               if (!(ear.spawnflags & 256))
                        return msgin;
 
-               if(!W_Tuba_HasPlayed(source, ear.message, ear.movedir_x, !(ear.spawnflags & 512), ear.movedir_y, ear.movedir_z))
+               if(!W_Tuba_HasPlayed(source, ear.message, ear.movedir.x, !(ear.spawnflags & 512), ear.movedir.y, ear.movedir.z))
                        return msgin;
 
-               magicear_matched = TRUE;
+               magicear_matched = true;
 
                if(dotrigger)
                {
@@ -1962,7 +1979,7 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
                        if(ear.spawnflags & 8)
                                return msgin;
        }
-       
+
        matchstart = -1;
        l = strlen(ear.message);
 
@@ -2013,7 +2030,7 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
        if(matchstart == -1) // no match
                return msgin;
 
-       magicear_matched = TRUE;
+       magicear_matched = true;
 
        if(dotrigger)
        {
@@ -2054,9 +2071,9 @@ string trigger_magicear_processmessage_forallears(entity source, float teamsay,
        for(ear = magicears; ear; ear = ear.enemy)
        {
                msgout = trigger_magicear_processmessage(ear, source, teamsay, privatesay, msgin);
-               if not(ear.spawnflags & 64)
-                       if(magicear_matched)
-                               return msgout;
+               if(!(ear.spawnflags & 64))
+               if(magicear_matched)
+                       return msgout;
                msgin = msgout;
        }
        return msgin;
@@ -2102,9 +2119,9 @@ void spawnfunc_trigger_magicear()
 void relay_activators_use()
 {
        entity trg, os;
-       
+
        os = self;
-       
+
        for(trg = world; (trg = find(trg, targetname, os.target)); )
        {
                self = trg;
@@ -2116,11 +2133,11 @@ void relay_activators_use()
                        if(os.cnt == ACTIVE_TOGGLE)
                                if(trg.active == ACTIVE_ACTIVE)
                                        trg.active = ACTIVE_NOT;
-                               else    
+                               else
                                        trg.active = ACTIVE_ACTIVE;
                        else
                                trg.active = os.cnt;
-               }               
+               }
        }
        self = os;
 }
@@ -2134,13 +2151,13 @@ void spawnfunc_relay_activate()
 void spawnfunc_relay_deactivate()
 {
        self.cnt = ACTIVE_NOT;
-       self.use = relay_activators_use;        
+       self.use = relay_activators_use;
 }
 
 void spawnfunc_relay_activatetoggle()
 {
        self.cnt = ACTIVE_TOGGLE;
-       self.use = relay_activators_use;        
+       self.use = relay_activators_use;
 }
 
 .string chmap, gametype;