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";
81 this.noise = "plats/medplat1.wav";
82 this.noise1 = "plats/medplat2.wav";
85 // WARNING: backwards compatibility because people don't use already existing fields :(
87 this.noise = this.sound1;
89 this.noise1 = this.sound2;
91 if(this.noise && this.noise != "")
93 precache_sound(this.noise);
95 if(this.noise1 && this.noise1 != "")
97 precache_sound(this.noise1);
100 this.mangle = this.angles;
101 this.angles = '0 0 0';
103 this.classname = "plat";
104 this.draggable = drag_undraggable;
105 if (!InitMovingBrushTrigger(this))
107 this.effects |= EF_LOWPRECISION;
108 setsize (this, this.mins , this.maxs);
110 setblocked(this, plat_crush);
112 if (!this.speed) this.speed = 150;
113 if (!this.lip) this.lip = 16;
114 if (!this.height) this.height = this.size.z - this.lip;
116 this.pos1 = this.origin;
117 this.pos2 = this.origin;
118 this.pos2_z = this.origin.z - this.height;
120 this.reset = plat_reset;
123 InitializeEntity(this, plat_delayedinit, INITPRIO_FINDTARGET);
126 void plat_draw(entity this)
128 Movetype_Physics_NoMatchServer(this);
129 //Movetype_Physics_MatchServer(autocvar_cl_projectiles_sloppy);
132 NET_HANDLE(ENT_CLIENT_PLAT, bool isnew)
134 float sf = ReadByte();
136 if(sf & SF_TRIGGER_INIT)
138 this.platmovetype_start = ReadByte();
139 this.platmovetype_turn = ReadByte();
140 this.platmovetype_end = ReadByte();
141 this.spawnflags = ReadByte();
143 this.model = strzone(ReadString());
144 _setmodel(this, this.model);
146 trigger_common_read(this, true);
148 this.pos1 = ReadVector();
149 this.pos2 = ReadVector();
151 this.size = ReadVector();
153 this.mangle = ReadAngleVector();
155 this.speed = ReadShort();
156 this.height = ReadShort();
157 this.lip = ReadByte();
158 this.state = ReadByte();
160 this.dmg = ReadShort();
162 this.classname = "plat";
163 this.solid = SOLID_BSP;
164 set_movetype(this, MOVETYPE_PUSH);
165 this.drawmask = MASK_NORMAL;
166 this.draw = plat_draw;
167 if (isnew) IL_PUSH(g_drawables, this);
169 this.entremove = trigger_remove_generic;
171 plat_reset(this); // also called here
173 set_movetype(this, MOVETYPE_PUSH);
174 this.move_time = time;
176 plat_spawn_inside_trigger(this);
179 if(sf & SF_TRIGGER_RESET)
183 this.move_time = time;