4 .count - total number of secrets to find
5 .cnt - number of secrets found
7 void secret_counter_create() {
8 print("^1secret_counter_create()\n");
9 secret_counter = spawn();
10 secret_counter.classname = "secret_counter";
11 secret_counter.count = 0;
12 secret_counter.cnt = 0;
16 A secret has been found!
18 void trigger_secret_touch() {
19 // only a player can trigger this
20 if (other.classname != "player")
23 // update secrets found counter
24 secret_counter.cnt += 1;
25 print("Secret found: ", ftos(secret_counter.cnt), "/");
26 print(ftos(secret_counter.count), " - ");
27 print("self=", self.classname, ", other=", other.classname, "\n");
29 // handle normal trigger features
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.
47 void spawnfunc_trigger_secret() {
48 // FIXME: should it be disabled in most modes?
50 // create secret counter
51 if not(secret_counter)
52 secret_counter_create();
54 // update secrets count
55 secret_counter.count += 1;
57 // add default message
58 if (self.message == "")
59 self.message = "You found a secret!";
64 self.sounds = 1; // misc/secret.wav
66 // this entity can't be a target itself!!!!
69 // you can't just shoot a room to find it, can you?
72 // a secret can not be delayed
75 // convert this trigger to trigger_once
76 self.classname = "trigger_once";
77 spawnfunc_trigger_once();
79 // take over the touch() function, so we can mark secret as found
80 self.touch = trigger_secret_touch;