11 bool autocvar_g_vehicle_racer =
true;
13 float autocvar_g_vehicle_racer_thinkrate = 0.05;
15 float autocvar_g_vehicle_racer_speed_afterburn = 3000;
17 float autocvar_g_vehicle_racer_afterburn_cost = 130;
19 float autocvar_g_vehicle_racer_waterburn_cost = 5;
20 float autocvar_g_vehicle_racer_waterburn_speed = 750;
22 float autocvar_g_vehicle_racer_water_speed_forward = 600;
23 float autocvar_g_vehicle_racer_water_speed_strafe = 600;
25 float autocvar_g_vehicle_racer_pitchlimit = 30;
27 float autocvar_g_vehicle_racer_water_downforce = 0.03;
28 float autocvar_g_vehicle_racer_water_upforcedamper = 15;
30 float autocvar_g_vehicle_racer_anglestabilizer = 1.75;
31 float autocvar_g_vehicle_racer_downforce = 0.01;
33 float autocvar_g_vehicle_racer_speed_forward = 650;
34 float autocvar_g_vehicle_racer_speed_strafe = 650;
35 float autocvar_g_vehicle_racer_springlength = 90;
36 float autocvar_g_vehicle_racer_upforcedamper = 2;
37 float autocvar_g_vehicle_racer_friction = 0.45;
39 float autocvar_g_vehicle_racer_water_time = 5;
44 int autocvar_g_vehicle_racer_hovertype = 0;
46 float autocvar_g_vehicle_racer_hoverpower = 8000;
48 float autocvar_g_vehicle_racer_turnroll = 30;
49 float autocvar_g_vehicle_racer_turnspeed = 220;
50 float autocvar_g_vehicle_racer_pitchspeed = 125;
52 float autocvar_g_vehicle_racer_energy = 100;
53 float autocvar_g_vehicle_racer_energy_regen = 90;
54 float autocvar_g_vehicle_racer_energy_regen_pause = 0.35;
56 float autocvar_g_vehicle_racer_health = 200;
57 float autocvar_g_vehicle_racer_health_regen = 0;
58 float autocvar_g_vehicle_racer_health_regen_pause = 0;
60 float autocvar_g_vehicle_racer_shield = 100;
61 float autocvar_g_vehicle_racer_shield_regen = 30;
62 float autocvar_g_vehicle_racer_shield_regen_pause = 1;
64 bool autocvar_g_vehicle_racer_rocket_locktarget =
true;
65 float autocvar_g_vehicle_racer_rocket_locking_time = 0.35;
66 float autocvar_g_vehicle_racer_rocket_locking_releasetime = 0.5;
67 float autocvar_g_vehicle_racer_rocket_locked_time = 4;
69 float autocvar_g_vehicle_racer_respawntime = 35;
71 float autocvar_g_vehicle_racer_blowup_radius = 250;
72 float autocvar_g_vehicle_racer_blowup_coredamage = 250;
73 float autocvar_g_vehicle_racer_blowup_edgedamage = 15;
74 float autocvar_g_vehicle_racer_blowup_forceintensity = 250;
77 float autocvar_g_vehicle_racer_bouncefactor = 0.25;
79 float autocvar_g_vehicle_racer_bouncestop = 0;
81 vector autocvar_g_vehicle_racer_bouncepain =
'200 0.15 150';
83 .float racer_watertime;
84 .float racer_air_finished;
86 var .vector(
entity this,
string tag_name,
float spring_length,
float max_power) racer_force_from_tag;
88 void racer_align4point(
entity this,
entity player,
float _delta)
91 float fl_push, fr_push, bl_push, br_push;
93 push_vector = this.racer_force_from_tag(
this,
"tag_engine_fr", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
94 fr_push = force_fromtag_normpower;
97 push_vector += this.racer_force_from_tag(
this,
"tag_engine_fl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
98 fl_push = force_fromtag_normpower;
101 push_vector += this.racer_force_from_tag(
this,
"tag_engine_br", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
102 br_push = force_fromtag_normpower;
105 push_vector += this.racer_force_from_tag(
this,
"tag_engine_bl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
106 bl_push = force_fromtag_normpower;
109 this.
velocity += push_vector * _delta;
111 float uforce = autocvar_g_vehicle_racer_upforcedamper;
113 int cont = pointcontents(this.
origin -
'0 0 64');
116 uforce = autocvar_g_vehicle_racer_water_upforcedamper;
119 this.velocity_z += 30;
121 this.velocity_z += 200;
126 if(this.velocity_z > 0)
127 this.velocity_z *= 1 - uforce * _delta;
129 push_vector_x = (fl_push - bl_push);
130 push_vector_x += (fr_push - br_push);
131 push_vector_x *= 360;
133 push_vector_z = (fr_push - fl_push);
134 push_vector_z += (br_push - bl_push);
135 push_vector_z *= 360;
138 this.angles_z += push_vector_z * _delta;
139 this.angles_x += push_vector_x * _delta;
142 this.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta);
143 this.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta);
149 racer_fire_rocket(
this, player, v,
v_forward, trg);
152 bool racer_frame(
entity this,
float dt)
155 entity vehic = player.vehicle;
170 int cont = Mod_Q1BSP_SuperContentsFromNativeContents(pointcontents(vehic.origin));
172 vehic.racer_air_finished = 0;
173 else if (!vehic.racer_air_finished)
174 vehic.racer_air_finished =
time + autocvar_g_vehicle_racer_water_time;
184 racer_align4point(vehic, player, dt);
190 vehic.angles_x *= -1;
193 float ftmp = autocvar_g_vehicle_racer_turnspeed * dt;
194 ftmp =
bound(-ftmp,
shortangle_f(player.v_angle_y - vehic.angles_y, vehic.angles_y), ftmp);
195 vehic.angles_y =
anglemods(vehic.angles_y + ftmp);
198 vehic.angles_z += -ftmp * autocvar_g_vehicle_racer_turnroll * dt;
201 ftmp = autocvar_g_vehicle_racer_pitchspeed * dt;
202 ftmp =
bound(-ftmp,
shortangle_f(player.v_angle_x - vehic.angles_x, vehic.angles_x), ftmp);
203 vehic.angles_x =
bound(-autocvar_g_vehicle_racer_pitchlimit,
anglemods(vehic.angles_x + ftmp), autocvar_g_vehicle_racer_pitchlimit);
206 vehic.angles_x *= -1;
209 vector df = vehic.velocity * -autocvar_g_vehicle_racer_friction;
216 if(PHYS_CS(player).movement_x) { df +=
v_forward * ((PHYS_CS(player).movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); }
217 if(PHYS_CS(player).movement_y) { df +=
v_right * ((PHYS_CS(player).movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); }
221 if(PHYS_CS(player).movement_x) { df +=
v_forward * ((PHYS_CS(player).movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); }
222 if(PHYS_CS(player).movement_y) { df +=
v_right * ((PHYS_CS(player).movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); }
226 if(vehic.sound_nexttime <
time || vehic.sounds != 1)
229 vehic.sound_nexttime =
time + 10.922667;
237 if(vehic.sound_nexttime <
time || vehic.sounds != 0)
240 vehic.sound_nexttime =
time + 11.888604;
247 if (
PHYS_INPUT_BUTTON_JUMP(player) && vehic.vehicle_energy >= (autocvar_g_vehicle_racer_afterburn_cost * dt))
250 if(
time - vehic.wait > 0.2)
256 if(cont & DPCONTENTS_LIQUIDSMASK)
258 vehic.vehicle_energy -= autocvar_g_vehicle_racer_waterburn_cost * dt;
259 df += (
v_forward * autocvar_g_vehicle_racer_waterburn_speed);
263 vehic.vehicle_energy -= autocvar_g_vehicle_racer_afterburn_cost * dt;
264 df += (
v_forward * autocvar_g_vehicle_racer_speed_afterburn);
270 if(vehic.invincible_finished <
time)
272 traceline(vehic.origin, vehic.origin -
'0 0 256',
MOVE_NORMAL, vehic);
276 vehic.invincible_finished =
time + 0.1 + (
random() * 0.1);
280 if(vehic.strength_finished <
time)
282 vehic.strength_finished =
time + 10.922667;
289 vehic.strength_finished = 0;
293 if(cont & DPCONTENTS_LIQUIDSMASK)
294 vehic.racer_watertime =
time;
296 float dforce = autocvar_g_vehicle_racer_downforce;
297 if(
time - vehic.racer_watertime <= 3)
298 dforce = autocvar_g_vehicle_racer_water_downforce;
300 df -=
v_up * (
vlen(vehic.velocity) * dforce);
301 PHYS_CS(player).movement = vehic.velocity += df * dt;
309 if (wep1.wr_checkammo1(wep1, vehic, weaponentity))
311 wep1.wr_think(wep1, vehic, weaponentity, 1);
314 if(autocvar_g_vehicle_racer_rocket_locktarget)
316 if(
time >= vehic.vehicle_last_trace)
321 (1 / autocvar_g_vehicle_racer_rocket_locking_releasetime) * dt,
322 autocvar_g_vehicle_racer_rocket_locked_time);
324 vehic.vehicle_last_trace =
time + autocvar_g_vehicle_racer_thinkrate;
327 if(vehic.lock_target)
329 if(vehic.lock_strength == 1)
331 else if(vehic.lock_strength > 0.5)
333 else if(vehic.lock_strength < 0.5)
339 if(
time > vehic.delay)
342 vehic.misc_bulletcounter += 1;
343 vehic.delay =
time + 0.3;
345 if(vehic.misc_bulletcounter == 1)
347 racer_fire_rocket_aim(vehic, player,
"tag_rocket_r", (vehic.lock_strength == 1 && vehic.lock_target) ? vehic.lock_target :
NULL);
348 player.vehicle_ammo2 = 50;
350 else if(vehic.misc_bulletcounter == 2)
352 racer_fire_rocket_aim(vehic, player,
"tag_rocket_l", (vehic.lock_strength == 1 && vehic.lock_target) ? vehic.lock_target :
NULL);
353 vehic.lock_strength = 0;
354 vehic.lock_target =
NULL;
355 vehic.misc_bulletcounter = 0;
356 vehic.delay =
time + autocvar_g_vehicle_racer_rocket_refire;
358 player.vehicle_ammo2 = 0;
361 else if(vehic.misc_bulletcounter == 0)
362 player.vehicle_ammo2 = 100;
364 player.vehicle_reload2 =
bound(0, 100 * ((
time - vehic.lip) / (vehic.delay - vehic.lip)), 100);
367 vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_racer_shield, autocvar_g_vehicle_racer_shield_regen_pause, autocvar_g_vehicle_racer_shield_regen, dt,
true);
370 vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, dt,
false,
RES_HEALTH);
373 vehicles_regen(vehic, vehic.wait, vehicle_energy, autocvar_g_vehicle_racer_energy, autocvar_g_vehicle_racer_energy_regen_pause, autocvar_g_vehicle_racer_energy_regen, dt,
false);
376 VEHICLE_UPDATE_PLAYER(player, vehic, energy, racer);
379 VEHICLE_UPDATE_PLAYER(player, vehic, shield, racer);
384 setorigin(player, vehic.origin +
'0 0 32');
386 player.oldorigin = player.origin;
388 player.velocity = vehic.velocity;
393 void racer_think(
entity this)
395 float dt = autocvar_g_vehicle_racer_thinkrate;
402 df_z += (1 -
trace_fraction) * autocvar_g_vehicle_racer_hoverpower +
sin(
time * 2) * (autocvar_g_vehicle_racer_springlength * 2);
404 float forced = autocvar_g_vehicle_racer_upforcedamper;
411 forced = autocvar_g_vehicle_racer_water_upforcedamper;
412 this.velocity_z += 200;
416 if(this.velocity_z > 0)
417 this.velocity_z *= 1 - forced * dt;
419 this.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * dt);
420 this.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * dt);
422 CSQCMODEL_AUTOUPDATE(
this);
425 void racer_exit(
entity this,
int eject)
443 this.
owner.velocity = (
v_up + v_forward * 0.25) * 750;
451 this.
owner.velocity_z += 200;
458 this.
owner.velocity_z += 10;
469 void racer_blowup(
entity this)
472 this.vehicle_exit(
this, VHEF_NORMAL);
475 autocvar_g_vehicle_racer_blowup_edgedamage,
476 autocvar_g_vehicle_racer_blowup_radius,
NULL,
NULL,
477 autocvar_g_vehicle_racer_blowup_forceintensity,
480 this.
nextthink =
time + autocvar_g_vehicle_racer_respawntime;
493 void racer_blowup_think(
entity this)
505 this.avelocity_x *= 0.7;
513 if(!autocvar_g_vehicle_racer) {
delete(
this);
return; }
522 if(autocvar_g_vehicle_racer_bouncepain)
523 vehicles_impact(instance, autocvar_g_vehicle_racer_bouncepain_x, autocvar_g_vehicle_racer_bouncepain_y, autocvar_g_vehicle_racer_bouncepain_z);
531 instance.owner.vehicle_health = (
GetResource(instance,
RES_HEALTH) / autocvar_g_vehicle_racer_health) * 100;
532 instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_racer_shield) * 100;
534 if(instance.owner.flagcarried)
535 setorigin(instance.owner.flagcarried,
'-190 0 96');
542 if(autocvar_g_vehicle_racer_hovertype != 0)
543 instance.racer_force_from_tag = vehicles_force_fromtag_maglev;
545 instance.racer_force_from_tag = vehicles_force_fromtag_hover;
548 instance.nextthink =
time;
550 instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
554 instance.delay =
time;
555 instance.scale = 0.5;
558 setattachment(instance.vehicle_hudmodel, instance,
"");
559 setattachment(instance.vehicle_viewport, instance,
"tag_viewport");
561 instance.PlayerPhysplug = racer_frame;
563 instance.bouncefactor = autocvar_g_vehicle_racer_bouncefactor;
564 instance.bouncestop = autocvar_g_vehicle_racer_bouncestop;
565 instance.damageforcescale = 0.5;
567 instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
581 instance.wait =
time;
583 instance.cnt = 1 +
random() * 2;
584 settouch(instance, racer_deadtouch);
586 Send_Effect(EFFECT_EXPLOSION_MEDIUM, instance.origin,
'0 0 0', 1);
589 instance.avelocity_z = 32;
591 instance.avelocity_z = -32;
593 instance.avelocity_x = -
vlen(instance.velocity) * 0.2;
594 instance.velocity +=
'0 0 700';
595 instance.colormod =
'-0.5 -0.5 -0.5';
597 setthink(instance, racer_blowup_think);
598 instance.nextthink =
time;
605 Vehicles_drawHUD(VEH_RACER.m_icon,
"vehicle_racer_weapon1",
"vehicle_racer_weapon2",
617 instance.vehicle_exit = racer_exit;
620 if(autocvar_g_vehicle_racer_energy && autocvar_g_vehicle_racer_energy_regen)
623 if(autocvar_g_vehicle_racer_shield)
626 if(autocvar_g_vehicle_racer_shield_regen)
629 if(autocvar_g_vehicle_racer_health_regen)
632 instance.respawntime = autocvar_g_vehicle_racer_respawntime;
634 instance.vehicle_shield = autocvar_g_vehicle_racer_shield;
#define PHYS_INPUT_BUTTON_ATCK2(s)
#define PHYS_INPUT_BUTTON_JUMP(s)
#define PHYS_INPUT_BUTTON_CROUCH(s)
const float SOLID_SLIDEBOX
const int VHF_HASSHIELD
Indicates vehicle.
void vehicles_regen_resource(entity this, float timer,.float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale, Resource resource)
ERASEABLE float anglemods(float v)
bool SetResourceExplicit(entity e, Resource res_type, float amount)
Sets the resource amount of an entity without calling any hooks.
void Vehicles_drawCrosshair(string crosshair)
void vehicles_spawn(entity this)
bool weaponUseForbidden(entity player)
ClientState CS(Client this)
void Vehicles_drawHUD(string vehicle, string vehicleWeapon1, string vehicleWeapon2, string iconAmmo1, vector colorAmmo1, string iconAmmo2, vector colorAmmo2)
#define PHYS_INPUT_BUTTON_ZOOM(s)
void vehicles_regen(entity this, float timer,.float regen_field, float field_max, float rpause, float regen, float delta_time, float _healthscale)
spawnfunc(info_player_attacker)
void antilag_clear(entity e, entity store)
#define METHOD(cname, name, prototype)
void crosshair_trace(entity pl)
void vehicles_impact(entity this, float _minspeed, float _speedfac, float _maxpain)
bool weaponLocked(entity player)
const float MOVE_NOMONSTERS
const int VHF_SHIELDREGEN
Vehicle has shileding.
const float CONTENT_SLIME
entity AuxiliaryXhair[MAX_AXH]
const float CONTENT_WATER
#define setSendEntity(e, f)
float trace_dpstartcontents
ERASEABLE float shortangle_f(float ang1, float ang2)
#define PHYS_INPUT_BUTTON_ATCK(s)
void vehicles_frame(entity this, entity actor)
vector autocvar_hud_progressbar_vehicles_ammo1_color
const int CH_TRIGGER_SINGLE
vector(float skel, float bonenum) _skel_get_boneabs_hidden
float GetResource(entity e, Resource res_type)
Returns the current amount of resource the given entity has.
const int VHF_HEALTHREGEN
Vehicles shield regenerates.
void vehicles_locktarget(entity this, float incr, float decr, float _lock_time)
#define vdist(v, cmp, f)
Vector distance comparison, avoids sqrt()
const int VHF_ENERGYREGEN
Vehicles health regenerates.
float RadiusDamage(entity inflictor, entity attacker, float coredamage, float edgedamage, float rad, entity cantbe, entity mustbe, float forceintensity, int deathtype,.entity weaponentity, entity directhitentity)
vector autocvar_hud_progressbar_vehicles_ammo2_color
entity weaponentities[MAX_WEAPONSLOTS]
void UpdateAuxiliaryXhair(entity own, vector loc, vector clr, int axh_id)
float DPCONTENTS_LIQUIDSMASK
#define sound(e, c, s, v, a)
fields which are explicitly/manually set are marked with "M", fields set automatically are marked wit...
const string vCROSS_GUIDE
bool vehicle_initialize(entity this, Vehicle info, bool nodrop)
void set_movetype(entity this, int mt)
vector vehicles_findgoodexit(entity this, entity player, vector prefer_spot)