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