Xonotic
swamp.qc
Go to the documentation of this file.
1 #include "swamp.qh"
2 #if defined(CSQC)
3 #elif defined(MENUQC)
4 #elif defined(SVQC)
6  #include <common/weapons/_all.qh>
7  #include <common/weapons/_all.qh>
8  #include <common/stats.qh>
9  #include <common/deathtypes/all.qh>
10 #endif
11 
12 /*
13 * t_swamp.c
14 * Adds spawnfunc_trigger_swamp and support routines for nexuiz 1.2.1+ and xonotic
15 * Author tZork (Jakob MG)
16 * jakob@games43.se
17 * 2005 11 29
18 */
19 
20 #ifdef SVQC
21 void swamp_think(entity this)
22 {
23  // set myself as current swampslug where possible
24  IL_EACH(g_swamped, it.swampslug == this,
25  {
26  it.swampslug = NULL;
27  IL_REMOVE(g_swamped, it);
28  });
29 
30  if(this.active == ACTIVE_ACTIVE)
31  {
32  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),
33  {
34  vector emin = it.absmin;
35  vector emax = it.absmax;
36  if(this.solid == SOLID_BSP)
37  {
38  emin -= '1 1 1';
39  emax += '1 1 1';
40  }
41  if(boxesoverlap(emin, emax, this.absmin, this.absmax)) // quick
42  if(WarpZoneLib_BoxTouchesBrush(emin, emax, this, it)) // accurate
43  {
44  if(!it.swampslug)
45  IL_PUSH(g_swamped, it);
46  it.swampslug = this;
47  }
48  });
49 
50  IL_EACH(g_swamped, it.swampslug == this,
51  {
52  if(time > it.swamp_interval)
53  {
54  Damage (it, this, this, this.dmg, DEATH_SWAMP.m_id, DMG_NOWEP, it.origin, '0 0 0');
55  it.swamp_interval = time + this.swamp_interval;
56  }
57  });
58  }
59 
60  this.nextthink = time;
61 }
62 
63 /*QUAKED spawnfunc_trigger_swamp (.5 .5 .5) ?
64 Players in the swamp will be
65 slowed down and damaged over time
66 */
67 spawnfunc(trigger_swamp)
68 {
69  // Init stuff
71  this.active = ACTIVE_ACTIVE;
72  //trigger_init(this);
73  setthink(this, swamp_think);
74  this.nextthink = time;
75 
76  // Setup default keys, if missing
77  if(!this.dmg)
78  this.dmg = 5;
79  if(!this.swamp_interval)
80  this.swamp_interval = 1;
81  if(!this.swamp_slowdown)
82  this.swamp_slowdown = 0.5;
83 }
84 #endif
#define IL_EACH(this, cond, body)
#define EXACTTRIGGER_INIT
Definition: common.qh:117
float swamp_slowdown
Definition: player.qh:59
entity() spawn
float dmg
Definition: platforms.qh:6
spawnfunc(info_player_attacker)
Definition: sv_assault.qc:283
vector absmax
Definition: csprogsdefs.qc:92
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
ERASEABLE float boxesoverlap(vector m1, vector m2, vector m3, vector m4)
requires that m2>m1 in all coordinates, and that m4>m3
Definition: vector.qh:73
float WarpZoneLib_BoxTouchesBrush(vector mi, vector ma, entity e, entity ig)
Definition: common.qc:138
const int ACTIVE_ACTIVE
Definition: defs.qh:37
#define IS_DEAD(s)
Definition: utils.qh:26
float nextthink
Definition: csprogsdefs.qc:121
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const float SOLID_BSP
Definition: csprogsdefs.qc:248
int active
Definition: defs.qh:34
#define setthink(e, f)
vector absmin
Definition: csprogsdefs.qc:92
const int ACTIVE_NOT
Definition: defs.qh:36
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
float solid
Definition: csprogsdefs.qc:99