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 WriteAngle(MSG_ENTITY, this.mangle_x);
35 WriteAngle(MSG_ENTITY, this.mangle_y);
36 WriteAngle(MSG_ENTITY, this.mangle_z);
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);
61 if (this.spawnflags & CRUSH)
66 if (this.dmg && (this.message == ""))
68 this.message = "was squished";
70 if (this.dmg && (this.message2 == ""))
72 this.message2 = "was squished by";
77 this.noise = "plats/plat1.wav";
78 this.noise1 = "plats/plat2.wav";
83 this.noise = "plats/medplat1.wav";
84 this.noise1 = "plats/medplat2.wav";
87 // WARNING: backwards compatibility because people don't use already existing fields :(
89 this.noise = this.sound1;
91 this.noise1 = this.sound2;
93 if(this.noise && this.noise != "")
95 precache_sound(this.noise);
97 if(this.noise1 && this.noise1 != "")
99 precache_sound(this.noise1);
102 this.mangle = this.angles;
103 this.angles = '0 0 0';
105 this.classname = "plat";
106 this.draggable = drag_undraggable;
107 if (!InitMovingBrushTrigger(this))
109 this.effects |= EF_LOWPRECISION;
110 setsize (this, this.mins , this.maxs);
112 setblocked(this, plat_crush);
114 if (!this.speed) this.speed = 150;
115 if (!this.lip) this.lip = 16;
116 if (!this.height) this.height = this.size.z - this.lip;
118 this.pos1 = this.origin;
119 this.pos2 = this.origin;
120 this.pos2_z = this.origin.z - this.height;
122 this.reset = plat_reset;
125 InitializeEntity(this, plat_delayedinit, INITPRIO_FINDTARGET);
128 void plat_draw(entity this)
130 Movetype_Physics_NoMatchServer(this);
131 //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
134 NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
136 float sf = ReadByte();
138 if(sf & SF_TRIGGER_INIT)
140 this.platmovetype_start = ReadByte();
141 this.platmovetype_turn = ReadByte();
142 this.platmovetype_end = ReadByte();
143 this.spawnflags = ReadByte();
145 this.model = strzone(ReadString());
146 _setmodel(this, this.model);
148 trigger_common_read(this, true);
150 this.pos1 = ReadVector();
151 this.pos2 = ReadVector();
153 this.size = ReadVector();
155 this.mangle_x = ReadAngle();
156 this.mangle_y = ReadAngle();
157 this.mangle_z = ReadAngle();
159 this.speed = ReadShort();
160 this.height = ReadShort();
161 this.lip = ReadByte();
162 this.state = ReadByte();
164 this.dmg = ReadShort();
166 this.classname = "plat";
167 this.solid = SOLID_BSP;
168 set_movetype(this, MOVETYPE_PUSH);
169 this.drawmask = MASK_NORMAL;
170 this.draw = plat_draw;
171 if (isnew) IL_PUSH(g_drawables, this);
173 this.entremove = trigger_remove_generic;
175 plat_reset(this); // also called here
177 set_movetype(this, MOVETYPE_PUSH);
178 this.move_time = time;
180 plat_spawn_inside_trigger(this);
183 if(sf & SF_TRIGGER_RESET)
187 this.move_time = time;