]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/triggers/trigger/secret.qc
b93ab03d0a4ded5fcb90f76e2cef41c1963bb195
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / triggers / trigger / secret.qc
1 #if defined(CSQC)
2 #elif defined(MENUQC)
3 #elif defined(SVQC)
4         #include "../../../server/_all.qh"
5     #include "../../util.qh"
6     #include "../../../server/defs.qh"
7     #include "secret.qh"
8 #endif
9
10 #ifdef SVQC
11
12 void secrets_setstatus() {
13         self.stat_secrets_total = secrets_total;
14         self.stat_secrets_found = secrets_found;
15 }
16
17 /**
18  * A secret has been found (maybe :P)
19  */
20 void trigger_secret_touch() {
21         // only a player can trigger this
22         if (!IS_PLAYER(other))
23                 return;
24
25         // update secrets found counter
26         secrets_found += 1;
27         //print("Secret found: ", ftos(secret_counter.cnt), "/");
28         //print(ftos(secret_counter.count), "\n");
29
30         // centerprint message (multi_touch() doesn't always call centerprint())
31         centerprint(other, self.message);
32         self.message = "";
33
34         // handle normal trigger features
35         multi_touch();
36         remove(self);
37 }
38
39 /*QUAKED trigger_secret (.5 .5 .5) ?
40 Variable sized secret trigger. Can be targeted at one or more entities.
41 Basically, it's a trigger_once (with restrictions, see notes) that additionally updates the number of secrets found.
42 -------- KEYS --------
43 sounds: 1 to play misc/secret.wav, 2 to play misc/talk.wav, 3 to play misc/trigger1.wav (default: 1)
44 noise: path to sound file, if you want to play something else
45 target: trigger all entities with this targetname when triggered
46 message: print this message to the player who activated the trigger instead of the standard 'You found a secret!'
47 killtarget: remove all entities with this targetname when triggered
48 -------- NOTES --------
49 You should create a common/trigger textured brush covering the entrance to a secret room/area.
50 Trigger secret can only be trigger by a player's touch and can not be a target itself.
51 */
52 void spawnfunc_trigger_secret() {
53         // FIXME: should it be disabled in most modes?
54
55         // update secrets count
56         secrets_total += 1;
57
58         // add default message
59         if (self.message == "")
60                 self.message = "You found a secret!";
61
62         // set default sound
63         if (self.noise == "")
64         if (!self.sounds)
65                 self.sounds = 1; // misc/secret.wav
66
67         // this entity can't be a target itself!!!!
68         self.targetname = "";
69
70         // you can't just shoot a room to find it, can you?
71         self.health = 0;
72
73         // a secret can not be delayed
74         self.delay = 0;
75
76         // convert this trigger to trigger_once
77         self.classname = "trigger_once";
78         spawnfunc_trigger_once();
79
80         // take over the touch() function, so we can mark secret as found
81         self.touch = trigger_secret_touch;
82         // ignore triggering;
83         self.use = func_null;
84 }
85 #endif