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