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