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