4 .count - total number of secrets to find
5 .cnt - number of secrets found
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;
15 A secret has been found!
17 void trigger_secret_touch() {
18 // only a player can trigger this
19 if (other.classname != "player")
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");
27 // handle normal trigger features
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.
45 void spawnfunc_trigger_secret() {
46 // FIXME: should it be disabled in most modes?
48 // create secret counter
49 if not(secret_counter)
50 secret_counter_create();
52 // update secrets count
53 secret_counter.count += 1;
55 // add default message
56 if (self.message == "")
57 self.message = "You found a secret!";
62 self.sounds = 1; // misc/secret.wav
64 // this entity can't be a target itself!!!!
67 // you can't just shoot a room to find it, can you?
70 // a secret can not be delayed
73 // convert this trigger to trigger_once
74 self.classname = "trigger_once";
75 spawnfunc_trigger_once();
77 // take over the touch() function, so we can mark secret as found
78 self.touch = trigger_secret_touch;