]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/vehicles/sv_vehicles.qh
New vehicle system based on weapons system
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / sv_vehicles.qh
1 // #define VEHICLES_USE_ODE
2
3 // vehicle cvars
4 float autocvar_g_vehicles;
5 float autocvar_g_vehicles_enter;
6 float autocvar_g_vehicles_enter_radius;
7 float autocvar_g_vehicles_steal;
8 float autocvar_g_vehicles_crush_dmg;
9 float autocvar_g_vehicles_crush_force;
10 float autocvar_g_vehicles_delayspawn;
11 float autocvar_g_vehicles_delayspawn_jitter;
12 float autocvar_g_vehicles_allow_bots;
13 var float autocvar_g_vehicles_nex_damagerate = 0.5;
14 var float autocvar_g_vehicles_uzi_damagerate = 0.5;
15 var float autocvar_g_vehicles_rifle_damagerate = 0.75;
16 var float autocvar_g_vehicles_minstanex_damagerate = 0.001;
17 var float autocvar_g_vehicles_tag_damagerate = 5;
18
19 // vehicle definitions
20 .entity gun1;
21 .entity gun2;
22 .entity gun3;
23 .entity vehicle_shieldent;  /// Entity to disply the shild effect on damage
24 .entity vehicle;
25 .entity vehicle_viewport;
26 .entity vehicle_hudmodel;
27 .entity vehicle_controller;
28
29 .entity gunner1;
30 .entity gunner2;
31
32 .float vehicle_health;      /// If self is player this is 0..100 indicating precentage of health left on vehicle. If self is vehile, this is the real health value.
33 .float vehicle_energy;      /// If self is player this is 0..100 indicating precentage of energy left on vehicle. If self is vehile, this is the real energy value.
34 .float vehicle_shield;      /// If self is player this is 0..100 indicating precentage of shield left on vehicle. If self is vehile, this is the real shield value.
35
36 .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.
37 .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.
38 .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.
39 .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.
40
41 .float sound_nexttime;
42 #define VOL_VEHICLEENGINE 1
43
44 const float SVC_SETVIEWPORT   = 5;   // Net.Protocol 0x05
45 const float SVC_SETVIEWANGLES = 10;  // Net.Protocol 0x0A
46 const float SVC_UPDATEENTITY  = 128; // Net.Protocol 0x80
47
48 #define VHSF_NORMAL 0
49 #define VHSF_FACTORY 2
50
51 .float hud;
52 .float dmg_time;
53
54 .float volly_counter;
55
56 const float MAX_AXH = 4;
57 .entity AuxiliaryXhair[MAX_AXH];
58
59 .entity wps_intruder;
60
61 .entity lock_target;
62 .float  lock_strength;
63 .float  lock_time;
64 .float  lock_soundtime;
65 const float     DAMAGE_TARGETDRONE = 10;
66
67 float  force_fromtag_power;
68 float  force_fromtag_normpower;
69 vector force_fromtag_origin;
70
71 float vehicles_exit_running;
72
73 #ifdef VEHICLES_USE_ODE
74 void(entity e, float physics_enabled) physics_enable = #540; // enable or disable physics on object
75 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
76 void(entity e, vector torque) physics_addtorque = #542; // add relative torque
77 #endif  // VEHICLES_USE_ODE
78
79 // functions used outside the vehicle code
80 void vehicles_exit(float eject);
81 void vehicles_enter(entity pl, entity veh);
82
83 // vehicle functions
84 .void(float _spawnflag) vehicle_spawn;  /// Vehicles custom fucntion to be efecuted when vehicle (re)spawns
85 .float(float _imp) vehicles_impulse;
86 .float vehicle_weapon2mode = volly_counter;
87 .void(float exit_flags) vehicle_exit;
88 const float VHEF_NORMAL = 0;  /// User pressed exit key
89 const float VHEF_EJECT  = 1;  /// User pressed exit key 3 times fast (not implemented) or vehile is dying
90 const float VHEF_RELESE = 2;  /// Release ownership, client possibly allready dissconnected / went spec / changed team / used "kill" (not implemented)
91
92 // macros
93 #define VEHICLE_UPDATE_PLAYER(ply,fld,vhname) \
94         ply.vehicle_##fld = (self.vehicle_##fld / autocvar_g_vehicle_##vhname##_##fld) * 100
95
96 #define vehicles_sweap_collision(orig,vel,dt,acm,mult) \
97         traceline(orig, orig + vel * dt, MOVE_NORMAL, self); \
98         if(trace_fraction != 1) \
99                 acm += normalize(self.origin - trace_endpos) * (vlen(vel) * mult)