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