Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
door_secret.qc
Go to the documentation of this file.
1#include "door_secret.qh"
2#ifdef SVQC
3void fd_secret_move1(entity this);
4void fd_secret_move2(entity this);
5void fd_secret_move3(entity this);
6void fd_secret_move4(entity this);
7void fd_secret_move5(entity this);
8void fd_secret_move6(entity this);
9void fd_secret_done(entity this);
10
11void fd_secret_use(entity this, entity actor, entity trigger)
12{
13 if(this.active != ACTIVE_ACTIVE)
14 return;
15
16 SetResourceExplicit(this, RES_HEALTH, 10000);
17 if(!this.bot_attack)
19 this.bot_attack = true;
20
21 // exit if still moving around...
22 if (this.origin != this.oldorigin)
23 return;
24
25 string message_save = this.message;
26 this.message = ""; // no more message
27 SUB_UseTargets(this, actor, trigger); // fire all targets / killtargets
28 this.message = message_save;
29
30 this.velocity = '0 0 0';
31
32 // Make a sound, wait a little...
33
34 if (this.noise1 != "")
36 this.nextthink = this.ltime + 0.1;
37
38 int temp = 1 - (this.spawnflags & DOOR_SECRET_1ST_LEFT); // 1 or -1
39 makevectors(this.mangle);
40
41 if (!this.t_width)
42 {
44 this.t_width = fabs(v_up * this.size);
45 else
46 this.t_width = fabs(v_right * this.size);
47 }
48
49 if (!this.t_length)
50 this.t_length = fabs(v_forward * this.size);
51
53 this.dest1 = this.origin - v_up * this.t_width;
54 else
55 this.dest1 = this.origin + v_right * (this.t_width * temp);
56
57 this.dest2 = this.dest1 + v_forward * this.t_length;
59 if (this.noise2 != "")
61}
62
63void fd_secret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype, .entity weaponentity, vector hitloc, vector force)
64{
65 fd_secret_use(this, NULL, NULL);
66}
67
68// Wait after first movement...
70{
71 this.nextthink = this.ltime + 1.0;
73 if (this.noise3 != "")
75}
76
77// Start moving sideways w/sound...
79{
80 if (this.noise2 != "")
83}
84
85// Wait here until time to go back...
87{
88 if (this.noise3 != "")
90 if (!(this.spawnflags & DOOR_SECRET_OPEN_ONCE) && this.wait >= 0)
91 {
92 this.nextthink = this.ltime + this.wait;
94 }
95}
96
97// Move backward...
99{
100 if (this.noise2 != "")
103}
104
105// Wait 1 second...
107{
108 this.nextthink = this.ltime + 1.0;
110 if (this.noise3 != "")
112}
113
115{
116 if (this.noise2 != "")
119}
120
122{
124 {
125 SetResourceExplicit(this, RES_HEALTH, 10000);
126 this.takedamage = DAMAGE_YES;
127 //this.th_pain = fd_secret_use;
128 }
129 if (this.noise3 != "")
131}
132
134
135void secret_blocked(entity this, entity blocker)
136{
137 if (time < this.door_finished)
138 return;
139 this.door_finished = time + 0.5;
140 //T_Damage (other, this, this, this.dmg, this.dmg, this.deathtype, DT_IMPACT, (this.absmin + this.absmax) * 0.5, '0 0 0', Obituary_Generic);
141}
142
143/*
144==============
145secret_touch
146
147Prints messages
148================
149*/
151{
152 if (!toucher.iscreature)
153 return;
154 if (this.door_finished > time)
155 return;
156 if (this.active != ACTIVE_ACTIVE)
157 return;
158
159 this.door_finished = time + 2;
160
161 if (this.message)
162 {
163 if (IS_CLIENT(toucher))
165 play2(toucher, this.noise);
166 }
167}
168
170{
172 {
173 SetResourceExplicit(this, RES_HEALTH, 10000);
174 this.takedamage = DAMAGE_YES;
175 }
176 setorigin(this, this.oldorigin);
177 setthink(this, func_null);
178 this.nextthink = 0;
179 this.active = ACTIVE_ACTIVE;
180}
181
182/*QUAKED spawnfunc_func_door_secret (0 .5 .8) ? open_once 1st_left 1st_down no_shoot always_shoot
183Basic secret door. Slides back, then to the side. Angle determines direction.
184wait = # of seconds before coming back
1851st_left = 1st move is left of arrow
1861st_down = 1st move is down from arrow
187always_shoot = even if targeted, keep shootable
188t_width = override WIDTH to move back (or height if going down)
189t_length = override LENGTH to move sideways
190"dmg" damage to inflict when blocked (2 default)
191
192If a secret door has a targetname, it will only be opened by it's botton or trigger, not by damage.
193"sounds"
1941) medieval
1952) metal
1963) base
197*/
198
199spawnfunc(func_door_secret)
200{
201 /*if (!this.deathtype) // map makers can override this
202 this.deathtype = " got in the way";*/
203
204 if (!this.dmg)
205 {
206 this.dmg = 2;
207 }
208
209 // Magic formula...
210 this.mangle = this.angles;
211 this.angles = '0 0 0';
212 this.classname = "door";
213 if (!InitMovingBrushTrigger(this)) return;
214 this.effects |= EF_LOWPRECISION;
215
216 // TODO: other soundpacks
217 if (this.sounds > 0)
218 {
219 this.noise1 = "plats/medplat1.wav";
220 this.noise2 = "plats/medplat1.wav";
221 this.noise3 = "plats/medplat2.wav";
222 }
223
224 // sound on touch
225 if (this.noise == "")
226 {
227 this.noise = "misc/talk.wav";
228 }
229 precache_sound(this.noise);
230 // sound while moving backwards
231 if (this.noise1 && this.noise1 != "")
232 {
234 }
235 // sound while moving sideways
236 if (this.noise2 && this.noise2 != "")
237 {
239 }
240 // sound when door stops moving
241 if (this.noise3 && this.noise3 != "")
242 {
244 }
245
246 settouch(this, secret_touch);
248 this.speed = 50;
249 this.use = fd_secret_use;
250 this.active = ACTIVE_ACTIVE;
251 if(!this.targetname || this.targetname == "")
253
255 {
256 //this.canteamdamage = true; // TODO
257 SetResourceExplicit(this, RES_HEALTH, 10000);
258 this.takedamage = DAMAGE_YES;
259 this.event_damage = fd_secret_damage;
260 }
261 this.oldorigin = this.origin;
262 if (!this.wait) this.wait = 5; // seconds before closing
263
264 this.reset = secret_reset;
265 this.reset(this);
266}
267#endif
float bot_attack
Definition api.qh:38
IntrusiveList g_bot_targets
Definition api.qh:149
float dmg
Definition breakable.qc:12
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
string message
Definition powerups.qc:19
float wait
Definition items.qc:17
int spawnflags
Definition ammo.qh:15
#define IS_CLIENT(s)
Definition player.qh:242
vector v_up
string classname
vector velocity
float effects
float time
vector v_right
vector size
float nextthink
vector v_forward
vector origin
vector oldorigin
#define use
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
float door_finished
Definition door.qc:286
void fd_secret_use(entity this, entity actor, entity trigger)
void fd_secret_done(entity this)
void fd_secret_move1(entity this)
void fd_secret_move4(entity this)
void fd_secret_move5(entity this)
void fd_secret_damage(entity this, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
void secret_reset(entity this)
void secret_touch(entity this, entity toucher)
void fd_secret_move6(entity this)
void fd_secret_move2(entity this)
void secret_blocked(entity this, entity blocker)
void fd_secret_move3(entity this)
const int DOOR_SECRET_1ST_DOWN
Definition door_secret.qh:6
const int DOOR_SECRET_YES_SHOOT
Definition door_secret.qh:8
const int DOOR_SECRET_OPEN_ONCE
Definition door_secret.qh:4
const int DOOR_SECRET_1ST_LEFT
Definition door_secret.qh:5
float EF_LOWPRECISION
float speed
Definition dynlight.qc:9
ent angles
Definition ent_cs.qc:121
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
string precache_sound(string sample)
void centerprint(string text,...)
float fabs(float f)
float ltime
Definition net.qc:10
var void func_null()
#define NULL
Definition post.qh:14
#define makevectors
Definition post.qh:21
#define setthink(e, f)
vector
Definition self.qh:92
entity entity toucher
Definition self.qh:72
#define settouch(e, f)
Definition self.qh:73
#define setblocked(e, f)
const int CH_TRIGGER_SINGLE
Definition sound.qh:13
const float VOL_BASE
Definition sound.qh:36
#define _sound(e, c, s, v, a)
Definition sound.qh:43
const float ATTEN_NORM
Definition sound.qh:30
void play2(entity e, string filename)
Definition all.qc:116
#define spawnfunc(id)
Definition spawnfunc.qh:96
bool InitMovingBrushTrigger(entity this)
Definition subs.qc:577
void SUB_CalcMove(entity this, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
Definition subs.qc:267
string noise
Definition subs.qh:83
const int DAMAGE_YES
Definition subs.qh:80
string noise1
Definition subs.qh:83
vector mangle
Definition subs.qh:51
float sounds
Definition subs.qh:42
vector dest1
Definition subs.qh:66
float t_width
Definition subs.qh:33
string noise3
Definition subs.qh:83
vector dest2
Definition subs.qh:66
float t_length
Definition subs.qh:33
string noise2
Definition subs.qh:83
const int TSPEED_LINEAR
Definition subs.qh:71
float takedamage
Definition subs.qh:78
string targetname
Definition triggers.qh:56