]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/g_triggers.qc
Merge branch 'Penguinum/Antiwall' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / g_triggers.qc
index c5fb08c965c2afa88d6f6f3aecf1d58974c333bd..cdca7e245a6066f33d4d928ecf79c612a97070c0 100644 (file)
@@ -1,10 +1,17 @@
+#include "g_triggers.qh"
+#include "_all.qh"
+
+#include "weapons/csqcprojectile.qh"
+#include "../common/deathtypes.qh"
+#include "../warpzonelib/util_server.qh"
+#include "g_subs.qh"
+#include "t_jumppads.qh"
+
 void SUB_DontUseTargets()
 {
 }
 
 
-void() SUB_UseTargets;
-
 void DelayThink()
 {
        activator = self.enemy;
@@ -102,6 +109,9 @@ void SUB_UseTargets()
                }
                if (s != "")
                {
+                       // Flag to set func_clientwall state
+                       // 1 == deactivate, 2 == activate, 0 == do nothing
+                       float aw_flag = self.antiwall_flag;
                        for(t = world; (t = find(t, targetname, s)); )
                        if(t.use)
                        {
@@ -111,6 +121,8 @@ void SUB_UseTargets()
                                }
                                else
                                {
+                                       if (t.classname == "func_clientwall" || t.classname == "func_clientillusionary")
+                                               t.antiwall_flag = aw_flag;
                                        self = t;
                                        other = stemp;
                                        activator = act;
@@ -136,9 +148,6 @@ void SUB_UseTargets()
 
 //=============================================================================
 
-const float    SPAWNFLAG_NOMESSAGE = 1;
-const float    SPAWNFLAG_NOTOUCH = 1;
-
 // the wait time has passed, so set back up for another activation
 void multi_wait()
 {
@@ -227,7 +236,7 @@ void multi_touch()
        multi_trigger ();
 }
 
-void multi_eventdamage (entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
+void multi_eventdamage (entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
 {
        if (!self.takedamage)
                return;
@@ -431,7 +440,6 @@ void trigger_hurt_use()
                self.enemy = world; // let's just destroy it, if taking over is too much work
 }
 
-.float triggerhurttime;
 void trigger_hurt_touch()
 {
        if (self.active != ACTIVE_ACTIVE)
@@ -478,9 +486,6 @@ Any object touching this will be hurt
 set dmg to damage amount
 defalt dmg = 5
 */
-.entity trigger_hurt_next;
-entity trigger_hurt_last;
-entity trigger_hurt_first;
 void spawnfunc_trigger_hurt()
 {
        EXACTTRIGGER_INIT;
@@ -509,9 +514,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;
 }
 
 //////////////////////////////////////////////////////////////
@@ -522,7 +527,6 @@ float tracebox_hits_trigger_hurt(vector start, vector mi, vector ma, vector end)
 //
 //////////////////////////////////////////////////////////////
 
-.float triggerhealtime;
 void trigger_heal_touch()
 {
        if (self.active != ACTIVE_ACTIVE)
@@ -572,7 +576,6 @@ void spawnfunc_trigger_heal()
 //
 //////////////////////////////////////////////////////////////
 
-.entity trigger_gravity_check;
 void trigger_gravity_remove(entity own)
 {
        if(own.trigger_gravity_check.owner == own)
@@ -614,7 +617,7 @@ void trigger_gravity_touch()
 {
        float g;
 
-       if(self.state != TRUE)
+       if(self.state != true)
                return;
 
        EXACTTRIGGER_TOUCH;
@@ -668,20 +671,18 @@ 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;
        }
 }
 
 //=============================================================================
 
 // TODO add a way to do looped sounds with sound(); then complete this entity
-.float volume, atten;
-void target_speaker_use_off();
 void target_speaker_use_activator()
 {
        if (!IS_REAL_CLIENT(activator))
@@ -693,11 +694,11 @@ void target_speaker_use_activator()
                sample = GetVoiceMessageSampleField(substring(self.noise, 1, -1));
                if(GetPlayerSoundSampleField_notFound)
                        snd = "misc/null.wav";
-               else if(activator.sample == "")
+               else if (activator.(sample) == "")
                        snd = "misc/null.wav";
                else
                {
-                       tokenize_console(activator.sample);
+                       tokenize_console(activator.(sample));
                        float n;
                        n = stof(argv(1));
                        if(n > 0)
@@ -720,11 +721,11 @@ void target_speaker_use_on()
                sample = GetVoiceMessageSampleField(substring(self.noise, 1, -1));
                if(GetPlayerSoundSampleField_notFound)
                        snd = "misc/null.wav";
-               else if(activator.sample == "")
+               else if (activator.(sample) == "")
                        snd = "misc/null.wav";
                else
                {
-                       tokenize_console(activator.sample);
+                       tokenize_console(activator.(sample));
                        float n;
                        n = stof(argv(1));
                        if(n > 0)
@@ -817,11 +818,6 @@ void spawnfunc_func_stardust() {
        self.effects = EF_STARDUST;
 }
 
-.string bgmscript;
-.float bgmscriptattack;
-.float bgmscriptdecay;
-.float bgmscriptsustain;
-.float bgmscriptrelease;
 float pointparticles_SendEntity(entity to, float fl)
 {
        WriteByte(MSG_ENTITY, ENT_CLIENT_POINTPARTICLES);
@@ -847,9 +843,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)
        {
@@ -858,12 +854,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
@@ -871,9 +867,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);
@@ -999,16 +995,16 @@ void spawnfunc_func_sparks()
        spawnfunc_func_pointparticles();
 }
 
-float rainsnow_SendEntity(entity to, float sf)
+float rainsnow_SendEntity(entity to, int 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);
@@ -1040,7 +1036,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)
@@ -1049,7 +1045,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);
 }
 
 
@@ -1078,7 +1074,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)
@@ -1087,10 +1083,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);
 }
 
-.float modelscale;
 void misc_laser_aim()
 {
        vector a;
@@ -1107,7 +1102,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;
@@ -1136,7 +1131,6 @@ void misc_laser_init()
                self.enemy = find(world, targetname, self.target);
 }
 
-.entity pusher;
 void misc_laser_think()
 {
        vector o;
@@ -1226,15 +1220,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)
@@ -1249,14 +1243,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)
@@ -1334,7 +1328,7 @@ void spawnfunc_misc_laser()
 
        self.mangle = self.angles;
 
-       Net_LinkEntity(self, FALSE, 0, laser_SendEntity);
+       Net_LinkEntity(self, false, 0, laser_SendEntity);
 
        IFTARGETED
        {
@@ -1347,10 +1341,6 @@ void spawnfunc_misc_laser()
 }
 
 // tZorks trigger impulse / gravity
-.float radius;
-.float falloff;
-.float strength;
-.float lastpushtime;
 
 // targeted (directional) mode
 void trigger_impulse_touch1()
@@ -1726,11 +1716,6 @@ void spawnfunc_trigger_gamestart() {
 
 
 
-.entity voicescript; // attached voice script
-.float voicescript_index; // index of next voice, or -1 to use the randomized ones
-.float voicescript_nextthink; // time to play next voice
-.float voicescript_voiceend; // time when this voice ends
-
 void target_voicescript_clear(entity pl)
 {
        pl.voicescript = world;
@@ -1894,8 +1879,6 @@ void spawnfunc_trigger_disablerelay()
        self.use = trigger_disablerelay_use;
 }
 
-float magicear_matched;
-float W_Tuba_HasPlayed(entity pl, string melody, float instrument, float ignorepitch, float mintempo, float maxtempo);
 string trigger_magicear_processmessage(entity ear, entity source, float teamsay, entity privatesay, string msgin)
 {
        float domatch, dotrigger, matchstart, l;
@@ -1903,7 +1886,7 @@ 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);
@@ -1917,10 +1900,10 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
                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)
                {
@@ -2011,7 +1994,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)
        {
@@ -2044,7 +2027,6 @@ string trigger_magicear_processmessage(entity ear, entity source, float teamsay,
                return msgin;
 }
 
-entity magicears;
 string trigger_magicear_processmessage_forallears(entity source, float teamsay, entity privatesay, string msgin)
 {
        entity ear;
@@ -2141,7 +2123,6 @@ void spawnfunc_relay_activatetoggle()
        self.use = relay_activators_use;
 }
 
-.string chmap, gametype;
 void spawnfunc_target_changelevel_use()
 {
        if(self.gametype != "")