]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mapobjects/trigger/secret.qc
Some more cleanup to map objects, allow trigger_delay and trigger_counter to be deact...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mapobjects / trigger / secret.qc
1 #include "secret.qh"
2 #if defined(CSQC)
3 #elif defined(MENUQC)
4 #elif defined(SVQC)
5     #include <common/util.qh>
6     #include <server/defs.qh>
7 #endif
8
9 #ifdef SVQC
10
11 /**
12  * A secret has been found (maybe :P)
13  */
14 void trigger_secret_touch(entity this, entity toucher)
15 {
16         // only a player can trigger this
17         if (!IS_PLAYER(toucher))
18                 return;
19
20         EXACTTRIGGER_TOUCH(this, toucher);
21
22         // update secrets found counter
23         secrets_found += 1;
24
25         // message and noise handled by SUB_UseTargets
26         SUB_UseTargets(this, toucher, toucher);
27
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);
31 }
32
33 #if 0
34 void trigger_secret_reset(entity this)
35 {
36         secrets_found = 0;
37         settouch(this, trigger_secret_touch);
38 }
39 #endif
40
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.
53 */
54 spawnfunc(trigger_secret)
55 {
56         // FIXME: should it be disabled in most modes?
57
58         // update secrets count
59         secrets_total += 1;
60
61         // add default message
62         if (!this.message || this.message == "")
63                 this.message = "You found a secret!";
64
65         // set default sound
66         if ((!this.noise || this.noise == "") && !this.sounds)
67                 this.sounds = 1; // misc/secret.wav
68
69         switch(this.sounds)
70         {
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;
74         }
75
76         if(this.noise && this.noise != "")
77                 precache_sound(this.noise);
78
79         // a secret cannot be delayed
80         this.delay = 0;
81
82         EXACTTRIGGER_INIT;
83
84         settouch(this, trigger_secret_touch);
85 // NOTE: old maps don't expect secrets to reset, so enabling resetting can cause issues!
86 #if 0
87         this.reset = trigger_secret_reset;
88 #endif
89 }
90 #endif