Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
door_rotating.qc
Go to the documentation of this file.
1#include "door_rotating.qh"
2/*QUAKED spawnfunc_func_door_rotating (0 .5 .8) ? START_OPEN BIDIR DOOR_DONT_LINK BIDIR_IN_DOWN x TOGGLE X_AXIS Y_AXIS
3if two doors touch, they are assumed to be connected and operate as a unit.
4
5TOGGLE causes the door to wait in both the start and end states for a trigger event.
6
7BIDIR makes the door work bidirectional, so that the opening direction is always away from the requestor.
8The usage of bidirectional doors requires two manually instantiated triggers (trigger_multiple), the one to open it in the other direction
9must have set trigger_reverse to 1.
10BIDIR_IN_DOWN will the door prevent from reopening while closing if it is triggered from the other side.
11
12START_OPEN causes the door to move to its destination when spawned, and operate in reverse. It is used to temporarily or permanently close off an area when triggered (not usefull for touch or takedamage doors).
13
14"message" is printed when the door is touched if it is a trigger door and it hasn't been fired yet
15"angle" determines the destination angle for opening. negative values reverse the direction.
16"targetname" if set, no touch field will be spawned and a remote button or trigger field activates the door.
17"health" if set, door must be shot open
18"speed" movement speed (100 default)
19"wait" wait before returning (3 default, -1 = never return)
20"dmg" damage to inflict when blocked (2 default)
21"sounds"
220) no sound
231) stone
242) base
253) stone chain
264) screechy metal
27FIXME: only one sound set available at the time being
28*/
29
30#ifdef GAMEQC
32{
33 if (this.noise1 != "")
35 this.state = STATE_TOP;
36 if (this.spawnflags & DOOR_TOGGLE)
37 return; // don't come down automatically
39 this.nextthink = this.ltime + this.wait;
40}
41
43{
44 if (this.noise1 != "")
46 if (this.lip==666) // this.lip is used to remember reverse opening direction for door_rotating
47 {
48 this.pos2 = '0 0 0' - this.pos2;
49 this.lip = 0;
50 }
51 this.state = STATE_BOTTOM;
52}
53
55{
56 if (this.noise2 != "")
58 if (this.max_health)
59 {
61 SetResourceExplicit(this, RES_HEALTH, this.max_health);
62 }
63
64 this.state = STATE_DOWN;
66}
67
69{
70 if (this.state == STATE_UP)
71 return; // already going up
72
73 if (this.state == STATE_TOP)
74 { // reset top wait time
75 this.nextthink = this.ltime + this.wait;
76 return;
77 }
78 if (this.noise2 != "")
80 this.state = STATE_UP;
82
83 string oldmessage = this.message;
84 this.message = "";
85 SUB_UseTargets(this, NULL, oth); // TODO: is oth needed here?
86 this.message = oldmessage;
87}
88#endif
89
90#ifdef SVQC
92{
93 this.angles = this.pos1;
94 this.avelocity = '0 0 0';
95 this.state = STATE_BOTTOM;
96 setthink(this, func_null);
97 this.nextthink = 0;
98}
99
101{
102 this.angles = this.movedir;
103 this.pos2 = '0 0 0';
104 this.pos1 = this.movedir;
105}
106
107spawnfunc(func_door_rotating)
108{
109 //if (!this.deathtype) // map makers can override this
110 // this.deathtype = " got in the way";
111
112 // I abuse "movedir" for denoting the axis for now
114 this.movedir = '0 0 1';
115 else if (this.spawnflags & DOOR_ROTATING_YAXIS)
116 this.movedir = '1 0 0';
117 else // Z
118 this.movedir = '0 1 0';
119
120 if (this.angles_y==0) this.angles_y = 90;
121
122 this.movedir *= this.angles_y;
123 this.angles = '0 0 0';
124
125 this.avelocity = this.movedir;
126 if (!InitMovingBrushTrigger(this))
127 return;
128 this.velocity = '0 0 0';
129 //this.effects |= EF_LOWPRECISION;
130 this.classname = "door_rotating";
131
133 this.use = door_use;
134 this.active = ACTIVE_ACTIVE;
135
136 this.pos1 = '0 0 0';
137 this.pos2 = this.movedir;
138
139// DOOR_START_OPEN is to allow an entity to be lighted in the closed position
140// but spawn in the open position
141 if (this.spawnflags & DOOR_START_OPEN)
143
144 door_init_shared(this);
145 if (!this.speed)
146 {
147 this.speed = 50;
148 }
149 this.lip = 0; // this.lip is used to remember reverse opening direction for door_rotating
150
151 settouch(this, door_touch);
152
153// LinkDoors can't be done until all of the doors have been spawned, so
154// the sizes can be detected properly.
156
157 this.reset = door_rotating_reset;
158}
159#endif
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
float max_health
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
float ltime
Definition net.qh:10
const int INITPRIO_SETLOCATION
Definition constants.qh:98
const int INITPRIO_LINKDOORS
Definition constants.qh:99
string classname
vector avelocity
vector velocity
float nextthink
#define use
int state
int active
Definition defs.qh:34
const int ACTIVE_ACTIVE
Definition defs.qh:37
void door_use(entity this, entity actor, entity trigger)
Definition door.qc:215
void door_init_shared(entity this)
Definition door.qc:666
void door_blocked(entity this, entity blocker)
Definition door.qc:28
void LinkDoors(entity this)
Definition door.qc:453
void door_touch(entity this, entity toucher)
Definition door.qc:295
const int DOOR_TOGGLE
Definition door.qh:11
const int DOOR_START_OPEN
Definition door.qh:7
void door_rotating_init_startopen(entity this)
void door_rotating_go_up(entity this, entity oth)
void door_rotating_hit_top(entity this)
void door_rotating_reset(entity this)
void door_rotating_hit_bottom(entity this)
void door_rotating_go_down(entity this)
const int DOOR_ROTATING_YAXIS
const int DOOR_ROTATING_XAXIS
float speed
Definition dynlight.qc:9
ent angles
Definition ent_cs.qc:121
angles_y
Definition ent_cs.qc:119
void SUB_UseTargets(entity this, entity actor, entity trigger)
Definition triggers.qc:344
vector movedir
Definition viewloc.qh:18
var void func_null()
#define NULL
Definition post.qh:14
#define setthink(e, f)
#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
#define spawnfunc(id)
Definition spawnfunc.qh:96
bool InitMovingBrushTrigger(entity this)
Definition subs.qc:576
void SUB_CalcAngleMove(entity this, vector destangle, float tspeedtype, float tspeed, void(entity this) func)
Definition subs.qc:346
const int DAMAGE_YES
Definition subs.qh:80
string noise1
Definition subs.qh:83
vector pos2
Definition subs.qh:50
float lip
Definition subs.qh:40
vector pos1
Definition subs.qh:50
string noise2
Definition subs.qh:83
const int TSPEED_LINEAR
Definition subs.qh:71
float takedamage
Definition subs.qh:78
#define STATE_UP
Definition sys-pre.qh:30
#define STATE_DOWN
Definition sys-pre.qh:31
#define STATE_TOP
Definition sys-pre.qh:28
#define STATE_BOTTOM
Definition sys-pre.qh:29
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2230