Xonotic
door.qc File Reference
#include "door.qh"
#include "door_rotating.qh"
+ Include dependency graph for door.qc:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void door_blocked (entity this, entity blocker)
 
bool door_check_keys (entity door, entity player)
 
void door_damage (entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
 
void door_fire (entity this, entity actor, entity trigger)
 
void door_generic_plat_blocked (entity this, entity blocker)
 
void door_go_down (entity this)
 
void door_go_up (entity this, entity actor, entity trigger)
 
void door_hit_bottom (entity this)
 
void door_hit_top (entity this)
 
void door_init_startopen (entity this)
 
void door_reset (entity this)
 
void door_spawnfield (entity this, vector fmins, vector fmaxs)
 
void door_touch (entity this, entity toucher)
 
void door_trigger_touch (entity this, entity toucher)
 
void door_use (entity this, entity actor, entity trigger)
 
void LinkDoors (entity this)
 
bool LinkDoors_isconnected (entity e1, entity e2, entity pass)
 
entity LinkDoors_nextent (entity cur, entity near, entity pass)
 

Variables

float door_finished
 

Function Documentation

◆ door_blocked()

void door_blocked ( entity  this,
entity  blocker 
)

Definition at line 28 of file door.qc.

References classname, Damage(), DAMAGE_NO, DAMAGE_YES, dmg, DMG_NOWEP, DOOR_CRUSH, door_go_down(), door_go_up(), IS_DEAD, NULL, spawnflags, state, STATE_DOWN, and wait.

Referenced by door_reset().

29 {
30  if((this.spawnflags & DOOR_CRUSH)
31 #ifdef SVQC
32  && (blocker.takedamage != DAMAGE_NO)
33 #elif defined(CSQC)
34  && !IS_DEAD(blocker)
35 #endif
36  )
37  { // KIll Kill Kill!!
38 #ifdef SVQC
39  Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
40 #endif
41  }
42  else
43  {
44 #ifdef SVQC
45  if((this.dmg) && (blocker.takedamage == DAMAGE_YES)) // Shall we bite?
46  Damage (blocker, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
47 #endif
48 
49  // don't change direction for dead or dying stuff
50  if(IS_DEAD(blocker)
51 #ifdef SVQC
52  && (blocker.takedamage == DAMAGE_NO)
53 #endif
54  )
55  {
56  if (this.wait >= 0)
57  {
58  if (this.state == STATE_DOWN)
59  {
60  if (this.classname == "door")
61  door_go_up(this, NULL, NULL);
62  else
63  door_rotating_go_up(this, blocker);
64  }
65  else
66  {
67  if (this.classname == "door")
68  door_go_down(this);
69  else
70  door_rotating_go_down(this);
71  }
72  }
73  }
74 #ifdef SVQC
75  else
76  {
77  //gib dying stuff just to make sure
78  if((this.dmg) && (blocker.takedamage != DAMAGE_NO)) // Shall we bite?
79  Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
80  }
81 #endif
82  }
83 }
float state
Definition: subs.qh:32
float dmg
Definition: platforms.qh:6
string classname
Definition: csprogsdefs.qc:107
#define STATE_DOWN
Definition: sys-pre.qh:33
float spawnflags
Definition: progsdefs.qc:191
#define DMG_NOWEP
Definition: damage.qh:126
void door_go_up(entity this, entity actor, entity trigger)
Definition: door.qc:123
const int DOOR_CRUSH
Definition: door.qh:14
float wait
Definition: subs.qh:39
#define NULL
Definition: post.qh:17
void door_go_down(entity this)
Definition: door.qc:109
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
#define IS_DEAD(s)
Definition: utils.qh:26
float DAMAGE_NO
Definition: progsdefs.qc:282
float DAMAGE_YES
Definition: progsdefs.qc:283
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_check_keys()

bool door_check_keys ( entity  door,
entity  player 
)

Definition at line 155 of file door.qc.

References entity(), IS_PLAYER, PS, and time.

Referenced by door_trigger_touch().

156 {
157  if(door.owner)
158  door = door.owner;
159 
160  // no key needed
161  if(!door.itemkeys)
162  return true;
163 
164  // this door require a key
165  // only a player can have a key
166  if(!IS_PLAYER(player))
167  return false;
168 
169  entity store = player;
170 #ifdef SVQC
171  store = PS(player);
172 #endif
173  int valid = (door.itemkeys & store.itemkeys);
174  door.itemkeys &= ~valid; // only some of the needed keys were given
175 
176  if(!door.itemkeys)
177  {
178 #ifdef SVQC
179  play2(player, door.noise);
180  Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_DOOR_UNLOCKED);
181 #endif
182  return true;
183  }
184 
185  if(!valid)
186  {
187 #ifdef SVQC
188  if(player.key_door_messagetime <= time)
189  {
190  play2(player, door.noise3);
191  Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_DOOR_LOCKED_NEED, item_keys_keylist(door.itemkeys));
192  player.key_door_messagetime = time + 2;
193  }
194 #endif
195  return false;
196  }
197 
198  // door needs keys the player doesn't have
199 #ifdef SVQC
200  if(player.key_door_messagetime <= time)
201  {
202  play2(player, door.noise3);
203  Send_Notification(NOTIF_ONE, player, MSG_CENTER, CENTER_DOOR_LOCKED_ALSONEED, item_keys_keylist(door.itemkeys));
204  player.key_door_messagetime = time + 2;
205  }
206 #endif
207 
208  return false;
209 }
entity() spawn
#define PS(this)
Definition: state.qh:18
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_damage()

void door_damage ( entity  this,
entity  inflictor,
entity  attacker,
float  damage,
int  deathtype,
.entity  weaponentity,
vector  hitloc,
vector  force 
)

Definition at line 263 of file door.qc.

References DAMAGE_NO, DEATH_ISSPECIAL, door_use(), GetResource(), HITTYPE_SPLASH, itemkeys, NOSPLASH, NULL, owner, RES_HEALTH, SetResourceExplicit(), spawnflags, and TakeResource().

Referenced by door_reset().

264 {
265  if(this.spawnflags & NOSPLASH)
266  if(!(DEATH_ISSPECIAL(deathtype)) && (deathtype & HITTYPE_SPLASH))
267  return;
268  TakeResource(this, RES_HEALTH, damage);
269 
270  if (this.itemkeys)
271  {
272  // don't allow opening doors through damage if keys are required
273  return;
274  }
275 
276  if (GetResource(this, RES_HEALTH) <= 0)
277  {
278  SetResourceExplicit(this.owner, RES_HEALTH, this.owner.max_health);
279  this.owner.takedamage = DAMAGE_NO; // will be reset upon return
280  door_use(this.owner, attacker, NULL);
281  }
282 }
const int HITTYPE_SPLASH
automatically set by RadiusDamage
Definition: all.qh:27
const int NOSPLASH
Definition: defs.qh:12
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
void door_use(entity this, entity actor, entity trigger)
Definition: door.qc:255
float spawnflags
Definition: progsdefs.qc:191
entity owner
Definition: main.qh:73
void TakeResource(entity receiver, Resource res_type, float amount)
Takes an entity some resource.
Definition: cl_resources.qc:31
RES_HEALTH
Definition: ent_cs.qc:126
#define NULL
Definition: post.qh:17
float itemkeys
Definition: subs.qh:61
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
#define DEATH_ISSPECIAL(t)
Definition: all.qh:35
float DAMAGE_NO
Definition: progsdefs.qc:282
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_fire()

void door_fire ( entity  this,
entity  actor,
entity  trigger 
)

Definition at line 211 of file door.qc.

References door_go_down(), door_go_up(), DOOR_ROTATING_BIDIR, DOOR_ROTATING_BIDIR_IN_DOWN, DOOR_TOGGLE, entity(), NULL, objerror(), owner, spawnflags, state, STATE_BOTTOM, STATE_DOWN, STATE_TOP, and STATE_UP.

Referenced by door_use().

212 {
213  if (this.owner != this)
214  objerror (this, "door_fire: this.owner != this");
215 
216  if (this.spawnflags & DOOR_TOGGLE)
217  {
218  if (this.state == STATE_UP || this.state == STATE_TOP)
219  {
220  entity e = this;
221  do {
222  if (e.classname == "door") {
223  door_go_down(e);
224  } else {
225  door_rotating_go_down(e);
226  }
227  e = e.enemy;
228  } while ((e != this) && (e != NULL));
229  return;
230  }
231  }
232 
233 // trigger all paired doors
234  entity e = this;
235  do {
236  if (e.classname == "door") {
237  door_go_up(e, actor, trigger);
238  } else {
239  // if the BIDIR spawnflag (==2) is set and the trigger has set trigger_reverse, reverse the opening direction
240  if ((e.spawnflags & DOOR_ROTATING_BIDIR) && trigger.trigger_reverse!=0 && e.lip != 666 && e.state == STATE_BOTTOM) {
241  e.lip = 666; // e.lip is used to remember reverse opening direction for door_rotating
242  e.pos2 = '0 0 0' - e.pos2;
243  }
244  // if BIDIR_IN_DOWN (==8) is set, prevent the door from reoping during closing if it is triggered from the wrong side
245  if (!((e.spawnflags & DOOR_ROTATING_BIDIR) && (e.spawnflags & DOOR_ROTATING_BIDIR_IN_DOWN) && e.state == STATE_DOWN
246  && (((e.lip == 666) && (trigger.trigger_reverse == 0)) || ((e.lip != 666) && (trigger.trigger_reverse != 0)))))
247  {
248  door_rotating_go_up(e, trigger);
249  }
250  }
251  e = e.enemy;
252  } while ((e != this) && (e != NULL));
253 }
float state
Definition: subs.qh:32
entity() spawn
#define STATE_TOP
Definition: sys-pre.qh:30
const int DOOR_ROTATING_BIDIR_IN_DOWN
Definition: door_rotating.qh:5
#define STATE_DOWN
Definition: sys-pre.qh:33
float spawnflags
Definition: progsdefs.qc:191
entity owner
Definition: main.qh:73
void door_go_up(entity this, entity actor, entity trigger)
Definition: door.qc:123
#define NULL
Definition: post.qh:17
void door_go_down(entity this)
Definition: door.qc:109
#define STATE_UP
Definition: sys-pre.qh:32
const int DOOR_ROTATING_BIDIR
Definition: door_rotating.qh:4
#define STATE_BOTTOM
Definition: sys-pre.qh:31
const int DOOR_TOGGLE
Definition: door.qh:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_generic_plat_blocked()

void door_generic_plat_blocked ( entity  this,
entity  blocker 
)

Definition at line 313 of file door.qc.

References Damage(), DAMAGE_NO, DAMAGE_YES, dmg, DMG_NOWEP, DOOR_CRUSH, IS_DEAD, spawnflags, state, STATE_DOWN, and wait.

314 {
315  if((this.spawnflags & DOOR_CRUSH) && (blocker.takedamage != DAMAGE_NO)) { // Kill Kill Kill!!
316 #ifdef SVQC
317  Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
318 #endif
319  }
320  else
321  {
322 
323 #ifdef SVQC
324  if((this.dmg) && (blocker.takedamage == DAMAGE_YES)) // Shall we bite?
325  Damage (blocker, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
326 #endif
327 
328  //Dont chamge direction for dead or dying stuff
329  if(IS_DEAD(blocker) && (blocker.takedamage == DAMAGE_NO))
330  {
331  if (this.wait >= 0)
332  {
333  if (this.state == STATE_DOWN)
334  door_rotating_go_up (this, blocker);
335  else
336  door_rotating_go_down (this);
337  }
338  }
339 #ifdef SVQC
340  else
341  {
342  //gib dying stuff just to make sure
343  if((this.dmg) && (blocker.takedamage != DAMAGE_NO)) // Shall we bite?
344  Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
345  }
346 #endif
347  }
348 }
float state
Definition: subs.qh:32
float dmg
Definition: platforms.qh:6
#define STATE_DOWN
Definition: sys-pre.qh:33
float spawnflags
Definition: progsdefs.qc:191
#define DMG_NOWEP
Definition: damage.qh:126
const int DOOR_CRUSH
Definition: door.qh:14
float wait
Definition: subs.qh:39
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition: damage.qc:583
#define IS_DEAD(s)
Definition: utils.qh:26
float DAMAGE_NO
Definition: progsdefs.qc:282
float DAMAGE_YES
Definition: progsdefs.qc:283
+ Here is the call graph for this function:

◆ door_go_down()

void door_go_down ( entity  this)

Definition at line 109 of file door.qc.

References _sound, ATTEN_NORM, CH_TRIGGER_SINGLE, DAMAGE_YES, door_hit_bottom(), max_health, noise2, pos1, RES_HEALTH, SetResourceExplicit(), speed, state, STATE_DOWN, SUB_CalcMove(), takedamage, TSPEED_LINEAR, and VOL_BASE.

Referenced by door_blocked(), door_fire(), and door_hit_top().

110 {
111  if (this.noise2 != "")
113  if (this.max_health)
114  {
115  this.takedamage = DAMAGE_YES;
117  }
118 
119  this.state = STATE_DOWN;
120  SUB_CalcMove (this, this.pos1, TSPEED_LINEAR, this.speed, door_hit_bottom);
121 }
float state
Definition: subs.qh:32
float speed
Definition: subs.qh:41
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
const int TSPEED_LINEAR
Definition: subs.qh:71
string noise2
Definition: progsdefs.qc:209
#define STATE_DOWN
Definition: sys-pre.qh:33
void SUB_CalcMove(entity this, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
Definition: subs.qc:256
RES_HEALTH
Definition: ent_cs.qc:126
float max_health
const float VOL_BASE
Definition: sound.qh:36
float takedamage
Definition: progsdefs.qc:147
const float ATTEN_NORM
Definition: sound.qh:30
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
void door_hit_bottom(entity this)
Definition: door.qc:102
#define _sound(e, c, s, v, a)
Definition: sound.qh:50
vector pos1
Definition: subs.qh:50
float DAMAGE_YES
Definition: progsdefs.qc:283
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_go_up()

void door_go_up ( entity  this,
entity  actor,
entity  trigger 
)

Definition at line 123 of file door.qc.

References _sound, ATTEN_NORM, CH_TRIGGER_SINGLE, door_hit_top(), ltime, message, nextthink, noise2, pos2, speed, state, STATE_TOP, STATE_UP, SUB_CalcMove(), SUB_UseTargets(), TSPEED_LINEAR, VOL_BASE, and wait.

Referenced by door_blocked(), and door_fire().

124 {
125  if (this.state == STATE_UP)
126  return; // already going up
127 
128  if (this.state == STATE_TOP)
129  { // reset top wait time
130  this.nextthink = this.ltime + this.wait;
131  return;
132  }
133 
134  if (this.noise2 != "")
136  this.state = STATE_UP;
137  SUB_CalcMove (this, this.pos2, TSPEED_LINEAR, this.speed, door_hit_top);
138 
139  string oldmessage;
140  oldmessage = this.message;
141  this.message = "";
142  SUB_UseTargets(this, actor, trigger);
143  this.message = oldmessage;
144 }
float state
Definition: subs.qh:32
float speed
Definition: subs.qh:41
#define STATE_TOP
Definition: sys-pre.qh:30
const int TSPEED_LINEAR
Definition: subs.qh:71
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition: triggers.qc:366
string noise2
Definition: progsdefs.qc:209
float ltime
Definition: progsdefs.qc:107
void SUB_CalcMove(entity this, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
Definition: subs.qc:256
float wait
Definition: subs.qh:39
string message
Definition: powerups.qc:19
const float VOL_BASE
Definition: sound.qh:36
const float ATTEN_NORM
Definition: sound.qh:30
float nextthink
Definition: csprogsdefs.qc:121
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
#define STATE_UP
Definition: sys-pre.qh:32
#define _sound(e, c, s, v, a)
Definition: sound.qh:50
vector pos2
Definition: subs.qh:50
void door_hit_top(entity this)
Definition: door.qc:85
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_hit_bottom()

void door_hit_bottom ( entity  this)

Definition at line 102 of file door.qc.

References _sound, ATTEN_NORM, CH_TRIGGER_SINGLE, noise1, state, STATE_BOTTOM, and VOL_BASE.

Referenced by door_go_down().

103 {
104  if (this.noise1 != "")
106  this.state = STATE_BOTTOM;
107 }
float state
Definition: subs.qh:32
string noise1
Definition: progsdefs.qc:209
const float VOL_BASE
Definition: sound.qh:36
const float ATTEN_NORM
Definition: sound.qh:30
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
#define _sound(e, c, s, v, a)
Definition: sound.qh:50
#define STATE_BOTTOM
Definition: sys-pre.qh:31
+ Here is the caller graph for this function:

◆ door_hit_top()

void door_hit_top ( entity  this)

Definition at line 85 of file door.qc.

References _sound, ATTEN_NORM, CH_TRIGGER_SINGLE, classname, door_go_down(), DOOR_TOGGLE, ltime, nextthink, noise1, setthink, spawnflags, state, STATE_TOP, VOL_BASE, and wait.

Referenced by door_go_up().

86 {
87  if (this.noise1 != "")
89  this.state = STATE_TOP;
90  if (this.spawnflags & DOOR_TOGGLE)
91  return; // don't come down automatically
92  if (this.classname == "door")
93  {
94  setthink(this, door_go_down);
95  } else
96  {
97  setthink(this, door_rotating_go_down);
98  }
99  this.nextthink = this.ltime + this.wait;
100 }
float state
Definition: subs.qh:32
#define STATE_TOP
Definition: sys-pre.qh:30
string classname
Definition: csprogsdefs.qc:107
float ltime
Definition: progsdefs.qc:107
float spawnflags
Definition: progsdefs.qc:191
float wait
Definition: subs.qh:39
string noise1
Definition: progsdefs.qc:209
const float VOL_BASE
Definition: sound.qh:36
void door_go_down(entity this)
Definition: door.qc:109
const float ATTEN_NORM
Definition: sound.qh:30
float nextthink
Definition: csprogsdefs.qc:121
const int CH_TRIGGER_SINGLE
Definition: sound.qh:13
#define _sound(e, c, s, v, a)
Definition: sound.qh:50
#define setthink(e, f)
const int DOOR_TOGGLE
Definition: door.qh:11
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_init_startopen()

void door_init_startopen ( entity  this)

Definition at line 602 of file door.qc.

References origin, pos1, pos2, setorigin(), and SF_TRIGGER_UPDATE.

Referenced by door_reset().

603 {
604  setorigin(this, this.pos2);
605  this.pos2 = this.pos1;
606  this.pos1 = this.origin;
607 
608 #ifdef SVQC
609  this.SendFlags |= SF_TRIGGER_UPDATE;
610 #endif
611 }
origin
Definition: ent_cs.qc:114
vector pos1
Definition: subs.qh:50
setorigin(ent, v)
vector pos2
Definition: subs.qh:50
const int SF_TRIGGER_UPDATE
Definition: defs.qh:23
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_reset()

void door_reset ( entity  this)

Definition at line 613 of file door.qc.

References classname, DAMAGE_YES, dmg, door_blocked(), DOOR_CRUSH, door_damage(), door_init_startopen(), DOOR_NONSOLID, DOOR_START_OPEN, door_touch(), door_use(), EF_LOWPRECISION, effects, entity(), fabs(), func_null(), GetField_fullspawndata(), GetResource(), InitializeEntity(), ITEM_KEY_BIT, itemkeys, items, LinkDoors(), lip, ltime, max(), max_health, message, move_time, movedir, MOVETYPE_PUSH, NET_HANDLE, nextthink, noise, noise1, noise2, noise3, origin, pos1, pos2, precache_sound(), q3compat, ReadString, RES_HEALTH, set_movetype(), setorigin(), setthink, SF_TRIGGER_INIT, SF_TRIGGER_RESET, SF_TRIGGER_UPDATE, size, solid, SOLID_BSP, SOLID_NOT, sounds, spawnflags, SPAWNFLAGS_GOLD_KEY, SPAWNFLAGS_SILVER_KEY, spawnfunc(), speed, state, STATE_BOTTOM, strzone(), takedamage, time, use, velocity, and wait.

614 {
615  setorigin(this, this.pos1);
616  this.velocity = '0 0 0';
617  this.state = STATE_BOTTOM;
618  setthink(this, func_null);
619  this.nextthink = 0;
620 
621 #ifdef SVQC
622  this.SendFlags |= SF_TRIGGER_RESET;
623 #endif
624 }
float state
Definition: subs.qh:32
const int SF_TRIGGER_RESET
Definition: defs.qh:24
float nextthink
Definition: csprogsdefs.qc:121
vector pos1
Definition: subs.qh:50
setorigin(ent, v)
#define setthink(e, f)
vector velocity
Definition: csprogsdefs.qc:103
var void func_null()
#define STATE_BOTTOM
Definition: sys-pre.qh:31
+ Here is the call graph for this function:

◆ door_spawnfield()

void door_spawnfield ( entity  this,
vector  fmins,
vector  fmaxs 
)

Definition at line 380 of file door.qc.

References door_trigger_touch(), entity(), MOVETYPE_NONE, set_movetype(), SOLID_TRIGGER, and vector().

Referenced by LinkDoors().

381 {
382  entity trigger;
383  vector t1 = fmins, t2 = fmaxs;
384 
385  trigger = new(doortriggerfield);
386  set_movetype(trigger, MOVETYPE_NONE);
387  trigger.solid = SOLID_TRIGGER;
388  trigger.owner = this;
389 #ifdef SVQC
390  settouch(trigger, door_trigger_touch);
391 #endif
392 
393  setsize (trigger, t1 - '60 60 8', t2 + '60 60 8');
394 }
float MOVETYPE_NONE
Definition: progsdefs.qc:246
void door_trigger_touch(entity this, entity toucher)
Definition: door.qc:358
entity() spawn
vector(float skel, float bonenum) _skel_get_boneabs_hidden
const float SOLID_TRIGGER
Definition: csprogsdefs.qc:245
void set_movetype(entity this, int mt)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_touch()

void door_touch ( entity  this,
entity  toucher 
)

Definition at line 294 of file door.qc.

References centerprint(), IS_CLIENT, IS_PLAYER, owner, and time.

Referenced by door_reset().

295 {
296  if (!IS_PLAYER(toucher))
297  return;
298  if (this.owner.door_finished > time)
299  return;
300 
301  this.owner.door_finished = time + 2;
302 
303 #ifdef SVQC
304  if (!(this.owner.dmg) && (this.owner.message != ""))
305  {
306  if (IS_CLIENT(toucher))
307  centerprint(toucher, this.owner.message);
308  play2(toucher, this.owner.noise);
309  }
310 #endif
311 }
#define IS_CLIENT(v)
Definition: utils.qh:13
entity owner
Definition: main.qh:73
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_trigger_touch()

void door_trigger_touch ( entity  this,
entity  toucher 
)

Definition at line 358 of file door.qc.

References door_check_keys(), door_finished, door_use(), GetResource(), IS_CLIENT, IS_DEAD, NULL, owner, RES_HEALTH, and time.

Referenced by door_spawnfield().

359 {
360  if (GetResource(toucher, RES_HEALTH) < 1)
361 #ifdef SVQC
362  if (!((toucher.iscreature || (toucher.flags & FL_PROJECTILE)) && !IS_DEAD(toucher)))
363 #elif defined(CSQC)
364  if(!((IS_CLIENT(toucher) || toucher.classname == "ENT_CLIENT_PROJECTILE") && !IS_DEAD(toucher)))
365 #endif
366  return;
367 
368  if (time < this.door_finished)
369  return;
370 
371  // check if door is locked
372  if (!door_check_keys(this, toucher))
373  return;
374 
375  this.door_finished = time + 1;
376 
377  door_use(this.owner, toucher, NULL);
378 }
float door_finished
Definition: door.qc:284
void door_use(entity this, entity actor, entity trigger)
Definition: door.qc:255
#define IS_CLIENT(v)
Definition: utils.qh:13
entity owner
Definition: main.qh:73
RES_HEALTH
Definition: ent_cs.qc:126
bool door_check_keys(entity door, entity player)
Definition: door.qc:155
#define NULL
Definition: post.qh:17
#define IS_DEAD(s)
Definition: utils.qh:26
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
float time
Definition: csprogsdefs.qc:16
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ door_use()

void door_use ( entity  this,
entity  actor,
entity  trigger 
)

Definition at line 255 of file door.qc.

References door_fire(), and owner.

Referenced by door_damage(), door_reset(), and door_trigger_touch().

256 {
257  //dprint("door_use (model: ");dprint(this.model);dprint(")\n");
258 
259  if (this.owner)
260  door_fire(this.owner, actor, trigger);
261 }
void door_fire(entity this, entity actor, entity trigger)
Definition: door.qc:211
entity owner
Definition: main.qh:73
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LinkDoors()

void LinkDoors ( entity  this)

Definition at line 429 of file door.qc.

References absmax, absmin, classname, DOOR_DONT_LINK, door_spawnfield(), enemy, entity(), etos(), FindConnectedComponent(), GetResource(), items, LinkDoors_isconnected(), LinkDoors_nextent(), lip, LOG_TRACE, ltime, message, model, NULL, origin, owner, pos1, pos2, REGISTER_NET_LINKED, RES_HEALTH, SetResourceExplicit(), SF_TRIGGER_INIT, SF_TRIGGER_RESET, SF_TRIGGER_UPDATE, size, spawnflags, speed, state, targetname, to, vector(), wait, WriteByte(), WriteCoord(), WriteShort(), and WriteString().

Referenced by door_reset().

430 {
431  entity t;
432  vector cmins, cmaxs;
433 
434 #ifdef SVQC
435  door_link();
436 #endif
437 
438  if (this.enemy)
439  return; // already linked by another door
440  if (this.spawnflags & DOOR_DONT_LINK)
441  {
442  this.owner = this.enemy = this;
443 
444  if (GetResource(this, RES_HEALTH))
445  return;
446  if(this.targetname && this.targetname != "")
447  return;
448  if (this.items)
449  return;
450 
451  door_spawnfield(this, this.absmin, this.absmax);
452 
453  return; // don't want to link this door
454  }
455 
457 
458  // set owner, and make a loop of the chain
459  LOG_TRACE("LinkDoors: linking doors:");
460  for(t = this; ; t = t.enemy)
461  {
462  LOG_TRACE(" ", etos(t));
463  t.owner = this;
464  if(t.enemy == NULL)
465  {
466  t.enemy = this;
467  break;
468  }
469  }
470  LOG_TRACE("");
471 
472  // collect health, targetname, message, size
473  cmins = this.absmin;
474  cmaxs = this.absmax;
475  for(t = this; ; t = t.enemy)
476  {
477  if(GetResource(t, RES_HEALTH) && !GetResource(this, RES_HEALTH))
479  if((t.targetname != "") && (this.targetname == ""))
480  this.targetname = t.targetname;
481  if((t.message != "") && (this.message == ""))
482  this.message = t.message;
483  if (t.absmin_x < cmins_x)
484  cmins_x = t.absmin_x;
485  if (t.absmin_y < cmins_y)
486  cmins_y = t.absmin_y;
487  if (t.absmin_z < cmins_z)
488  cmins_z = t.absmin_z;
489  if (t.absmax_x > cmaxs_x)
490  cmaxs_x = t.absmax_x;
491  if (t.absmax_y > cmaxs_y)
492  cmaxs_y = t.absmax_y;
493  if (t.absmax_z > cmaxs_z)
494  cmaxs_z = t.absmax_z;
495  if(t.enemy == this)
496  break;
497  }
498 
499  // distribute health, targetname, message
500  for(t = this; t; t = t.enemy)
501  {
503  t.targetname = this.targetname;
504  t.message = this.message;
505  if(t.enemy == this)
506  break;
507  }
508 
509  // shootable, or triggered doors just needed the owner/enemy links,
510  // they don't spawn a field
511 
512  if (GetResource(this, RES_HEALTH))
513  return;
514  if(this.targetname && this.targetname != "")
515  return;
516  if (this.items)
517  return;
518 
519  door_spawnfield(this, cmins, cmaxs);
520 }
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
Definition: cl_resources.qc:15
entity() spawn
void FindConnectedComponent(entity e,.entity fld, findNextEntityNearFunction_t nxt, isConnectedFunction_t iscon, entity pass)
Definition: util.qc:1630
float spawnflags
Definition: progsdefs.qc:191
entity owner
Definition: main.qh:73
void door_spawnfield(entity this, vector fmins, vector fmaxs)
Definition: door.qc:380
vector absmax
Definition: csprogsdefs.qc:92
RES_HEALTH
Definition: ent_cs.qc:126
const int DOOR_DONT_LINK
Definition: door.qh:8
entity enemy
Definition: sv_ctf.qh:143
string message
Definition: powerups.qc:19
#define NULL
Definition: post.qh:17
vector(float skel, float bonenum) _skel_get_boneabs_hidden
bool LinkDoors_isconnected(entity e1, entity e2, entity pass)
Definition: door.qc:413
entity LinkDoors_nextent(entity cur, entity near, entity pass)
Definition: door.qc:405
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
Definition: cl_resources.qc:10
#define LOG_TRACE(...)
Definition: log.qh:81
float items
Definition: progsdefs.qc:145
string targetname
Definition: progsdefs.qc:194
vector absmin
Definition: csprogsdefs.qc:92
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ LinkDoors_isconnected()

bool LinkDoors_isconnected ( entity  e1,
entity  e2,
entity  pass 
)

Definition at line 413 of file door.qc.

Referenced by LinkDoors().

414 {
415  float DELTA = 4;
416  if((e1.absmin_x > e2.absmax_x + DELTA)
417  || (e1.absmin_y > e2.absmax_y + DELTA)
418  || (e1.absmin_z > e2.absmax_z + DELTA)
419  || (e2.absmin_x > e1.absmax_x + DELTA)
420  || (e2.absmin_y > e1.absmax_y + DELTA)
421  || (e2.absmin_z > e1.absmax_z + DELTA)
422  ) { return false; }
423  return true;
424 }
+ Here is the caller graph for this function:

◆ LinkDoors_nextent()

entity LinkDoors_nextent ( entity  cur,
entity  near,
entity  pass 
)

Definition at line 405 of file door.qc.

References classname, DOOR_DONT_LINK, and find().

Referenced by LinkDoors().

406 {
407  while((cur = find(cur, classname, pass.classname)) && ((cur.spawnflags & DOOR_DONT_LINK) || cur.enemy))
408  {
409  }
410  return cur;
411 }
string classname
Definition: csprogsdefs.qc:107
const int DOOR_DONT_LINK
Definition: door.qh:8
#define pass(name, colormin, colormax)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Variable Documentation

◆ door_finished

float door_finished

Definition at line 284 of file door.qc.

Referenced by door_trigger_touch().