2 REGISTER_NET_LINKED(ENT_CLIENT_PLAT)
5 void plat_link(entity this);
7 void plat_delayedinit(entity 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
15 float plat_send(entity this, entity to, float sf)
17 WriteHeader(MSG_ENTITY, ENT_CLIENT_PLAT);
18 WriteByte(MSG_ENTITY, sf);
20 if(sf & SF_TRIGGER_INIT)
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);
27 WriteString(MSG_ENTITY, this.model);
29 trigger_common_write(this, true);
31 WriteVector(MSG_ENTITY, this.pos1);
32 WriteVector(MSG_ENTITY, this.pos2);
34 WriteVector(MSG_ENTITY, this.size);
36 WriteAngleVector(MSG_ENTITY, this.mangle);
38 WriteShort(MSG_ENTITY, this.speed);
39 WriteShort(MSG_ENTITY, this.height);
40 WriteByte(MSG_ENTITY, this.lip);
41 WriteByte(MSG_ENTITY, this.state);
43 WriteShort(MSG_ENTITY, this.dmg);
46 if(sf & SF_TRIGGER_RESET)
54 void plat_link(entity this)
56 //Net_LinkEntity(this, 0, false, plat_send);
63 this.spawnflags = 0; // Q3 plats have no spawnflags
64 if (!this.dmg) this.dmg = 2;
66 else if (this.spawnflags & CRUSH)
71 if (this.dmg && (this.message == ""))
73 this.message = "was squished";
75 if (this.dmg && (this.message2 == ""))
77 this.message2 = "was squished by";
82 this.noise = "plats/plat1.wav";
83 this.noise1 = "plats/plat2.wav";
86 if (this.sounds == 2 || q3compat)
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";
93 // WARNING: backwards compatibility because people don't use already existing fields :(
95 this.noise = this.sound1;
97 this.noise1 = this.sound2;
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);
106 this.noise = strzone(s);
109 // PK3s supporting Q3A sometimes include custom sounds at Q3 default paths
110 s = "sound/movers/plats/pt1_strt.wav";
111 if (FindFileInMapPack(s))
116 this.noise1 = strzone(e);
119 e = "sound/movers/plats/pt1_end.wav";
120 if (FindFileInMapPack(e))
125 if(this.noise && this.noise != "")
127 precache_sound(this.noise);
129 if(this.noise1 && this.noise1 != "")
131 precache_sound(this.noise1);
134 this.mangle = this.angles;
135 this.angles = '0 0 0';
137 this.classname = "plat";
138 this.draggable = drag_undraggable;
139 if (!InitMovingBrushTrigger(this))
141 this.effects |= EF_LOWPRECISION;
142 setsize (this, this.mins , this.maxs);
144 setblocked(this, plat_crush);
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;
150 this.pos1 = this.origin;
151 this.pos2 = this.origin;
152 this.pos2_z = this.origin.z - this.height;
154 this.reset = plat_reset;
157 InitializeEntity(this, plat_delayedinit, INITPRIO_FINDTARGET);
160 void plat_draw(entity this)
162 Movetype_Physics_NoMatchServer(this);
163 //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
166 NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
168 float sf = ReadByte();
170 if(sf & SF_TRIGGER_INIT)
172 this.platmovetype_start = ReadByte();
173 this.platmovetype_turn = ReadByte();
174 this.platmovetype_end = ReadByte();
175 this.spawnflags = ReadByte();
177 this.model = strzone(ReadString());
178 _setmodel(this, this.model);
180 trigger_common_read(this, true);
182 this.pos1 = ReadVector();
183 this.pos2 = ReadVector();
185 this.size = ReadVector();
187 this.mangle = ReadAngleVector();
189 this.speed = ReadShort();
190 this.height = ReadShort();
191 this.lip = ReadByte();
192 this.state = ReadByte();
194 this.dmg = ReadShort();
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);
203 this.entremove = trigger_remove_generic;
205 plat_reset(this); // also called here
207 set_movetype(this, MOVETYPE_PUSH);
208 this.move_time = time;
210 if(!Q3COMPAT_COMMON || this.targetname == "")
211 plat_spawn_inside_trigger(this);
214 if(sf & SF_TRIGGER_RESET)
218 this.move_time = time;