1 #ifdef REGISTER_VEHICLE
4 /* function */ v_racer,
5 /* spawnflags */ VHF_DMGSHAKE | VHF_DMGROLL,
6 /* mins,maxs */ '-120 -120 -40' * 0.5, '120 120 40' * 0.5,
7 /* model */ "models/vehicles/wakizashi.dpm",
8 /* head_model */ "null",
9 /* hud_model */ "models/vehicles/wakizashi_cockpit.dpm",
10 /* tags */ "", "", "tag_viewport",
11 /* netname */ "racer",
12 /* fullname */ _("Racer")
16 float autocvar_g_vehicle_racer;
18 float autocvar_g_vehicle_racer_speed_afterburn;
19 float autocvar_g_vehicle_racer_afterburn_cost;
21 float autocvar_g_vehicle_racer_waterburn_cost;
22 float autocvar_g_vehicle_racer_waterburn_speed;
24 float autocvar_g_vehicle_racer_water_speed_forward;
25 float autocvar_g_vehicle_racer_water_speed_strafe;
27 float autocvar_g_vehicle_racer_anglestabilizer;
28 float autocvar_g_vehicle_racer_downforce;
30 float autocvar_g_vehicle_racer_speed_forward;
31 float autocvar_g_vehicle_racer_speed_strafe;
32 float autocvar_g_vehicle_racer_springlength;
33 float autocvar_g_vehicle_racer_upforcedamper;
34 float autocvar_g_vehicle_racer_friction;
36 float autocvar_g_vehicle_racer_hovertype;
37 float autocvar_g_vehicle_racer_hoverpower;
39 float autocvar_g_vehicle_racer_turnroll;
40 float autocvar_g_vehicle_racer_turnspeed;
41 float autocvar_g_vehicle_racer_pitchspeed;
43 float autocvar_g_vehicle_racer_energy;
44 float autocvar_g_vehicle_racer_energy_regen;
45 float autocvar_g_vehicle_racer_energy_regen_pause;
47 float autocvar_g_vehicle_racer_health;
48 float autocvar_g_vehicle_racer_health_regen;
49 float autocvar_g_vehicle_racer_health_regen_pause;
51 float autocvar_g_vehicle_racer_shield;
52 float autocvar_g_vehicle_racer_shield_regen;
53 float autocvar_g_vehicle_racer_shield_regen_pause;
55 float autocvar_g_vehicle_racer_cannon_cost;
56 float autocvar_g_vehicle_racer_cannon_damage;
57 float autocvar_g_vehicle_racer_cannon_radius;
58 float autocvar_g_vehicle_racer_cannon_refire;
59 float autocvar_g_vehicle_racer_cannon_speed;
60 float autocvar_g_vehicle_racer_cannon_spread;
61 float autocvar_g_vehicle_racer_cannon_force;
63 float autocvar_g_vehicle_racer_rocket_accel;
64 float autocvar_g_vehicle_racer_rocket_damage;
65 float autocvar_g_vehicle_racer_rocket_radius;
66 float autocvar_g_vehicle_racer_rocket_force;
67 float autocvar_g_vehicle_racer_rocket_refire;
68 float autocvar_g_vehicle_racer_rocket_speed;
69 float autocvar_g_vehicle_racer_rocket_turnrate;
71 float autocvar_g_vehicle_racer_rocket_locktarget;
72 float autocvar_g_vehicle_racer_rocket_locking_time;
73 float autocvar_g_vehicle_racer_rocket_locking_releasetime;
74 float autocvar_g_vehicle_racer_rocket_locked_time;
75 float autocvar_g_vehicle_racer_rocket_locked_maxangle;
76 float autocvar_g_vehicle_racer_rocket_climbspeed;
78 float autocvar_g_vehicle_racer_respawntime;
80 float autocvar_g_vehicle_racer_blowup_radius;
81 float autocvar_g_vehicle_racer_blowup_coredamage;
82 float autocvar_g_vehicle_racer_blowup_edgedamage;
83 float autocvar_g_vehicle_racer_blowup_forceintensity;
85 float autocvar_g_vehicle_racer_bouncefactor;
86 float autocvar_g_vehicle_racer_bouncestop;
87 vector autocvar_g_vehicle_racer_bouncepain;
89 var vector racer_force_from_tag(string tag_name, float spring_length, float max_power);
91 void racer_align4point(float _delta)
94 float fl_push, fr_push, bl_push, br_push;
96 push_vector = racer_force_from_tag("tag_engine_fr", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
97 fr_push = force_fromtag_normpower;
98 //vehicles_sweap_collision(force_fromtag_origin, self.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier);
100 push_vector += racer_force_from_tag("tag_engine_fl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
101 fl_push = force_fromtag_normpower;
102 //vehicles_sweap_collision(force_fromtag_origin, self.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier);
104 push_vector += racer_force_from_tag("tag_engine_br", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
105 br_push = force_fromtag_normpower;
106 //vehicles_sweap_collision(force_fromtag_origin, self.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier);
108 push_vector += racer_force_from_tag("tag_engine_bl", autocvar_g_vehicle_racer_springlength, autocvar_g_vehicle_racer_hoverpower);
109 bl_push = force_fromtag_normpower;
110 //vehicles_sweap_collision(force_fromtag_origin, self.velocity, _delta, v_add, autocvar_g_vehicle_racer_collision_multiplier);
112 self.velocity += push_vector * _delta;
114 if(pointcontents(self.origin - '0 0 64') == CONTENT_WATER)
115 if(self.owner.BUTTON_CROUCH && time < self.air_finished)
116 self.velocity_z += 30;
118 self.velocity_z += 200;
121 if(self.velocity_z > 0)
122 self.velocity_z *= 1 - autocvar_g_vehicle_racer_upforcedamper * _delta;
124 push_vector_x = (fl_push - bl_push);
125 push_vector_x += (fr_push - br_push);
126 push_vector_x *= 360;
128 push_vector_z = (fr_push - fl_push);
129 push_vector_z += (br_push - bl_push);
130 push_vector_z *= 360;
132 // Apply angle diffrance
133 self.angles_z += push_vector_z * _delta;
134 self.angles_x += push_vector_x * _delta;
137 self.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta);
138 self.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * _delta);
141 void racer_fire_cannon(string tagname)
146 v = gettaginfo(self, gettagindex(self, tagname));
147 bolt = vehicles_projectile("wakizashi_gun_muzzleflash", "weapons/lasergun_fire.wav",
148 v, normalize(v_forward + randomvec() * autocvar_g_vehicle_racer_cannon_spread) * autocvar_g_vehicle_racer_cannon_speed,
149 autocvar_g_vehicle_racer_cannon_damage, autocvar_g_vehicle_racer_cannon_radius, autocvar_g_vehicle_racer_cannon_force, 0,
150 DEATH_VH_WAKI_GUN, PROJECTILE_WAKICANNON, 0, TRUE, TRUE, self.owner);
152 // Fix z-aim (for chase mode)
153 v = normalize(trace_endpos - bolt.origin);
154 v_forward_z = v_z * 0.5;
155 bolt.velocity = v_forward * autocvar_g_vehicle_racer_cannon_speed;
158 void racer_rocket_groundhugger()
160 vector olddir, newdir;
161 float oldvel, newvel;
163 self.nextthink = time;
165 if(self.owner.deadflag != DEAD_NO || self.cnt < time)
171 if(!self.realowner.vehicle)
173 UpdateCSQCProjectile(self);
177 olddir = normalize(self.velocity);
178 oldvel = vlen(self.velocity);
179 newvel = oldvel + self.lip;
181 tracebox(self.origin, self.mins, self.maxs, self.origin + olddir * 64, MOVE_WORLDONLY,self);
182 if(trace_fraction <= 0.5)
184 // Hitting somethign soon, just speed ahead
185 self.velocity = olddir * newvel;
186 UpdateCSQCProjectile(self);
190 traceline(trace_endpos, trace_endpos - '0 0 64', MOVE_NORMAL, self);
191 if(trace_fraction != 1.0)
193 newdir = normalize(trace_endpos + '0 0 64' - self.origin) * autocvar_g_vehicle_racer_rocket_turnrate;
194 self.velocity = normalize(olddir + newdir) * newvel;
198 self.velocity = olddir * newvel;
199 self.velocity_z -= 1600 * sys_frametime; // 2x grav looks better for this one
202 if(pointcontents(self.origin - '0 0 32') == CONTENT_WATER)
203 self.velocity_z += 200;
205 UpdateCSQCProjectile(self);
209 void racer_rocket_tracker()
211 vector olddir, newdir;
212 float oldvel, newvel;
214 self.nextthink = time;
216 if (self.owner.deadflag != DEAD_NO || self.cnt < time)
222 if(!self.realowner.vehicle)
224 UpdateCSQCProjectile(self);
228 olddir = normalize(self.velocity);
229 oldvel = vlen(self.velocity);
230 newvel = oldvel + self.lip;
231 makevectors(vectoangles(olddir));
233 float time_to_impact = min(vlen(self.enemy.origin - self.origin) / vlen(self.velocity), 1);
234 vector predicted_origin = self.enemy.origin + self.enemy.velocity * time_to_impact;
236 traceline(self.origin, self.origin + v_forward * 64 - '0 0 32', MOVE_NORMAL, self);
237 newdir = normalize(predicted_origin - self.origin);
240 float height_diff = predicted_origin_z - self.origin_z;
242 if(vlen(newdir - v_forward) > autocvar_g_vehicle_racer_rocket_locked_maxangle)
244 //bprint("Target lost!\n");
245 //dprint("OF:", ftos(vlen(newdir - v_forward)), "\n");
246 self.think = racer_rocket_groundhugger;
250 if(trace_fraction != 1.0 && trace_ent != self.enemy)
251 newdir_z += 16 * sys_frametime;
253 self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_racer_rocket_turnrate) * newvel;
254 self.velocity_z -= 800 * sys_frametime;
255 self.velocity_z += max(height_diff, autocvar_g_vehicle_racer_rocket_climbspeed) * sys_frametime ;
257 UpdateCSQCProjectile(self);
261 void racer_fire_rocket(string tagname, entity trg)
263 vector v = gettaginfo(self, gettagindex(self, tagname));
264 entity rocket = rocket = vehicles_projectile("wakizashi_rocket_launch", "weapons/rocket_fire.wav",
265 v, v_forward * autocvar_g_vehicle_racer_rocket_speed,
266 autocvar_g_vehicle_racer_rocket_damage, autocvar_g_vehicle_racer_rocket_radius, autocvar_g_vehicle_racer_rocket_force, 3,
267 DEATH_VH_WAKI_ROCKET, PROJECTILE_WAKIROCKET, 20, FALSE, FALSE, self.owner);
269 rocket.lip = autocvar_g_vehicle_racer_rocket_accel * sys_frametime;
270 rocket.wait = autocvar_g_vehicle_racer_rocket_turnrate;
271 rocket.nextthink = time;
273 rocket.cnt = time + 15;
276 rocket.think = racer_rocket_tracker;
278 rocket.think = racer_rocket_groundhugger;
283 entity player, racer;
287 if(intermission_running)
289 self.vehicle.velocity = '0 0 0';
294 racer = self.vehicle;
297 vehicles_painframe();
299 if(pointcontents(racer.origin) != CONTENT_WATER)
300 racer.air_finished = time + 5;
302 if(racer.deadflag != DEAD_NO)
305 player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
309 racer_align4point(frametime);
311 player.BUTTON_ZOOM = player.BUTTON_CROUCH = 0;
313 crosshair_trace(player);
315 racer.angles_x *= -1;
318 ftmp = autocvar_g_vehicle_racer_turnspeed * frametime;
319 ftmp = bound(-ftmp, shortangle_f(player.v_angle_y - racer.angles_y, racer.angles_y), ftmp);
320 racer.angles_y = anglemods(racer.angles_y + ftmp);
323 racer.angles_z += -ftmp * autocvar_g_vehicle_racer_turnroll * frametime;
326 ftmp = autocvar_g_vehicle_racer_pitchspeed * frametime;
327 ftmp = bound(-ftmp, shortangle_f(player.v_angle_x - racer.angles_x, racer.angles_x), ftmp);
328 racer.angles_x = bound(-30, anglemods(racer.angles_x + ftmp), 30);
330 makevectors(racer.angles);
331 racer.angles_x *= -1;
333 //ftmp = racer.velocity_z;
334 df = racer.velocity * -autocvar_g_vehicle_racer_friction;
335 //racer.velocity_z = ftmp;
337 if(vlen(player.movement) != 0)
339 if(pointcontents(racer.origin) == CONTENT_WATER)
341 if(player.movement_x) { df += v_forward * ((player.movement_x > 0) ? autocvar_g_vehicle_racer_water_speed_forward : -autocvar_g_vehicle_racer_water_speed_forward); }
342 if(player.movement_y) { df += v_right * ((player.movement_y > 0) ? autocvar_g_vehicle_racer_water_speed_strafe : -autocvar_g_vehicle_racer_water_speed_strafe); }
346 if(player.movement_x) { df += v_forward * ((player.movement_x > 0) ? autocvar_g_vehicle_racer_speed_forward : -autocvar_g_vehicle_racer_speed_forward); }
347 if(player.movement_y) { df += v_right * ((player.movement_y > 0) ? autocvar_g_vehicle_racer_speed_strafe : -autocvar_g_vehicle_racer_speed_strafe); }
350 if(self.sound_nexttime < time || self.sounds != 1)
353 self.sound_nexttime = time + 10.922667; //soundlength("vehicles/racer_move.wav");
354 sound (self, CH_TRIGGER_SINGLE, "vehicles/racer_move.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
359 if(self.sound_nexttime < time || self.sounds != 0)
362 self.sound_nexttime = time + 11.888604; //soundlength("vehicles/racer_idle.wav");
363 sound (self, CH_TRIGGER_SINGLE, "vehicles/racer_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
368 if (player.BUTTON_JUMP && racer.vehicle_energy >= (autocvar_g_vehicle_racer_afterburn_cost * frametime))
370 if(time - racer.wait > 0.2)
371 pointparticles(particleeffectnum("wakizashi_booster_smoke"), self.origin - v_forward * 32, v_forward * vlen(self.velocity), 1);
375 if(pointcontents(racer.origin) == CONTENT_WATER)
377 racer.vehicle_energy -= autocvar_g_vehicle_racer_waterburn_cost * frametime;
378 df += (v_forward * autocvar_g_vehicle_racer_waterburn_speed);
382 racer.vehicle_energy -= autocvar_g_vehicle_racer_afterburn_cost * frametime;
383 df += (v_forward * autocvar_g_vehicle_racer_speed_afterburn);
386 if(racer.invincible_finished < time)
388 traceline(racer.origin, racer.origin - '0 0 256', MOVE_NORMAL, self);
389 if(trace_fraction != 1.0)
390 pointparticles(particleeffectnum("smoke_small"), trace_endpos, '0 0 0', 1);
392 racer.invincible_finished = time + 0.1 + (random() * 0.1);
395 if(racer.strength_finished < time)
397 racer.strength_finished = time + 10.922667; //soundlength("vehicles/racer_boost.wav");
398 sound (racer.tur_head, CH_TRIGGER_SINGLE, "vehicles/racer_boost.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
403 racer.strength_finished = 0;
404 sound (racer.tur_head, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
407 df -= v_up * (vlen(racer.velocity) * autocvar_g_vehicle_racer_downforce);
408 player.movement = racer.velocity += df * frametime;
410 if(!forbidWeaponUse(player))
411 if(player.BUTTON_ATCK)
412 if(time > racer.attack_finished_single)
413 if(racer.vehicle_energy >= autocvar_g_vehicle_racer_cannon_cost)
415 racer.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost;
418 crosshair_trace(player);
421 racer_fire_cannon("tag_fire1");
426 racer_fire_cannon("tag_fire2");
429 racer.attack_finished_single = time + autocvar_g_vehicle_racer_cannon_refire;
432 if(autocvar_g_vehicle_racer_rocket_locktarget)
434 vehicles_locktarget((1 / autocvar_g_vehicle_racer_rocket_locking_time) * frametime,
435 (1 / autocvar_g_vehicle_racer_rocket_locking_releasetime) * frametime,
436 autocvar_g_vehicle_racer_rocket_locked_time);
440 if(racer.lock_strength == 1)
441 UpdateAuxiliaryXhair(player, real_origin(self.lock_target), '1 0 0', 0);
442 else if(self.lock_strength > 0.5)
443 UpdateAuxiliaryXhair(player, real_origin(self.lock_target), '0 1 0', 0);
444 else if(self.lock_strength < 0.5)
445 UpdateAuxiliaryXhair(player, real_origin(self.lock_target), '0 0 1', 0);
449 if(!forbidWeaponUse(player))
450 if(time > racer.delay)
451 if(player.BUTTON_ATCK2)
453 racer.misc_bulletcounter += 1;
454 racer.delay = time + 0.3;
456 if(racer.misc_bulletcounter == 1)
457 racer_fire_rocket("tag_rocket_r", (racer.lock_strength == 1 && racer.lock_target) ? racer.lock_target : world);
458 else if(racer.misc_bulletcounter == 2)
460 racer_fire_rocket("tag_rocket_l", (racer.lock_strength == 1 && racer.lock_target) ? racer.lock_target : world);
461 racer.lock_strength = 0;
462 racer.lock_target = world;
463 racer.misc_bulletcounter = 0;
465 racer.delay = time + autocvar_g_vehicle_racer_rocket_refire;
469 player.vehicle_reload1 = bound(0, 100 * ((time - racer.lip) / (racer.delay - racer.lip)), 100);
471 if(racer.vehicle_flags & VHF_SHIELDREGEN)
472 vehicles_regen(racer.dmg_time, vehicle_shield, autocvar_g_vehicle_racer_shield, autocvar_g_vehicle_racer_shield_regen_pause, autocvar_g_vehicle_racer_shield_regen, frametime, TRUE);
474 if(racer.vehicle_flags & VHF_HEALTHREGEN)
475 vehicles_regen(racer.dmg_time, vehicle_health, autocvar_g_vehicle_racer_health, autocvar_g_vehicle_racer_health_regen_pause, autocvar_g_vehicle_racer_health_regen, frametime, FALSE);
477 if(racer.vehicle_flags & VHF_ENERGYREGEN)
478 vehicles_regen(racer.wait, vehicle_energy, autocvar_g_vehicle_racer_energy, autocvar_g_vehicle_racer_energy_regen_pause, autocvar_g_vehicle_racer_energy_regen, frametime, FALSE);
481 VEHICLE_UPDATE_PLAYER(player, health, racer);
482 VEHICLE_UPDATE_PLAYER(player, energy, racer);
484 if(racer.vehicle_flags & VHF_HASSHIELD)
485 VEHICLE_UPDATE_PLAYER(player, shield, racer);
487 player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
488 setorigin(player,racer.origin + '0 0 32');
489 player.velocity = racer.velocity;
497 self.nextthink = time;
499 float pushdeltatime = time - self.lastpushtime;
500 if (pushdeltatime > 0.15) pushdeltatime = 0;
501 self.lastpushtime = time;
502 if(!pushdeltatime) return;
504 tracebox(self.origin, self.mins, self.maxs, self.origin - ('0 0 1' * autocvar_g_vehicle_racer_springlength), MOVE_NOMONSTERS, self);
506 vector df = self.velocity * -autocvar_g_vehicle_racer_friction;
507 df_z += (1 - trace_fraction) * autocvar_g_vehicle_racer_hoverpower + sin(time * 2) * (autocvar_g_vehicle_racer_springlength * 2);
509 if(pointcontents(self.origin - '0 0 64') == CONTENT_WATER)
510 self.velocity_z += 200;
512 self.velocity += df * pushdeltatime;
513 if(self.velocity_z > 0)
514 self.velocity_z *= 1 - autocvar_g_vehicle_racer_upforcedamper * pushdeltatime;
516 self.angles_x *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * pushdeltatime);
517 self.angles_z *= 1 - (autocvar_g_vehicle_racer_anglestabilizer * pushdeltatime);
519 CSQCMODEL_AUTOUPDATE();
522 void racer_exit(float eject)
526 self.think = racer_think;
527 self.nextthink = time;
528 self.movetype = MOVETYPE_BOUNCE;
529 sound (self.tur_head, CH_TRIGGER_SINGLE, "misc/null.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
534 makevectors(self.angles);
537 spot = self.origin + v_forward * 100 + '0 0 64';
538 spot = vehicles_findgoodexit(spot);
539 setorigin(self.owner , spot);
540 self.owner.velocity = (v_up + v_forward * 0.25) * 750;
541 self.owner.oldvelocity = self.owner.velocity;
545 if(vlen(self.velocity) > 2 * autocvar_sv_maxairspeed)
547 self.owner.velocity = normalize(self.velocity) * autocvar_sv_maxairspeed * 2;
548 self.owner.velocity_z += 200;
549 spot = self.origin + v_forward * 32 + '0 0 32';
550 spot = vehicles_findgoodexit(spot);
554 self.owner.velocity = self.velocity * 0.5;
555 self.owner.velocity_z += 10;
556 spot = self.origin - v_forward * 200 + '0 0 32';
557 spot = vehicles_findgoodexit(spot);
559 self.owner.oldvelocity = self.owner.velocity;
560 setorigin(self.owner , spot);
562 antilag_clear(self.owner);
568 self.deadflag = DEAD_DEAD;
569 self.vehicle_exit(VHEF_NORMAL);
571 RadiusDamage (self, self.enemy, autocvar_g_vehicle_racer_blowup_coredamage,
572 autocvar_g_vehicle_racer_blowup_edgedamage,
573 autocvar_g_vehicle_racer_blowup_radius, world,
574 autocvar_g_vehicle_racer_blowup_forceintensity,
575 DEATH_VH_WAKI_DEATH, world);
577 self.nextthink = time + autocvar_g_vehicle_racer_respawntime;
578 self.think = vehicles_spawn;
579 self.movetype = MOVETYPE_NONE;
580 self.effects = EF_NODRAW;
582 self.colormod = '0 0 0';
583 self.avelocity = '0 0 0';
584 self.velocity = '0 0 0';
586 setorigin(self, self.pos1);
589 void racer_blowup_think()
591 self.nextthink = time;
593 if(time >= self.delay)
596 CSQCMODEL_AUTOUPDATE();
599 void racer_deadtouch()
601 self.avelocity_x *= 0.7;
607 void spawnfunc_vehicle_racer()
609 if(!autocvar_g_vehicle_racer) { remove(self); return; }
610 if(!vehicle_initialize(VEH_RACER, FALSE)) { remove(self); return; }
613 float v_racer(float req)
619 if(autocvar_g_vehicle_racer_bouncepain)
620 vehicles_impact(autocvar_g_vehicle_racer_bouncepain_x, autocvar_g_vehicle_racer_bouncepain_y, autocvar_g_vehicle_racer_bouncepain_z);
625 self.movetype = MOVETYPE_BOUNCE;
626 self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_racer_health) * 100;
627 self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_racer_shield) * 100;
629 if(self.owner.flagcarried)
630 setorigin(self.owner.flagcarried, '-190 0 96');
641 self.event_damage = func_null;
642 self.solid = SOLID_CORPSE;
643 self.takedamage = DAMAGE_NO;
644 self.deadflag = DEAD_DYING;
645 self.movetype = MOVETYPE_BOUNCE;
647 self.delay = 2 + time + random() * 3;
648 self.cnt = 1 + random() * 2;
649 self.touch = racer_deadtouch;
651 pointparticles(particleeffectnum("explosion_medium"), self.origin, '0 0 0', 1);
654 self.avelocity_z = 32;
656 self.avelocity_z = -32;
658 self.avelocity_x = -vlen(self.velocity) * 0.2;
659 self.velocity += '0 0 700';
660 self.colormod = '-0.5 -0.5 -0.5';
662 self.think = racer_blowup_think;
663 self.nextthink = time;
669 if(self.scale != 0.5)
671 if(autocvar_g_vehicle_racer_hovertype != 0)
672 racer_force_from_tag = vehicles_force_fromtag_maglev;
674 racer_force_from_tag = vehicles_force_fromtag_hover;
676 // FIXME: this be hakkz, fix the models insted (scale body, add tag_viewport to the hudmodel).
678 setattachment(self.vehicle_hudmodel, self, "");
679 setattachment(self.vehicle_viewport, self, "tag_viewport");
684 self.think = racer_think;
685 self.nextthink = time;
686 self.vehicle_health = autocvar_g_vehicle_racer_health;
687 self.vehicle_shield = autocvar_g_vehicle_racer_shield;
689 self.movetype = MOVETYPE_TOSS;
690 self.solid = SOLID_SLIDEBOX;
694 self.PlayerPhysplug = racer_frame;
696 self.bouncefactor = autocvar_g_vehicle_racer_bouncefactor;
697 self.bouncestop = autocvar_g_vehicle_racer_bouncestop;
698 self.damageforcescale = 0.5;
699 self.vehicle_health = autocvar_g_vehicle_racer_health;
700 self.vehicle_shield = autocvar_g_vehicle_racer_shield;
706 if(autocvar_g_vehicle_racer_energy)
707 if(autocvar_g_vehicle_racer_energy_regen)
708 self.vehicle_flags |= VHF_ENERGYREGEN;
710 if(autocvar_g_vehicle_racer_shield)
711 self.vehicle_flags |= VHF_HASSHIELD;
713 if(autocvar_g_vehicle_racer_shield_regen)
714 self.vehicle_flags |= VHF_SHIELDREGEN;
716 if(autocvar_g_vehicle_racer_health_regen)
717 self.vehicle_flags |= VHF_HEALTHREGEN;
719 self.vehicle_exit = racer_exit;
720 self.respawntime = autocvar_g_vehicle_racer_respawntime;
721 self.vehicle_health = autocvar_g_vehicle_racer_health;
722 self.vehicle_shield = autocvar_g_vehicle_racer_shield;
723 self.max_health = self.vehicle_health;
729 precache_sound ("weapons/lasergun_fire.wav");
730 precache_sound ("weapons/rocket_fire.wav");
732 precache_sound ("vehicles/racer_idle.wav");
733 precache_sound ("vehicles/racer_move.wav");
734 precache_sound ("vehicles/racer_boost.wav");
736 precache_model ("models/vhshield.md3");
737 precache_model ("models/vehicles/wakizashi.dpm");
738 precache_model ("models/vehicles/wakizashi_cockpit.dpm");
749 #define waki_ico "gfx/vehicles/waki.tga"
750 #define waki_eng "gfx/vehicles/waki_e.tga"
751 #define waki_gun "gfx/vehicles/waki_guns.tga"
752 #define waki_rkt "gfx/vehicles/waki_rockets.tga"
753 #define waki_xhair "gfx/vehicles/axh-special1.tga"
755 float v_racer(float req)
761 if(autocvar_r_letterbox)
764 vector picsize, hudloc = '0 0 0', pic2size, picloc;
766 // Fetch health & ammo stats
769 picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
770 hudloc_y = vid_conheight - picsize_y;
771 hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
773 drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
780 pic2size = draw_getimagesize(waki_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
781 picloc = picsize * 0.5 - pic2size * 0.5;
783 drawpic(hudloc + picloc, waki_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
785 drawpic(hudloc + picloc, waki_ico, pic2size, '1 1 1' * vh_health + '1 0 0' * (1 - vh_health), 1, DRAWFLAG_NORMAL);
786 drawpic(hudloc + picloc, waki_eng, pic2size, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
787 drawpic(hudloc + picloc, waki_gun, pic2size, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
788 drawpic(hudloc + picloc, waki_rkt, pic2size, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
789 drawpic(hudloc + picloc, hud_sh, pic2size, '1 1 1', shield, DRAWFLAG_NORMAL);
792 picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
793 picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
794 drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
795 drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
798 picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
799 picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
802 if(alarm1time < time)
804 alarm1time = time + 2;
805 vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
808 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
812 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
815 vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
822 picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
823 picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
824 drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
825 drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
828 picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
829 picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
832 if(alarm2time < time)
834 alarm2time = time + 1;
835 vehicle_alarm(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav");
837 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
841 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
844 vehicle_alarm(self, CH_TRIGGER_SINGLE, "misc/null.wav");
850 picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
851 picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
852 drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
853 drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
856 picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
857 picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
859 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
861 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
864 picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
865 picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
866 drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
867 drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
870 pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
871 picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
873 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
875 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
877 if (scoreboard_showscores)
878 HUD_DrawScoreboard();
881 picsize = draw_getimagesize(waki_xhair);
886 drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), waki_xhair, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
892 AuxiliaryXhair[0].axh_image = "gfx/vehicles/axh-bracket.tga";
893 AuxiliaryXhair[0].axh_scale = 0.25;
898 precache_model ("models/vhshield.md3");
899 precache_model ("models/vehicles/wakizashi.dpm");
900 precache_model ("models/vehicles/wakizashi_cockpit.dpm");
909 #endif // REGISTER_VEHICLE