1 #ifdef REGISTER_VEHICLE
4 /* function */ v_raptor,
5 /* spawnflags */ VHF_DMGSHAKE | VHF_DMGROLL,
6 /* mins,maxs */ '-80 -80 0', '80 80 70',
7 /* model */ "models/vehicles/raptor.dpm",
9 /* hud_model */ "models/vehicles/raptor_cockpit.dpm",
10 /* tags */ "", "tag_hud", "tag_camera",
11 /* netname */ "raptor",
12 /* fullname */ _("Raptor")
16 const float RSM_FIRST = 1;
17 const float RSM_BOMB = 1;
18 const float RSM_FLARE = 2;
19 const float RSM_LAST = 2;
22 float autocvar_g_vehicle_raptor;
24 float autocvar_g_vehicle_raptor_respawntime;
25 float autocvar_g_vehicle_raptor_takeofftime;
27 float autocvar_g_vehicle_raptor_movestyle;
28 float autocvar_g_vehicle_raptor_turnspeed;
29 float autocvar_g_vehicle_raptor_pitchspeed;
30 float autocvar_g_vehicle_raptor_pitchlimit;
32 float autocvar_g_vehicle_raptor_speed_forward;
33 float autocvar_g_vehicle_raptor_speed_strafe;
34 float autocvar_g_vehicle_raptor_speed_up;
35 float autocvar_g_vehicle_raptor_speed_down;
36 float autocvar_g_vehicle_raptor_friction;
38 float autocvar_g_vehicle_raptor_bomblets;
39 float autocvar_g_vehicle_raptor_bomblet_alt;
40 float autocvar_g_vehicle_raptor_bomblet_time;
41 float autocvar_g_vehicle_raptor_bomblet_damage;
42 float autocvar_g_vehicle_raptor_bomblet_spread;
43 float autocvar_g_vehicle_raptor_bomblet_edgedamage;
44 float autocvar_g_vehicle_raptor_bomblet_radius;
45 float autocvar_g_vehicle_raptor_bomblet_force;
46 float autocvar_g_vehicle_raptor_bomblet_explode_delay;
47 float autocvar_g_vehicle_raptor_bombs_refire;
49 float autocvar_g_vehicle_raptor_flare_refire;
50 float autocvar_g_vehicle_raptor_flare_lifetime;
51 float autocvar_g_vehicle_raptor_flare_chase;
52 float autocvar_g_vehicle_raptor_flare_range;
54 float autocvar_g_vehicle_raptor_cannon_turnspeed;
55 float autocvar_g_vehicle_raptor_cannon_turnlimit;
56 float autocvar_g_vehicle_raptor_cannon_pitchlimit_up;
57 float autocvar_g_vehicle_raptor_cannon_pitchlimit_down;
59 float autocvar_g_vehicle_raptor_cannon_locktarget;
60 float autocvar_g_vehicle_raptor_cannon_locking_time;
61 float autocvar_g_vehicle_raptor_cannon_locking_releasetime;
62 float autocvar_g_vehicle_raptor_cannon_locked_time;
63 float autocvar_g_vehicle_raptor_cannon_predicttarget;
65 float autocvar_g_vehicle_raptor_cannon_cost;
66 float autocvar_g_vehicle_raptor_cannon_damage;
67 float autocvar_g_vehicle_raptor_cannon_radius;
68 float autocvar_g_vehicle_raptor_cannon_refire;
69 float autocvar_g_vehicle_raptor_cannon_speed;
70 float autocvar_g_vehicle_raptor_cannon_spread;
71 float autocvar_g_vehicle_raptor_cannon_force;
73 float autocvar_g_vehicle_raptor_energy;
74 float autocvar_g_vehicle_raptor_energy_regen;
75 float autocvar_g_vehicle_raptor_energy_regen_pause;
77 float autocvar_g_vehicle_raptor_health;
78 float autocvar_g_vehicle_raptor_health_regen;
79 float autocvar_g_vehicle_raptor_health_regen_pause;
81 float autocvar_g_vehicle_raptor_shield;
82 float autocvar_g_vehicle_raptor_shield_regen;
83 float autocvar_g_vehicle_raptor_shield_regen_pause;
85 float autocvar_g_vehicle_raptor_bouncefactor;
86 float autocvar_g_vehicle_raptor_bouncestop;
87 vector autocvar_g_vehicle_raptor_bouncepain;
92 float raptor_altitude(float amax)
94 tracebox(self.origin, self.mins, self.maxs, self.origin - ('0 0 1' * amax), MOVE_WORLDONLY, self);
95 return vlen(self.origin - trace_endpos);
98 void raptor_bomblet_boom()
100 RadiusDamage (self, self.realowner, autocvar_g_vehicle_raptor_bomblet_damage,
101 autocvar_g_vehicle_raptor_bomblet_edgedamage,
102 autocvar_g_vehicle_raptor_bomblet_radius, world,
103 autocvar_g_vehicle_raptor_bomblet_force, DEATH_VH_RAPT_BOMB, world);
107 void raptor_bomblet_touch()
109 if(other == self.owner)
113 self.think = raptor_bomblet_boom;
114 self.nextthink = time + random() * autocvar_g_vehicle_raptor_bomblet_explode_delay;
117 void raptor_bomb_burst()
120 if(autocvar_g_vehicle_raptor_bomblet_alt)
122 self.nextthink = time;
123 traceline(self.origin, self.origin + (normalize(self.velocity) * autocvar_g_vehicle_raptor_bomblet_alt), MOVE_NORMAL, self);
124 if((trace_fraction == 1.0) || (vlen(self.origin - self.owner.origin) < autocvar_g_vehicle_raptor_bomblet_radius))
126 UpdateCSQCProjectile(self);
134 Damage_DamageInfo(self.origin, 0, 0, 0, '0 0 0', DEATH_VH_RAPT_FRAGMENT, 0, self);
136 for(i = 0; i < autocvar_g_vehicle_raptor_bomblets; ++i)
139 setorigin(bomblet, self.origin);
141 bomblet.movetype = MOVETYPE_TOSS;
142 bomblet.touch = raptor_bomblet_touch;
143 bomblet.think = raptor_bomblet_boom;
144 bomblet.nextthink = time + 5;
145 bomblet.owner = self.owner;
146 bomblet.realowner = self.realowner;
147 bomblet.velocity = normalize(normalize(self.velocity) + (randomvec() * autocvar_g_vehicle_raptor_bomblet_spread)) * vlen(self.velocity);
149 PROJECTILE_MAKETRIGGER(bomblet);
150 CSQCProjectile(bomblet, TRUE, PROJECTILE_RAPTORBOMBLET, TRUE);
156 void raptor_bombdrop()
158 entity bomb_1, bomb_2;
163 setorigin(bomb_1, gettaginfo(self, gettagindex(self, "bombmount_left")));
164 setorigin(bomb_2, gettaginfo(self, gettagindex(self, "bombmount_right")));
166 bomb_1.movetype = bomb_2.movetype = MOVETYPE_BOUNCE;
167 bomb_1.velocity = bomb_2.velocity = self.velocity;
168 bomb_1.touch = bomb_2.touch = raptor_bomb_burst;
169 bomb_1.think = bomb_2.think = raptor_bomb_burst;
170 bomb_1.cnt = bomb_2.cnt = time + 10;
172 if(autocvar_g_vehicle_raptor_bomblet_alt)
173 bomb_1.nextthink = bomb_2.nextthink = time;
175 bomb_1.nextthink = bomb_2.nextthink = time + autocvar_g_vehicle_raptor_bomblet_time;
177 bomb_1.owner = bomb_2.owner = self;
178 bomb_1.realowner = bomb_2.realowner = self.owner;
179 bomb_1.solid = bomb_2.solid = SOLID_BBOX;
180 bomb_1.gravity = bomb_2.gravity = 1;
182 PROJECTILE_MAKETRIGGER(bomb_1);
183 PROJECTILE_MAKETRIGGER(bomb_2);
185 CSQCProjectile(bomb_1, TRUE, PROJECTILE_RAPTORBOMB, TRUE);
186 CSQCProjectile(bomb_2, TRUE, PROJECTILE_RAPTORBOMB, TRUE);
190 void raptor_fire_cannon(entity gun, string tagname)
192 vehicles_projectile("raptor_cannon_muzzleflash", "weapons/lasergun_fire.wav",
193 gettaginfo(gun, gettagindex(gun, tagname)), normalize(v_forward + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed,
194 autocvar_g_vehicle_raptor_cannon_damage, autocvar_g_vehicle_raptor_cannon_radius, autocvar_g_vehicle_raptor_cannon_force, 0,
195 DEATH_VH_RAPT_CANNON, PROJECTILE_RAPTORCANNON, 0, TRUE, TRUE, self.owner);
202 hgt = raptor_altitude(512);
203 self.velocity = (self.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
204 self.angles_x *= 0.95;
205 self.angles_z *= 0.95;
209 self.frame = (hgt / 128) * 25;
211 self.bomb1.gun1.avelocity_y = 90 + ((self.frame / 25) * 2000);
212 self.bomb1.gun2.avelocity_y = -self.bomb1.gun1.avelocity_y;
216 self.movetype = MOVETYPE_TOSS;
217 self.think = vehicles_think;
221 self.nextthink = time;
223 CSQCMODEL_AUTOUPDATE();
226 void raptor_exit(float eject)
229 self.tur_head.exteriormodeltoclient = world;
231 if(self.deadflag == DEAD_NO)
233 self.think = raptor_land;
234 self.nextthink = time;
240 makevectors(self.angles);
243 spot = self.origin + v_forward * 100 + '0 0 64';
244 spot = vehicles_findgoodexit(spot);
245 setorigin(self.owner , spot);
246 self.owner.velocity = (v_up + v_forward * 0.25) * 750;
247 self.owner.oldvelocity = self.owner.velocity;
251 if(vlen(self.velocity) > 2 * autocvar_sv_maxairspeed)
253 self.owner.velocity = normalize(self.velocity) * autocvar_sv_maxairspeed * 2;
254 self.owner.velocity_z += 200;
255 spot = self.origin + v_forward * 32 + '0 0 64';
256 spot = vehicles_findgoodexit(spot);
260 self.owner.velocity = self.velocity * 0.5;
261 self.owner.velocity_z += 10;
262 spot = self.origin - v_forward * 200 + '0 0 64';
263 spot = vehicles_findgoodexit(spot);
265 self.owner.oldvelocity = self.owner.velocity;
266 setorigin(self.owner , spot);
269 antilag_clear(self.owner);
273 void raptor_flare_touch()
278 void raptor_flare_damage(entity inflictor, entity attacker, float damage, float deathtype, vector hitloc, vector force)
280 self.health -= damage;
285 void raptor_flare_think()
287 self.nextthink = time + 0.1;
288 entity _missile = findchainentity(enemy, self.owner);
291 if(_missile.flags & FL_PROJECTILE)
292 if(vlen(self.origin - _missile.origin) < autocvar_g_vehicle_raptor_flare_range)
293 if(random() > autocvar_g_vehicle_raptor_flare_chase)
294 _missile.enemy = self;
295 _missile = _missile.chain;
298 if(self.tur_impacttime < time)
304 entity player, raptor;
308 if(intermission_running)
310 self.vehicle.velocity = '0 0 0';
315 raptor = self.vehicle;
318 vehicles_painframe();
320 ftmp = vlen(self.velocity);
321 if(ftmp > autocvar_g_vehicle_raptor_speed_forward)
324 ftmp = ftmp / autocvar_g_vehicle_raptor_speed_forward;
327 if(self.sound_nexttime < time)
329 self.sound_nexttime = time + 7.955812;
330 //sound (self.tur_head, CH_TRIGGER_SINGLE, "vehicles/raptor_fly.wav", 1 - ftmp, ATTEN_NORM );
331 sound (self, CH_TRIGGER_SINGLE, "vehicles/raptor_speed.wav", 1, ATTEN_NORM);
335 else if(fabs(ftmp - self.wait) > 0.2)
337 sound (self.tur_head, CH_TRIGGER_SINGLE, "", 1 - ftmp, ATTEN_NORM );
338 sound (self, CH_TRIGGER_SINGLE, "", ftmp, ATTEN_NORM);
343 if(raptor.deadflag != DEAD_NO)
346 player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
349 crosshair_trace(player);
352 vang = raptor.angles;
353 df = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
356 if(df_x > 180) df_x -= 360;
357 if(df_x < -180) df_x += 360;
358 if(df_y > 180) df_y -= 360;
359 if(df_y < -180) df_y += 360;
361 ftmp = shortangle_f(player.v_angle_y - vang_y, vang_y);
362 if(ftmp > 180) ftmp -= 360; if(ftmp < -180) ftmp += 360;
363 raptor.avelocity_y = bound(-autocvar_g_vehicle_raptor_turnspeed, ftmp + raptor.avelocity_y * 0.9, autocvar_g_vehicle_raptor_turnspeed);
367 if(player.movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5;
368 else if(player.movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20;
370 df_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x , autocvar_g_vehicle_raptor_pitchlimit);
371 ftmp = vang_x - bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x + ftmp, autocvar_g_vehicle_raptor_pitchlimit);
372 raptor.avelocity_x = bound(-autocvar_g_vehicle_raptor_pitchspeed, ftmp + raptor.avelocity_x * 0.9, autocvar_g_vehicle_raptor_pitchspeed);
374 raptor.angles_x = anglemods(raptor.angles_x);
375 raptor.angles_y = anglemods(raptor.angles_y);
376 raptor.angles_z = anglemods(raptor.angles_z);
378 if(autocvar_g_vehicle_raptor_movestyle == 1)
379 makevectors('0 1 0' * raptor.angles_y);
381 makevectors(player.v_angle);
383 df = raptor.velocity * -autocvar_g_vehicle_raptor_friction;
385 if(player.movement_x != 0)
387 if(player.movement_x > 0)
388 df += v_forward * autocvar_g_vehicle_raptor_speed_forward;
389 else if(player.movement_x < 0)
390 df -= v_forward * autocvar_g_vehicle_raptor_speed_forward;
393 if(player.movement_y != 0)
395 if(player.movement_y < 0)
396 df -= v_right * autocvar_g_vehicle_raptor_speed_strafe;
397 else if(player.movement_y > 0)
398 df += v_right * autocvar_g_vehicle_raptor_speed_strafe;
400 raptor.angles_z = bound(-30,raptor.angles_z + (player.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
404 raptor.angles_z *= 0.95;
405 if(raptor.angles_z >= -1 && raptor.angles_z <= -1)
409 if(player.BUTTON_CROUCH)
410 df -= v_up * autocvar_g_vehicle_raptor_speed_down;
411 else if (player.BUTTON_JUMP)
412 df += v_up * autocvar_g_vehicle_raptor_speed_up;
414 raptor.velocity += df * frametime;
415 player.velocity = player.movement = raptor.velocity;
416 setorigin(player, raptor.origin + '0 0 32');
418 player.vehicle_weapon2mode = raptor.vehicle_weapon2mode;
421 // Target lock & predict
422 if(autocvar_g_vehicle_raptor_cannon_locktarget == 2)
424 if(raptor.gun1.lock_time < time || raptor.gun1.enemy.deadflag)
425 raptor.gun1.enemy = world;
428 if(trace_ent.movetype)
429 if(trace_ent.takedamage)
430 if(!trace_ent.deadflag)
434 if(trace_ent.team != player.team)
436 raptor.gun1.enemy = trace_ent;
437 raptor.gun1.lock_time = time + 5;
442 raptor.gun1.enemy = trace_ent;
443 raptor.gun1.lock_time = time + 0.5;
447 if(raptor.gun1.enemy)
449 float distance, impact_time;
451 vf = real_origin(raptor.gun1.enemy);
452 UpdateAuxiliaryXhair(player, vf, '1 0 0', 1);
453 vector _vel = raptor.gun1.enemy.velocity;
454 if(raptor.gun1.enemy.movetype == MOVETYPE_WALK)
457 if(autocvar_g_vehicle_raptor_cannon_predicttarget)
460 distance = vlen(ad - player.origin);
461 impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
462 ad = vf + _vel * impact_time;
469 else if(autocvar_g_vehicle_raptor_cannon_locktarget == 1)
472 vehicles_locktarget((1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime,
473 (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * frametime,
474 autocvar_g_vehicle_raptor_cannon_locked_time);
476 if(self.lock_target != world)
477 if(autocvar_g_vehicle_raptor_cannon_predicttarget)
478 if(self.lock_strength == 1)
480 float i, distance, impact_time;
482 vf = real_origin(raptor.lock_target);
484 for(i = 0; i < 4; ++i)
486 distance = vlen(ad - raptor.origin);
487 impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
488 ad = vf + raptor.lock_target.velocity * impact_time;
495 if(raptor.lock_strength == 1)
496 UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '1 0 0', 1);
497 else if(self.lock_strength > 0.5)
498 UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '0 1 0', 1);
499 else if(self.lock_strength < 0.5)
500 UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '0 0 1', 1);
505 vehicle_aimturret(raptor, trace_endpos, raptor.gun1, "fire1",
506 autocvar_g_vehicle_raptor_cannon_pitchlimit_down * -1, autocvar_g_vehicle_raptor_cannon_pitchlimit_up,
507 autocvar_g_vehicle_raptor_cannon_turnlimit * -1, autocvar_g_vehicle_raptor_cannon_turnlimit, autocvar_g_vehicle_raptor_cannon_turnspeed);
509 vehicle_aimturret(raptor, trace_endpos, raptor.gun2, "fire1",
510 autocvar_g_vehicle_raptor_cannon_pitchlimit_down * -1, autocvar_g_vehicle_raptor_cannon_pitchlimit_up,
511 autocvar_g_vehicle_raptor_cannon_turnlimit * -1, autocvar_g_vehicle_raptor_cannon_turnlimit, autocvar_g_vehicle_raptor_cannon_turnspeed);
515 v_forward = vf * 0.5;
516 traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, raptor);
517 UpdateAuxiliaryXhair(player, trace_endpos, '0 1 0', 0);
520 if(!forbidWeaponUse(player))
521 if(player.BUTTON_ATCK)
522 if(raptor.attack_finished_single <= time)
523 if(raptor.vehicle_energy > autocvar_g_vehicle_raptor_cannon_cost)
525 raptor.misc_bulletcounter += 1;
526 raptor.attack_finished_single = time + autocvar_g_vehicle_raptor_cannon_refire;
527 if(raptor.misc_bulletcounter <= 2)
528 raptor_fire_cannon(self.gun1, "fire1");
529 else if(raptor.misc_bulletcounter == 3)
530 raptor_fire_cannon(self.gun2, "fire1");
533 raptor.attack_finished_single = time + autocvar_g_vehicle_raptor_cannon_refire * 2;
534 raptor_fire_cannon(self.gun2, "fire1");
535 raptor.misc_bulletcounter = 0;
537 raptor.vehicle_energy -= autocvar_g_vehicle_raptor_cannon_cost;
541 if(self.vehicle_flags & VHF_SHIELDREGEN)
542 vehicles_regen(raptor.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, TRUE);
544 if(self.vehicle_flags & VHF_HEALTHREGEN)
545 vehicles_regen(raptor.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, FALSE);
547 if(self.vehicle_flags & VHF_ENERGYREGEN)
548 vehicles_regen(raptor.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, FALSE);
550 if(!forbidWeaponUse(player))
551 if(raptor.vehicle_weapon2mode == RSM_BOMB)
553 if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire)
554 if(player.BUTTON_ATCK2)
557 raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
563 if(time > raptor.lip + autocvar_g_vehicle_raptor_flare_refire)
564 if(player.BUTTON_ATCK2)
569 for(i = 0; i < 3; ++i)
572 setmodel(_flare, "models/runematch/rune.mdl");
573 _flare.effects = EF_LOWPRECISION | EF_FLAME;
575 setorigin(_flare, self.origin - '0 0 16');
576 _flare.movetype = MOVETYPE_TOSS;
577 _flare.gravity = 0.15;
578 _flare.velocity = 0.25 * raptor.velocity + (v_forward + randomvec() * 0.25)* -500;
579 _flare.think = raptor_flare_think;
580 _flare.nextthink = time;
581 _flare.owner = raptor;
582 _flare.solid = SOLID_CORPSE;
583 _flare.takedamage = DAMAGE_YES;
584 _flare.event_damage = raptor_flare_damage;
586 _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
587 _flare.touch = raptor_flare_touch;
589 raptor.delay = time + autocvar_g_vehicle_raptor_flare_refire;
594 raptor.bomb1.alpha = raptor.bomb2.alpha = (time - raptor.lip) / (raptor.delay - raptor.lip);
595 player.vehicle_reload2 = bound(0, raptor.bomb1.alpha * 100, 100);
597 if(self.bomb1.cnt < time)
599 entity _missile = findchainentity(enemy, raptor);
600 float _incomming = 0;
603 if(_missile.flags & FL_PROJECTILE)
604 if(MISSILE_IS_TRACKING(_missile))
605 if(vlen(self.origin - _missile.origin) < 2 * autocvar_g_vehicle_raptor_flare_range)
608 _missile = _missile.chain;
612 sound(self, CH_PAIN_SINGLE, "vehicles/missile_alarm.wav", VOL_BASE, ATTEN_NONE);
614 self.bomb1.cnt = time + 1;
618 VEHICLE_UPDATE_PLAYER(player, health, raptor);
619 VEHICLE_UPDATE_PLAYER(player, energy, raptor);
620 if(self.vehicle_flags & VHF_HASSHIELD)
621 VEHICLE_UPDATE_PLAYER(player, shield, raptor);
623 player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
629 float raptor_takeoff()
631 entity player, raptor;
634 raptor = self.vehicle;
637 self.nextthink = time;
638 CSQCMODEL_AUTOUPDATE();
639 self.nextthink = 0; // will this work?
641 if(self.sound_nexttime < time)
643 self.sound_nexttime = time + 7.955812; //soundlength("vehicles/raptor_fly.wav");
644 sound (self, CH_TRIGGER_SINGLE, "vehicles/raptor_speed.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
648 if(raptor.frame < 25)
650 raptor.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / sys_frametime);
651 raptor.velocity_z = min(raptor.velocity_z * 1.5, 256);
652 self.bomb1.gun1.avelocity_y = 90 + ((raptor.frame / 25) * 25000);
653 self.bomb1.gun2.avelocity_y = -self.bomb1.gun1.avelocity_y;
654 player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
656 setorigin(player, raptor.origin + '0 0 32');
659 player.PlayerPhysplug = raptor_frame;
661 if(self.vehicle_flags & VHF_SHIELDREGEN)
662 vehicles_regen(raptor.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, TRUE);
664 if(self.vehicle_flags & VHF_HEALTHREGEN)
665 vehicles_regen(raptor.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, FALSE);
667 if(self.vehicle_flags & VHF_ENERGYREGEN)
668 vehicles_regen(raptor.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, FALSE);
671 raptor.bomb1.alpha = raptor.bomb2.alpha = (time - raptor.lip) / (raptor.delay - raptor.lip);
672 player.vehicle_reload2 = bound(0, raptor.bomb1.alpha * 100, 100);
674 VEHICLE_UPDATE_PLAYER(player, health, raptor);
675 VEHICLE_UPDATE_PLAYER(player, energy, raptor);
676 if(self.vehicle_flags & VHF_HASSHIELD)
677 VEHICLE_UPDATE_PLAYER(player, shield, raptor);
679 player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
686 self.deadflag = DEAD_DEAD;
687 self.vehicle_exit(VHEF_NORMAL);
688 RadiusDamage (self, self.enemy, 250, 15, 250, world, 250, DEATH_VH_RAPT_DEATH, world);
691 self.movetype = MOVETYPE_NONE;
692 self.effects = EF_NODRAW;
693 self.colormod = '0 0 0';
694 self.avelocity = '0 0 0';
695 self.velocity = '0 0 0';
697 setorigin(self, self.pos1);
698 self.touch = func_null;
702 void raptor_diethink()
704 if(time >= self.wait)
705 self.think = raptor_blowup;
709 sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
710 pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
712 self.nextthink = time;
714 CSQCMODEL_AUTOUPDATE();
717 // If we dont do this ever now and then, the raptors rotors
718 // stop working, presumably due to angle overflow. cute.
719 void raptor_rotor_anglefix()
721 self.gun1.angles_y = anglemods(self.gun1.angles_y);
722 self.gun2.angles_y = anglemods(self.gun2.angles_y);
723 self.nextthink = time + 15;
726 float raptor_impulse(float _imp)
733 self.vehicle.vehicle_weapon2mode += 1;
734 if(self.vehicle.vehicle_weapon2mode > RSM_LAST)
735 self.vehicle.vehicle_weapon2mode = RSM_FIRST;
737 CSQCVehicleSetup(self, 0);
742 self.vehicle.vehicle_weapon2mode -= 1;
743 if(self.vehicle.vehicle_weapon2mode < RSM_FIRST)
744 self.vehicle.vehicle_weapon2mode = RSM_LAST;
746 CSQCVehicleSetup(self, 0);
750 case 17: // toss gun, could be used to exit?
752 case 20: // Manual minigun reload?
759 void spawnfunc_vehicle_raptor()
761 if(!autocvar_g_vehicle_raptor) { remove(self); return; }
762 if(!vehicle_initialize(VEH_RAPTOR, FALSE)) { remove(self); return; }
765 float v_raptor(float req)
771 if(autocvar_g_vehicle_raptor_bouncepain)
772 vehicles_impact(autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z);
778 self.vehicle_weapon2mode = RSM_BOMB;
779 self.owner.PlayerPhysplug = raptor_takeoff;
780 self.movetype = MOVETYPE_BOUNCEMISSILE;
781 self.solid = SOLID_SLIDEBOX;
782 self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_raptor_health) * 100;
783 self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100;
784 self.velocity_z = 1; // Nudge upwards to takeoff sequense can work.
785 self.tur_head.exteriormodeltoclient = self.owner;
787 self.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
790 if(self.owner.flagcarried)
791 setorigin(self.owner.flagcarried, '-20 0 96');
793 CSQCVehicleSetup(self.owner, 0);
803 self.event_damage = func_null;
804 self.solid = SOLID_CORPSE;
805 self.takedamage = DAMAGE_NO;
806 self.deadflag = DEAD_DYING;
807 self.movetype = MOVETYPE_BOUNCE;
808 self.think = raptor_diethink;
809 self.nextthink = time;
810 self.wait = time + 5 + (random() * 5);
812 pointparticles(particleeffectnum("explosion_medium"), findbetterlocation (self.origin, 16), '0 0 0', 1);
814 self.velocity_z += 600;
816 self.avelocity = '0 0.5 1' * (random() * 400);
817 self.avelocity -= '0 0.5 1' * (random() * 400);
819 self.colormod = '-0.5 -0.5 -0.5';
820 self.touch = raptor_blowup;
830 //FIXME: Camera is in a bad place in HUD model.
831 //setorigin(self.vehicle_viewport, '25 0 5');
833 self.vehicles_impulse = raptor_impulse;
837 self.bomb1 = spawn();
838 self.bomb2 = spawn();
842 setmodel(self.bomb1,"models/vehicles/clusterbomb_folded.md3");
843 setmodel(self.bomb2,"models/vehicles/clusterbomb_folded.md3");
844 setmodel(self.gun1, "models/vehicles/raptor_gun.dpm");
845 setmodel(self.gun2, "models/vehicles/raptor_gun.dpm");
846 setmodel(self.tur_head, "models/vehicles/raptor_body.dpm");
848 setattachment(self.bomb1, self, "bombmount_left");
849 setattachment(self.bomb2, self, "bombmount_right");
850 setattachment(self.tur_head, self,"root");
852 // FIXMODEL Guns mounts to angled bones
853 self.bomb1.angles = self.angles;
854 self.angles = '0 0 0';
855 // This messes up gun-aim, so work arround it.
856 //setattachment(self.gun1, self, "gunmount_left");
857 ofs = gettaginfo(self, gettagindex(self, "gunmount_left"));
859 setattachment(self.gun1, self, "");
860 setorigin(self.gun1, ofs);
862 //setattachment(self.gun2, self, "gunmount_right");
863 ofs = gettaginfo(self, gettagindex(self, "gunmount_right"));
865 setattachment(self.gun2, self, "");
866 setorigin(self.gun2, ofs);
868 self.angles = self.bomb1.angles;
869 self.bomb1.angles = '0 0 0';
872 spinner.owner = self;
873 setmodel(spinner,"models/vehicles/spinner.dpm");
874 setattachment(spinner, self, "engine_left");
875 spinner.movetype = MOVETYPE_NOCLIP;
876 spinner.avelocity = '0 90 0';
877 self.bomb1.gun1 = spinner;
880 spinner.owner = self;
881 setmodel(spinner,"models/vehicles/spinner.dpm");
882 setattachment(spinner, self, "engine_right");
883 spinner.movetype = MOVETYPE_NOCLIP;
884 spinner.avelocity = '0 -90 0';
885 self.bomb1.gun2 = spinner;
888 self.bomb1.think = raptor_rotor_anglefix;
889 self.bomb1.nextthink = time;
895 self.vehicle_health = autocvar_g_vehicle_raptor_health;
896 self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
897 self.movetype = MOVETYPE_TOSS;
898 self.solid = SOLID_SLIDEBOX;
899 self.vehicle_energy = 1;
901 self.PlayerPhysplug = raptor_frame;
903 self.bomb1.gun1.avelocity_y = 90;
904 self.bomb1.gun2.avelocity_y = -90;
908 self.bouncefactor = autocvar_g_vehicle_raptor_bouncefactor;
909 self.bouncestop = autocvar_g_vehicle_raptor_bouncestop;
910 self.damageforcescale = 0.25;
911 self.vehicle_health = autocvar_g_vehicle_raptor_health;
912 self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
917 if(autocvar_g_vehicle_raptor_shield)
918 self.vehicle_flags |= VHF_HASSHIELD;
920 if(autocvar_g_vehicle_raptor_shield_regen)
921 self.vehicle_flags |= VHF_SHIELDREGEN;
923 if(autocvar_g_vehicle_raptor_health_regen)
924 self.vehicle_flags |= VHF_HEALTHREGEN;
926 if(autocvar_g_vehicle_raptor_energy_regen)
927 self.vehicle_flags |= VHF_ENERGYREGEN;
929 self.vehicle_exit = raptor_exit;
930 self.respawntime = autocvar_g_vehicle_raptor_respawntime;
931 self.vehicle_health = autocvar_g_vehicle_raptor_health;
932 self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
933 self.max_health = self.vehicle_health;
939 precache_model ("models/vehicles/raptor.dpm");
940 precache_model ("models/vehicles/raptor_gun.dpm");
941 precache_model ("models/vehicles/spinner.dpm");
942 precache_model ("models/vehicles/raptor_cockpit.dpm");
943 precache_model ("models/vehicles/clusterbomb_folded.md3");
944 precache_model ("models/vehicles/raptor_body.dpm");
946 precache_sound ("vehicles/raptor_fly.wav");
947 precache_sound ("vehicles/raptor_speed.wav");
948 precache_sound ("vehicles/missile_alarm.wav");
959 #define raptor_ico "gfx/vehicles/raptor.tga"
960 #define raptor_gun "gfx/vehicles/raptor_guns.tga"
961 #define raptor_bomb "gfx/vehicles/raptor_bombs.tga"
962 #define raptor_drop "gfx/vehicles/axh-dropcross.tga"
964 float v_raptor(float req)
970 if(autocvar_r_letterbox)
973 vector picsize, hudloc = '0 0 0', pic2size, picloc;
976 // Fetch health & ammo stats
979 picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
980 hudloc_y = vid_conheight - picsize_y;
981 hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
983 drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
990 reload1 = reload2 * 0.01;
993 pic2size = draw_getimagesize(raptor_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
994 picloc = picsize * 0.5 - pic2size * 0.5;
996 drawpic(hudloc + picloc, raptor_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
998 drawpic(hudloc + picloc, raptor_ico, pic2size, '1 1 1' * vh_health + '1 0 0' * (1 - vh_health), 1, DRAWFLAG_NORMAL);
999 drawpic(hudloc + picloc, raptor_bomb, pic2size, '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
1000 drawpic(hudloc + picloc, raptor_gun, pic2size, '1 1 1' * energy + '1 0 0' * (1 - energy), 1, DRAWFLAG_NORMAL);
1001 drawpic(hudloc + picloc, hud_sh, pic2size, '1 1 1', shield, DRAWFLAG_NORMAL);
1004 picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
1005 picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
1006 drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
1007 drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
1008 drawresetcliparea();
1010 picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
1011 picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
1012 if(vh_health < 0.25)
1014 if(alarm1time < time)
1016 alarm1time = time + 2;
1017 vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
1020 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1024 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1027 vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
1033 picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
1034 picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
1035 drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
1036 drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1037 drawresetcliparea();
1039 picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
1040 picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
1043 if(alarm2time < time)
1045 alarm2time = time + 1;
1046 vehicle_alarm(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav");
1048 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1052 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1055 vehicle_alarm(self, CH_TRIGGER_SINGLE, "misc/null.wav");
1061 picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
1062 picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
1063 drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
1064 drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1065 drawresetcliparea();
1067 picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
1068 picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
1070 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1072 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1075 picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
1076 picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
1077 drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
1078 drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1079 drawresetcliparea();
1081 pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1082 picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
1084 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1086 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
1088 if(getstati(STAT_VEHICLESTAT_W2MODE) == RSM_FLARE)
1090 raptor_xhair = "gfx/vehicles/axh-bracket.tga";
1094 raptor_xhair = "gfx/vehicles/axh-ring.tga";
1096 // Bombing crosshair
1100 dropmark.owner = self;
1101 dropmark.gravity = 1;
1108 setorigin(dropmark, pmove_org);
1109 dropmark.velocity = pmove_vel;
1110 tracetoss(dropmark, self);
1112 where = project_3d_to_2d(trace_endpos);
1114 setorigin(dropmark, trace_endpos);
1115 picsize = draw_getimagesize(raptor_drop) * 0.2;
1117 if(!(where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight))
1119 where_x -= picsize_x * 0.5;
1120 where_y -= picsize_y * 0.5;
1122 drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
1124 dropmark.cnt = time + 5;
1129 if(dropmark.cnt > time)
1131 where = project_3d_to_2d(dropmark.origin);
1132 picsize = draw_getimagesize(raptor_drop) * 0.25;
1134 if(!(where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight))
1136 where_x -= picsize_x * 0.5;
1137 where_y -= picsize_y * 0.5;
1139 drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
1145 if (scoreboard_showscores)
1146 HUD_DrawScoreboard();
1149 picsize = draw_getimagesize(raptor_xhair);
1153 drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), raptor_xhair, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1160 AuxiliaryXhair[0].axh_image = "gfx/vehicles/axh-special2.tga";
1161 AuxiliaryXhair[0].axh_scale = 0.5;
1163 AuxiliaryXhair[1].axh_image = "gfx/vehicles/axh-bracket.tga";
1164 AuxiliaryXhair[1].axh_scale = 0.25;
1169 precache_model ("models/vehicles/raptor.dpm");
1170 precache_model ("models/vehicles/raptor_gun.dpm");
1171 precache_model ("models/vehicles/spinner.dpm");
1172 precache_model ("models/vehicles/raptor_cockpit.dpm");
1173 precache_model ("models/vehicles/clusterbomb_folded.md3");
1174 precache_model ("models/vehicles/raptor_body.dpm");
1184 #endif // REGISTER_VEHICLE