Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
secret.qc
Go to the documentation of this file.
1#include "secret.qh"
2#if defined(CSQC)
3#elif defined(MENUQC)
4#elif defined(SVQC)
5 #include <common/util.qh>
7 #include <common/stats.qh>
8#endif
9
10#ifdef SVQC
11
16{
17 // only a player can trigger this
18 if (!IS_PLAYER(toucher))
19 return;
20
22
23 // update secrets found counter
24 secrets_found += 1;
25
26 // message and noise handled by SUB_UseTargets
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
35void trigger_secret_reset(entity this)
36{
37 secrets_found = 0;
39}
40#endif
41
42/*QUAKED trigger_secret (.5 .5 .5) ?
43Variable sized secret trigger. Can be targeted at one or more entities.
44Basically, it's a trigger_once (with restrictions, see notes) that additionally updates the number of secrets found.
45-------- KEYS --------
46sounds: 1 to play misc/secret.wav, 2 to play misc/talk.wav, 3 to play misc/trigger1.wav (default: 1)
47noise: path to sound file, if you want to play something else
48target: trigger all entities with this targetname when triggered
49message: print this message to the player who activated the trigger instead of the standard 'You found a secret!'
50killtarget: remove all entities with this targetname when triggered
51-------- NOTES --------
52You should create a common/trigger textured brush covering the entrance to a secret room/area.
53Trigger secret can only be trigger by a player's touch and can not be a target itself.
54*/
55spawnfunc(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 != "")
79
80 // a secret cannot be delayed
81 this.delay = 0;
82
84
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
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
string message
Definition powerups.qc:19
float delay
Definition items.qc:17
#define IS_PLAYER(s)
Definition player.qh:243
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
#define EXACTTRIGGER_TOUCH(e, t)
Definition common.qh:115
#define EXACTTRIGGER_INIT
Definition common.qh:116
string precache_sound(string sample)
string strzone(string s)
var void func_null()
void trigger_secret_touch(entity this, entity toucher)
A secret has been found (maybe :P)
Definition secret.qc:15
int secrets_total
Definition secret.qh:5
int secrets_found
Definition secret.qh:8
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
#define SND(id)
Definition all.qh:35
#define spawnfunc(id)
Definition spawnfunc.qh:96
string noise
Definition subs.qh:83
float sounds
Definition subs.qh:42