5 #include <common/util.qh>
6 #include <server/defs.qh>
12 * A secret has been found (maybe :P)
14 void trigger_secret_touch(entity this, entity toucher)
16 // only a player can trigger this
17 if (!IS_PLAYER(toucher))
20 EXACTTRIGGER_TOUCH(this, toucher);
22 // update secrets found counter
25 // message and noise handled by SUB_UseTargets
26 SUB_UseTargets(this, toucher, toucher);
28 // we can't just delete(this) here, because this is a touch function
29 // called while C code is looping through area links...
30 settouch(this, func_null);
34 void trigger_secret_reset(entity this)
37 settouch(this, trigger_secret_touch);
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.
54 spawnfunc(trigger_secret)
56 // FIXME: should it be disabled in most modes?
58 // update secrets count
61 // add default message
62 if (!this.message || this.message == "")
63 this.message = "You found a secret!";
66 if ((!this.noise || this.noise == "") && !this.sounds)
67 this.sounds = 1; // misc/secret.wav
71 case 1: this.noise = "misc/secret.wav"; break;
72 case 2: this.noise = strzone(SND(TALK)); break;
73 case 3: this.noise = "misc/trigger1.wav"; break;
76 if(this.noise && this.noise != "")
77 precache_sound(this.noise);
79 // a secret cannot be delayed
84 settouch(this, trigger_secret_touch);
85 // NOTE: old maps don't expect secrets to reset, so enabling resetting can cause issues!
87 this.reset = trigger_secret_reset;