void vehicles_setreturn();
-#define MAX_AXH 4
+/** AuxiliaryXhair*
+ Send addictional points of interest to be drawn, to vehicle owner
+**/
+float MAX_AXH = 4;
.entity AuxiliaryXhair[MAX_AXH];
float SendAuxiliaryXhair(entity to, float sf)
}
*/
+// End AuxiliaryXhair
void CSQCVehicleSetup(entity own, float vehicle_id)
{
WriteByte(MSG_ONE, vehicle_id);
}
+/** vehicles_locktarget
+
+ Generic target locking.
+
+ Figure out if what target is "locked" (if any), for missile tracking as such.
+
+ after calling, "if(self.lock_target != world && self.lock_strength == 1)" mean
+ you have a locked in target.
+
+ Exspects a crosshair_trace() or equivalent to be
+ dont before calling.
+
+**/
.entity lock_target;
.float lock_strength;
.float lock_time;
if(trace_fraction != 1) \
acm += normalize(self.origin - trace_endpos) * (vlen(vel) * mult)
+// Hover movement support
float force_fromtag_power;
float force_fromtag_normpower;
vector force_fromtag_origin;
return v_forward * force_fromtag_power;
}
+// Experimental hovermode wich uses attraction/repulstion from surface unsted of gravity/repulsion
+// Can possibly be use to move abt any surface (inclusing walls/celings)
vector vehicles_force_fromtag_maglev(string tag_name, float spring_length, float max_power)
{
v_forward = normalize(v_forward) * -1;
traceline(force_fromtag_origin, force_fromtag_origin - (v_forward * spring_length), MOVE_NORMAL, self);
+ // TODO - this may NOT be compatible with wall/celing movement, unhardcode 0.25 (engine count multiplier)
if(trace_fraction == 1.0)
{
force_fromtag_normpower = -0.25;
return v_forward * force_fromtag_power;
}
+// Generic vehile projectile system
void vehicles_projectile_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
{
self.health -= damage;
return proj;
}
+// End generic vehile projectile system
+/** vehicles_spawn
+ Exetuted for all vehiles on (re)spawn.
+ Sets defaults for newly spawned units.
+**/
void vehicles_spawn()
{
dprint("Spawning vehicle: ", self.netname, "\n");
self.effects = _effects;
}
-//#define VEHICLES_CSQC
-#ifdef VEHICLES_CSQC
-#define VSF_ORG 2
-#define VSF_VEL 4
-#define VSF_ANG 8
-#define VSF_COLORMAP 16
-#define VSF_STAT1 32
-
-float SendVehicle(entity to, float sf)
-{
- WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE_RACER);
-
- WriteByte(MSG_ENTITY, self.cnt);
-
- WriteCoord(MSG_ENTITY, self.origin_x);
- WriteCoord(MSG_ENTITY, self.origin_y);
- WriteCoord(MSG_ENTITY, self.origin_z);
-
- WriteCoord(MSG_ENTITY, self.velocity_x);
- WriteCoord(MSG_ENTITY, self.velocity_y);
- WriteCoord(MSG_ENTITY, self.velocity_z);
-
- WriteAngle(MSG_ENTITY, self.angles_x);
- WriteAngle(MSG_ENTITY, self.angles_y);
- WriteAngle(MSG_ENTITY, self.angles_z);
-
- return TRUE;
-}
-
-void NetLinkVehicle()
-{
- self.SendFlags = 0xFFFFFF;
- Net_LinkEntity(self, FALSE, 0, SendVehicle);
-}
-#endif
-
float vehicle_initialize(string net_name,
string bodymodel,
string topmodel,
self.vehicle_spawn = self.vehicle_exit;
self.AuxiliaryXhair = self.AuxiliaryXhair;
}
+
+#ifdef VEHICLES_CSQC
+// SendFlags
+float VSF_SETUP = 2; /// Send vehicle type etc
+float VSF_ORIGIN = 4; /// Send location
+float VSF_MOVEMENT = 8; /// Send movement update (and angle/avelocity)
+float VSF_STATS = 16; /// Send ammo, health etc
+float VSF_EXTRA = 32; /// Send additional data (turret rotations and such) handeld per vehicle type.
+float VSF_FULL_UPDATE = 16777215 /// Send everything
+
+
+#ifdef SVQC
+float send_vehile(entity to, float sf)
+{
+ WriteByte(MSG_ENTITY, ENT_CLIENT_VEHICLE);
+
+ WriteByte(MSG_ENTITY, sf);
+
+ if(sf & VSF_SETUP)
+ {
+ WriteByte(MSG_ENTITY, self.hud); //vehicle type = hud
+ WriteByte(MSG_ENTITY, self.team);
+ WriteShort(MSG_ENTITY, self.colormap);
+ }
+
+ if(sf & VSF_ORIGIN)
+ {
+ WriteCoord(MSG_ENTITY, self.origin_x);
+ WriteCoord(MSG_ENTITY, self.origin_y);
+ WriteCoord(MSG_ENTITY, self.origin_z);
+ }
+
+ if(sf & VSF_MOVEMENT)
+ {
+ WriteCoord(MSG_ENTITY, self.velocity_x);
+ WriteCoord(MSG_ENTITY, self.velocity_y);
+ WriteCoord(MSG_ENTITY, self.velocity_z);
+
+ WriteAngle(MSG_ENTITY, self.angles_x);
+ WriteAngle(MSG_ENTITY, self.angles_y);
+ WriteAngle(MSG_ENTITY, self.angles_z);
+
+ WriteCoord(MSG_ENTITY, self.avelocity_x);
+ WriteCoord(MSG_ENTITY, self.avelocity_y);
+ WriteCoord(MSG_ENTITY, self.avelocity_z);
+ }
+
+ if(sf & VSF_STATS)
+ {
+ WriteShort(MSG_ENTITY, self.vehicle_health);
+ WriteShort(MSG_ENTITY, self.vehicle_shield);
+ WriteShort(MSG_ENTITY, self.vehicle_energy);
+ WriteShort(MSG_ENTITY, self.vehicle_ammo1);
+ WriteShort(MSG_ENTITY, self.vehicle_reload1);
+ WriteShort(MSG_ENTITY, self.vehicle_ammo2);
+ WriteShort(MSG_ENTITY, self.vehicle_reload2);
+ }
+
+ if(sf & VSF_EXTRA)
+ {
+ self.vehile_send_exta(to);
+ }
+
+ return TRUE;
+}
+
+void net_link_vehile()
+{
+ self.SendFlags = 0xFFFFFF;
+ Net_LinkEntity(self, FALSE, 0, send_vehile);
+}
+#endif // SVQC
+
+#ifdef CSQC
+void Net_ReadVehicle(float bIsNew)
+{
+ float sf;
+
+ sf = ReadByte();
+
+ if(sf & VSF_SETUP)
+ {
+ float vhtype;
+ vhtype = ReadByte();
+
+ }
+
+ if(bIsNew)
+ {
+ setmodel(self, "models/vehicles/wakizashi.dpm");
+ self.move_movetype = MOVETYPE_BOUNCE;
+ self.entremove = VehicleRacerRemove;
+ setsize(self, '-60 -60 -20', '60 60 20');
+ self.draw = VehicleRacerDraw;
+ self.scale = 0.5;
+ }
+
+ self.cnt = ReadByte();
+
+ self.origin_x = ReadCoord();
+ self.origin_y = ReadCoord();
+ self.origin_z = ReadCoord();
+
+ self.velocity_x = ReadCoord();
+ self.velocity_y = ReadCoord();
+ self.velocity_z = ReadCoord();
+
+ self.angles_x = ReadAngle();
+ self.angles_y = ReadAngle();
+ self.angles_z = ReadAngle();
+
+ self.move_origin = self.origin;
+ self.move_velocity = self.velocity;
+ self.move_angles = self.angles;
+}
+#endif // CSQC
+
+#endif // VEHICLES_CSQC
+// #define VEHICLES_CSQC
+// #define VEHICLES_USE_ODE
#define VEHICLES_ENABLED
#ifdef VEHICLES_ENABLED
//#define VEHICLES_VIEWROTATE_CROSSHAIR
-
#message "with tZork vehicles (experimental)"
-float SVC_SETVIEWPORT = 5; // Net.Protocol 0x05
-float SVC_SETVIEWANGLES = 10; // Net.Protocol 0x0A
-float SVC_UPDATEENTITY = 128; // Net.Protocol 0x80
-
.float vehicle_flags;
-#define VHF_ISVEHICLE 2
-#define VHF_HASSHIELD 4
-#define VHF_SHIELDREGEN 8
-#define VHF_HEALTHREGEN 16
-#define VHF_ENERGYREGEN 32
-#define VHF_DEATHEJECT 64
-#define VHF_MOVE_GROUND 128
-#define VHF_MOVE_HOVER 256
-#define VHF_MOVE_FLY 512
+float VHF_ISVEHICLE = 2; /// Indicates vehicle
+float VHF_HASSHIELD = 4; /// Vehicle has shileding
+float VHF_SHIELDREGEN = 8; /// Vehicles shield regenerates
+float VHF_HEALTHREGEN = 16; /// Vehicles health regenerates
+float VHF_ENERGYREGEN = 32; /// Vehicles energy regenerates
+float VHF_DEATHEJECT = 64; /// Vehicle ejects pilot upon fatal damage
+float VHF_MOVE_GROUND = 128; /// Vehicle moves on gound
+float VHF_MOVE_HOVER = 256; /// Vehicle hover close to gound
+float VHF_MOVE_FLY = 512; /// Vehicle is airborn
.float hud;
.entity gun1;
.entity gun2;
-.entity vehicle_shieldent;
-
-.float vehicle_health;
-.float vehicle_shield;
-.float vehicle_energy;
+.float vehicle_health; /// If self is player this is 0..1 indicating precentage of health left on vehicle. If self is vehile, this is the real health value.
+.float vehicle_energy; /// If self is player this is 0..1 indicating precentage of energy left on vehicle. If self is vehile, this is the real energy value.
+.float vehicle_shield; /// If self is player this is 0..1 indicating precentage of shield left on vehicle. If self is vehile, this is the real shield value.
+.entity vehicle_shieldent; /// Entity to disply the shild effect on damage
-.float vehicle_ammo1;
-.float vehicle_reload1;
-
-.float vehicle_ammo2;
-.float vehicle_reload2;
+.float vehicle_ammo1; /// If self is player this field's use depends on the individual vehile. If self is vehile, this is the real ammo1 value.
+.float vehicle_reload1; /// If self is player this field's use depends on the individual vehile. If self is vehile, this is the real reload1 value.
+.float vehicle_ammo2; /// If self is player this field's use depends on the individual vehile. If self is vehile, this is the real ammo2 value.
+.float vehicle_reload2; /// If self is player this field's use depends on the individual vehile. If self is vehile, this is the real reload2 value.
.entity vehicle;
.entity vehicle_viewport;
.entity vehicle_hudmodel;
+#ifdef SVQC
.float dmg_time;
-
.float vehicle_respawntime;
.void() vehicle_spawn;
var .void(float exit_flags) vehicle_exit;
-#define VHEF_NORMAL 0
-#define VHEF_EJECT 1
-#define VHEF_RELESE 2
+float VHEF_NORMAL = 0; /// User pressed exit key
+float VHEF_EJECT = 1; /// User pressed exit key 3 times fast (not implemented) or vehile is dying
+float VHEF_RELESE = 2; /// Release ownership, client possibly allready dissconnected / went spec / changed team / used "kill" (not implemented)
+
+float SVC_SETVIEWPORT = 5; // Net.Protocol 0x05
+float SVC_SETVIEWANGLES = 10; // Net.Protocol 0x0A
+float SVC_UPDATEENTITY = 128; // Net.Protocol 0x80
-var .void() vehicle_enter;
-var .void() vehicle_die;
-var .void() vehicle_spawn;
+var .void() vehicle_enter; /// Vehicles custom funciton to be executed when owner exit it
+var .void() vehicle_die; /// Vehicles custom function to be executed when vehile die
+var .void() vehicle_spawn; /// Vehicles custom fucntion to be efecuted when vehicle (re)spawns
-#endif
+#ifdef VEHICLES_CSQC
+var .void(entity to) vehile_send_exta; /// Vehicles custom send code (for extra bits, stats and whatnot)
+void net_link_vehile(); /// Initiates csqc networking for vehicle
+#endif //VEHICLES_CSQC
+#endif //SVQC
+#ifdef VEHICLES_USE_ODE
void(entity e, float physics_enabled) physics_enable = #540; // enable or disable physics on object
void(entity e, vector force, vector force_pos) physics_addforce = #541; // apply a force from certain origin, length of force vector is power of force
void(entity e, vector torque) physics_addtorque = #542; // add relative torque
+#endif // VEHICLES_USE_ODE
+#endif // VEHICLES_ENABLED
\ No newline at end of file