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

Go to the source code of this file.

Functions

void trigger_keylock_kill (string s)
 kill killtarget of trigger keylock. More...
 
void trigger_keylock_touch (entity this, entity toucher)
 
void trigger_keylock_trigger (entity this, entity actor, string s)
 trigger given targets More...
 

Function Documentation

◆ trigger_keylock_kill()

void trigger_keylock_kill ( string  s)

kill killtarget of trigger keylock.

Definition at line 15 of file keylock.qc.

References entity(), find(), NULL, and targetname.

Referenced by trigger_keylock_touch().

16 {
17  entity t;
18  for(t = NULL; (t = find(t, targetname, s)); )
19  delete(t);
20 }
entity() spawn
#define NULL
Definition: post.qh:17
string targetname
Definition: progsdefs.qc:194
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ trigger_keylock_touch()

void trigger_keylock_touch ( entity  this,
entity  toucher 
)

Definition at line 22 of file keylock.qc.

References centerprint(), delay, entity(), EXACTTRIGGER_INIT, height, IS_PLAYER, itemkeys, killtarget, message, NET_HANDLE, noise, noise1, noise2, precache_sound(), PS, REGISTER_NET_LINKED, SND, sounds, spawnfunc(), strzone(), target, target2, time, to, trigger_keylock_kill(), trigger_keylock_trigger(), wait, and WriteByte().

23 {
24  bool key_used = false;
25  bool started_delay = false;
26 
27  // only player may trigger the lock
28  if(!IS_PLAYER(toucher))
29  return;
30 
31  // check silver key
32  if(this.itemkeys)
33  {
34 #ifdef SVQC
35  entity store = PS(toucher);
36 #elif defined(CSQC)
37  entity store = toucher;
38 #endif
39  key_used = item_keys_usekey(this, store);
40  }
41 
42  if(this.itemkeys)
43  {
44 #ifdef SVQC
45  // at least one of the keys is missing
46  if(key_used)
47  {
48  // one or more keys were given, but others are still missing!
49  play2(toucher, this.noise1);
50  Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_DOOR_LOCKED_ALSONEED, item_keys_keylist(this.itemkeys));
51  toucher.key_door_messagetime = time + 2;
52  }
53  else if(toucher.key_door_messagetime <= time)
54  {
55  // no keys were given
56  play2(toucher, this.noise2);
57  Send_Notification(NOTIF_ONE, toucher, MSG_CENTER, CENTER_DOOR_LOCKED_NEED, item_keys_keylist(this.itemkeys));
58  toucher.key_door_messagetime = time + 2;
59  }
60 #endif
61 
62  // trigger target2
63  if(this.delay <= time || started_delay == true)
64  if(this.target2)
65  {
66  trigger_keylock_trigger(this, toucher, this.target2);
67  started_delay = true;
68  this.delay = time + this.wait;
69  }
70  }
71  else
72  {
73 #ifdef SVQC
74  // all keys were given!
75  play2(toucher, this.noise);
76  centerprint(toucher, this.message);
77 #endif
78 
79  if(this.target)
80  trigger_keylock_trigger(this, toucher, this.target);
81 
82  if(this.killtarget)
84 
85  delete(this);
86  }
87 
88 }
void trigger_keylock_kill(string s)
kill killtarget of trigger keylock.
Definition: keylock.qc:15
string killtarget
Definition: subs.qh:48
string noise
Definition: progsdefs.qc:209
void trigger_keylock_trigger(entity this, entity actor, string s)
trigger given targets
Definition: keylock.qc:5
entity() spawn
#define PS(this)
Definition: state.qh:18
string noise2
Definition: progsdefs.qc:209
float wait
Definition: subs.qh:39
float delay
Definition: subs.qh:38
string noise1
Definition: progsdefs.qc:209
string message
Definition: powerups.qc:19
float itemkeys
Definition: subs.qh:61
string target2
Definition: sv_onslaught.qh:45
string target
Definition: progsdefs.qc:193
float time
Definition: csprogsdefs.qc:16
#define IS_PLAYER(v)
Definition: utils.qh:9
+ Here is the call graph for this function:

◆ trigger_keylock_trigger()

void trigger_keylock_trigger ( entity  this,
entity  actor,
string  s 
)

trigger given targets

Definition at line 5 of file keylock.qc.

References entity(), find(), NULL, and targetname.

Referenced by trigger_keylock_touch().

6 {
7  for(entity t = NULL; (t = find(t, targetname, s)); )
8  if(t.use)
9  t.use(t, actor, this);
10 }
entity() spawn
#define NULL
Definition: post.qh:17
string targetname
Definition: progsdefs.qc:194
+ Here is the call graph for this function:
+ Here is the caller graph for this function: