3 float VSF_SETUP = 1; /// Send vehicle type etc
4 float VSF_ORIGIN = 2; /// Send location
5 float VSF_MOVEMENT = 4; /// Send movement update (and angles)
6 float VSF_AVEL = 8; /// Send Angular velocity
7 float VSF_STATS = 16; /// Send ammo, health etc
8 float VSF_EXTRA = 32; /// Send additional data (turret rotations etc). Handeld per vehicle type.
9 float VSF_ANIMINFO = 64; /// Animation info
10 float VSF_FULL_UPDATE = 16777215; /// Send everything
18 #define VSX_FARDISTANCE 2000
19 float send_vehile(entity to, float sf)
23 var void WriteFunc(float, float);
25 dist = vlen(self.origin - to.origin);
28 else if(dist > VSX_FARDISTANCE)
31 // Always send a movement and origin to owner
33 sf |= VSF_ORIGIN | VSF_MOVEMENT;
35 WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE);
37 // We need to know client-side what was sent
38 WriteByte(MSG_ENTITY, sf);
39 WriteByte(MSG_ENTITY, xf);
43 WriteByte(MSG_ENTITY, self.hud); //vehicle type = hud
44 WriteByte(MSG_ENTITY, self.team);
45 WriteShort(MSG_ENTITY, self.colormap);
46 WriteShort(MSG_ENTITY, self.vehicle_flags);
51 WriteFunc = ((xf & VSX_FAR) ? WriteShort : WriteCoord);
52 WriteFunc(MSG_ENTITY, self.origin_x);
53 WriteFunc(MSG_ENTITY, self.origin_y);
54 WriteFunc(MSG_ENTITY, self.origin_z);
59 WriteFunc = ((xf & VSX_FAR) ? WriteShort : WriteCoord);
60 WriteFunc(MSG_ENTITY, self.velocity_x);
61 WriteFunc(MSG_ENTITY, self.velocity_y);
62 WriteFunc(MSG_ENTITY, self.velocity_z);
64 WriteFunc = ((xf & VSX_FAR) ? WriteShort : WriteAngle);
65 WriteFunc(MSG_ENTITY, self.angles_x);
66 WriteFunc(MSG_ENTITY, self.angles_y);
67 WriteFunc(MSG_ENTITY, self.angles_z);
72 WriteFunc = ((xf & VSX_FAR) ? WriteShort : WriteCoord);
73 WriteFunc(MSG_ENTITY, self.avelocity_x);
74 WriteFunc(MSG_ENTITY, self.avelocity_y);
75 WriteFunc(MSG_ENTITY, self.avelocity_z);
80 WriteByte(MSG_ENTITY, self.vehicle_health);
83 WriteByte(MSG_ENTITY, self.vehicle_shield);
84 WriteByte(MSG_ENTITY, self.vehicle_energy);
86 WriteByte(MSG_ENTITY, self.vehicle_ammo1);
87 WriteByte(MSG_ENTITY, self.vehicle_reload1);
89 WriteByte(MSG_ENTITY, self.vehicle_ammo2);
90 WriteByte(MSG_ENTITY, self.vehicle_reload2);
96 self.vehile_send_exta(to, sf);
101 void net_link_vehile()
103 self.SendFlags = 0xFFFFFF;
104 Net_LinkEntity(self, FALSE, 0, send_vehile);
109 void vehicle_spiderbot_assemble()
114 void vehicle_raptor_assemble()
119 void vehicle_bumblebee_assemble()
125 void read_vehicle(float bIsNew)
128 var float ReadFunc();
138 self.vehicle_hud = ReadByte();
139 self.team = ReadByte();
140 self.colormap = ReadShort();
141 self.vehicle_flags = ReadShort();
143 switch(self.vehicle_hud)
146 vehicle_racer_assemble();
149 vehicle_spiderbot_assemble();
152 vehicle_raptor_assemble();
155 vehicle_bumblebee_assemble();
162 if(self.vehicle_hud == HUD_WAKIZASHI && xf & VSX_OWNER)
165 vehicle_hudmodel.owner = self;
169 // dprint("Client vehicle faaar set\n");
173 ReadFunc = ((xf & VSX_FAR) ? ReadShort : ReadCoord);
174 self.origin_x = ReadFunc();
175 self.origin_y = ReadFunc();
176 self.origin_z = ReadFunc();
178 setorigin(self, self.origin);
179 //self.lastupdate = time;
182 if(sf & VSF_MOVEMENT)
184 ReadFunc = ((xf & VSX_FAR) ? ReadShort : ReadCoord);
185 self.velocity_x = ReadFunc();
186 self.velocity_y = ReadFunc();
187 self.velocity_z = ReadFunc();
189 ReadFunc = ((sf & VSX_FAR) ? ReadShort : ReadAngle);
190 self.angles_x = ReadFunc();
191 self.angles_y = ReadFunc();
192 self.angles_z = ReadFunc();
194 //self.lastupdate = time;
195 // self.move_velocity = self.velocity;
196 // self.move_angles = self.angles;
201 ReadFunc = ((xf & VSX_FAR) ? ReadShort : ReadCoord);
202 self.avelocity_x = ReadFunc();
203 self.avelocity_y = ReadFunc();
204 self.avelocity_z = ReadFunc();
206 // self.move_avelocity = self.avelocity;
211 self.vehicle_health = ReadByte();
214 self.vehicle_shield = ReadByte();
215 self.vehicle_energy = ReadByte();
216 self.vehicle_ammo1 = ReadByte();
217 self.vehicle_reload1 = ReadByte();
218 self.vehicle_ammo2 = ReadByte();
219 self.vehicle_reload2 = ReadByte();
224 self.vehile_read_exta(sf);
232 void read_vehicle(float bIsNew)
237 #endif // VEHICLES_CSQC