5 #include <common/util.qh>
6 #include <common/weapons/_all.qh>
7 #include <common/stats.qh>
13 * A secret has been found (maybe :P)
15 void trigger_secret_touch(entity this, entity toucher)
17 // only a player can trigger this
18 if (!IS_PLAYER(toucher))
21 EXACTTRIGGER_TOUCH(this, toucher);
23 // update secrets found counter
26 // message and noise handled by SUB_UseTargets
27 SUB_UseTargets(this, toucher, toucher);
29 // we can't just delete(this) here, because this is a touch function
30 // called while C code is looping through area links...
31 settouch(this, func_null);
35 void trigger_secret_reset(entity this)
38 settouch(this, trigger_secret_touch);
42 /*QUAKED trigger_secret (.5 .5 .5) ?
43 Variable sized secret trigger. Can be targeted at one or more entities.
44 Basically, it's a trigger_once (with restrictions, see notes) that additionally updates the number of secrets found.
45 -------- KEYS --------
46 sounds: 1 to play misc/secret.wav, 2 to play misc/talk.wav, 3 to play misc/trigger1.wav (default: 1)
47 noise: path to sound file, if you want to play something else
48 target: trigger all entities with this targetname when triggered
49 message: print this message to the player who activated the trigger instead of the standard 'You found a secret!'
50 killtarget: remove all entities with this targetname when triggered
51 -------- NOTES --------
52 You should create a common/trigger textured brush covering the entrance to a secret room/area.
53 Trigger secret can only be trigger by a player's touch and can not be a target itself.
55 spawnfunc(trigger_secret)
57 // FIXME: should it be disabled in most modes?
59 // update secrets count
62 // add default message
63 if (!this.message || this.message == "")
64 this.message = "You found a secret!";
67 if ((!this.noise || this.noise == "") && !this.sounds)
68 this.sounds = 1; // misc/secret.wav
72 case 1: this.noise = "misc/secret.wav"; break;
73 case 2: this.noise = strzone(SND(TALK)); break;
74 case 3: this.noise = "misc/trigger1.wav"; break;
77 if(this.noise && this.noise != "")
78 precache_sound(this.noise);
80 // a secret cannot be delayed
85 settouch(this, trigger_secret_touch);
86 // NOTE: old maps don't expect secrets to reset, so enabling resetting can cause issues!
88 this.reset = trigger_secret_reset;