2 REGISTER_NET_LINKED(ENT_CLIENT_PLAT)
5 void plat_link(entity this);
7 void plat_delayedinit(entity this)
10 plat_spawn_inside_trigger(this); // the "start moving" trigger
13 float plat_send(entity this, entity to, float sf)
15 WriteHeader(MSG_ENTITY, ENT_CLIENT_PLAT);
16 WriteByte(MSG_ENTITY, sf);
18 if(sf & SF_TRIGGER_INIT)
20 WriteByte(MSG_ENTITY, this.platmovetype_start);
21 WriteByte(MSG_ENTITY, this.platmovetype_turn);
22 WriteByte(MSG_ENTITY, this.platmovetype_end);
23 WriteByte(MSG_ENTITY, this.spawnflags);
25 WriteString(MSG_ENTITY, this.model);
27 trigger_common_write(this, true);
29 WriteVector(MSG_ENTITY, this.pos1);
30 WriteVector(MSG_ENTITY, this.pos2);
32 WriteVector(MSG_ENTITY, this.size);
34 WriteAngleVector(MSG_ENTITY, this.mangle);
36 WriteShort(MSG_ENTITY, this.speed);
37 WriteShort(MSG_ENTITY, this.height);
38 WriteByte(MSG_ENTITY, this.lip);
39 WriteByte(MSG_ENTITY, this.state);
41 WriteShort(MSG_ENTITY, this.dmg);
44 if(sf & SF_TRIGGER_RESET)
52 void plat_link(entity this)
54 //Net_LinkEntity(this, 0, false, plat_send);
59 if (this.spawnflags & CRUSH)
64 if (this.dmg && (this.message == ""))
66 this.message = _("was squished");
68 if (this.dmg && (this.message2 == ""))
70 this.message2 = _("was squished by");
75 this.noise = "plats/plat1.wav";
76 this.noise1 = "plats/plat2.wav";
79 if (this.sounds == 2 || q3compat)
81 // Plats in Q3 always have sounds (they're hard coded in Q3 engine)
82 this.noise = "plats/medplat1.wav";
83 this.noise1 = "plats/medplat2.wav";
86 // WARNING: backwards compatibility because people don't use already existing fields :(
88 this.noise = this.sound1;
90 this.noise1 = this.sound2;
94 // CPMA adds these fields for overriding the engine sounds
95 string s = GetField_fullspawndata(this, "sound_start", true);
96 string e = GetField_fullspawndata(this, "sound_end", true);
99 this.noise = strzone(s);
101 this.noise1 = strzone(e);
104 if(this.noise && this.noise != "")
106 precache_sound(this.noise);
108 if(this.noise1 && this.noise1 != "")
110 precache_sound(this.noise1);
113 this.mangle = this.angles;
114 this.angles = '0 0 0';
116 this.classname = "plat";
117 this.draggable = drag_undraggable;
118 if (!InitMovingBrushTrigger(this))
120 this.effects |= EF_LOWPRECISION;
121 setsize (this, this.mins , this.maxs);
123 setblocked(this, plat_crush);
125 if (!this.speed) this.speed = 150;
126 if (!this.lip) this.lip = 16;
127 if (!this.height) this.height = this.size.z - this.lip;
129 this.pos1 = this.origin;
130 this.pos2 = this.origin;
131 this.pos2_z = this.origin.z - this.height;
133 this.reset = plat_reset;
136 InitializeEntity(this, plat_delayedinit, INITPRIO_FINDTARGET);
139 void plat_draw(entity this)
141 Movetype_Physics_NoMatchServer(this);
142 //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
145 NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
147 float sf = ReadByte();
149 if(sf & SF_TRIGGER_INIT)
151 this.platmovetype_start = ReadByte();
152 this.platmovetype_turn = ReadByte();
153 this.platmovetype_end = ReadByte();
154 this.spawnflags = ReadByte();
156 this.model = strzone(ReadString());
157 _setmodel(this, this.model);
159 trigger_common_read(this, true);
161 this.pos1 = ReadVector();
162 this.pos2 = ReadVector();
164 this.size = ReadVector();
166 this.mangle = ReadAngleVector();
168 this.speed = ReadShort();
169 this.height = ReadShort();
170 this.lip = ReadByte();
171 this.state = ReadByte();
173 this.dmg = ReadShort();
175 this.classname = "plat";
176 this.solid = SOLID_BSP;
177 set_movetype(this, MOVETYPE_PUSH);
178 this.drawmask = MASK_NORMAL;
179 this.draw = plat_draw;
180 if (isnew) IL_PUSH(g_drawables, this);
182 this.entremove = trigger_remove_generic;
184 plat_reset(this); // also called here
186 set_movetype(this, MOVETYPE_PUSH);
187 this.move_time = time;
189 plat_spawn_inside_trigger(this);
192 if(sf & SF_TRIGGER_RESET)
196 this.move_time = time;