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 engine sounds
102 string s = GetField_fullspawndata(this, "sound_start", true);
103 string e = GetField_fullspawndata(this, "sound_end", true);
106 this.noise = strzone(s);
108 this.noise1 = strzone(e);
111 if(this.noise && this.noise != "")
113 precache_sound(this.noise);
115 if(this.noise1 && this.noise1 != "")
117 precache_sound(this.noise1);
120 this.mangle = this.angles;
121 this.angles = '0 0 0';
123 this.classname = "plat";
124 this.draggable = drag_undraggable;
125 if (!InitMovingBrushTrigger(this))
127 this.effects |= EF_LOWPRECISION;
128 setsize (this, this.mins , this.maxs);
130 setblocked(this, plat_crush);
132 if (!this.speed) this.speed = q3compat ? 200 : 150;
133 if (!this.lip) this.lip = q3compat ? 8 : 16;
134 if (!this.height) this.height = this.size.z - this.lip;
136 this.pos1 = this.origin;
137 this.pos2 = this.origin;
138 this.pos2_z = this.origin.z - this.height;
140 this.reset = plat_reset;
143 InitializeEntity(this, plat_delayedinit, INITPRIO_FINDTARGET);
146 void plat_draw(entity this)
148 Movetype_Physics_NoMatchServer(this);
149 //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
152 NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
154 float sf = ReadByte();
156 if(sf & SF_TRIGGER_INIT)
158 this.platmovetype_start = ReadByte();
159 this.platmovetype_turn = ReadByte();
160 this.platmovetype_end = ReadByte();
161 this.spawnflags = ReadByte();
163 this.model = strzone(ReadString());
164 _setmodel(this, this.model);
166 trigger_common_read(this, true);
168 this.pos1 = ReadVector();
169 this.pos2 = ReadVector();
171 this.size = ReadVector();
173 this.mangle = ReadAngleVector();
175 this.speed = ReadShort();
176 this.height = ReadShort();
177 this.lip = ReadByte();
178 this.state = ReadByte();
180 this.dmg = ReadShort();
182 this.classname = "plat";
183 this.solid = SOLID_BSP;
184 set_movetype(this, MOVETYPE_PUSH);
185 this.drawmask = MASK_NORMAL;
186 this.draw = plat_draw;
187 if (isnew) IL_PUSH(g_drawables, this);
189 this.entremove = trigger_remove_generic;
191 plat_reset(this); // also called here
193 set_movetype(this, MOVETYPE_PUSH);
194 this.move_time = time;
196 if (!Q3COMPAT_COMMON || this.targetname == "")
197 plat_spawn_inside_trigger(this);
200 if(sf & SF_TRIGGER_RESET)
204 this.move_time = time;