]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/vehicles/unit/raptor.qc
Merge branch 'master' into Mario/vehicles
[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 float RSM_FIRST = 1;
17 const float RSM_BOMB = 1;
18 const float RSM_FLARE = 2;
19 const float RSM_LAST = 2;
20
21 #ifdef SVQC
22 float 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,
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, float 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                 return 1;
312         }
313
314         player = self;
315         raptor = self.vehicle;
316         self   = raptor;
317         
318         vehicles_painframe();
319         /*
320         ftmp = vlen(self.velocity);
321         if(ftmp > autocvar_g_vehicle_raptor_speed_forward)
322                 ftmp = 1;
323         else
324                 ftmp = ftmp / autocvar_g_vehicle_raptor_speed_forward;
325         */
326
327         if(self.sound_nexttime < time)
328         {
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);
332                 self.wait = ftmp;
333         }
334         /*
335         else if(fabs(ftmp - self.wait) > 0.2)
336         {
337                 sound (self.tur_head, CH_TRIGGER_SINGLE, "", 1 - ftmp,   ATTEN_NORM );
338                 sound (self, CH_TRIGGER_SINGLE, "", ftmp, ATTEN_NORM);
339                 self.wait = ftmp;
340         }
341         */
342
343         if(raptor.deadflag != DEAD_NO)
344         {
345                 self = player;
346                 player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
347                 return 1;
348         }
349         crosshair_trace(player);
350
351         vector vang;
352         vang = raptor.angles;
353         df = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
354         vang_x *= -1;
355         df_x *= -1;
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;
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);
364
365         // Pitch
366         ftmp = 0;
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;
369
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);
373
374         raptor.angles_x = anglemods(raptor.angles_x);
375         raptor.angles_y = anglemods(raptor.angles_y);
376         raptor.angles_z = anglemods(raptor.angles_z);
377
378         if(autocvar_g_vehicle_raptor_movestyle == 1)
379                 makevectors('0 1 0' * raptor.angles_y);
380         else
381                 makevectors(player.v_angle);
382
383         df = raptor.velocity * -autocvar_g_vehicle_raptor_friction;
384
385         if(player.movement_x != 0)
386         {
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;
391         }
392
393         if(player.movement_y != 0)
394         {
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;
399
400                 raptor.angles_z = bound(-30,raptor.angles_z + (player.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
401         }
402         else
403         {
404                 raptor.angles_z *= 0.95;
405                 if(raptor.angles_z >= -1 && raptor.angles_z <= -1)
406                         raptor.angles_z = 0;
407         }
408
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;
413
414         raptor.velocity  += df * frametime;
415         player.velocity = player.movement  = raptor.velocity;
416         setorigin(player, raptor.origin + '0 0 32');
417
418         player.vehicle_weapon2mode = raptor.vehicle_weapon2mode;
419
420         vector vf, ad;
421         // Target lock & predict
422         if(autocvar_g_vehicle_raptor_cannon_locktarget == 2)
423         {
424                 if(raptor.gun1.lock_time < time || raptor.gun1.enemy.deadflag)
425                         raptor.gun1.enemy = world;
426
427                 if(trace_ent)
428                 if(trace_ent.movetype)
429                 if(trace_ent.takedamage)
430                 if(!trace_ent.deadflag)
431                 {
432                         if(teamplay)
433                         {
434                                 if(trace_ent.team != player.team)
435                                 {
436                                         raptor.gun1.enemy = trace_ent;
437                                         raptor.gun1.lock_time = time + 5;
438                                 }
439                         }
440                         else
441                         {
442                                 raptor.gun1.enemy = trace_ent;
443                                 raptor.gun1.lock_time = time + 0.5;
444                         }
445                 }
446
447                 if(raptor.gun1.enemy)
448                 {
449                         float distance, impact_time;
450
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)
455                                 _vel_z *= 0.1;
456
457                         if(autocvar_g_vehicle_raptor_cannon_predicttarget)
458                         {
459                                 ad = vf;
460                                 distance = vlen(ad - player.origin);
461                                 impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
462                                 ad = vf + _vel * impact_time;
463                                 trace_endpos = ad;
464                         }
465                         else
466                                 trace_endpos = vf;
467                 }
468         }
469         else if(autocvar_g_vehicle_raptor_cannon_locktarget == 1)
470         {
471
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);
475
476                 if(self.lock_target != world)
477                 if(autocvar_g_vehicle_raptor_cannon_predicttarget)
478                 if(self.lock_strength == 1)
479                 {
480                         float i, distance, impact_time;
481
482                         vf = real_origin(raptor.lock_target);
483                         ad = vf;
484                         for(i = 0; i < 4; ++i)
485                         {
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;
489                         }
490                         trace_endpos = ad;
491                 }
492
493                 if(self.lock_target)
494                 {
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);
501                 }
502         }
503
504
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);
508
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);
512
513         /*
514         ad = ad * 0.5;
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);
518         */
519
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)
524         {
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");
531                 else
532                 {
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;
536                 }
537                 raptor.vehicle_energy -= autocvar_g_vehicle_raptor_cannon_cost;
538                 self.cnt = time;
539         }
540
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);
543
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);
546
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);
549
550         if(!forbidWeaponUse(player))
551         if(raptor.vehicle_weapon2mode == RSM_BOMB)
552         {
553                 if(time > raptor.lip + autocvar_g_vehicle_raptor_bombs_refire)
554                 if(player.BUTTON_ATCK2)
555                 {
556                         raptor_bombdrop();
557                         raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
558                         raptor.lip   = time;
559                 }
560         }
561         else
562         {
563                 if(time > raptor.lip + autocvar_g_vehicle_raptor_flare_refire)
564                 if(player.BUTTON_ATCK2)
565                 {
566                         float i;
567                         entity _flare;
568
569                         for(i = 0; i < 3; ++i)
570                         {
571                         _flare = spawn();
572                         setmodel(_flare, "models/runematch/rune.mdl");
573                         _flare.effects = EF_LOWPRECISION | EF_FLAME;
574                         _flare.scale = 0.5;
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;
585                         _flare.health = 20;
586                         _flare.tur_impacttime = time + autocvar_g_vehicle_raptor_flare_lifetime;
587                         _flare.touch = raptor_flare_touch;
588                         }
589                         raptor.delay = time + autocvar_g_vehicle_raptor_flare_refire;
590                         raptor.lip   = time;
591                 }
592         }
593
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);
596
597         if(self.bomb1.cnt < time)
598         {
599                 entity _missile = findchainentity(enemy, raptor);
600                 float _incomming = 0;
601                 while(_missile)
602                 {
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)
606                                 ++_incomming;
607
608                         _missile = _missile.chain;
609                 }
610
611                 if(_incomming)
612                         sound(self, CH_PAIN_SINGLE, "vehicles/missile_alarm.wav", VOL_BASE, ATTEN_NONE);
613
614                 self.bomb1.cnt = time + 1;
615         }
616
617
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);
622
623         player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
624
625         self = player;
626         return 1;
627 }
628
629 float raptor_takeoff()
630 {
631         entity player, raptor;
632
633         player = self;
634         raptor = self.vehicle;
635         self   = raptor;
636         
637         self.nextthink = time;
638         CSQCMODEL_AUTOUPDATE();
639         self.nextthink = 0; // will this work?
640         
641         if(self.sound_nexttime < time)
642         {
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);
645         }
646
647         // Takeoff sequense
648         if(raptor.frame < 25)
649         {
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;
655
656                 setorigin(player, raptor.origin + '0 0 32');
657         }
658         else
659                 player.PlayerPhysplug = raptor_frame;
660
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);
663
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);
666
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);
669
670
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);
673
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);
678
679         player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
680         self = player;
681         return 1;
682 }
683
684 void raptor_blowup()
685 {
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);
689
690         self.alpha                = -1;
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';
696
697         setorigin(self, self.pos1);
698         self.touch = func_null;
699         self.nextthink = 0;
700 }
701
702 void raptor_diethink()
703 {
704         if(time >= self.wait)
705                 self.think = raptor_blowup;
706
707         if(random() < 0.05)
708         {
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);
711         }
712         self.nextthink = time;
713         
714         CSQCMODEL_AUTOUPDATE();
715 }
716
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()
720 {
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;
724 }
725
726 float raptor_impulse(float _imp)
727 {
728         switch(_imp)
729         {
730                 case 10:
731                 case 15:
732                 case 18:
733                         self.vehicle.vehicle_weapon2mode += 1;
734                         if(self.vehicle.vehicle_weapon2mode > RSM_LAST)
735                                 self.vehicle.vehicle_weapon2mode = RSM_FIRST;
736
737                         CSQCVehicleSetup(self, 0);
738                         return TRUE;
739                 case 12:
740                 case 16:
741                 case 19:
742                         self.vehicle.vehicle_weapon2mode -= 1;
743                         if(self.vehicle.vehicle_weapon2mode < RSM_FIRST)
744                                 self.vehicle.vehicle_weapon2mode = RSM_LAST;
745
746                         CSQCVehicleSetup(self, 0);
747                         return TRUE;
748
749                 /*
750                 case 17: // toss gun, could be used to exit?
751                         break;
752                 case 20: // Manual minigun reload?
753                         break;
754                 */
755         }
756         return FALSE;
757 }
758
759 void spawnfunc_vehicle_raptor()
760 {
761         if(!autocvar_g_vehicle_raptor) { remove(self); return; }
762         if(!vehicle_initialize(VEH_RAPTOR, FALSE)) { remove(self); return; }
763 }
764
765 float v_raptor(float req)
766 {
767         switch(req)
768         {
769                 case VR_IMPACT:
770                 {
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);
773                                 
774                         return TRUE;
775                 }
776                 case VR_ENTER:
777                 {
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;
786
787                         self.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
788                         self.lip   = time;
789
790                         if(self.owner.flagcarried)
791                            setorigin(self.owner.flagcarried, '-20 0 96');
792
793                         CSQCVehicleSetup(self.owner, 0);
794                         return TRUE;
795                 }
796                 case VR_THINK:
797                 {
798                         return TRUE;
799                 }
800                 case VR_DEATH:
801                 {
802                         self.health                             = 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);
811
812                         pointparticles(particleeffectnum("explosion_medium"), findbetterlocation (self.origin, 16), '0 0 0', 1);
813
814                         self.velocity_z += 600;
815
816                         self.avelocity = '0 0.5 1' * (random() * 400);
817                         self.avelocity -= '0 0.5 1' * (random() * 400);
818
819                         self.colormod = '-0.5 -0.5 -0.5';
820                         self.touch = raptor_blowup;
821                         return TRUE;
822                 }
823                 case VR_SPAWN:
824                 {
825                         if(!self.gun1)
826                         {
827                                 entity spinner;
828                                 vector ofs;
829
830                                 //FIXME: Camera is in a bad place in HUD model.
831                                 //setorigin(self.vehicle_viewport, '25 0 5');
832
833                                 self.vehicles_impulse   = raptor_impulse;
834
835                                 self.frame = 0;
836
837                                 self.bomb1 = spawn();
838                                 self.bomb2 = spawn();
839                                 self.gun1  = spawn();
840                                 self.gun2  = spawn();
841
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");
847
848                                 setattachment(self.bomb1, self, "bombmount_left");
849                                 setattachment(self.bomb2, self, "bombmount_right");
850                                 setattachment(self.tur_head, self,"root");
851
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"));
858                                 ofs -= self.origin;
859                                 setattachment(self.gun1, self, "");
860                                 setorigin(self.gun1, ofs);
861
862                                 //setattachment(self.gun2, self, "gunmount_right");
863                                 ofs = gettaginfo(self, gettagindex(self, "gunmount_right"));
864                                 ofs -= self.origin;
865                                 setattachment(self.gun2, self, "");
866                                 setorigin(self.gun2, ofs);
867
868                                 self.angles = self.bomb1.angles;
869                                 self.bomb1.angles = '0 0 0';
870
871                                 spinner = spawn();
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;
878
879                                 spinner = spawn();
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;
886
887                                 // Sigh.
888                                 self.bomb1.think = raptor_rotor_anglefix;
889                                 self.bomb1.nextthink = time;
890
891                                 self.mass                          = 1 ;
892                         }
893
894                         self.frame                = 0;
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;
900                         
901                         self.PlayerPhysplug = raptor_frame;
902
903                         self.bomb1.gun1.avelocity_y = 90;
904                         self.bomb1.gun2.avelocity_y = -90;
905                         
906                         self.delay = time;
907
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;
913                         return TRUE;
914                 }
915                 case VR_SETUP:
916                 {
917                         if(autocvar_g_vehicle_raptor_shield)
918                                 self.vehicle_flags |= VHF_HASSHIELD;
919
920                         if(autocvar_g_vehicle_raptor_shield_regen)
921                                 self.vehicle_flags |= VHF_SHIELDREGEN;
922
923                         if(autocvar_g_vehicle_raptor_health_regen)
924                                 self.vehicle_flags |= VHF_HEALTHREGEN;
925
926                         if(autocvar_g_vehicle_raptor_energy_regen)
927                                 self.vehicle_flags |= VHF_ENERGYREGEN;
928                                 
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;
934                                 
935                         return TRUE;
936                 }
937                 case VR_PRECACHE:
938                 {
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");
945
946                         precache_sound ("vehicles/raptor_fly.wav");
947                         precache_sound ("vehicles/raptor_speed.wav");
948                         precache_sound ("vehicles/missile_alarm.wav");
949                 
950                         return TRUE;
951                 }
952         }
953
954         return TRUE;
955 }
956
957 #endif // SVQC
958 #ifdef CSQC
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"
963
964 float v_raptor(float req)
965 {
966         switch(req)
967         {
968                 case VR_HUD:
969                 {
970                         if(autocvar_r_letterbox)
971                                 return TRUE;
972
973                         vector picsize, hudloc = '0 0 0', pic2size, picloc;
974                         string raptor_xhair;
975
976                         // Fetch health & ammo stats
977                         HUD_GETVEHICLESTATS
978
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;
982
983                         drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
984
985                         ammo1   *= 0.01;
986                         ammo2   *= 0.01;
987                         shield  *= 0.01;
988                         vh_health  *= 0.01;
989                         energy  *= 0.01;
990                         reload1 = reload2 * 0.01;
991                         //reload2 *= 0.01;
992
993                         pic2size = draw_getimagesize(raptor_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
994                         picloc = picsize * 0.5 - pic2size * 0.5;
995                         if(vh_health < 0.25)
996                                 drawpic(hudloc + picloc, raptor_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
997                         else
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);
1002
1003                 // Health bar
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();
1009                 // ..  and icon
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)
1013                         {
1014                                 if(alarm1time < time)
1015                                 {
1016                                         alarm1time = time + 2;
1017                                         vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
1018                                 }
1019
1020                                 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1021                         }
1022                         else
1023                         {
1024                                 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1025                                 if(alarm1time)
1026                                 {
1027                                         vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
1028                                         alarm1time = 0;
1029                                 }
1030                         }
1031
1032                 // Shield bar
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();
1038                 // ..  and icon
1039                         picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
1040                         picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
1041                         if(shield < 0.25)
1042                         {
1043                                 if(alarm2time < time)
1044                                 {
1045                                         alarm2time = time + 1;
1046                                         vehicle_alarm(self, CH_TRIGGER_SINGLE, "vehicles/alarm_shield.wav");
1047                                 }
1048                                 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1049                         }
1050                         else
1051                         {
1052                                 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1053                                 if(alarm2time)
1054                                 {
1055                                         vehicle_alarm(self, CH_TRIGGER_SINGLE, "misc/null.wav");
1056                                         alarm2time = 0;
1057                                 }
1058                         }
1059
1060                 // Gun bar
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();
1066                 // ..  and icon
1067                         picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
1068                         picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
1069                         if(energy < 0.2)
1070                                 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1071                         else
1072                                 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1073
1074                 // Bomb bar
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();
1080                 // ..  and icon
1081                         pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1082                         picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
1083                         if(reload1 != 1)
1084                                 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1085                         else
1086                                 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
1087
1088                         if(getstati(STAT_VEHICLESTAT_W2MODE) == RSM_FLARE)
1089                         {
1090                                 raptor_xhair =  "gfx/vehicles/axh-bracket.tga";
1091                         }
1092                         else
1093                         {
1094                                 raptor_xhair =  "gfx/vehicles/axh-ring.tga";
1095
1096                                 // Bombing crosshair
1097                                 if(!dropmark)
1098                                 {
1099                                         dropmark = spawn();
1100                                         dropmark.owner = self;
1101                                         dropmark.gravity = 1;
1102                                 }
1103
1104                                 if(reload2 == 100)
1105                                 {
1106                                         vector where;
1107
1108                                         setorigin(dropmark, pmove_org);
1109                                         dropmark.velocity = pmove_vel;
1110                                         tracetoss(dropmark, self);
1111
1112                                         where = project_3d_to_2d(trace_endpos);
1113
1114                                         setorigin(dropmark, trace_endpos);
1115                                         picsize = draw_getimagesize(raptor_drop) * 0.2;
1116
1117                                         if(!(where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight))
1118                                         {
1119                                                 where_x -= picsize_x * 0.5;
1120                                                 where_y -= picsize_y * 0.5;
1121                                                 where_z = 0;
1122                                                 drawpic(where, raptor_drop, picsize, '0 2 0', 1, DRAWFLAG_ADDITIVE);
1123                                         }
1124                                         dropmark.cnt = time + 5;
1125                                 }
1126                                 else
1127                                 {
1128                                         vector where;
1129                                         if(dropmark.cnt > time)
1130                                         {
1131                                                 where = project_3d_to_2d(dropmark.origin);
1132                                                 picsize = draw_getimagesize(raptor_drop) * 0.25;
1133
1134                                                 if(!(where_z < 0 || where_x < 0 || where_y < 0 || where_x > vid_conwidth || where_y > vid_conheight))
1135                                                 {
1136                                                         where_x -= picsize_x * 0.5;
1137                                                         where_y -= picsize_y * 0.5;
1138                                                         where_z = 0;
1139                                                         drawpic(where, raptor_drop, picsize, '2 0 0', 1, DRAWFLAG_ADDITIVE);
1140                                                 }
1141                                         }
1142                                 }
1143                         }
1144
1145                         if (scoreboard_showscores)
1146                                 HUD_DrawScoreboard();
1147                         else
1148                         {
1149                                 picsize = draw_getimagesize(raptor_xhair);
1150                                 picsize_x *= 0.5;
1151                                 picsize_y *= 0.5;
1152
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);
1154                         }
1155                         
1156                         return TRUE;
1157                 }
1158                 case VR_SETUP:
1159                 {
1160                         AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-special2.tga";
1161                         AuxiliaryXhair[0].axh_scale   = 0.5;
1162                         
1163                         AuxiliaryXhair[1].axh_image = "gfx/vehicles/axh-bracket.tga";
1164                         AuxiliaryXhair[1].axh_scale = 0.25;
1165                         return TRUE;
1166                 }
1167                 case VR_PRECACHE:
1168                 {
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");
1175                         
1176                         return TRUE;
1177                 }
1178         }
1179
1180         return TRUE;
1181 }
1182
1183 #endif // CSQC
1184 #endif // REGISTER_VEHICLE