Xonotic QuakeC
The free, fast arena FPS with crisp movement and a wide array of weapons
plat.qc
Go to the documentation of this file.
1
#include "
plat.qh
"
2
REGISTER_NET_LINKED
(ENT_CLIENT_PLAT)
3
4
#ifdef SVQC
5
void
plat_link
(
entity
this
);
6
7
void
plat_delayedinit
(
entity
this
)
8
{
9
plat_link
(
this
);
10
// Q3 uses only a truth check of .targetname to decide whether to spawn a trigger
11
if
(!
Q3COMPAT_COMMON
|| this.
targetname
==
""
)
12
plat_spawn_inside_trigger
(
this
);
// the "start moving" trigger
13
}
14
15
float
plat_send
(
entity
this
,
entity
to,
float
sf)
16
{
17
WriteHeader
(
MSG_ENTITY
, ENT_CLIENT_PLAT);
18
WriteByte
(
MSG_ENTITY
, sf);
19
20
if
(sf &
SF_TRIGGER_INIT
)
21
{
22
WriteByte
(
MSG_ENTITY
, this.
platmovetype_start
);
23
WriteByte
(
MSG_ENTITY
, this.
platmovetype_turn
);
24
WriteByte
(
MSG_ENTITY
, this.
platmovetype_end
);
25
WriteByte
(
MSG_ENTITY
, this.
spawnflags
);
26
27
WriteString
(
MSG_ENTITY
, this.
model
);
28
29
trigger_common_write
(
this
,
true
);
30
31
WriteVector(
MSG_ENTITY
, this.
pos1
);
32
WriteVector(
MSG_ENTITY
, this.
pos2
);
33
34
WriteVector(
MSG_ENTITY
, this.
size
);
35
36
WriteAngleVector(
MSG_ENTITY
, this.
mangle
);
37
38
WriteShort
(
MSG_ENTITY
, this.
speed
);
39
WriteShort
(
MSG_ENTITY
, this.
height
);
40
WriteByte
(
MSG_ENTITY
, this.
lip
);
41
WriteByte
(
MSG_ENTITY
, this.
state
);
42
43
WriteShort
(
MSG_ENTITY
, this.
dmg
);
44
}
45
46
if
(sf &
SF_TRIGGER_RESET
)
47
{
48
// used on client
49
}
50
51
return
true
;
52
}
53
54
void
plat_link
(
entity
this
)
55
{
56
//Net_LinkEntity(this, 0, false, plat_send);
57
}
58
59
spawnfunc
(func_plat)
60
{
61
if
(
q3compat
)
62
{
63
this.
spawnflags
= 0;
// Q3 plats have no spawnflags
64
if
(!this.
dmg
) this.
dmg
= 2;
65
}
66
else
if
(this.
spawnflags
&
CRUSH
)
67
{
68
this.
dmg
= 10000;
69
}
70
71
if
(this.
dmg
&& (this.
message
==
""
))
72
{
73
this.
message
=
"was squished"
;
74
}
75
if
(this.
dmg
&& (this.
message2
==
""
))
76
{
77
this.
message2
=
"was squished by"
;
78
}
79
80
if
(this.
sounds
== 1)
81
{
82
this.
noise
=
"plats/plat1.wav"
;
83
this.
noise1
=
"plats/plat2.wav"
;
84
}
85
86
if
(this.
sounds
== 2 ||
q3compat
)
87
{
88
// Plats in Q3 always have sounds (they're hard coded in Q3 engine)
89
this.
noise
=
"plats/medplat1.wav"
;
90
this.
noise1
=
"plats/medplat2.wav"
;
91
}
92
93
// WARNING: backwards compatibility because people don't use already existing fields :(
94
if
(this.
sound1
)
95
this.
noise
= this.
sound1
;
96
if
(this.
sound2
)
97
this.
noise1
= this.
sound2
;
98
99
if
(
q3compat
)
100
{
101
// CPMA adds these fields for overriding the Q3 default sounds
102
string
s =
GetField_fullspawndata
(
this
,
"sound_start"
,
true
);
103
string
e =
GetField_fullspawndata
(
this
,
"sound_end"
,
true
);
104
105
if
(s)
106
this.
noise
=
strzone
(s);
107
else
108
{
109
// PK3s supporting Q3A sometimes include custom sounds at Q3 default paths
110
s =
"sound/movers/plats/pt1_strt.wav"
;
111
if
(
FindFileInMapPack
(s))
112
this.
noise
= s;
113
}
114
115
if
(e)
116
this.
noise1
=
strzone
(e);
117
else
118
{
119
e =
"sound/movers/plats/pt1_end.wav"
;
120
if
(
FindFileInMapPack
(e))
121
this.
noise1
= e;
122
}
123
}
124
125
if
(this.
noise
&& this.
noise
!=
""
)
126
{
127
precache_sound
(this.
noise
);
128
}
129
if
(this.
noise1
&& this.
noise1
!=
""
)
130
{
131
precache_sound
(this.
noise1
);
132
}
133
134
this.
mangle
= this.
angles
;
135
this.
angles
=
'0 0 0'
;
136
137
this.
classname
=
"plat"
;
138
this.draggable =
drag_undraggable
;
139
if
(!
InitMovingBrushTrigger
(
this
))
140
return
;
141
this.
effects
|=
EF_LOWPRECISION
;
142
setsize (
this
, this.
mins
, this.
maxs
);
143
144
setblocked
(
this
,
plat_crush
);
145
146
if
(!this.
speed
) this.
speed
=
q3compat
? 200 : 150;
147
if
(!this.
lip
) this.
lip
=
q3compat
? 8 : 16;
148
if
(!this.
height
) this.
height
= this.
size
.z - this.
lip
;
149
150
this.
pos1
= this.
origin
;
151
this.
pos2
= this.
origin
;
152
this.pos2_z = this.
origin
.z - this.
height
;
153
154
this.reset =
plat_reset
;
155
this.reset(
this
);
156
157
InitializeEntity
(
this
,
plat_delayedinit
,
INITPRIO_FINDTARGET
);
158
}
159
#elif defined(CSQC)
160
void
plat_draw(
entity
this
)
161
{
162
Movetype_Physics_NoMatchServer
(
this
);
163
//Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
164
}
165
166
NET_HANDLE
(ENT_CLIENT_PLAT,
bool
isnew)
167
{
168
float
sf =
ReadByte
();
169
170
if
(sf &
SF_TRIGGER_INIT
)
171
{
172
this.
platmovetype_start
=
ReadByte
();
173
this.
platmovetype_turn
=
ReadByte
();
174
this.
platmovetype_end
=
ReadByte
();
175
this.
spawnflags
=
ReadByte
();
176
177
this.
model
=
strzone
(
ReadString
());
178
_setmodel(
this
, this.
model
);
179
180
trigger_common_read
(
this
,
true
);
181
182
this.
pos1
=
ReadVector
();
183
this.
pos2
=
ReadVector
();
184
185
this.
size
=
ReadVector
();
186
187
this.
mangle
=
ReadAngleVector
();
188
189
this.
speed
= ReadShort();
190
this.
height
= ReadShort();
191
this.
lip
=
ReadByte
();
192
this.
state
=
ReadByte
();
193
194
this.
dmg
= ReadShort();
195
196
this.
classname
=
"plat"
;
197
this.
solid
=
SOLID_BSP
;
198
set_movetype
(
this
,
MOVETYPE_PUSH
);
199
this.
drawmask
=
MASK_NORMAL
;
200
this.draw = plat_draw;
201
if
(isnew)
IL_PUSH
(
g_drawables
,
this
);
202
this.
use
=
plat_use
;
203
this.entremove =
trigger_remove_generic
;
204
205
plat_reset
(
this
);
// also called here
206
207
set_movetype
(
this
,
MOVETYPE_PUSH
);
208
this.
move_time
=
time
;
209
210
if
(!
Q3COMPAT_COMMON
|| this.
targetname
==
""
)
211
plat_spawn_inside_trigger
(
this
);
212
}
213
214
if
(sf &
SF_TRIGGER_RESET
)
215
{
216
plat_reset
(
this
);
217
218
this.
move_time
=
time
;
219
}
220
return
true
;
221
}
222
#endif
height
float height
Definition
bobbing.qc:3
dmg
float dmg
Definition
breakable.qc:12
drag_undraggable
bool drag_undraggable(entity draggee, entity dragger)
Definition
cheats.qc:903
entity
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
ReadString
#define ReadString
Definition
cl_minigames.qc:158
message
string message
Definition
powerups.qc:19
g_drawables
IntrusiveList g_drawables
Definition
main.qh:91
spawnflags
int spawnflags
Definition
ammo.qh:15
Q3COMPAT_COMMON
#define Q3COMPAT_COMMON
Definition
stats.qh:368
INITPRIO_FINDTARGET
const int INITPRIO_FINDTARGET
Definition
constants.qh:96
classname
string classname
Definition
csprogsdefs.qc:111
drawmask
float drawmask
Definition
csprogsdefs.qc:99
MASK_NORMAL
const float MASK_NORMAL
Definition
csprogsdefs.qc:168
mins
vector mins
Definition
csprogsdefs.qc:117
effects
float effects
Definition
csprogsdefs.qc:115
time
float time
Definition
csprogsdefs.qc:16
maxs
vector maxs
Definition
csprogsdefs.qc:117
size
vector size
Definition
csprogsdefs.qc:118
origin
vector origin
Definition
csprogsdefs.qc:105
SOLID_BSP
const float SOLID_BSP
Definition
csprogsdefs.qc:252
use
#define use
Definition
csprogsdefs.qh:50
state
int state
Definition
damageeffects.qc:72
SF_TRIGGER_RESET
const int SF_TRIGGER_RESET
Definition
defs.qh:24
SF_TRIGGER_INIT
const int SF_TRIGGER_INIT
Definition
defs.qh:22
CRUSH
const int CRUSH
Definition
defs.qh:11
EF_LOWPRECISION
float EF_LOWPRECISION
Definition
dpextensions.qc:274
speed
float speed
Definition
dynlight.qc:9
angles
ent angles
Definition
ent_cs.qc:121
model
model
Definition
ent_cs.qc:139
solid
solid
Definition
ent_cs.qc:165
IL_PUSH
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
Definition
intrusivelist.qh:61
NET_HANDLE
#define NET_HANDLE(id, param)
Definition
net.qh:15
MSG_ENTITY
const int MSG_ENTITY
Definition
net.qh:115
ReadVector
#define ReadVector()
Definition
net.qh:367
ReadAngleVector
#define ReadAngleVector()
Definition
net.qh:369
WriteHeader
#define WriteHeader(to, id)
Definition
net.qh:221
REGISTER_NET_LINKED
#define REGISTER_NET_LINKED(id)
Definition
net.qh:55
ReadByte
int ReadByte()
WriteString
void WriteString(string data, float dest, float desto)
WriteShort
void WriteShort(float data, float dest, float desto)
precache_sound
string precache_sound(string sample)
WriteByte
void WriteByte(float data, float dest, float desto)
strzone
string strzone(string s)
set_movetype
void set_movetype(entity this, int mt)
Definition
movetypes.qc:4
Movetype_Physics_NoMatchServer
void Movetype_Physics_NoMatchServer(entity this)
Definition
movetypes.qc:805
MOVETYPE_PUSH
const int MOVETYPE_PUSH
Definition
movetypes.qh:136
move_time
float move_time
Definition
movetypes.qh:77
plat_link
void plat_link(entity this)
Definition
plat.qc:54
plat_send
float plat_send(entity this, entity to, float sf)
Definition
plat.qc:15
plat_delayedinit
void plat_delayedinit(entity this)
Definition
plat.qc:7
plat.qh
plat_use
void plat_use(entity this, entity actor, entity trigger)
Definition
platforms.qc:168
plat_spawn_inside_trigger
void plat_spawn_inside_trigger(entity this)
Definition
platforms.qc:21
plat_crush
void plat_crush(entity this, entity blocker)
Definition
platforms.qc:138
sound1
string sound1
Definition
platforms.qc:186
plat_reset
void plat_reset(entity this)
Definition
platforms.qc:188
sound2
string sound2
Definition
platforms.qc:186
q3compat
q3compat
Definition
quake3.qc:59
setblocked
#define setblocked(e, f)
GetField_fullspawndata
string GetField_fullspawndata(entity e, string fieldname, bool vfspath)
Retrieves the value of a map entity field from fullspawndata.
Definition
main.qc:451
FindFileInMapPack
string FindFileInMapPack(string pattern)
Definition
main.qc:500
spawnfunc
#define spawnfunc(id)
Definition
spawnfunc.qh:96
InitMovingBrushTrigger
bool InitMovingBrushTrigger(entity this)
Definition
subs.qc:577
platmovetype_turn
float platmovetype_turn
Definition
subs.qc:113
noise
string noise
Definition
subs.qh:83
noise1
string noise1
Definition
subs.qh:83
platmovetype_start
float platmovetype_start
Definition
subs.qh:44
pos2
vector pos2
Definition
subs.qh:50
mangle
vector mangle
Definition
subs.qh:51
lip
float lip
Definition
subs.qh:40
sounds
float sounds
Definition
subs.qh:42
platmovetype_end
float platmovetype_end
Definition
subs.qh:44
pos1
vector pos1
Definition
subs.qh:50
trigger_common_write
void trigger_common_write(entity this, bool withtarget)
Definition
triggers.qc:110
trigger_remove_generic
void trigger_remove_generic(entity this)
message2
string message2
Definition
triggers.qh:19
targetname
string targetname
Definition
triggers.qh:56
trigger_common_read
void trigger_common_read(entity this, bool withtarget)
InitializeEntity
void InitializeEntity(entity e, void(entity this) func, int order)
Definition
world.qc:2209
common
mapobjects
func
plat.qc
Generated on
for Xonotic QuakeC by
1.14.0