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