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 and such). Handeld per vehicle type.
9 float VSF_ANIMINFO = 64; /// Animation info
11 float VSF_FULL_UPDATE = 16777215; /// Send everything
14 #define VSF_FARDISTANCE 2000
15 float send_vehile(entity to, float sf)
18 var void WriteFunc(float, float);
20 dist = vlen(self.origin - to.origin);
21 if(dist > VSF_FARDISTANCE && to != self.owner)
24 // Always send a movement and origin to owner
26 sf |= VSF_ORIGIN | VSF_MOVEMENT;
28 WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE);
30 // We need to know client-side what was sent
31 WriteByte(MSG_ENTITY, sf);
35 WriteByte(MSG_ENTITY, self.hud); //vehicle type = hud
36 WriteByte(MSG_ENTITY, self.team);
37 WriteShort(MSG_ENTITY, self.colormap);
42 WriteFunc = ((sf & VSF_FAR) ? WriteShort : WriteCoord);
43 WriteFunc(MSG_ENTITY, self.origin_x);
44 WriteFunc(MSG_ENTITY, self.origin_y);
45 WriteFunc(MSG_ENTITY, self.origin_z);
50 WriteFunc = ((sf & VSF_FAR) ? WriteShort : WriteCoord);
51 WriteCoord(MSG_ENTITY, self.velocity_x);
52 WriteCoord(MSG_ENTITY, self.velocity_y);
53 WriteCoord(MSG_ENTITY, self.velocity_z);
55 WriteFunc = ((sf & VSF_FAR) ? WriteShort : WriteAngle);
56 WriteAngle(MSG_ENTITY, self.angles_x);
57 WriteAngle(MSG_ENTITY, self.angles_y);
58 WriteAngle(MSG_ENTITY, self.angles_z);
63 WriteFunc = ((sf & VSF_FAR) ? WriteShort : WriteCoord);
64 WriteCoord(MSG_ENTITY, self.avelocity_x);
65 WriteCoord(MSG_ENTITY, self.avelocity_y);
66 WriteCoord(MSG_ENTITY, self.avelocity_z);
73 WriteByte(MSG_ENTITY, 1);
74 WriteByte(MSG_ENTITY, self.vehicle_shield);
75 WriteByte(MSG_ENTITY, self.vehicle_energy);
77 WriteByte(MSG_ENTITY, self.vehicle_ammo1);
78 WriteByte(MSG_ENTITY, self.vehicle_reload1);
80 WriteByte(MSG_ENTITY, self.vehicle_ammo2);
81 WriteByte(MSG_ENTITY, self.vehicle_reload2);
85 WriteByte(MSG_ENTITY, 0);
87 WriteByte(MSG_ENTITY, self.vehicle_health);
91 self.vehile_send_exta(to, sf);
96 void net_link_vehile()
98 self.SendFlags = 0xFFFFFF;
99 Net_LinkEntity(self, FALSE, 0, send_vehile);
104 void Net_ReadVehicle(float bIsNew)
107 var float ReadFunc();
111 /*setmodel(self, "models/vehicles/wakizashi.dpm");
112 self.move_movetype = MOVETYPE_BOUNCE;
113 self.entremove = VehicleRacerRemove;
114 setsize(self, '-60 -60 -20', '60 60 20');
115 self.draw = VehicleRacerDraw;
122 self.vehicle_hud = ReadByte();
123 self.team = ReadByte();
124 self.colormap = ReadShort();
126 switch(self.vehicle_hud)
143 ReadFunc = ((sf & VSF_FAR) ? ReadShort : ReadCoord);
144 self.origin_x = ReadCoord();
145 self.origin_y = ReadCoord();
146 self.origin_z = ReadCoord();
147 self.move_origin = self.origin;
150 if(sf & VSF_MOVEMENT)
152 ReadFunc = ((sf & VSF_FAR) ? ReadShort : ReadCoord);
153 self.velocity_x = ReadFunc();
154 self.velocity_y = ReadFunc();
155 self.velocity_z = ReadFunc();
157 ReadFunc = ((sf & VSF_FAR) ? ReadShort : ReadAngle);
158 self.angles_x = ReadFunc();
159 self.angles_y = ReadFunc();
160 self.angles_z = ReadFunc();
162 self.move_velocity = self.velocity;
163 self.move_angles = self.angles;
168 ReadFunc = ((sf & VSF_FAR) ? ReadShort : ReadCoord);
169 self.avelocity_x = ReadFunc();
170 self.avelocity_y = ReadFunc();
171 self.avelocity_z = ReadFunc();
175 self.vehile_read_exta(sf);
181 #endif // VEHICLES_CSQC