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"
2REGISTER_NET_LINKED(ENT_CLIENT_PLAT)
3
4#ifdef SVQC
5void plat_link(entity this);
6
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
15float plat_send(entity this, entity to, float sf)
16{
17 WriteHeader(MSG_ENTITY, ENT_CLIENT_PLAT);
19
20 if(sf & SF_TRIGGER_INIT)
21 {
26
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
42
44 }
45
46 if(sf & SF_TRIGGER_RESET)
47 {
48 // used on client
49 }
50
51 return true;
52}
53
54void plat_link(entity this)
55{
56 //Net_LinkEntity(this, 0, false, plat_send);
57}
58
59spawnfunc(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 {
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
158}
159#elif defined(CSQC)
160void plat_draw(entity this)
161{
163 //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
164}
165
166NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
167{
168 float sf = ReadByte();
169
170 if(sf & SF_TRIGGER_INIT)
171 {
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;
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
208 this.move_time = time;
209
210 if (!Q3COMPAT_COMMON || this.targetname == "")
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
float height
Definition bobbing.qc:3
float dmg
Definition breakable.qc:12
bool drag_undraggable(entity draggee, entity dragger)
Definition cheats.qc:903
var entity(vector mins, vector maxs,.entity tofield) findbox_tofield_OrFallback
#define ReadString
string message
Definition powerups.qc:19
IntrusiveList g_drawables
Definition main.qh:91
int spawnflags
Definition ammo.qh:15
#define Q3COMPAT_COMMON
Definition stats.qh:368
const int INITPRIO_FINDTARGET
Definition constants.qh:96
string classname
float drawmask
const float MASK_NORMAL
vector mins
float effects
float time
vector maxs
vector size
vector origin
const float SOLID_BSP
#define use
int state
const int SF_TRIGGER_RESET
Definition defs.qh:24
const int SF_TRIGGER_INIT
Definition defs.qh:22
const int CRUSH
Definition defs.qh:11
float EF_LOWPRECISION
float speed
Definition dynlight.qc:9
ent angles
Definition ent_cs.qc:121
model
Definition ent_cs.qc:139
solid
Definition ent_cs.qc:165
ERASEABLE entity IL_PUSH(IntrusiveList this, entity it)
Push to tail.
#define NET_HANDLE(id, param)
Definition net.qh:15
const int MSG_ENTITY
Definition net.qh:115
#define ReadVector()
Definition net.qh:367
#define ReadAngleVector()
Definition net.qh:369
#define WriteHeader(to, id)
Definition net.qh:221
#define REGISTER_NET_LINKED(id)
Definition net.qh:55
int ReadByte()
void WriteString(string data, float dest, float desto)
void WriteShort(float data, float dest, float desto)
string precache_sound(string sample)
void WriteByte(float data, float dest, float desto)
string strzone(string s)
void set_movetype(entity this, int mt)
Definition movetypes.qc:4
void Movetype_Physics_NoMatchServer(entity this)
Definition movetypes.qc:805
const int MOVETYPE_PUSH
Definition movetypes.qh:136
float move_time
Definition movetypes.qh:77
void plat_link(entity this)
Definition plat.qc:54
float plat_send(entity this, entity to, float sf)
Definition plat.qc:15
void plat_delayedinit(entity this)
Definition plat.qc:7
void plat_use(entity this, entity actor, entity trigger)
Definition platforms.qc:168
void plat_spawn_inside_trigger(entity this)
Definition platforms.qc:21
void plat_crush(entity this, entity blocker)
Definition platforms.qc:138
string sound1
Definition platforms.qc:186
void plat_reset(entity this)
Definition platforms.qc:188
string sound2
Definition platforms.qc:186
q3compat
Definition quake3.qc:59
#define setblocked(e, f)
string GetField_fullspawndata(entity e, string fieldname, bool vfspath)
Retrieves the value of a map entity field from fullspawndata.
Definition main.qc:451
string FindFileInMapPack(string pattern)
Definition main.qc:500
#define spawnfunc(id)
Definition spawnfunc.qh:96
bool InitMovingBrushTrigger(entity this)
Definition subs.qc:577
float platmovetype_turn
Definition subs.qc:113
string noise
Definition subs.qh:83
string noise1
Definition subs.qh:83
float platmovetype_start
Definition subs.qh:44
vector pos2
Definition subs.qh:50
vector mangle
Definition subs.qh:51
float lip
Definition subs.qh:40
float sounds
Definition subs.qh:42
float platmovetype_end
Definition subs.qh:44
vector pos1
Definition subs.qh:50
void trigger_common_write(entity this, bool withtarget)
Definition triggers.qc:110
void trigger_remove_generic(entity this)
string message2
Definition triggers.qh:19
string targetname
Definition triggers.qh:56
void trigger_common_read(entity this, bool withtarget)
void InitializeEntity(entity e, void(entity this) func, int order)
Definition world.qc:2209