]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mapobjects/trigger/swamp.qc
Merge branch 'master' into Mario/speed_var
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapobjects / trigger / swamp.qc
1 #include "swamp.qh"
2 #if defined(CSQC)
3 #elif defined(MENUQC)
4 #elif defined(SVQC)
5     #include <lib/warpzone/util_server.qh>
6     #include <common/weapons/_all.qh>
7     #include <server/defs.qh>
8     #include <common/deathtypes/all.qh>
9 #endif
10
11 /*
12 *               t_swamp.c
13 *               Adds spawnfunc_trigger_swamp and support routines for nexuiz 1.2.1+ and xonotic
14 *               Author tZork (Jakob MG)
15 *               jakob@games43.se
16 *               2005 11 29
17 */
18
19 #ifdef SVQC
20 void swamp_think(entity this)
21 {
22         // set myself as current swampslug where possible
23         IL_EACH(g_swamped, it.swampslug == this,
24         {
25                 it.swampslug = NULL;
26                 IL_REMOVE(g_swamped, it);
27         });
28
29         if(this.active == ACTIVE_ACTIVE)
30         {
31                 FOREACH_ENTITY_RADIUS((this.absmin + this.absmax) * 0.5, vlen(this.absmax - this.absmin) * 0.5 + 1, it.swampslug.active == ACTIVE_NOT && IS_PLAYER(it) && !IS_DEAD(it),
32                 {
33                         vector emin = it.absmin;
34                         vector emax = it.absmax;
35                         if(this.solid == SOLID_BSP)
36                         {
37                                 emin -= '1 1 1';
38                                 emax += '1 1 1';
39                         }
40                         if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
41                                 if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, it)) // accurate
42                                 {
43                                         if(!it.swampslug)
44                                                 IL_PUSH(g_swamped, it);
45                                         it.swampslug = this;
46                                 }
47                 });
48
49                 IL_EACH(g_swamped, it.swampslug == this,
50                 {
51                         if(time > it.swamp_interval)
52                         {
53                                 Damage (it, this, this, this.dmg, DEATH_SWAMP.m_id, DMG_NOWEP, it.origin, '0 0 0');
54                                 it.swamp_interval = time + this.swamp_interval;
55                         }
56                 });
57         }
58
59         this.nextthink = time;
60 }
61
62 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
63 Players in the swamp will be
64 slowed down and damaged over time
65 */
66 spawnfunc(trigger_swamp)
67 {
68         // Init stuff
69         EXACTTRIGGER_INIT;
70         this.active = ACTIVE_ACTIVE;
71         //trigger_init(this);
72         setthink(this, swamp_think);
73         this.nextthink = time;
74
75         // Setup default keys, if missing
76         if(!this.dmg)
77                 this.dmg = 5;
78         if(!this.swamp_interval)
79                 this.swamp_interval = 1;
80         if(!this.swamp_slowdown)
81                 this.swamp_slowdown = 0.5;
82 }
83 #endif