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