Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
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

 spawnfunc (trigger_keylock)
void trigger_keylock_kill (string s)
 kill killtarget of trigger keylock.
void trigger_keylock_link (entity this)
bool trigger_keylock_send (entity this, entity to, int sf)
void trigger_keylock_touch (entity this, entity toucher)
void trigger_keylock_trigger (entity this, entity actor, string s)
 trigger given targets

Function Documentation

◆ spawnfunc()

spawnfunc ( trigger_keylock )

Definition at line 130 of file keylock.qc.

131{
132 if(!this.itemkeys) { delete(this); return; }
133
134 // set unlocked message
135 if(this.message == "")
136 this.message = "Unlocked!";
137
138 // set default unlock noise
139 if(this.noise == "")
140 {
141 if(this.sounds == 1)
142 this.noise = "misc/secret.wav";
143 else if(this.sounds == 2)
144 this.noise = strzone(SND(TALK));
145 else //if (this.sounds == 3) {
146 this.noise = "misc/trigger1.wav";
147 }
148
149 // set default use key sound
150 if(this.noise1 == "")
151 this.noise1 = "misc/decreasevalue.wav";
152
153 // set closed sourd
154 if(this.noise2 == "")
155 this.noise2 = SND(TALK);
156
157 // delay between triggering message2 and trigger2
158 if(!this.wait) { this.wait = 5; }
159
160 // precache sounds
161 precache_sound(this.noise);
164
166
168
170}
string message
Definition powerups.qc:19
float wait
Definition items.qc:17
void trigger_keylock_touch(entity this, entity toucher)
Definition keylock.qc:22
void trigger_keylock_link(entity this)
Definition keylock.qc:105
#define EXACTTRIGGER_INIT
Definition common.qh:116
string precache_sound(string sample)
string strzone(string s)
#define settouch(e, f)
Definition self.qh:73
#define SND(id)
Definition all.qh:35
string noise
Definition subs.qh:83
string noise1
Definition subs.qh:83
float itemkeys
Definition subs.qh:61
float sounds
Definition subs.qh:42
string noise2
Definition subs.qh:83

References EXACTTRIGGER_INIT, itemkeys, message, noise, noise1, noise2, precache_sound(), settouch, SND, sounds, strzone(), trigger_keylock_link(), trigger_keylock_touch(), and wait.

◆ trigger_keylock_kill()

void trigger_keylock_kill ( string s)

kill killtarget of trigger keylock.

Definition at line 15 of file keylock.qc.

16{
17 entity t;
18 for(t = NULL; (t = find(t, targetname, s)); )
19 delete(t);
20}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
entity find(entity start,.string field, string match)
#define NULL
Definition post.qh:14
string targetname
Definition triggers.qh:56

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

Referenced by trigger_keylock_touch().

◆ trigger_keylock_link()

void trigger_keylock_link ( entity this)

Definition at line 105 of file keylock.qc.

106{
107 // uncomment to network keylocks
108 //Net_LinkEntity(this, false, 0, trigger_keylock_send);
109}

References entity().

Referenced by spawnfunc().

◆ trigger_keylock_send()

bool trigger_keylock_send ( entity this,
entity to,
int sf )

Definition at line 93 of file keylock.qc.

94{
95 WriteHeader(MSG_ENTITY, ENT_CLIENT_KEYLOCK);
96
97 WriteInt24_t(MSG_ENTITY, this.itemkeys);
99
100 trigger_common_write(this, true);
101
102 return true;
103}
float height
Definition bobbing.qc:3
const int MSG_ENTITY
Definition net.qh:115
#define WriteHeader(to, id)
Definition net.qh:221
void WriteByte(float data, float dest, float desto)
void trigger_common_write(entity this, bool withtarget)
Definition triggers.qc:110

References entity(), height, itemkeys, MSG_ENTITY, trigger_common_write(), WriteByte(), and WriteHeader.

◆ trigger_keylock_touch()

void trigger_keylock_touch ( entity this,
entity toucher )

Definition at line 22 of file keylock.qc.

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 {
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);
77#endif
78
79 if(this.target)
81
82 if(this.killtarget)
84
85 delete(this);
86 }
87
88}
float delay
Definition items.qc:17
#define IS_PLAYER(s)
Definition player.qh:243
float time
void trigger_keylock_trigger(entity this, entity actor, string s)
trigger given targets
Definition keylock.qc:5
void trigger_keylock_kill(string s)
kill killtarget of trigger keylock.
Definition keylock.qc:15
bool item_keys_usekey(entity l, entity p)
Use keys from p on l.
Definition keys.qc:4
string item_keys_keylist(float keylist)
Returns a string with a comma separated list of key names, as specified in keylist.
Definition keys.qc:40
void centerprint(string text,...)
void Send_Notification(NOTIF broadcast, entity client, MSG net_type, Notification net_name,...count)
Definition all.qc:1573
entity entity toucher
Definition self.qh:72
void play2(entity e, string filename)
Definition all.qc:116
#define PS(this)
Definition state.qh:18
string killtarget
Definition subs.qh:48
string target2
string target
Definition triggers.qh:55

References centerprint(), delay, entity(), IS_PLAYER, item_keys_keylist(), item_keys_usekey(), itemkeys, killtarget, message, noise, noise1, noise2, play2(), PS, Send_Notification(), target, target2, time, toucher, trigger_keylock_kill(), trigger_keylock_trigger(), and wait.

Referenced by spawnfunc().

◆ trigger_keylock_trigger()

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

trigger given targets

Definition at line 5 of file keylock.qc.

6{
7 for(entity t = NULL; (t = find(t, targetname, s)); )
8 if(t.use)
9 t.use(t, actor, this);
10}

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

Referenced by trigger_keylock_touch().