]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/mapobjects/trigger/secret.qc
Merge branch 't0uYK8Ne/set_slick_friction' into 'master'
[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 void secrets_setstatus(entity this)
12 {
13         // TODO: use global stats!
14         STAT(SECRETS_TOTAL, this) = secrets_total;
15         STAT(SECRETS_FOUND, this) = secrets_found;
16 }
17
18 /**
19  * A secret has been found (maybe :P)
20  */
21 void trigger_secret_touch(entity this, entity toucher)
22 {
23         // only a player can trigger this
24         if (!IS_PLAYER(toucher))
25                 return;
26
27         // update secrets found counter
28         secrets_found += 1;
29         //print("Secret found: ", ftos(secret_counter.cnt), "/");
30         //print(ftos(secret_counter.count), "\n");
31
32         // centerprint message (multi_touch() doesn't always call centerprint())
33         centerprint(toucher, this.message);
34         this.message = "";
35
36         // handle normal trigger features
37         multi_touch(this, toucher);
38         // we can't just delete(this) here, because this is a touch function
39         // called while C code is looping through area links...
40         //delete(this);
41 }
42
43 /*QUAKED trigger_secret (.5 .5 .5) ?
44 Variable sized secret trigger. Can be targeted at one or more entities.
45 Basically, it's a trigger_once (with restrictions, see notes) that additionally updates the number of secrets found.
46 -------- KEYS --------
47 sounds: 1 to play misc/secret.wav, 2 to play misc/talk.wav, 3 to play misc/trigger1.wav (default: 1)
48 noise: path to sound file, if you want to play something else
49 target: trigger all entities with this targetname when triggered
50 message: print this message to the player who activated the trigger instead of the standard 'You found a secret!'
51 killtarget: remove all entities with this targetname when triggered
52 -------- NOTES --------
53 You should create a common/trigger textured brush covering the entrance to a secret room/area.
54 Trigger secret can only be trigger by a player's touch and can not be a target itself.
55 */
56 spawnfunc(trigger_secret)
57 {
58         // FIXME: should it be disabled in most modes?
59
60         // update secrets count
61         secrets_total += 1;
62
63         // add default message
64         if (this.message == "")
65                 this.message = "You found a secret!";
66
67         // set default sound
68         if (this.noise == "")
69         if (!this.sounds)
70                 this.sounds = 1; // misc/secret.wav
71
72         // this entity can't be a target itself!!!!
73         this.targetname = "";
74
75         // you can't just shoot a room to find it, can you?
76         SetResourceExplicit(this, RES_HEALTH, 0);
77
78         // a secret can not be delayed
79         this.delay = 0;
80
81         // convert this trigger to trigger_once
82         //this.classname = "trigger_once";
83         spawnfunc_trigger_once(this);
84
85         // take over the touch() function, so we can mark secret as found
86         settouch(this, trigger_secret_touch);
87         // ignore triggering;
88         this.use = func_null;
89 }
90 #endif