137bdccabfee0f965dcce6156b6bf05517efd288
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / unit / raptor.qc
1 #ifdef REGISTER_VEHICLE
2 REGISTER_VEHICLE(
3 /* VEH_##id   */ RAPTOR,
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",
8 /* head_model */ "",
9 /* hud_model  */ "models/vehicles/raptor_cockpit.dpm",
10 /* tags           */ "", "tag_hud", "tag_camera",
11 /* netname        */ "raptor",
12 /* fullname   */ _("Raptor")
13 );
14 #else
15
16 const int RSM_FIRST = 1;
17 const int RSM_BOMB = 1;
18 const int RSM_FLARE = 2;
19 const int RSM_LAST = 2;
20
21 #ifdef SVQC
22 bool autocvar_g_vehicle_raptor;
23
24 float autocvar_g_vehicle_raptor_respawntime;
25 float autocvar_g_vehicle_raptor_takeofftime;
26
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;
31
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;
37
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;
48
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;
53
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;
58
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;
64
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;
72
73 float autocvar_g_vehicle_raptor_energy;
74 float autocvar_g_vehicle_raptor_energy_regen;
75 float autocvar_g_vehicle_raptor_energy_regen_pause;
76
77 float autocvar_g_vehicle_raptor_health;
78 float autocvar_g_vehicle_raptor_health_regen;
79 float autocvar_g_vehicle_raptor_health_regen_pause;
80
81 float autocvar_g_vehicle_raptor_shield;
82 float autocvar_g_vehicle_raptor_shield_regen;
83 float autocvar_g_vehicle_raptor_shield_regen_pause;
84
85 float autocvar_g_vehicle_raptor_bouncefactor;
86 float autocvar_g_vehicle_raptor_bouncestop;
87 vector autocvar_g_vehicle_raptor_bouncepain;
88
89 .entity bomb1;
90 .entity bomb2;
91
92 float raptor_altitude(float amax)
93 {
94         tracebox(self.origin, self.mins, self.maxs, self.origin - ('0 0 1' * amax), MOVE_WORLDONLY, self);
95         return vlen(self.origin - trace_endpos);
96 }
97
98 void raptor_bomblet_boom()
99 {
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, world,
103                                                                         autocvar_g_vehicle_raptor_bomblet_force, DEATH_VH_RAPT_BOMB, world);
104         remove(self);
105 }
106
107 void raptor_bomblet_touch()
108 {
109         if(other == self.owner)
110                 return;
111
112         PROJECTILE_TOUCH;
113         self.think = raptor_bomblet_boom;
114         self.nextthink = time + random() * autocvar_g_vehicle_raptor_bomblet_explode_delay;
115 }
116
117 void raptor_bomb_burst()
118 {
119         if(self.cnt > time)
120         if(autocvar_g_vehicle_raptor_bomblet_alt)
121         {
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))
125                 {
126                         UpdateCSQCProjectile(self);
127                         return;
128                 }
129         }
130
131         entity bomblet;
132         float i;
133
134         Damage_DamageInfo(self.origin, 0, 0, 0, '0 0 0', DEATH_VH_RAPT_FRAGMENT, 0, self);
135
136         for(i = 0; i < autocvar_g_vehicle_raptor_bomblets; ++i)
137         {
138                 bomblet = spawn();
139                 setorigin(bomblet, self.origin);
140
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);
148
149                 PROJECTILE_MAKETRIGGER(bomblet);
150                 CSQCProjectile(bomblet, true, PROJECTILE_RAPTORBOMBLET, true);
151         }
152
153         remove(self);
154 }
155
156 void raptor_bombdrop()
157 {
158         entity bomb_1, bomb_2;
159
160         bomb_1 = spawn();
161         bomb_2 = spawn();
162
163         setorigin(bomb_1, gettaginfo(self, gettagindex(self, "bombmount_left")));
164         setorigin(bomb_2, gettaginfo(self, gettagindex(self, "bombmount_right")));
165
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;
171
172         if(autocvar_g_vehicle_raptor_bomblet_alt)
173                 bomb_1.nextthink = bomb_2.nextthink  = time;
174         else
175                 bomb_1.nextthink = bomb_2.nextthink  = time + autocvar_g_vehicle_raptor_bomblet_time;
176
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;
181
182         PROJECTILE_MAKETRIGGER(bomb_1);
183         PROJECTILE_MAKETRIGGER(bomb_2);
184
185         CSQCProjectile(bomb_1, true, PROJECTILE_RAPTORBOMB, true);
186         CSQCProjectile(bomb_2, true, PROJECTILE_RAPTORBOMB, true);
187 }
188
189
190 void raptor_fire_cannon(entity gun, string tagname)
191 {
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);
196 }
197
198 void raptor_land()
199 {
200         float hgt;
201
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;
206
207         if(hgt < 128)
208         if(hgt > 0)
209                 self.frame = (hgt / 128) * 25;
210
211         self.bomb1.gun1.avelocity_y = 90 + ((self.frame / 25) * 2000);
212         self.bomb1.gun2.avelocity_y = -self.bomb1.gun1.avelocity_y;
213
214         if(hgt < 16)
215         {
216                 self.movetype = MOVETYPE_TOSS;
217                 self.think      = vehicles_think;
218                 self.frame      = 0;
219         }
220
221         self.nextthink  = time;
222         
223         CSQCMODEL_AUTOUPDATE();
224 }
225
226 void raptor_exit(float eject)
227 {
228         vector spot;
229         self.tur_head.exteriormodeltoclient = world;
230
231         if(self.deadflag == DEAD_NO)
232         {
233                 self.think        = raptor_land;
234                 self.nextthink  = time;
235         }
236
237         if(!self.owner)
238                 return;
239
240         makevectors(self.angles);
241         if(eject)
242         {
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;
248         }
249         else
250         {
251                 if(vlen(self.velocity) > 2 * autocvar_sv_maxairspeed)
252                 {
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);
257                 }
258                 else
259                 {
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);
264                 }
265                 self.owner.oldvelocity = self.owner.velocity;
266                 setorigin(self.owner , spot);
267         }
268
269         antilag_clear(self.owner);
270         self.owner = world;
271 }
272
273 void raptor_flare_touch()
274 {
275         remove(self);
276 }
277
278 void raptor_flare_damage(entity inflictor, entity attacker, float damage, int deathtype, vector hitloc, vector force)
279 {
280         self.health -= damage;
281         if(self.health <= 0)
282                 remove(self);
283 }
284
285 void raptor_flare_think()
286 {
287         self.nextthink = time + 0.1;
288         entity _missile = findchainentity(enemy, self.owner);
289         while(_missile)
290         {
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;
296         }
297
298         if(self.tur_impacttime < time)
299                 remove(self);
300 }
301
302 float raptor_frame()
303 {
304         entity player, raptor;
305         float ftmp = 0;
306         vector df;
307
308         if(intermission_running)
309         {
310                 self.vehicle.velocity = '0 0 0';
311                 self.vehicle.avelocity = '0 0 0';
312                 return 1;
313         }
314
315         player = self;
316         raptor = self.vehicle;
317         self   = raptor;
318         
319         vehicles_painframe();
320         /*
321         ftmp = vlen(self.velocity);
322         if(ftmp > autocvar_g_vehicle_raptor_speed_forward)
323                 ftmp = 1;
324         else
325                 ftmp = ftmp / autocvar_g_vehicle_raptor_speed_forward;
326         */
327
328         if(self.sound_nexttime < time)
329         {
330                 self.sound_nexttime = time + 7.955812;
331                 //sound (self.tur_head, CH_TRIGGER_SINGLE, "vehicles/raptor_fly.wav", 1 - ftmp,   ATTEN_NORM );
332                 sound (self, CH_TRIGGER_SINGLE, "vehicles/raptor_speed.wav", 1, ATTEN_NORM);
333                 self.wait = ftmp;
334         }
335         /*
336         else if(fabs(ftmp - self.wait) > 0.2)
337         {
338                 sound (self.tur_head, CH_TRIGGER_SINGLE, "", 1 - ftmp,   ATTEN_NORM );
339                 sound (self, CH_TRIGGER_SINGLE, "", ftmp, ATTEN_NORM);
340                 self.wait = ftmp;
341         }
342         */
343
344         if(raptor.deadflag != DEAD_NO)
345         {
346                 self = player;
347                 player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
348                 return 1;
349         }
350         crosshair_trace(player);
351
352         vector vang;
353         vang = raptor.angles;
354         df = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
355         vang_x *= -1;
356         df_x *= -1;
357         if(df_x > 180)  df_x -= 360;
358         if(df_x < -180) df_x += 360;
359         if(df_y > 180)  df_y -= 360;
360         if(df_y < -180) df_y += 360;
361
362         ftmp = shortangle_f(player.v_angle_y - vang_y, vang_y);
363         if(ftmp > 180)  ftmp -= 360; if(ftmp < -180) ftmp += 360;
364         raptor.avelocity_y = bound(-autocvar_g_vehicle_raptor_turnspeed, ftmp + raptor.avelocity_y * 0.9, autocvar_g_vehicle_raptor_turnspeed);
365
366         // Pitch
367         ftmp = 0;
368         if(player.movement_x > 0 && vang_x < autocvar_g_vehicle_raptor_pitchlimit) ftmp = 5;
369         else if(player.movement_x < 0 && vang_x > -autocvar_g_vehicle_raptor_pitchlimit) ftmp = -20;
370
371         df_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x , autocvar_g_vehicle_raptor_pitchlimit);
372         ftmp = vang_x - bound(-autocvar_g_vehicle_raptor_pitchlimit, df_x + ftmp, autocvar_g_vehicle_raptor_pitchlimit);
373         raptor.avelocity_x = bound(-autocvar_g_vehicle_raptor_pitchspeed, ftmp + raptor.avelocity_x * 0.9, autocvar_g_vehicle_raptor_pitchspeed);
374
375         raptor.angles_x = anglemods(raptor.angles_x);
376         raptor.angles_y = anglemods(raptor.angles_y);
377         raptor.angles_z = anglemods(raptor.angles_z);
378
379         if(autocvar_g_vehicle_raptor_movestyle == 1)
380                 makevectors('0 1 0' * raptor.angles_y);
381         else
382                 makevectors(player.v_angle);
383
384         df = raptor.velocity * -autocvar_g_vehicle_raptor_friction;
385
386         if(player.movement_x != 0)
387         {
388                 if(player.movement_x > 0)
389                         df += v_forward  * autocvar_g_vehicle_raptor_speed_forward;
390                 else if(player.movement_x < 0)
391                         df -= v_forward  * autocvar_g_vehicle_raptor_speed_forward;
392         }
393
394         if(player.movement_y != 0)
395         {
396                 if(player.movement_y < 0)
397                         df -= v_right * autocvar_g_vehicle_raptor_speed_strafe;
398                 else if(player.movement_y > 0)
399                         df += v_right * autocvar_g_vehicle_raptor_speed_strafe;
400
401                 raptor.angles_z = bound(-30,raptor.angles_z + (player.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
402         }
403         else
404         {
405                 raptor.angles_z *= 0.95;
406                 if(raptor.angles_z >= -1 && raptor.angles_z <= -1)
407                         raptor.angles_z = 0;
408         }
409
410         if(player.BUTTON_CROUCH)
411                 df -=   v_up * autocvar_g_vehicle_raptor_speed_down;
412         else if (player.BUTTON_JUMP)
413                 df +=  v_up * autocvar_g_vehicle_raptor_speed_up;
414
415         raptor.velocity  += df * frametime;
416         player.velocity = player.movement  = raptor.velocity;
417         setorigin(player, raptor.origin + '0 0 32');
418
419         player.vehicle_weapon2mode = raptor.vehicle_weapon2mode;
420
421         vector vf, ad;
422         // Target lock & predict
423         if(autocvar_g_vehicle_raptor_cannon_locktarget == 2)
424         {
425                 if(raptor.gun1.lock_time < time || raptor.gun1.enemy.deadflag)
426                         raptor.gun1.enemy = world;
427
428                 if(trace_ent)
429                 if(trace_ent.movetype)
430                 if(trace_ent.takedamage)
431                 if(!trace_ent.deadflag)
432                 {
433                         if(teamplay)
434                         {
435                                 if(trace_ent.team != player.team)
436                                 {
437                                         raptor.gun1.enemy = trace_ent;
438                                         raptor.gun1.lock_time = time + 5;
439                                 }
440                         }
441                         else
442                         {
443                                 raptor.gun1.enemy = trace_ent;
444                                 raptor.gun1.lock_time = time + 0.5;
445                         }
446                 }
447
448                 if(raptor.gun1.enemy)
449                 {
450                         float distance, impact_time;
451
452                         vf = real_origin(raptor.gun1.enemy);
453                         UpdateAuxiliaryXhair(player, vf, '1 0 0', 1);
454                         vector _vel = raptor.gun1.enemy.velocity;
455                         if(raptor.gun1.enemy.movetype == MOVETYPE_WALK)
456                                 _vel_z *= 0.1;
457
458                         if(autocvar_g_vehicle_raptor_cannon_predicttarget)
459                         {
460                                 ad = vf;
461                                 distance = vlen(ad - player.origin);
462                                 impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
463                                 ad = vf + _vel * impact_time;
464                                 trace_endpos = ad;
465                         }
466                         else
467                                 trace_endpos = vf;
468                 }
469         }
470         else if(autocvar_g_vehicle_raptor_cannon_locktarget == 1)
471         {
472
473                 vehicles_locktarget((1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime,
474                                                          (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * frametime,
475                                                          autocvar_g_vehicle_raptor_cannon_locked_time);
476
477                 if(self.lock_target != world)
478                 if(autocvar_g_vehicle_raptor_cannon_predicttarget)
479                 if(self.lock_strength == 1)
480                 {
481                         float i, distance, impact_time;
482
483                         vf = real_origin(raptor.lock_target);
484                         ad = vf;
485                         for(i = 0; i < 4; ++i)
486                         {
487                                 distance = vlen(ad - raptor.origin);
488                                 impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
489                                 ad = vf + raptor.lock_target.velocity * impact_time;
490                         }
491                         trace_endpos = ad;
492                 }
493
494                 if(self.lock_target)
495                 {
496                         if(raptor.lock_strength == 1)
497                                 UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '1 0 0', 1);
498                         else if(self.lock_strength > 0.5)
499                                 UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '0 1 0', 1);
500                         else if(self.lock_strength < 0.5)
501                                 UpdateAuxiliaryXhair(player, real_origin(raptor.lock_target), '0 0 1', 1);
502                 }
503         }
504
505
506         vehicle_aimturret(raptor, trace_endpos, raptor.gun1, "fire1",
507                                                   autocvar_g_vehicle_raptor_cannon_pitchlimit_down * -1,  autocvar_g_vehicle_raptor_cannon_pitchlimit_up,
508                                                   autocvar_g_vehicle_raptor_cannon_turnlimit * -1,  autocvar_g_vehicle_raptor_cannon_turnlimit,  autocvar_g_vehicle_raptor_cannon_turnspeed);
509
510         vehicle_aimturret(raptor, trace_endpos, raptor.gun2, "fire1",
511                                                   autocvar_g_vehicle_raptor_cannon_pitchlimit_down * -1,  autocvar_g_vehicle_raptor_cannon_pitchlimit_up,
512                                                   autocvar_g_vehicle_raptor_cannon_turnlimit * -1,  autocvar_g_vehicle_raptor_cannon_turnlimit,  autocvar_g_vehicle_raptor_cannon_turnspeed);
513
514         /*
515         ad = ad * 0.5;
516         v_forward = vf * 0.5;
517         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, raptor);
518         UpdateAuxiliaryXhair(player, trace_endpos, '0 1 0', 0);
519         */
520
521         if(!forbidWeaponUse(player))
522         if(player.BUTTON_ATCK)
523         if(raptor.attack_finished_single <= time)
524         if(raptor.vehicle_energy > autocvar_g_vehicle_raptor_cannon_cost)
525         {
526                 raptor.misc_bulletcounter += 1;
527                 raptor.attack_finished_single = time + autocvar_g_vehicle_raptor_cannon_refire;
528                 if(raptor.misc_bulletcounter <= 2)
529                         raptor_fire_cannon(self.gun1, "fire1");
530                 else if(raptor.misc_bulletcounter == 3)
531                         raptor_fire_cannon(self.gun2, "fire1");
532                 else
533                 {
534                         raptor.attack_finished_single = time + autocvar_g_vehicle_raptor_cannon_refire * 2;
535                         raptor_fire_cannon(self.gun2, "fire1");
536                         raptor.misc_bulletcounter = 0;
537                 }
538                 raptor.vehicle_energy -= autocvar_g_vehicle_raptor_cannon_cost;
539                 self.cnt = time;
540         }
541
542         if(self.vehicle_flags  & VHF_SHIELDREGEN)
543                 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
545         if(self.vehicle_flags  & VHF_HEALTHREGEN)
546                 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
548         if(self.vehicle_flags  & VHF_ENERGYREGEN)
549                 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
551         if(!forbidWeaponUse(player))
552         if(raptor.vehicle_weapon2mode == RSM_BOMB)
553         {
554                 if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire)
555                 if(player.BUTTON_ATCK2)
556                 {
557                         raptor_bombdrop();
558                         raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
559                         raptor.lip   = time;
560                 }
561         }
562         else
563         {
564                 if(time > raptor.lip + autocvar_g_vehicle_raptor_flare_refire)
565                 if(player.BUTTON_ATCK2)
566                 {
567                         float i;
568                         entity _flare;
569
570                         for(i = 0; i < 3; ++i)
571                         {
572                         _flare = spawn();
573                         setmodel(_flare, "models/runematch/rune.mdl");
574                         _flare.effects = EF_LOWPRECISION | EF_FLAME;
575                         _flare.scale = 0.5;
576                         setorigin(_flare, self.origin - '0 0 16');
577                         _flare.movetype = MOVETYPE_TOSS;
578                         _flare.gravity = 0.15;
579                         _flare.velocity = 0.25 * raptor.velocity + (v_forward + randomvec() * 0.25)* -500;
580                         _flare.think = raptor_flare_think;
581                         _flare.nextthink = time;
582                         _flare.owner = raptor;
583                         _flare.solid = SOLID_CORPSE;
584                         _flare.takedamage = DAMAGE_YES;
585                         _flare.event_damage = raptor_flare_damage;
586                         _flare.health = 20;
587                         _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
588                         _flare.touch = raptor_flare_touch;
589                         }
590                         raptor.delay = time + autocvar_g_vehicle_raptor_flare_refire;
591                         raptor.lip   = time;
592                 }
593         }
594
595         raptor.bomb1.alpha = raptor.bomb2.alpha = (time - raptor.lip) / (raptor.delay - raptor.lip);
596         player.vehicle_reload2 = bound(0, raptor.bomb1.alpha * 100, 100);
597
598         if(self.bomb1.cnt < time)
599         {
600                 entity _missile = findchainentity(enemy, raptor);
601                 float _incomming = 0;
602                 while(_missile)
603                 {
604                         if(_missile.flags & FL_PROJECTILE)
605                         if(MISSILE_IS_TRACKING(_missile))
606                         if(vlen(self.origin - _missile.origin) < 2 * autocvar_g_vehicle_raptor_flare_range)
607                                 ++_incomming;
608
609                         _missile = _missile.chain;
610                 }
611
612                 if(_incomming)
613                         sound(self, CH_PAIN_SINGLE, "vehicles/missile_alarm.wav", VOL_BASE, ATTEN_NONE);
614
615                 self.bomb1.cnt = time + 1;
616         }
617
618
619         VEHICLE_UPDATE_PLAYER(player, health, raptor);
620         VEHICLE_UPDATE_PLAYER(player, energy, raptor);
621         if(self.vehicle_flags & VHF_HASSHIELD)
622                 VEHICLE_UPDATE_PLAYER(player, shield, raptor);
623
624         player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
625
626         self = player;
627         return 1;
628 }
629
630 float raptor_takeoff()
631 {
632         entity player, raptor;
633
634         player = self;
635         raptor = self.vehicle;
636         self   = raptor;
637         
638         self.nextthink = time;
639         CSQCMODEL_AUTOUPDATE();
640         self.nextthink = 0; // will this work?
641         
642         if(self.sound_nexttime < time)
643         {
644                 self.sound_nexttime = time + 7.955812; //soundlength("vehicles/raptor_fly.wav");
645                 sound (self, CH_TRIGGER_SINGLE, "vehicles/raptor_speed.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
646         }
647
648         // Takeoff sequense
649         if(raptor.frame < 25)
650         {
651                 raptor.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / sys_frametime);
652                 raptor.velocity_z = min(raptor.velocity_z * 1.5, 256);
653                 self.bomb1.gun1.avelocity_y = 90 + ((raptor.frame / 25) * 25000);
654                 self.bomb1.gun2.avelocity_y = -self.bomb1.gun1.avelocity_y;
655                 player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
656
657                 setorigin(player, raptor.origin + '0 0 32');
658         }
659         else
660                 player.PlayerPhysplug = raptor_frame;
661
662         if(self.vehicle_flags  & VHF_SHIELDREGEN)
663                 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
665         if(self.vehicle_flags  & VHF_HEALTHREGEN)
666                 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
668         if(self.vehicle_flags  & VHF_ENERGYREGEN)
669                 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);
670
671
672         raptor.bomb1.alpha = raptor.bomb2.alpha = (time - raptor.lip) / (raptor.delay - raptor.lip);
673         player.vehicle_reload2 = bound(0, raptor.bomb1.alpha * 100, 100);
674
675         VEHICLE_UPDATE_PLAYER(player, health, raptor);
676         VEHICLE_UPDATE_PLAYER(player, energy, raptor);
677         if(self.vehicle_flags & VHF_HASSHIELD)
678                 VEHICLE_UPDATE_PLAYER(player, shield, raptor);
679
680         player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
681         self = player;
682         return 1;
683 }
684
685 void raptor_blowup()
686 {
687         self.deadflag   = DEAD_DEAD;
688         self.vehicle_exit(VHEF_NORMAL);
689         RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_RAPT_DEATH, world);
690
691         self.alpha                = -1;
692         self.movetype      = MOVETYPE_NONE;
693         self.effects            = EF_NODRAW;
694         self.colormod      = '0 0 0';
695         self.avelocity    = '0 0 0';
696         self.velocity      = '0 0 0';
697
698         setorigin(self, self.pos1);
699         self.touch = func_null;
700         self.nextthink = 0;
701 }
702
703 void raptor_diethink()
704 {
705         if(time >= self.wait)
706                 self.think = raptor_blowup;
707
708         if(random() < 0.05)
709         {
710                 sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
711                 pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
712         }
713         self.nextthink = time;
714         
715         CSQCMODEL_AUTOUPDATE();
716 }
717
718 // If we dont do this ever now and then, the raptors rotors
719 // stop working, presumably due to angle overflow. cute.
720 void raptor_rotor_anglefix()
721 {
722         self.gun1.angles_y = anglemods(self.gun1.angles_y);
723         self.gun2.angles_y = anglemods(self.gun2.angles_y);
724         self.nextthink = time + 15;
725 }
726
727 float raptor_impulse(float _imp)
728 {
729         switch(_imp)
730         {
731                 case 1:
732                 case 230:
733                         self.vehicle.vehicle_weapon2mode = RSM_BOMB;
734                         CSQCVehicleSetup(self, 0);
735                         return true;
736                 case 2:
737                 case 231:
738                         self.vehicle.vehicle_weapon2mode = RSM_FLARE;
739                         CSQCVehicleSetup(self, 0);
740                         return true;
741
742                 case 10:
743                 case 15:
744                 case 18:
745                         self.vehicle.vehicle_weapon2mode += 1;
746                         if(self.vehicle.vehicle_weapon2mode > RSM_LAST)
747                                 self.vehicle.vehicle_weapon2mode = RSM_FIRST;
748
749                         CSQCVehicleSetup(self, 0);
750                         return true;
751                 case 11:
752                 case 12:
753                 case 16:
754                 case 19:
755                         self.vehicle.vehicle_weapon2mode -= 1;
756                         if(self.vehicle.vehicle_weapon2mode < RSM_FIRST)
757                                 self.vehicle.vehicle_weapon2mode = RSM_LAST;
758
759                         CSQCVehicleSetup(self, 0);
760                         return true;
761
762                 /*
763                 case 17: // toss gun, could be used to exit?
764                         break;
765                 case 20: // Manual minigun reload?
766                         break;
767                 */
768         }
769         return false;
770 }
771
772 void spawnfunc_vehicle_raptor()
773 {
774         if(!autocvar_g_vehicle_raptor) { remove(self); return; }
775         if(!vehicle_initialize(VEH_RAPTOR, false)) { remove(self); return; }
776 }
777
778 float v_raptor(float req)
779 {
780         switch(req)
781         {
782                 case VR_IMPACT:
783                 {
784                         if(autocvar_g_vehicle_raptor_bouncepain)
785                                 vehicles_impact(autocvar_g_vehicle_raptor_bouncepain_x, autocvar_g_vehicle_raptor_bouncepain_y, autocvar_g_vehicle_raptor_bouncepain_z);
786                                 
787                         return true;
788                 }
789                 case VR_ENTER:
790                 {
791                         self.vehicle_weapon2mode = RSM_BOMB;
792                         self.owner.PlayerPhysplug = raptor_takeoff;
793                         self.movetype      = MOVETYPE_BOUNCEMISSILE;
794                         self.solid                = SOLID_SLIDEBOX;
795                         self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_raptor_health) * 100;
796                         self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100;
797                         self.velocity_z = 1; // Nudge upwards to takeoff sequense can work.
798                         self.tur_head.exteriormodeltoclient = self.owner;
799
800                         self.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
801                         self.lip   = time;
802
803                         if(self.owner.flagcarried)
804                            setorigin(self.owner.flagcarried, '-20 0 96');
805
806                         CSQCVehicleSetup(self.owner, 0);
807                         return true;
808                 }
809                 case VR_THINK:
810                 {
811                         return true;
812                 }
813                 case VR_DEATH:
814                 {
815                         self.health                             = 0;
816                         self.event_damage               = func_null;
817                         self.solid                              = SOLID_CORPSE;
818                         self.takedamage                 = DAMAGE_NO;
819                         self.deadflag                   = DEAD_DYING;
820                         self.movetype                   = MOVETYPE_BOUNCE;
821                         self.think                              = raptor_diethink;
822                         self.nextthink                  = time;
823                         self.wait                               = time + 5 + (random() * 5);
824
825                         pointparticles(particleeffectnum("explosion_medium"), findbetterlocation (self.origin, 16), '0 0 0', 1);
826
827                         self.velocity_z += 600;
828
829                         self.avelocity = '0 0.5 1' * (random() * 400);
830                         self.avelocity -= '0 0.5 1' * (random() * 400);
831
832                         self.colormod = '-0.5 -0.5 -0.5';
833                         self.touch = raptor_blowup;
834                         return true;
835                 }
836                 case VR_SPAWN:
837                 {
838                         if(!self.gun1)
839                         {
840                                 entity spinner;
841                                 vector ofs;
842
843                                 //FIXME: Camera is in a bad place in HUD model.
844                                 //setorigin(self.vehicle_viewport, '25 0 5');
845
846                                 self.vehicles_impulse   = raptor_impulse;
847
848                                 self.frame = 0;
849
850                                 self.bomb1 = spawn();
851                                 self.bomb2 = spawn();
852                                 self.gun1  = spawn();
853                                 self.gun2  = spawn();
854
855                                 setmodel(self.bomb1,"models/vehicles/clusterbomb_folded.md3");
856                                 setmodel(self.bomb2,"models/vehicles/clusterbomb_folded.md3");
857                                 setmodel(self.gun1, "models/vehicles/raptor_gun.dpm");
858                                 setmodel(self.gun2, "models/vehicles/raptor_gun.dpm");
859                                 setmodel(self.tur_head, "models/vehicles/raptor_body.dpm");
860
861                                 setattachment(self.bomb1, self, "bombmount_left");
862                                 setattachment(self.bomb2, self, "bombmount_right");
863                                 setattachment(self.tur_head, self,"root");
864
865                                 // FIXMODEL Guns mounts to angled bones
866                                 self.bomb1.angles = self.angles;
867                                 self.angles = '0 0 0';
868                                 // This messes up gun-aim, so work arround it.
869                                 //setattachment(self.gun1, self, "gunmount_left");
870                                 ofs = gettaginfo(self, gettagindex(self, "gunmount_left"));
871                                 ofs -= self.origin;
872                                 setattachment(self.gun1, self, "");
873                                 setorigin(self.gun1, ofs);
874
875                                 //setattachment(self.gun2, self, "gunmount_right");
876                                 ofs = gettaginfo(self, gettagindex(self, "gunmount_right"));
877                                 ofs -= self.origin;
878                                 setattachment(self.gun2, self, "");
879                                 setorigin(self.gun2, ofs);
880
881                                 self.angles = self.bomb1.angles;
882                                 self.bomb1.angles = '0 0 0';
883
884                                 spinner = spawn();
885                                 spinner.owner = self;
886                                 setmodel(spinner,"models/vehicles/spinner.dpm");
887                                 setattachment(spinner, self, "engine_left");
888                                 spinner.movetype = MOVETYPE_NOCLIP;
889                                 spinner.avelocity = '0 90 0';
890                                 self.bomb1.gun1 = spinner;
891
892                                 spinner = spawn();
893                                 spinner.owner = self;
894                                 setmodel(spinner,"models/vehicles/spinner.dpm");
895                                 setattachment(spinner, self, "engine_right");
896                                 spinner.movetype = MOVETYPE_NOCLIP;
897                                 spinner.avelocity = '0 -90 0';
898                                 self.bomb1.gun2 = spinner;
899
900                                 // Sigh.
901                                 self.bomb1.think = raptor_rotor_anglefix;
902                                 self.bomb1.nextthink = time;
903
904                                 self.mass                          = 1 ;
905                         }
906
907                         self.frame                = 0;
908                         self.vehicle_health = autocvar_g_vehicle_raptor_health;
909                         self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
910                         self.movetype      = MOVETYPE_TOSS;
911                         self.solid                = SOLID_SLIDEBOX;
912                         self.vehicle_energy = 1;
913                         
914                         self.PlayerPhysplug = raptor_frame;
915
916                         self.bomb1.gun1.avelocity_y = 90;
917                         self.bomb1.gun2.avelocity_y = -90;
918                         
919                         self.delay = time;
920
921                         self.bouncefactor = autocvar_g_vehicle_raptor_bouncefactor;
922                         self.bouncestop = autocvar_g_vehicle_raptor_bouncestop;
923                         self.damageforcescale = 0.25;
924                         self.vehicle_health = autocvar_g_vehicle_raptor_health;
925                         self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
926                         return true;
927                 }
928                 case VR_SETUP:
929                 {
930                         if(autocvar_g_vehicle_raptor_shield)
931                                 self.vehicle_flags |= VHF_HASSHIELD;
932
933                         if(autocvar_g_vehicle_raptor_shield_regen)
934                                 self.vehicle_flags |= VHF_SHIELDREGEN;
935
936                         if(autocvar_g_vehicle_raptor_health_regen)
937                                 self.vehicle_flags |= VHF_HEALTHREGEN;
938
939                         if(autocvar_g_vehicle_raptor_energy_regen)
940                                 self.vehicle_flags |= VHF_ENERGYREGEN;
941                                 
942                         self.vehicle_exit = raptor_exit;
943                         self.respawntime = autocvar_g_vehicle_raptor_respawntime;
944                         self.vehicle_health = autocvar_g_vehicle_raptor_health;
945                         self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
946                         self.max_health = self.vehicle_health;
947                                 
948                         return true;
949                 }
950                 case VR_PRECACHE:
951                 {
952                         precache_model ("models/vehicles/raptor.dpm");
953                         precache_model ("models/vehicles/raptor_gun.dpm");
954                         precache_model ("models/vehicles/spinner.dpm");
955                         precache_model ("models/vehicles/raptor_cockpit.dpm");
956                         precache_model ("models/vehicles/clusterbomb_folded.md3");
957                         precache_model ("models/vehicles/raptor_body.dpm");
958
959                         precache_sound ("vehicles/raptor_fly.wav");
960                         precache_sound ("vehicles/raptor_speed.wav");
961                         precache_sound ("vehicles/missile_alarm.wav");
962                 
963                         return true;
964                 }
965         }
966
967         return true;
968 }
969
970 #endif // SVQC
971 #ifdef CSQC
972 #define raptor_ico  "gfx/vehicles/raptor.tga"
973 #define raptor_gun  "gfx/vehicles/raptor_guns.tga"
974 #define raptor_bomb "gfx/vehicles/raptor_bombs.tga"
975 #define raptor_drop "gfx/vehicles/axh-dropcross.tga"
976
977 void RaptorCBShellfragDraw()
978 {
979         if(wasfreed(self))
980                 return;
981
982         Movetype_Physics_MatchTicrate(autocvar_cl_gibs_ticrate, autocvar_cl_gibs_sloppy);
983         self.move_avelocity += randomvec() * 15;
984         self.renderflags = 0;
985
986         if(self.cnt < time)
987                 self.alpha = bound(0, self.nextthink - time, 1);
988
989         if(self.alpha < ALPHA_MIN_VISIBLE)
990                 remove(self);
991 }
992
993 void RaptorCBShellfragToss(vector _org, vector _vel, vector _ang)
994 {
995         entity sfrag;
996
997         sfrag = spawn();
998         setmodel(sfrag, "models/vehicles/clusterbomb_fragment.md3");
999         setorigin(sfrag, _org);
1000
1001         sfrag.move_movetype = MOVETYPE_BOUNCE;
1002         sfrag.gravity = 0.15;
1003         sfrag.solid = SOLID_CORPSE;
1004
1005         sfrag.draw = RaptorCBShellfragDraw;
1006
1007         sfrag.move_origin = sfrag.origin = _org;
1008         sfrag.move_velocity = _vel;
1009         sfrag.move_avelocity = prandomvec() * vlen(sfrag.move_velocity);
1010         sfrag.angles = self.move_angles = _ang;
1011
1012         sfrag.move_time = time;
1013         sfrag.damageforcescale = 4;
1014
1015         sfrag.nextthink = time + 3;
1016         sfrag.cnt = time + 2;
1017         sfrag.alpha = 1;
1018         sfrag.drawmask = MASK_NORMAL;
1019 }
1020
1021 float v_raptor(float req)
1022 {
1023         switch(req)
1024         {
1025                 case VR_HUD:
1026                 {
1027                         if(autocvar_r_letterbox)
1028                                 return true;
1029
1030                         vector picsize, hudloc = '0 0 0', pic2size, picloc;
1031                         string raptor_xhair;
1032
1033                         // Fetch health & ammo stats
1034                         HUD_GETVEHICLESTATS
1035
1036                         picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
1037                         hudloc_y = vid_conheight - picsize_y;
1038                         hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
1039
1040                         drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
1041
1042                         ammo1   *= 0.01;
1043                         ammo2   *= 0.01;
1044                         shield  *= 0.01;
1045                         vh_health  *= 0.01;
1046                         energy  *= 0.01;
1047                         reload1 = reload2 * 0.01;
1048                         //reload2 *= 0.01;
1049
1050                         pic2size = draw_getimagesize(raptor_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
1051                         picloc = picsize * 0.5 - pic2size * 0.5;
1052                         if(vh_health < 0.25)
1053                                 drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
1054                         else
1055                                 drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
1056                         drawpic(hudloc + picloc, raptor_bomb, pic2size,  '1 1 1' * reload1 + '1 0 0' * (1 - reload1), 1, DRAWFLAG_NORMAL);
1057                         drawpic(hudloc + picloc, raptor_gun, pic2size, '1 1 1' * energy   + '1 0 0' * (1 - energy),   1, DRAWFLAG_NORMAL);
1058                         drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
1059
1060                 // Health bar
1061                         picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
1062                         picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
1063                         drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
1064                         drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
1065                         drawresetcliparea();
1066                 // ..  and icon
1067                         picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
1068                         picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
1069                         if(vh_health < 0.25)
1070                         {
1071                                 if(alarm1time < time)
1072                                 {
1073                                         alarm1time = time + 2;
1074                                         vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
1075                                 }
1076
1077                                 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1078                         }
1079                         else
1080                         {
1081                                 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1082                                 if(alarm1time)
1083                                 {
1084                                         vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
1085                                         alarm1time = 0;
1086                                 }
1087                         }
1088
1089                 // Shield bar
1090                         picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
1091                         picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
1092                         drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
1093                         drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1094                         drawresetcliparea();
1095                 // ..  and icon
1096                         picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
1097                         picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
1098                         if(shield < 0.25)
1099                         {
1100                                 if(alarm2time < time)
1101                                 {
1102                                         alarm2time = time + 1;
1103                                         vehicle_alarm(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav");
1104                                 }
1105                                 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1106                         }
1107                         else
1108                         {
1109                                 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1110                                 if(alarm2time)
1111                                 {
1112                                         vehicle_alarm(self, CH_TRIGGER_SINGLE, "misc/null.wav");
1113                                         alarm2time = 0;
1114                                 }
1115                         }
1116
1117                 // Gun bar
1118                         picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
1119                         picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
1120                         drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * energy, vid_conheight);
1121                         drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1122                         drawresetcliparea();
1123                 // ..  and icon
1124                         picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
1125                         picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
1126                         if(energy < 0.2)
1127                                 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1128                         else
1129                                 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1130
1131                 // Bomb bar
1132                         picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
1133                         picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
1134                         drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload1, vid_conheight);
1135                         drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1136                         drawresetcliparea();
1137                 // ..  and icon
1138                         pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1139                         picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
1140                         if(reload1 != 1)
1141                                 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1142                         else
1143                                 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
1144
1145                         if(getstati(STAT_VEHICLESTAT_W2MODE) == RSM_FLARE)
1146                         {
1147                                 raptor_xhair =  "gfx/vehicles/axh-bracket.tga";
1148                         }
1149                         else
1150                         {
1151                                 raptor_xhair =  "gfx/vehicles/axh-ring.tga";
1152
1153                                 // Bombing crosshair
1154                                 if(!dropmark)
1155                                 {
1156                                         dropmark = spawn();
1157                                         dropmark.owner = self;
1158                                         dropmark.gravity = 1;
1159                                 }
1160
1161                                 if(reload2 == 100)
1162                                 {
1163                                         vector where;
1164
1165                                         setorigin(dropmark, pmove_org);
1166                                         dropmark.velocity = pmove_vel;
1167                                         tracetoss(dropmark, self);
1168
1169                                         where = project_3d_to_2d(trace_endpos);
1170
1171                                         setorigin(dropmark, trace_endpos);
1172                                         picsize = draw_getimagesize(raptor_drop) * 0.2;
1173
1174                                         if(!(where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight))
1175                                         {
1176                                                 where_x -= picsize_x * 0.5;
1177                                                 where_y -= picsize_y * 0.5;
1178                                                 where_z = 0;
1179                                                 drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
1180                                         }
1181                                         dropmark.cnt = time + 5;
1182                                 }
1183                                 else
1184                                 {
1185                                         vector where;
1186                                         if(dropmark.cnt > time)
1187                                         {
1188                                                 where = project_3d_to_2d(dropmark.origin);
1189                                                 picsize = draw_getimagesize(raptor_drop) * 0.25;
1190
1191                                                 if(!(where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight))
1192                                                 {
1193                                                         where_x -= picsize_x * 0.5;
1194                                                         where_y -= picsize_y * 0.5;
1195                                                         where_z = 0;
1196                                                         drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
1197                                                 }
1198                                         }
1199                                 }
1200                         }
1201
1202                         if (scoreboard_showscores)
1203                                 HUD_DrawScoreboard();
1204                         else
1205                         {
1206                                 picsize = draw_getimagesize(raptor_xhair);
1207                                 picsize_x *= 0.5;
1208                                 picsize_y *= 0.5;
1209
1210                                 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);
1211                         }
1212                         
1213                         return true;
1214                 }
1215                 case VR_SETUP:
1216                 {
1217                         AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-special2.tga";
1218                         AuxiliaryXhair[0].axh_scale   = 0.5;
1219                         
1220                         AuxiliaryXhair[1].axh_image = "gfx/vehicles/axh-bracket.tga";
1221                         AuxiliaryXhair[1].axh_scale = 0.25;
1222                         return true;
1223                 }
1224                 case VR_PRECACHE:
1225                 {
1226                         return true;
1227                 }
1228         }
1229
1230         return true;
1231 }
1232
1233 #endif // CSQC
1234 #endif // REGISTER_VEHICLE