Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
platforms.qc File Reference
#include "platforms.qh"
Include dependency graph for platforms.qc:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void generic_plat_blocked (entity this, entity blocker)
void plat_center_touch (entity this, entity toucher)
void plat_crush (entity this, entity blocker)
void plat_go_down (entity this)
void plat_go_up (entity this)
void plat_hit_bottom (entity this)
void plat_hit_top (entity this)
void plat_outside_touch (entity this, entity toucher)
void plat_reset (entity this)
void plat_spawn_inside_trigger (entity this)
void plat_target_use (entity this, entity actor, entity trigger)
void plat_trigger_use (entity this, entity actor, entity trigger)
void plat_use (entity this, entity actor, entity trigger)
bool set_platmovetype (entity e, string s)

Variables

float platmovetype_end_default
float platmovetype_start_default
string sound1
string sound2

Function Documentation

◆ generic_plat_blocked()

void generic_plat_blocked ( entity this,
entity blocker )

Definition at line 3 of file platforms.qc.

4{
5#ifdef SVQC
6 if(this.dmg && blocker.takedamage != DAMAGE_NO)
7 {
8 if(this.dmgtime2 < time)
9 {
10 Damage (blocker, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
11 this.dmgtime2 = time + this.dmgtime;
12 }
13
14 // Gib dead/dying stuff
15 if(IS_DEAD(blocker))
16 Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
17 }
18#endif
19}
float dmg
Definition breakable.qc:12
#define IS_DEAD(s)
Definition player.qh:245
float time
void Damage(entity targ, entity inflictor, entity attacker, float damage, int deathtype,.entity weaponentity, vector hitloc, vector force)
Definition damage.qc:503
#define DMG_NOWEP
Definition damage.qh:104
float dmgtime
Definition platforms.qh:7
float dmgtime2
Definition platforms.qh:8
const int DAMAGE_NO
Definition subs.qh:79

References Damage(), DAMAGE_NO, dmg, DMG_NOWEP, dmgtime, dmgtime2, entity(), IS_DEAD, and time.

Referenced by spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), spawnfunc(), and spawnfunc().

◆ plat_center_touch()

void plat_center_touch ( entity this,
entity toucher )

Definition at line 90 of file platforms.qc.

91{
92#ifdef SVQC
93 if (!toucher.iscreature)
94 return;
95
96 if (GetResource(toucher, RES_HEALTH) <= 0)
97 return;
98#elif defined(CSQC)
99 if (!IS_PLAYER(toucher))
100 return;
101 if(IS_DEAD(toucher))
102 return;
103#endif
104
105 if (this.enemy.state == STATE_BOTTOM) {
106 plat_go_up(this.enemy);
107 } else if (this.enemy.state == STATE_TOP)
108 this.enemy.nextthink = this.enemy.ltime + 1;
109}
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
#define IS_PLAYER(s)
Definition player.qh:243
void plat_go_up(entity this)
Definition platforms.qc:83
entity entity toucher
Definition self.qh:72
entity enemy
Definition sv_ctf.qh:153
#define STATE_TOP
Definition sys-pre.qh:28
#define STATE_BOTTOM
Definition sys-pre.qh:29

References enemy, entity(), GetResource(), IS_DEAD, IS_PLAYER, plat_go_up(), STATE_BOTTOM, STATE_TOP, and toucher.

Referenced by plat_spawn_inside_trigger().

◆ plat_crush()

void plat_crush ( entity this,
entity blocker )

Definition at line 138 of file platforms.qc.

139{
140 if((this.spawnflags & CRUSH) && (blocker.takedamage != DAMAGE_NO))
141 { // KIll Kill Kill!!
142#ifdef SVQC
143 Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
144#endif
145 }
146 else
147 {
148#ifdef SVQC
149 if((this.dmg) && (blocker.takedamage != DAMAGE_NO))
150 { // Shall we bite?
151 Damage (blocker, this, this, this.dmg, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
152 // Gib dead/dying stuff
153 if(IS_DEAD(blocker))
154 Damage (blocker, this, this, 10000, DEATH_HURTTRIGGER.m_id, DMG_NOWEP, blocker.origin, '0 0 0');
155 }
156#endif
157
158 if (this.state == STATE_UP)
159 plat_go_down (this);
160 else if (this.state == STATE_DOWN)
161 plat_go_up (this);
162 // when in other states, then the plat_crush event came delayed after
163 // plat state already had changed
164 // this isn't a bug per se!
165 }
166}
int spawnflags
Definition ammo.qh:15
int state
const int CRUSH
Definition defs.qh:11
void plat_go_down(entity this)
Definition platforms.qc:76
#define STATE_UP
Definition sys-pre.qh:30
#define STATE_DOWN
Definition sys-pre.qh:31

References CRUSH, Damage(), DAMAGE_NO, dmg, DMG_NOWEP, entity(), IS_DEAD, plat_go_down(), plat_go_up(), spawnflags, state, STATE_DOWN, and STATE_UP.

Referenced by spawnfunc().

◆ plat_go_down()

void plat_go_down ( entity this)

Definition at line 76 of file platforms.qc.

77{
79 this.state = STATE_DOWN;
81}
float speed
Definition dynlight.qc:9
void plat_hit_bottom(entity this)
Definition platforms.qc:70
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 SUB_CalcMove(entity this, vector tdest, float tspeedtype, float tspeed, void(entity this) func)
Definition subs.qc:267
string noise
Definition subs.qh:83
vector pos2
Definition subs.qh:50
const int TSPEED_LINEAR
Definition subs.qh:71

References _sound, ATTEN_NORM, CH_TRIGGER_SINGLE, entity(), noise, plat_hit_bottom(), pos2, speed, state, STATE_DOWN, SUB_CalcMove(), TSPEED_LINEAR, and VOL_BASE.

Referenced by plat_crush(), plat_hit_top(), plat_outside_touch(), plat_trigger_use(), and plat_use().

◆ plat_go_up()

void plat_go_up ( entity this)

Definition at line 83 of file platforms.qc.

84{
86 this.state = STATE_UP;
88}
void plat_hit_top(entity this)
Definition platforms.qc:61
vector pos1
Definition subs.qh:50

References _sound, ATTEN_NORM, CH_TRIGGER_SINGLE, entity(), noise, plat_hit_top(), pos1, speed, state, STATE_UP, SUB_CalcMove(), TSPEED_LINEAR, and VOL_BASE.

Referenced by plat_center_touch(), plat_crush(), and plat_target_use().

◆ plat_hit_bottom()

void plat_hit_bottom ( entity this)

Definition at line 70 of file platforms.qc.

71{
73 this.state = STATE_BOTTOM;
74}
string noise1
Definition subs.qh:83

References _sound, ATTEN_NORM, CH_TRIGGER_SINGLE, entity(), noise1, state, STATE_BOTTOM, and VOL_BASE.

Referenced by plat_go_down().

◆ plat_hit_top()

void plat_hit_top ( entity this)

Definition at line 61 of file platforms.qc.

62{
64 this.state = STATE_TOP;
65
67 this.nextthink = this.ltime + 3;
68}
float nextthink
float ltime
Definition net.qc:10
#define setthink(e, f)

References _sound, ATTEN_NORM, CH_TRIGGER_SINGLE, entity(), ltime, nextthink, noise1, plat_go_down(), setthink, state, STATE_TOP, and VOL_BASE.

Referenced by plat_go_up().

◆ plat_outside_touch()

void plat_outside_touch ( entity this,
entity toucher )

Definition at line 111 of file platforms.qc.

112{
113#ifdef SVQC
114 if (!toucher.iscreature)
115 return;
116
117 if (GetResource(toucher, RES_HEALTH) <= 0)
118 return;
119#elif defined(CSQC)
120 if (!IS_PLAYER(toucher))
121 return;
122#endif
123
124 if (this.enemy.state == STATE_TOP) {
125 entity e = this.enemy;
126 plat_go_down(e);
127 }
128}
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback

References enemy, entity(), GetResource(), IS_PLAYER, plat_go_down(), STATE_TOP, and toucher.

◆ plat_reset()

void plat_reset ( entity this)

Definition at line 188 of file platforms.qc.

189{
190 if (this.targetname && this.targetname != "" && !Q3COMPAT_COMMON)
191 {
192 setorigin(this, this.pos1);
193 this.state = STATE_UP;
194 this.use = plat_use;
195 }
196 else
197 {
198 setorigin(this, this.pos2);
199 this.state = STATE_BOTTOM;
201 }
202
203#ifdef SVQC
205#endif
206}
#define Q3COMPAT_COMMON
Definition stats.qh:368
#define use
const int SF_TRIGGER_RESET
Definition defs.qh:24
int SendFlags
Definition net.qh:118
void plat_use(entity this, entity actor, entity trigger)
Definition platforms.qc:168
void plat_target_use(entity this, entity actor, entity trigger)
Definition platforms.qc:176
void plat_trigger_use(entity this, entity actor, entity trigger)
Definition platforms.qc:130
string targetname
Definition triggers.qh:56

References entity(), plat_target_use(), plat_trigger_use(), plat_use(), pos1, pos2, Q3COMPAT_COMMON, SendFlags, SF_TRIGGER_RESET, state, STATE_BOTTOM, STATE_UP, targetname, and use.

Referenced by spawnfunc().

◆ plat_spawn_inside_trigger()

void plat_spawn_inside_trigger ( entity this)

Definition at line 21 of file platforms.qc.

22{
23 vector tmin, tmax;
24
25 entity trigger = spawn();
28 trigger.solid = SOLID_TRIGGER;
29 trigger.enemy = this;
30
31 tmin = this.absmin + '25 25 0';
32 tmax = this.absmax - '25 25 -8';
33 tmin_z = tmax_z - (this.pos1_z - this.pos2_z + 8);
35 tmax_z = tmin_z + 8;
36
37 if (this.size_x <= 50)
38 {
39 tmin_x = (this.mins_x + this.maxs_x) / 2;
40 tmax_x = tmin_x + 1;
41 }
42 if (this.size_y <= 50)
43 {
44 tmin_y = (this.mins_y + this.maxs_y) / 2;
45 tmax_y = tmin_y + 1;
46 }
47
48 if(tmin_x < tmax_x)
49 if(tmin_y < tmax_y)
50 if(tmin_z < tmax_z)
51 {
52 setsize (trigger, tmin, tmax);
53 return;
54 }
55
56 // otherwise, something is fishy...
57 delete(trigger);
58 objerror(this, "plat_spawn_inside_trigger: platform has odd size or lip, can't spawn");
59}
const float SOLID_TRIGGER
vector absmax
vector absmin
#define spawn
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
const int MOVETYPE_NONE
Definition movetypes.qh:129
void plat_center_touch(entity this, entity toucher)
Definition platforms.qc:90
const int PLAT_LOW_TRIGGER
Definition platforms.qh:4
#define objerror
Definition pre.qh:8
vector
Definition self.qh:92
#define settouch(e, f)
Definition self.qh:73

References absmax, absmin, entity(), MOVETYPE_NONE, objerror, plat_center_touch(), PLAT_LOW_TRIGGER, set_movetype(), settouch, SOLID_TRIGGER, spawn, spawnflags, and vector.

Referenced by plat_delayedinit().

◆ plat_target_use()

void plat_target_use ( entity this,
entity actor,
entity trigger )

Definition at line 176 of file platforms.qc.

177{
178 if (this.state == STATE_TOP)
179 this.nextthink = this.ltime + 1;
180 else if (this.state != STATE_UP)
181 plat_go_up(this);
182}

References entity(), ltime, nextthink, plat_go_up(), state, STATE_TOP, and STATE_UP.

Referenced by plat_reset().

◆ plat_trigger_use()

void plat_trigger_use ( entity this,
entity actor,
entity trigger )

Definition at line 130 of file platforms.qc.

131{
132 if (getthink(this))
133 return; // already activated
134 plat_go_down(this);
135}
#define getthink(e)

References entity(), getthink, and plat_go_down().

Referenced by plat_reset().

◆ plat_use()

void plat_use ( entity this,
entity actor,
entity trigger )

Definition at line 168 of file platforms.qc.

169{
170 this.use = func_null;
171 if (this.state != STATE_UP)
172 objerror (this, "plat_use: not in up state");
173 plat_go_down(this);
174}
var void func_null()

References entity(), func_null(), objerror, plat_go_down(), state, STATE_UP, and use.

Referenced by plat_reset().

◆ set_platmovetype()

bool set_platmovetype ( entity e,
string s )

Definition at line 209 of file platforms.qc.

210{
211 // sets platmovetype_start and platmovetype_end based on a string consisting of two values
212
213 int n = tokenize_console(s);
214 if(n > 0)
215 e.platmovetype_start = stof(argv(0));
216 else
217 e.platmovetype_start = 0;
218
219 if(n > 1)
220 e.platmovetype_end = stof(argv(1));
221 else
222 e.platmovetype_end = e.platmovetype_start;
223
224 if(n > 2)
225 if(argv(2) == "force")
226 return true; // no checking, return immediately
227
228 if(!cubic_speedfunc_is_sane(e.platmovetype_start, e.platmovetype_end))
229 {
230 objerror(e, "Invalid platform move type; platform would go in reverse, which is not allowed.");
231 return false;
232 }
233
234 return true;
235}
#define tokenize_console
ERASEABLE bool cubic_speedfunc_is_sane(float startspeedfactor, float endspeedfactor)
Definition math.qh:135
float stof(string val,...)
string argv(float n)

References argv(), cubic_speedfunc_is_sane(), entity(), objerror, stof(), and tokenize_console.

Referenced by spawnfunc(), and spawnfunc().

Variable Documentation

◆ platmovetype_end_default

float platmovetype_end_default

Definition at line 208 of file platforms.qc.

Referenced by spawnfunc(), and train_next().

◆ platmovetype_start_default

float platmovetype_start_default

Definition at line 208 of file platforms.qc.

Referenced by spawnfunc(), and train_next().

◆ sound1

string sound1

Definition at line 186 of file platforms.qc.

Referenced by spawnfunc().

◆ sound2

string sound2

Definition at line 186 of file platforms.qc.

Referenced by spawnfunc().