]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/vehicles/raptor.qc
Make colormap & fullbright work (uses g_fullbrightplayers), fix raptor shirt/pants...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / raptor.qc
1 #define RAPTOR_MIN '-80 -80 0'
2 #define RAPTOR_MAX '80 80 70'
3
4 float autocvar_g_vehicle_raptor_respawntime;
5
6 float autocvar_g_vehicle_raptor_movestyle;
7 float autocvar_g_vehicle_raptor_turnspeed;
8 float autocvar_g_vehicle_raptor_pitchspeed;
9 float autocvar_g_vehicle_raptor_pitchlimit;
10
11 float autocvar_g_vehicle_raptor_speed_forward;
12 float autocvar_g_vehicle_raptor_speed_strafe;
13 float autocvar_g_vehicle_raptor_speed_up;
14 float autocvar_g_vehicle_raptor_speed_down;
15
16 float autocvar_g_vehicle_raptor_bomblets;
17 float autocvar_g_vehicle_raptor_bomblet_alt;
18 float autocvar_g_vehicle_raptor_bomblet_time;
19 float autocvar_g_vehicle_raptor_bomblet_damage;
20 float autocvar_g_vehicle_raptor_bomblet_spread;
21 float autocvar_g_vehicle_raptor_bomblet_edgedamage;
22 float autocvar_g_vehicle_raptor_bomblet_radius;
23 float autocvar_g_vehicle_raptor_bomblet_force;
24 float autocvar_g_vehicle_raptor_bombs_refire;
25
26 float autocvar_g_vehicle_raptor_guns_turnspeed;
27 float autocvar_g_vehicle_raptor_guns_turnlimit;
28 float autocvar_g_vehicle_raptor_guns_pitchlimit_up;
29 float autocvar_g_vehicle_raptor_guns_pitchlimit_down;
30
31 float autocvar_g_vehicle_raptor_cannon_locktarget;
32 float autocvar_g_vehicle_raptor_cannon_locking_time;
33 float autocvar_g_vehicle_raptor_cannon_locking_releasetime;
34 float autocvar_g_vehicle_raptor_cannon_locked_time;
35 float autocvar_g_vehicle_raptor_cannon_predicttarget;
36
37 float autocvar_g_vehicle_raptor_cannon_cost;
38 float autocvar_g_vehicle_raptor_cannon_damage;
39 float autocvar_g_vehicle_raptor_cannon_radius;
40 float autocvar_g_vehicle_raptor_cannon_refire;
41 float autocvar_g_vehicle_raptor_cannon_speed;
42 float autocvar_g_vehicle_raptor_cannon_spread;
43
44
45 float autocvar_g_vehicle_raptor_energy;
46 float autocvar_g_vehicle_raptor_energy_regen;
47 float autocvar_g_vehicle_raptor_energy_regen_pause;
48
49 float autocvar_g_vehicle_raptor_health;
50 float autocvar_g_vehicle_raptor_health_regen;
51 float autocvar_g_vehicle_raptor_health_regen_pause;
52
53 float autocvar_g_vehicle_raptor_shield;
54 float autocvar_g_vehicle_raptor_shield_regen;
55 float autocvar_g_vehicle_raptor_shield_regen_pause;
56
57 void raptor_spawn();
58 //void raptor_return();
59 float raptor_frame();
60 //float raptor_takeoff();
61
62 .entity bomb1;
63 .entity bomb2;
64 .entity camera;
65
66 float raptor_altitude(float amax)
67 {
68         tracebox(self.origin, self.mins, self.maxs, self.origin - ('0 0 1' * amax), TRUE, self);
69     return vlen(self.origin - trace_endpos);
70 }
71
72 void raptor_bomblet_boom()
73 {
74     if(other == self.owner || other.owner == self.owner)
75         return;
76
77     pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
78     RadiusDamage (self, self.enemy, autocvar_g_vehicle_raptor_bomblet_damage,
79                                     autocvar_g_vehicle_raptor_bomblet_edgedamage,
80                                     autocvar_g_vehicle_raptor_bomblet_radius, world,
81                                     autocvar_g_vehicle_raptor_bomblet_force, DEATH_SBROCKET, world);
82     remove(self);
83 }
84
85 void raptor_bomb_burst()
86 {
87     if(autocvar_g_vehicle_raptor_bomblet_alt)
88     {
89         self.nextthink = time;
90         // FIXME: this can make bombs stic forever if fierd at low altitude and land close to vehicle.
91         traceline(self.origin, self.origin + (normalize(self.velocity) * autocvar_g_vehicle_raptor_bomblet_alt), MOVE_NORMAL, self);
92         if(trace_fraction == 1.0)
93             return;
94
95         if(vlen(self.origin - self.owner.origin) < autocvar_g_vehicle_raptor_bomblet_radius)
96             return;
97     }
98
99     entity bomblet;
100     float i;
101
102     pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
103
104     for(i = 0; i < autocvar_g_vehicle_raptor_bomblets; ++i)
105     {
106         bomblet = spawn();
107         setorigin(bomblet, self.origin);
108
109         bomblet.scale       = 0.5;
110         bomblet.solid       = SOLID_TRIGGER;
111         bomblet.movetype    = MOVETYPE_BOUNCE;
112         bomblet.touch       = raptor_bomblet_boom;
113         bomblet.think       = raptor_bomblet_boom;
114         bomblet.nextthink   = time + 5;
115         bomblet.owner       = self.owner;
116         bomblet.velocity    = normalize(normalize(self.velocity) + (randomvec() * autocvar_g_vehicle_raptor_bomblet_spread)) * vlen(self.velocity);
117
118         CSQCProjectile(bomblet, TRUE, PROJECTILE_RAPTORBOMB, TRUE);
119     }
120
121     remove(self);
122 }
123
124 void raptor_bomb_touch()
125 {
126     raptor_bomb_burst();
127 }
128
129 void raptor_bombdrop()
130 {
131     entity bomb_1, bomb_2;
132
133     //self.bomb1.alpha = 0;
134     //self.bomb2.alpha = 0;
135
136     bomb_1 = spawn();
137     bomb_2 = spawn();
138
139     setorigin(bomb_1, gettaginfo(self, gettagindex(self, "bombmount_left")));
140     setorigin(bomb_2, gettaginfo(self, gettagindex(self, "bombmount_right")));
141
142     bomb_1.movetype  = bomb_2.movetype   = MOVETYPE_TOSS;
143     bomb_1.velocity  = bomb_2.velocity   = self.velocity;
144     bomb_1.touch     = bomb_2.touch      = raptor_bomb_touch;
145     bomb_1.think     = bomb_2.think      = raptor_bomb_burst;
146
147     if(autocvar_g_vehicle_raptor_bomblet_alt)
148         bomb_1.nextthink = bomb_2.nextthink  = time;
149     else
150         bomb_1.nextthink = bomb_2.nextthink  = time + autocvar_g_vehicle_raptor_bomblet_time;
151
152     bomb_1.owner     = bomb_2.owner      = self;
153     bomb_1.enemy     = bomb_2.enemy      = self.owner;
154     bomb_1.solid     = bomb_2.solid      = SOLID_BBOX;
155
156     CSQCProjectile(bomb_1, TRUE, PROJECTILE_RAPTORBOMB, TRUE);
157     CSQCProjectile(bomb_2, TRUE, PROJECTILE_RAPTORBOMB, TRUE);
158
159 }
160
161 void raptor_bolt_explode()
162 {
163         PROJECTILE_TOUCH;
164     pointparticles(particleeffectnum("raptor_cannon_impact"), findbetterlocation (self.origin, 8), trace_plane_normal * 1000, 1);
165     RadiusDamage (self, self.realowner, autocvar_g_vehicle_raptor_cannon_damage, 0, autocvar_g_vehicle_raptor_cannon_radius, world, 25, DEATH_WAKIGUN, world);
166     sound (self, CHAN_PROJECTILE, "weapons/laserimpact.wav", VOL_BASE, ATTN_NORM);
167     remove (self);
168 }
169
170 void raptor_fire_cannon(entity gun, string tagname)
171 {
172     entity bolt;
173
174     bolt = spawn();
175
176     PROJECTILE_MAKETRIGGER(bolt);
177     sound (gun, CHAN_WEAPON, "weapons/lasergun_fire.wav", VOL_BASE, ATTN_NORM);
178     setorigin(bolt, gettaginfo(gun, gettagindex(gun, tagname)));
179
180     bolt.movetype        = MOVETYPE_FLYMISSILE;
181     bolt.flags           = FL_PROJECTILE | FL_NOTARGET;
182     bolt.owner           = self;
183     bolt.realowner       = self.owner;
184     bolt.touch           = raptor_bolt_explode;
185     bolt.think           = raptor_bolt_explode;
186     bolt.nextthink       = time + 9;
187     bolt.bot_dodge       = TRUE;
188     bolt.bot_dodgerating = autocvar_g_vehicle_raptor_cannon_damage;
189     bolt.velocity        = normalize(v_forward + randomvec() * autocvar_g_vehicle_raptor_cannon_spread) * autocvar_g_vehicle_raptor_cannon_speed;
190
191     pointparticles(particleeffectnum("raptor_cannon_muzzleflash"), bolt.origin, bolt.velocity, 1);
192     //pointparticles(particleeffectnum("spiderbot_minigun_muzzleflash"), bolt.origin, bolt.velocity, 1);
193
194     CSQCProjectile(bolt, TRUE, PROJECTILE_CRYLINK, TRUE);
195 }
196
197 void raptor_think()
198 {
199 }
200
201 void raptor_enter()
202 {
203     self.movetype   = MOVETYPE_BOUNCEMISSILE;
204     self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_raptor_health);
205     self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_raptor_shield);
206     self.velocity_z = 1;
207     //setorigin(self.vehicle_viewport, self.origin);
208 }
209
210 void raptor_land()
211 {
212     float hgt;
213
214     hgt = raptor_altitude(512);
215     self.velocity = (self.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
216     self.angles_x *= 0.95;
217     self.angles_z *= 0.95;
218
219     if(hgt < 128)
220         if(self.frame != 0)
221             self.frame = max(self.frame - 0.25, 0);
222
223     self.bomb1.gun1.avelocity_y = 90 + ((self.frame / 25) * 2000);
224     self.bomb1.gun2.avelocity_y = -self.bomb1.gun1.avelocity_y;
225
226     if(hgt < 16)
227     {
228         self.movetype   = MOVETYPE_BOUNCE;
229         self.think      = raptor_think;
230     }
231
232     self.nextthink  = time;
233 }
234
235 void raptor_exit(float eject)
236 {
237
238     if(self.deadflag == DEAD_NO)
239     {
240         vehicles_setreturn(autocvar_g_vehicle_raptor_respawntime, raptor_spawn);
241         self.think      = raptor_land;
242         self.nextthink  = time;
243     }
244
245     if not (self.owner)
246         return;
247
248         makevectors(self.angles);
249         if(eject)
250         {
251             setorigin(self.owner,self.origin + v_forward * 100 + '0 0 64');
252             self.owner.velocity = (v_up + v_forward * 0.25) * 750;
253         }
254         else
255         setorigin(self.owner,self.origin - v_forward * 200 + '0 0 64');
256
257     self.owner = world;
258 }
259
260 float raptor_frame()
261 {
262     entity player, raptor;
263     float ftmp, ftmp2;
264     vector df;
265
266     player = self;
267     raptor   = self.vehicle;
268     self    = raptor;
269
270     if(player.BUTTON_USE)
271     {
272         self = raptor;
273         vehicles_exit(VHEF_NORMAL);
274         self = player;
275         return 0;
276     }
277
278     if(raptor.deadflag != DEAD_NO)
279     {
280         self = player;
281         player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
282         return 1;
283     }
284
285     // Takeoff sequense
286     if(raptor.frame < 25)
287     {
288         raptor.frame += 0.25;
289         raptor.velocity_z = min(raptor.velocity_z * 1.5, 256);
290         self.bomb1.gun1.avelocity_y = 90 + ((raptor.frame / 25) * 2000);
291         self.bomb1.gun2.avelocity_y = -self.bomb1.gun1.avelocity_y;
292         player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
293         self = player;
294         return 1;
295     }
296
297     /*
298     raptor.angles_x *= -1;
299     // Rotate Body
300     ftmp = autocvar_g_vehicle_raptor_turnspeed * sys_frametime;
301     ftmp = bound(-ftmp, shortangle_f(player.v_angle_y - raptor.angles_y, raptor.angles_y), ftmp);
302
303     // Turn
304     raptor.angles_y = anglemods(raptor.angles_y + ftmp);
305
306     // Pitch Body
307     ftmp = autocvar_g_vehicle_raptor_pitchspeed  * sys_frametime;
308     ftmp = bound(-ftmp, shortangle_f(player.v_angle_x - raptor.angles_x, raptor.angles_x), ftmp);
309
310     raptor.angles_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, anglemods(raptor.angles_x + ftmp), autocvar_g_vehicle_raptor_pitchlimit);
311     raptor.angles_x *= -1;
312
313     if(autocvar_g_vehicle_raptor_movestyle == 1)
314     {
315         ftmp = raptor.angles_z;
316         raptor.angles_z = 0;
317         ftmp2 = raptor.angles_x;
318         raptor.angles_x = 0;
319         fixedmakevectors(raptor.angles);
320         raptor.angles_z = ftmp;
321         raptor.angles_x = ftmp2;
322     }
323     else
324         makevectors(player.v_angle);
325     */
326
327     crosshair_trace(player);
328     //df = vectoangles(normalize(trace_endpos - gettaginfo(raptor ,gettagindex(raptor, "tag_hud"))) - raptor.angles);
329     df = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
330     if(df_x > 180)  df_x -= 360;
331     if(df_x < -180) df_x += 360;
332     if(df_y > 180)  df_y -= 360;
333     if(df_y < -180) df_y += 360;
334
335     //raptor.angles_x *= -1;
336     // Rotate Body
337     ftmp = autocvar_g_vehicle_raptor_turnspeed * sys_frametime;
338     ftmp = bound(-ftmp, shortangle_f(df_y - raptor.angles_y, raptor.angles_y), ftmp);
339
340     // Turn
341     raptor.angles_y = anglemods(raptor.angles_y + ftmp);
342
343     // Pitch Body
344     ftmp = autocvar_g_vehicle_raptor_pitchspeed  * sys_frametime;
345     ftmp = bound(-ftmp, shortangle_f(df_x - raptor.angles_x, raptor.angles_x), ftmp);
346
347     raptor.angles_x = bound(-autocvar_g_vehicle_raptor_pitchlimit, anglemods(raptor.angles_x + ftmp), autocvar_g_vehicle_raptor_pitchlimit);
348     //raptor.angles_x *= -1;
349
350     if(autocvar_g_vehicle_raptor_movestyle == 1)
351     {
352         ftmp = raptor.angles_z;
353         raptor.angles_z = 0;
354         ftmp2 = raptor.angles_x;
355         raptor.angles_x = 0;
356         fixedmakevectors(raptor.angles);
357         raptor.angles_z = ftmp;
358         raptor.angles_x = ftmp2;
359     }
360     else
361         makevectors(player.v_angle);
362
363
364
365     /*
366     float dist, spd, back, up;
367     //dist = normalize(self.vehicle_viewport.origin - self.origin);
368     spd = vlen(self.velocity) + 0.01;
369     back = spd / autocvar_g_vehicle_raptor_speed_forward;
370     up = 1 - back;
371     back = back;
372     back = back * 1250;
373     back += 150;
374     up = up * 200;
375     up = up + 100;
376
377     setorigin(self.vehicle_viewport, self.origin + (v_up * up) + (v_forward * -back));
378     */
379
380     df = raptor.velocity * -1;
381
382     if(player.movement_x != 0)
383     {
384         if(player.movement_x > 0)
385             df += v_forward  * autocvar_g_vehicle_raptor_speed_forward;
386         else if(player.movement_x < 0)
387             df -= v_forward  * autocvar_g_vehicle_raptor_speed_forward;
388     }
389
390     if(player.movement_y != 0)
391     {
392         if(player.movement_y < 0)
393             df -= v_right * autocvar_g_vehicle_raptor_speed_strafe;
394         else if(player.movement_y > 0)
395             df += v_right * autocvar_g_vehicle_raptor_speed_strafe;
396
397         raptor.angles_z = bound(-30,raptor.angles_z + (player.movement_y / autocvar_g_vehicle_raptor_speed_strafe),30);
398     }
399     else
400     {
401         raptor.angles_z *= 0.95;
402         if(raptor.angles_z >= -1 && raptor.angles_z <= -1)
403             raptor.angles_z = 0;
404     }
405
406     if(player.BUTTON_CROUCH)
407         df -=   v_up * autocvar_g_vehicle_raptor_speed_down;
408     else if (player.BUTTON_JUMP)
409         df +=  v_up * autocvar_g_vehicle_raptor_speed_up;
410
411     raptor.velocity  += df * frametime;
412     player.velocity = player.movement  = raptor.velocity;
413     setorigin(player,raptor.origin + '0 0 32');
414
415     vector vf, ad;
416     // Target lock & predict
417     if(autocvar_g_vehicle_raptor_cannon_locktarget)
418     {
419
420         vehicles_locktarget2((1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime,
421                              (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * frametime,
422                              autocvar_g_vehicle_raptor_cannon_locked_time);
423
424         if(autocvar_g_vehicle_raptor_cannon_predicttarget && self.lock_strength == 1)
425         {
426             vector o;
427             if(self.lock_target != world)
428             {
429                 float i, distance, impact_time;
430
431                 vf = real_origin(raptor.lock_target);
432                 ad = vf;
433                 o = raptor.origin;
434                 for(i = 0; i < 4; ++i)
435                 {
436
437                     distance = vlen(ad - o);
438                     impact_time = distance / autocvar_g_vehicle_raptor_cannon_speed;
439                     ad = vf + raptor.lock_target.velocity * impact_time;
440                     o = raptor.origin + raptor.velocity * impact_time;
441                 }
442                 trace_endpos = ad;
443             }
444         }
445
446         if(self.lock_target != world)
447         if(self.lock_strength == 1)
448             UpdateAuxiliaryXhair(player, real_origin(self.lock_target), '0 0 1', 1);
449         else
450             UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * (1 - self.lock_strength)) + '0 1 0' * self.lock_strength, 1);
451     }
452
453     // Aim the gunz
454     ftmp2 = autocvar_g_vehicle_raptor_guns_turnspeed * frametime;
455     ftmp = -ftmp2;
456
457     // Gun1
458     df = gettaginfo(raptor.gun1, gettagindex(raptor.gun1, "fire1"));
459     ad = df;
460     vf = v_forward;
461     df = vectoangles(normalize(trace_endpos - df)); // Find the direction & angle
462     df = shortangle_vxy(df - (raptor.angles + raptor.gun1.angles), raptor.angles + raptor.gun1.angles);     // Find aim offset
463     // Bind to aimspeed
464     df_x = bound(ftmp, df_x, ftmp2);
465     df_y = bound(ftmp, df_y, ftmp2);
466     // Bind to limts
467     raptor.gun1.angles_x = bound(-autocvar_g_vehicle_raptor_guns_pitchlimit_down, df_x + raptor.gun1.angles_x, autocvar_g_vehicle_raptor_guns_pitchlimit_up);
468     raptor.gun1.angles_y = bound(-autocvar_g_vehicle_raptor_guns_turnlimit,  df_y + raptor.gun1.angles_y, autocvar_g_vehicle_raptor_guns_turnlimit);
469
470     //Gun 2
471     df = gettaginfo(raptor.gun2, gettagindex(raptor.gun2, "fire1"));
472     ad += df;
473     vf += v_forward;
474     df = vectoangles(normalize(trace_endpos - df)); // Find the direction & angle
475     df = shortangle_vxy(df - (raptor.angles + raptor.gun2.angles), raptor.angles + raptor.gun2.angles);     // Find aim offset
476     // Bind to aimspeed
477     df_x = bound(ftmp, df_x, ftmp2);
478     df_y = bound(ftmp, df_y, ftmp2);
479     // Bind to limts
480     raptor.gun2.angles_x = bound(-autocvar_g_vehicle_raptor_guns_pitchlimit_down, df_x + raptor.gun2.angles_x, autocvar_g_vehicle_raptor_guns_pitchlimit_up);
481     raptor.gun2.angles_y = bound(-autocvar_g_vehicle_raptor_guns_turnlimit,  df_y + raptor.gun2.angles_y, autocvar_g_vehicle_raptor_guns_turnlimit);
482
483
484     /*
485     ad = ad * 0.5;
486     v_forward = vf * 0.5;
487     traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, raptor);
488     UpdateAuxiliaryXhair(player, trace_endpos, '0 1 0', 0);
489     */
490
491     if(player.BUTTON_ATCK)
492     if(raptor.attack_finished_single <= time)
493     if(raptor.vehicle_energy > autocvar_g_vehicle_raptor_cannon_cost)
494     {
495         raptor_fire_cannon(self.gun1, "fire1");
496         raptor_fire_cannon(self.gun2, "fire1");
497
498         raptor.vehicle_energy -= autocvar_g_vehicle_raptor_cannon_cost;
499         raptor.attack_finished_single = time + autocvar_g_vehicle_raptor_cannon_refire;
500         self.cnt = time;
501     }
502
503     if(self.vehicle_flags  & VHF_SHIELDREGEN)
504         vehicles_regen(dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime);
505
506     if(self.vehicle_flags  & VHF_HEALTHREGEN)
507         vehicles_regen(dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime);
508
509     if(self.vehicle_flags  & VHF_ENERGYREGEN)
510         vehicles_regen(cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime);
511
512     player.vehicle_energy = raptor.vehicle_energy / autocvar_g_vehicle_raptor_energy;
513
514
515     if(time > raptor.delay)
516     {
517         if(player.BUTTON_ATCK2)
518         {
519             raptor_bombdrop();
520             raptor.delay = time + autocvar_g_vehicle_raptor_bombs_refire;
521         }
522         player.vehicle_reload1 = 1;
523     }
524     else
525     {
526         player.vehicle_reload1 = min(time / raptor.delay, 1);
527         raptor.bomb1.alpha = raptor.bomb2.alpha = player.vehicle_reload1; //(player.vehicle_reload1 == 1 ? 1 : player.vehicle_reload1 * 0.25);
528     }
529
530
531
532     VEHICLE_UPDATE_PLAYER(health, raptor);
533
534     if(self.vehicle_flags & VHF_HASSHIELD)
535         VEHICLE_UPDATE_PLAYER(shield, raptor);
536
537     player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
538     return 1;
539 }
540
541 void raptor_touch()
542 {
543     if(self.owner)
544     {
545         if(vlen(self.velocity) == 0)
546             return;
547
548         if(other.classname != "player")
549             return;
550
551         return;
552     }
553
554     if(other.classname != "player")
555         return;
556
557     if(other.deadflag != DEAD_NO)
558         return;
559
560     if(other.vehicle != world)
561         return;
562
563     vehicles_enter();
564 }
565
566 void raptor_blowup()
567 {
568     sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
569     pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
570
571     self.deadflag    = DEAD_DEAD;
572     self.vehicle_exit(VHEF_NORMAL);
573     RadiusDamage (self, self, 250, 15, 250, world, 250, DEATH_WAKIBLOWUP, world);
574
575     self.alpha          = -1;
576     self.movetype       = MOVETYPE_NONE;
577     self.effects        = EF_NODRAW;
578     self.colormod       = '0 0 0';
579     self.avelocity      = '0 0 0';
580     self.velocity       = '0 0 0';
581
582     setorigin(self, self.pos1);
583     self.touch = SUB_Null;
584 }
585
586 void raptor_die()
587 {
588     self.health       = 0;
589     self.event_damage = SUB_Null;
590     self.iscreature   = FALSE;
591     self.solid        = SOLID_CORPSE;
592     self.takedamage   = DAMAGE_NO;
593     self.deadflag     = DEAD_DYING;
594     self.movetype     = MOVETYPE_BOUNCE;
595     //self.wait         = time;
596
597     pointparticles(particleeffectnum("rocket_explode"), findbetterlocation (self.origin, 16), '0 0 0', 1);
598
599     self.velocity_z += 128;
600
601     if(random() < 0.5)
602         self.avelocity_z  = 45 + random() * 270;
603     else
604         self.avelocity_z  = -45 + random() * -270;
605
606     self.colormod = '-0.5 -0.5 -0.5';
607
608         self.touch     = raptor_blowup;
609         self.think     = raptor_spawn;
610         self.nextthink = time + autocvar_g_vehicle_raptor_respawntime;
611 }
612
613 void raptor_spawn()
614 {
615     self.flags     = FL_NOTARGET;
616     self.effects   = 0;
617
618     self.vehicle_health = autocvar_g_vehicle_raptor_health;
619     self.vehicle_shield = autocvar_g_vehicle_raptor_shield;
620     self.event_damage   = vehicles_damage;
621     self.touch          = raptor_touch;
622     self.iscreature     = TRUE;
623     self.movetype       = MOVETYPE_FLY;
624     self.solid          = SOLID_SLIDEBOX;
625     self.takedamage     = DAMAGE_AIM;
626         self.deadflag       = DEAD_NO;
627     self.bot_attack     = TRUE;
628     self.vehicle_energy = 1;
629     self.vehicle_hudmodel.viewmodelforclient = self;
630
631     self.bomb1.gun1.avelocity_y = 90;
632     self.bomb1.gun2.avelocity_y = -90;
633     self.frame = 0;
634
635     setorigin(self, self.pos1);
636     self.angles = self.pos2;
637
638     setsize(self, RAPTOR_MIN, RAPTOR_MAX );
639     pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
640     self.delay = time;
641
642     vehicles_common_spawn();
643 }
644
645 void raptor_dinit()
646 {
647     entity spinner;
648     vector ofs;
649
650     if not (vehicle_initialize(
651              "Raptor",
652              "models/vehicles/raptor.dpm",
653              "",
654              "models/vehicles/raptor_cockpit.dpm",
655              "", "tag_hud", "tag_camera",
656              HUD_RAPTOR,
657              RAPTOR_MIN, RAPTOR_MAX,
658              FALSE,
659              raptor_spawn, raptor_frame,
660              raptor_enter, raptor_exit,
661              raptor_die,   raptor_think))
662     {
663         remove(self);
664         return;
665     }
666
667     //FIXME: Camera is in a bad place in HUD model.
668     setorigin(self.vehicle_viewport, '10 0 3');
669
670     self.frame = 0;
671
672     self.bomb1 = spawn();
673     self.bomb2 = spawn();
674     self.gun1  = spawn();
675     self.gun2  = spawn();
676
677     //setattachment(self.vehicle_viewport, world, "");
678
679     setmodel(self.bomb1,"models/vehicles/raptor_bomb.dpm");
680     setmodel(self.bomb2,"models/vehicles/raptor_bomb.dpm");
681     setmodel(self.gun1, "models/vehicles/raptor_gun.dpm");
682     setmodel(self.gun2, "models/vehicles/raptor_gun.dpm");
683
684     setattachment(self.bomb1, self,"bombmount_left");
685     setattachment(self.bomb2, self,"bombmount_right");
686
687
688     // FIXME Guns mounts to angled bones
689     self.bomb1.angles = self.angles;
690     self.angles = '0 0 0';
691     // This messes up gun-aim, so work arround it.
692     //setattachment(self.gun1, self, "gunmount_left");
693     ofs = gettaginfo(self, gettagindex(self, "gunmount_left"));
694     ofs -= self.origin;
695     setattachment(self.gun1, self, "");
696     setorigin(self.gun1, ofs);
697
698     //setattachment(self.gun2, self, "gunmount_right");
699     ofs = gettaginfo(self, gettagindex(self, "gunmount_right"));
700     ofs -= self.origin;
701     setattachment(self.gun2, self, "");
702     setorigin(self.gun2, ofs);
703
704     self.angles = self.bomb1.angles;
705     self.bomb1.angles = '0 0 0';
706
707
708     spinner = spawn();
709     spinner.owner = self;
710     setmodel(spinner,"models/vehicles/spinner.dpm");
711     setattachment(spinner, self, "engine_left");
712     spinner.movetype = MOVETYPE_NOCLIP;
713     spinner.avelocity = '0 90 0';
714     self.bomb1.gun1 = spinner;
715
716     spinner = spawn();
717     spinner.owner = self;
718     setmodel(spinner,"models/vehicles/spinner.dpm");
719     setattachment(spinner, self, "engine_right");
720     spinner.movetype = MOVETYPE_NOCLIP;
721     spinner.avelocity = '0 -90 0';
722     self.bomb1.gun2 = spinner;
723 }
724
725 void spawnfunc_vehicle_raptor()
726 {
727     vehicles_configcheck("vehicle_raptor.cfg", autocvar_g_vehicle_raptor_health);
728
729     if(autocvar_g_vehicle_raptor_shield)
730         self.vehicle_flags |= VHF_HASSHIELD;
731
732     if(autocvar_g_vehicle_raptor_shield_regen)
733         self.vehicle_flags |= VHF_SHIELDREGEN;
734
735     if(autocvar_g_vehicle_raptor_health_regen)
736         self.vehicle_flags |= VHF_HEALTHREGEN;
737
738     if(autocvar_g_vehicle_raptor_energy_regen)
739         self.vehicle_flags |= VHF_ENERGYREGEN;
740
741     precache_model ("models/vehicles/raptor.dpm");
742     precache_model ("models/vehicles/raptor_gun.dpm");
743     precache_model ("models/vehicles/spinner.dpm");
744     precache_model ("models/vehicles/raptor_cockpit.dpm");
745     precache_model ("models/vehicles/raptor_bomb.dpm");
746
747     self.think = raptor_dinit;
748     self.nextthink = time + 1;
749 }