]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/secret.qc
Merge remote-tracking branch 'origin/master' into terencehill/ca_arena_mutators
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / secret.qc
1
2
3 void secrets_setstatus() {
4         self.stat_secrets_total = secrets_total;
5         self.stat_secrets_found = secrets_found;
6 }
7
8 /**
9  * A secret has been found (maybe :P)
10  */
11 void trigger_secret_touch() {
12         // only a player can trigger this
13         if (other.classname != "player")
14                 return;
15         
16         // update secrets found counter
17         secrets_found += 1;
18         //print("Secret found: ", ftos(secret_counter.cnt), "/");
19         //print(ftos(secret_counter.count), "\n");
20
21         // centerprint message (multi_touch() doesn't always call centerprint())
22         centerprint(other, self.message);
23         self.message = "";
24         
25         // handle normal trigger features
26         multi_touch();
27         remove(self);
28 }
29
30 /*QUAKED trigger_secret (.5 .5 .5) ?
31 Variable sized secret trigger. Can be targeted at one or more entities.
32 Basically, it's a trigger_once (with restrictions, see notes) that additionally updates the number of secrets found.
33 -------- KEYS --------
34 sounds: 1 to play misc/secret.wav, 2 to play misc/talk.wav, 3 to play misc/trigger1.wav (default: 1)
35 noise: path to sound file, if you want to play something else
36 target: trigger all entities with this targetname when triggered
37 message: print this message to the player who activated the trigger instead of the standard 'You found a secret!'
38 killtarget: remove all entities with this targetname when triggered
39 -------- NOTES --------
40 You should create a common/trigger textured brush covering the entrance to a secret room/area.
41 Trigger secret can only be trigger by a player's touch and can not be a target itself.
42 */
43 void spawnfunc_trigger_secret() {
44         // FIXME: should it be disabled in most modes?
45         
46         // update secrets count
47         secrets_total += 1;
48         
49         // add default message
50         if (self.message == "")
51                 self.message = "You found a secret!";
52         
53         // set default sound
54         if (self.noise == "")
55         if not(self.sounds)
56                 self.sounds = 1; // misc/secret.wav
57         
58         // this entity can't be a target itself!!!!
59         self.targetname = "";
60         
61         // you can't just shoot a room to find it, can you?
62         self.health = 0;
63         
64         // a secret can not be delayed
65         self.delay = 0;
66         
67         // convert this trigger to trigger_once
68         self.classname = "trigger_once";
69         spawnfunc_trigger_once();
70         
71         // take over the touch() function, so we can mark secret as found
72         self.touch = trigger_secret_touch;
73         // ignore triggering;
74         self.use = func_null;
75 }
76