]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/vehicles/raptor.qc
d7f4de67aa61eda41f70256ecf3979402074a22b
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / raptor.qc
1 #define RAPTOR_MIN '-40 -40 0'
2 #define RAPTOR_MAX '40 40 40'
3
4 float raptor_movestyle;
5 float raptor_turnspeed;
6 float raptor_turnroll;
7 float raptor_pitchspeed;
8 float raptor_speed_forward;
9 float raptor_speed_strafe;
10 float raptor_speed_up;
11 float raptor_speed_down;
12
13 float raptor_bomblet_waves;
14 float raptor_bomblet_wavefirst;
15 float raptor_bomblet_wavenext;
16 float raptor_bomblet_wawespread;
17 float raptor_bomblets;
18 float raptor_bomblet_damage;
19 float raptor_bomblet_edgedamage;
20 float raptor_bomblet_radius;
21 float raptor_bomblet_force;
22 float raptor_bombs_refire;
23
24 float raptor_beam_dps;
25 float raptor_beam_fops;
26 float raptor_beam_aps;
27 float raptor_beam_size;
28 float raptor_beam_leangth;
29 float raptor_beam_refire;
30
31 float raptor_shield_max;
32 float raptor_shield_regen;
33
34 float raptor_health_max;
35 float raptor_health_regen;
36
37 float raptor_energy_max;
38 float raptor_energy_regen;
39
40 void raptor_spawn();
41 void raptor_return();
42 float raptor_pplug();
43 float raptor_takeoff();
44 float raptor_land();
45
46 .entity bomb1;
47 .entity bomb2;
48
49 float raptor_altitude(float amax)
50 {
51         tracebox(self.origin, self.mins, self.maxs, '0 0 -1' * amax, TRUE, self);
52         if(trace_fraction == 1)
53         return amax+1;
54     else
55         return vlen(self.origin - trace_endpos);
56 }
57
58 void raptor_loadsettings()
59 {
60     raptor_movestyle     = CCVAR("_movestyle");
61     raptor_turnspeed     = CCVAR("_turnspeed");
62     raptor_turnroll      = CCVAR("_turnroll");
63     raptor_pitchspeed    = CCVAR("_pitchspeed");
64     raptor_speed_forward = CCVAR("_speed_forward");
65     raptor_speed_strafe  = CCVAR("_speed_strafe");
66     raptor_speed_up      = CCVAR("_speed_up");
67     raptor_speed_down    = CCVAR("_speed_down");
68
69     raptor_bomblet_waves      = CCVAR("_bomblet_waves ");
70     raptor_bomblet_wavefirst  = CCVAR("_bomblet_wavefirst");
71     raptor_bomblet_wavenext   = CCVAR("_bomblet_wavenext");
72     raptor_bomblet_wawespread = CCVAR("_bomblet_wawespread");
73     raptor_bomblets           = CCVAR("_bomblets");
74     raptor_bomblet_damage     = CCVAR("_bomblet_damage");
75     raptor_bomblet_edgedamage = CCVAR("_bomblet_edgedamage");
76     raptor_bomblet_radius     = CCVAR("_bomblet_radius");
77     raptor_bomblet_force      = CCVAR("_bomblet_force ");
78     raptor_bombs_refire       = CCVAR("_bombs_refire");
79
80     raptor_beam_dps     = CCVAR("_beam_dps");
81     raptor_beam_fops    = CCVAR("_beam_fops");
82     raptor_beam_aps     = CCVAR("_beam_aps");
83     raptor_beam_size    = CCVAR("_beam_size");
84     raptor_beam_leangth = CCVAR("_beam_length");
85     raptor_beam_refire  = CCVAR("_beam_refire");
86
87     raptor_shield_max    = CCVAR("_shield_max");
88     raptor_shield_regen  = CCVAR("_shield_regen");
89
90     raptor_health_max    = CCVAR("_health_max");
91     raptor_health_regen  = CCVAR("_health_regen");
92
93     raptor_energy_max    = CCVAR("_energy_max");
94     raptor_energy_regen  = CCVAR("_energy_regen");
95 }
96
97 void raptor_bombs_return()
98 {
99     self.owner.bomb1.alpha = 1;
100     self.owner.bomb2.alpha = 1;
101     remove(self);
102 }
103
104 void raptor_bomblet_boom()
105 {
106     if(other.enemy == self.enemy)
107         return;
108
109     pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
110     RadiusDamage (self, self.enemy, raptor_bomblet_damage, raptor_bomblet_edgedamage, raptor_bomblet_radius, world, raptor_bomblet_force, DEATH_SBROCKET, world);
111     remove(self);
112 }
113
114 void raptor_bomb_burst()
115 {
116     self.angles = vectoangles(self.velocity);
117
118     if(self.cnt < time)
119     {
120         entity bomblet;
121         float i,v;
122         vector d;
123
124         makevectors(self.angles);
125         v = vlen(self.velocity) + random();
126         d = normalize(self.velocity);
127         pointparticles(particleeffectnum("rocket_explode"), self.origin, '0 0 0', 1);
128
129         for(i = 0; i < raptor_bomblets; ++i)
130         {
131
132             bomblet = spawn();
133             setorigin(bomblet,self.origin);
134
135             setmodel(bomblet,"models/vehicles/raptor_bomb.dpm");
136             bomblet.scale = 0.5;
137
138             bomblet.owner = self.owner;
139             bomblet.enemy = self.enemy;
140
141             bomblet.solid = SOLID_TRIGGER;
142             bomblet.movetype    = MOVETYPE_BOUNCE;
143             bomblet.touch = raptor_bomblet_boom;
144
145             bomblet.think = raptor_bomblet_boom;
146             bomblet.nextthink = time + 5;
147
148             //bomblet.modelflags = MF_ROCKET;
149             bomblet.modelflags = MF_GRENADE;
150
151             bomblet.velocity =  normalize(d + randomvec() * raptor_bomblet_wawespread) * v;
152
153             bomblet.angles = vectoangles(bomblet.velocity);
154         }
155
156         self.wait -= 1;
157         if(self.wait <= 0)
158         {
159             remove(self);
160             return;
161         }
162
163         self.cnt = time + raptor_bomblet_wavenext;
164     }
165
166     self.nextthink = time;
167 }
168
169 void raptor_bomb_touch()
170 {
171     raptor_bomb_burst();
172 }
173
174 void raptor_bombdrop()
175 {
176     entity bomb_1, bomb_2;
177
178     self.bomb1.alpha = 0.25;
179     self.bomb2.alpha = 0.25;
180
181     bomb_1 = spawn();
182     bomb_2 = spawn();
183
184     setmodel(bomb_1,"models/vehicles/raptor_bomb.dpm");
185     setmodel(bomb_2,"models/vehicles/raptor_bomb.dpm");
186
187     setorigin(bomb_1, gettaginfo(self, gettagindex(self, "bombmount_left")));
188     setorigin(bomb_2, gettaginfo(self, gettagindex(self, "bombmount_right")));
189
190     bomb_1.movetype  = bomb_2.movetype    = MOVETYPE_TOSS;
191     bomb_1.velocity  = bomb_2.velocity    = self.velocity;
192     bomb_1.touch     = bomb_2.touch       = raptor_bomb_touch;
193     bomb_1.think     = bomb_2.think       = raptor_bomb_burst;
194     bomb_1.nextthink = bomb_2.nextthink   = time;
195     bomb_1.cnt       = bomb_2.cnt         = time + raptor_bomblet_wavefirst;
196     bomb_1.wait       = bomb_2.wait       = raptor_bomblet_waves;
197
198     bomb_1.avelocity = bomb_2.avelocity   = '0 0 180';
199     bomb_1.owner     = bomb_2.owner       = self;
200     bomb_1.enemy     = bomb_2.enemy       = self.owner;
201     bomb_1.angles    = bomb_2.angles      = self.angles;
202     bomb_1.solid     = bomb_2.solid      = SOLID_BBOX;
203
204     bomb_1 = spawn();
205     bomb_1.owner = self;
206     bomb_1.think = raptor_bombs_return;
207     bomb_1.nextthink = time + raptor_bombs_refire;
208 }
209
210 void raptor_animator_think()
211 {
212     self.owner.frame += 1;
213     if(self.owner.frame == self.cnt)
214         remove(self);
215     else
216         self.nextthink = time + self.wait;
217 }
218
219 void raptor_setanim(float start, float end, float length)
220 {
221     entity ani;
222     if(self.tur_head.enemy)
223         ani = self.tur_head.enemy;
224     else
225         ani = spawn();
226
227     self.tur_head.enemy = ani;
228     ani.owner = self;
229     self.frame = start;
230     ani.cnt = end;
231     ani.wait = sys_frametime / length;
232     ani.think = raptor_animator_think;
233     ani.nextthink = time + ani.wait;
234 }
235
236 void raptor_beam (vector start, vector end, vector smin, vector smax, float bforce, float f_dmg, float deathtype)
237
238 {
239     vector hitloc, force, endpoint, dir;
240     entity ent;
241
242     dir = normalize(end - start);
243     force = dir * bforce;
244
245     // go a little bit into the wall because we need to hit this wall later
246     end = end + dir;
247
248     // trace multiple times until we hit a wall, each obstacle will be made unsolid.
249     // note down which entities were hit so we can damage them later
250     while (1)
251     {
252         tracebox(start, smin, smax, end, FALSE, world);
253
254         // if it is world we can't hurt it so stop now
255         if (trace_ent == world || trace_fraction == 1)
256             break;
257
258         if (trace_ent.solid == SOLID_BSP)
259             break;
260
261         // make the entity non-solid so we can hit the next one
262         trace_ent.railgunhit = TRUE;
263         trace_ent.railgunhitloc = end;
264         trace_ent.railgunhitsolidbackup = trace_ent.solid;
265
266         // make the entity non-solid
267         trace_ent.solid = SOLID_NOT;
268     }
269
270     endpoint = trace_endpos;
271
272     // find all the entities the railgun hit and hurt them
273     ent = findchainfloat(railgunhit, TRUE);
274     while (ent)
275     {
276         // get the details we need to call the damage function
277         ent.solid = ent.railgunhitsolidbackup;
278         hitloc = ent.railgunhitloc;
279         ent.railgunhitloc = '0 0 0';
280         ent.railgunhitsolidbackup = SOLID_NOT;
281         ent.railgunhit = FALSE;
282
283         // apply the damage
284         if (ent.takedamage)
285             Damage (ent, self, self, f_dmg, deathtype, hitloc, force);
286
287         ent = ent.chain;
288     }
289     trace_endpos = endpoint;
290 }
291
292
293 void raptor_enter()
294 {
295     // Remove this when bots know how to use vehicles
296     if (clienttype(other) != CLIENTTYPE_REAL)
297         return;
298
299     if(teamplay)
300         if(self.team)
301             if(self.team != other.team)
302                 return;
303
304     self.owner = other;
305     self.switchweapon = other.switchweapon;
306
307     self.event_damage          = vehicle_stdproc_damage;
308     self.colormap              = self.owner.colormap;
309     self.vehicle_hudmodel.viewmodelforclient = self.owner;
310     self.nextthink             = 0;
311     self.owner.angles          = self.angles;
312     self.owner.takedamage      = DAMAGE_NO;
313     self.owner.solid           = SOLID_NOT;
314     self.owner.movetype        = MOVETYPE_NOCLIP;
315     self.owner.alpha           = -1;
316     self.owner.PlayerPhysplug  = raptor_takeoff;
317     self.owner.vehicle         = self;
318     self.owner.event_damage    = SUB_Null;
319     self.owner.hud             = HUD_RAPTOR;
320     self.owner.vehicle_health  = self.vehicle_health / raptor_health_max;
321     self.owner.vehicle_shield  = self.vehicle_shield / raptor_shield_max;
322     self.owner.view_ofs        = '0 0 1';
323     self.owner.vehicle_ammo1   = self.vehicle_ammo1;
324     self.owner.vehicle_ammo2   = self.vehicle_ammo2;
325     self.owner.vehicle_reload1 = self.vehicle_reload1;
326     self.owner.vehicle_reload2 = self.vehicle_reload2;
327
328     other.flags &~= FL_ONGROUND;
329     self.flags &~= FL_ONGROUND;
330
331     self.frame = 0;
332     raptor_setanim(0, 25, 1);
333
334     self.team                 = self.owner.team;
335     self.flags               -= FL_NOTARGET;
336
337     self.velocity = '0 0 1';
338
339     setorigin(other,self.origin + '0 0 32');
340     other.velocity = self.velocity;
341
342     other.flags &~= FL_ONGROUND;
343     msg_entity = other;
344     WriteByte (MSG_ONE, SVC_SETVIEWPORT);
345     WriteEntity( MSG_ONE, self.vehicle_viewport);
346
347     WriteByte (MSG_ONE, SVC_SETVIEWANGLES);     // 10 = SVC_SETVIEWANGLES
348     WriteAngle(MSG_ONE,  self.angles_x * -1);   // tilt
349     WriteAngle(MSG_ONE,  self.angles_y);        // yaw
350     WriteAngle(MSG_ONE,  0);                    // roll
351 }
352
353 void raptor_exit(float eject)
354 {
355         self.colormap   = 1024;
356         self.flags      = FL_NOTARGET;
357
358     if not (self.owner)
359         return;
360
361     msg_entity = self.owner;
362     WriteByte (MSG_ONE, SVC_SETVIEWPORT);
363     WriteEntity( MSG_ONE, self.owner);
364
365     WriteByte (MSG_ONE, SVC_SETVIEWANGLES);    // 10 = SVC_SETVIEWANGLES
366     WriteAngle(MSG_ONE,  0);                   // tilt
367     WriteAngle(MSG_ONE,  self.angles_y); // yaw
368     WriteAngle(MSG_ONE,  0);                   // roll
369
370     if (self.deadflag == DEAD_NO)
371     {
372         //self.think = racer_exitthink;
373         self.nextthink = time;
374     }
375
376     self.owner.takedamage     = DAMAGE_AIM;
377     self.owner.solid          = SOLID_SLIDEBOX;
378     self.owner.movetype       = MOVETYPE_WALK;
379
380     setsize(self.owner,PL_MIN,PL_MAX);
381
382     self.owner.effects        &~= EF_NODRAW;
383     self.owner.alpha          = 1;
384     self.owner.PlayerPhysplug = SUB_Null;
385     self.owner.vehicle        = world;
386         self.owner.view_ofs       = PL_VIEW_OFS;
387         self.owner.event_damage   = PlayerDamage;
388         self.owner.hud            = HUD_NORMAL;
389         //self.exteriormodeltoclient = self;
390
391     self.vehicle_hudmodel.viewmodelforclient = self;
392
393         if(eject)
394         {
395             makevectors(self.angles);
396             setorigin(self.owner,self.origin + v_forward * 100);
397             self.owner.velocity = (v_up + v_forward * 0.25) * 750;
398         }
399         else
400         {
401             self.owner.velocity = (v_forward) * -150;
402         setorigin(self.owner,self.origin - v_forward * 128);
403         }
404
405     self.owner = world;
406
407     if (self.deadflag != DEAD_NO)
408     {
409         entity ret;
410         ret = spawn();
411         ret.enemy = self;
412         ret.think = raptor_return;
413         ret.nextthink = time + cvar("g_vehicle_racer_respawntime");
414     }
415 }
416
417
418 float raptor_pplug()
419 {
420     entity player, vhic;
421     float ftmp, ftmp2, energy_used;
422     vector df;
423
424
425     if(cvar("g_vehicle_raptor_reload"))
426     {
427         raptor_loadsettings();
428         cvar_set("g_vehicle_raptor_reload","0");
429     }
430
431     player = self;
432     vhic   = self.vehicle;
433     self    = vhic;
434
435     if(player.BUTTON_USE)
436     {
437         self = vhic;
438         raptor_exit(0);
439         self = player;
440         return 0;
441     }
442
443     if(vhic.deadflag != DEAD_NO)
444     {
445         self = player;
446         player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
447         return 1;
448     }
449
450     vhic.angles_x *= -1;
451     // Rotate Body
452     ftmp = raptor_turnspeed * sys_frametime;
453
454     ftmp = bound(-ftmp, shortangle_f(player.v_angle_y - vhic.angles_y, vhic.angles_y), ftmp);
455
456     // Roll
457     //ftmp = bound(-90,shortangle_f(player.v_angle_z + ((vhic.angles_y - ftmp2) * raptor_turnroll), vhic.angles_z),90);
458     //ftmp = safeangle(vhic.angles_z + ftmp);
459     //vhic.angles_z = ftmp;
460
461     // Turn
462     vhic.angles_y = safeangle(vhic.angles_y + ftmp);
463
464     // Pitch Body
465     ftmp = raptor_pitchspeed  * sys_frametime;
466
467     ftmp = bound(-ftmp, shortangle_f(player.v_angle_x - vhic.angles_x,vhic.angles_x), ftmp);
468
469     vhic.angles_x = bound(-60,safeangle(vhic.angles_x + ftmp),60);
470     vhic.angles_x *= -1;
471
472     if(raptor_movestyle == 1)
473     {
474         ftmp = vhic.angles_z;
475         vhic.angles_z = 0;
476         ftmp2 = vhic.angles_x;
477         vhic.angles_x = 0;
478         fixedmakevectors(vhic.angles);
479         vhic.angles_z = ftmp;
480         vhic.angles_x = ftmp2;
481     }
482     else
483         fixedmakevectors(vhic.angles);
484
485     df = vhic.velocity * -1;
486
487     if(player.movement_x != 0)
488     {
489         if(player.movement_x > 0)
490             df += v_forward  * raptor_speed_forward;
491         else if(player.movement_x < 0)
492             df -= v_forward  * raptor_speed_forward;
493     }
494
495     if(player.movement_y != 0)
496     {
497         if(player.movement_y < 0)
498             df -= v_right * raptor_speed_strafe;
499         else if(player.movement_y > 0)
500             df += v_right * raptor_speed_strafe;
501
502         vhic.angles_z = bound(-30,vhic.angles_z + (player.movement_y / raptor_speed_strafe),30);
503     }
504     else
505     {
506         vhic.angles_z *= 0.95;
507         if(vhic.angles_z >= -1 && vhic.angles_z <= -1)
508             vhic.angles_z = 0;
509     }
510
511     if(player.BUTTON_CROUCH)
512         df -=   v_up * raptor_speed_down;
513     else if (player.BUTTON_JUMP)
514         df +=  v_up * raptor_speed_up;
515     //else
516         //df_z = vhic.velocity_z * -1;
517
518     vhic.velocity  += df * frametime;
519     player.velocity = player.movement  = vhic.velocity;
520     setorigin(player,vhic.origin + '0 0 32');
521
522     // Aim the gunz
523     vector target_angle, move_angle, org1, org2, targ;
524
525     makevectors(player.v_angle);
526
527     //targ = (vhic.origin + player.view_ofs) + v_forward * MAX_SHOT_DISTANCE;
528     targ = player.cursor_trace_endpos;
529
530     org1 = gettaginfo(vhic.gun1,gettagindex(vhic.gun1, "fire1"));
531     org2 = gettaginfo(vhic.gun2,gettagindex(vhic.gun2, "fire1"));
532
533     traceline(vhic.origin + player.view_ofs, targ, FALSE, vhic);
534     targ = trace_endpos;
535
536     // Find the direction
537     target_angle = vectoangles(normalize(targ - org1)); // And make a angle
538
539     // Find the diffrence between where we currently aim and where we want to aim
540     move_angle = target_angle - (vhic.angles + vhic.gun1.angles);
541     move_angle = shortangle_vxy(move_angle,(vhic.angles + vhic.gun1.angles));
542     vhic.gun1.angles_x = bound(-10, move_angle_x + vhic.gun1.angles_x, 10);
543     vhic.gun1.angles_y = bound(-15, move_angle_y + vhic.gun1.angles_y, 15);
544
545     // Find the direction
546     target_angle = vectoangles(normalize(targ - org2)); // And make a angle
547
548     move_angle = target_angle - (vhic.angles + vhic.gun2.angles);
549     move_angle = shortangle_vxy(move_angle,(vhic.angles + vhic.gun2.angles));
550     vhic.gun2.angles_x = bound(-15,move_angle_x + vhic.gun2.angles_x,15);
551     vhic.gun2.angles_y = bound(-20,move_angle_y + vhic.gun2.angles_y,20);
552
553     if(player.BUTTON_ATCK)
554     if(vhic.vehicle_energy > (raptor_beam_aps * sys_frametime))
555     {
556         vector start;
557         self = player;
558
559         start = gettaginfo(vhic.gun1, gettagindex(vhic.gun1, "fire1"));
560         traceline(start, start + v_forward * MAX_SHOT_DISTANCE, TRUE, player);
561         te_lightning1(vhic.gun1, start, trace_endpos);
562         raptor_beam(start, trace_endpos, '-1 -1 -1' * raptor_beam_size, '1 1 1' * raptor_beam_size, raptor_beam_fops * sys_frametime, raptor_beam_dps * sys_frametime, DEATH_SBROCKET);
563
564
565         start = gettaginfo(vhic.gun2, gettagindex(vhic.gun2, "fire1"));
566         traceline(start, start + v_forward * MAX_SHOT_DISTANCE, TRUE, player);
567         te_lightning1(vhic.gun2, start, trace_endpos);
568         raptor_beam(start, trace_endpos, '-1 -1 -1' * raptor_beam_size, '1 1 1' * raptor_beam_size, raptor_beam_fops * sys_frametime, raptor_beam_dps * sys_frametime, DEATH_SBROCKET);
569
570         self = vhic;
571
572         vhic.vehicle_energy -= raptor_beam_aps * sys_frametime;
573         vhic.cnt = time + 1;
574     }
575
576     if(vhic.cnt < time)
577         vhic.vehicle_energy = min(vhic.vehicle_energy += raptor_energy_regen * frametime, raptor_energy_max);
578
579     player.vehicle_energy = vhic.vehicle_energy / raptor_energy_max;
580
581
582     if(player.BUTTON_ATCK2)
583     if(time > vhic.delay)
584     {
585         raptor_bombdrop();
586         vhic.delay = time + raptor_bombs_refire;
587     }
588
589     player.BUTTON_ATCK = player.BUTTON_ATCK2 = player.BUTTON_CROUCH = 0;
590     vehicle_stdproc_shiledregen(raptor_shield_max, frametime);
591     vehicle_stdproc_healthregen(raptor_health_max, frametime);
592
593     self = player;
594
595     return 1;
596 }
597
598 float raptor_takeoff()
599 {
600     entity player, vhic;
601
602     if(self.vehicle.frame < 25)
603         return 1;
604
605     player = self;
606     vhic   = self.vehicle;
607     self    = vhic;
608
609     if(raptor_altitude(512) <= 256)
610     {
611         vhic.velocity_z = min(vhic.velocity_z * 1.5, 256);
612     }
613     else
614     {
615         player.PlayerPhysplug = raptor_pplug;
616     }
617
618     player.BUTTON_CROUCH = player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
619     self = player;
620
621     return 1;
622 }
623
624 float raptor_land()
625 {
626     return 0;
627 }
628
629 void raptor_return()
630 {
631     pointparticles(particleeffectnum("teleport"), self.enemy.origin + '0 0 64', '0 0 0', 1);
632     self.enemy.think = raptor_spawn;
633     self.enemy.nextthink = time;
634     remove(self);
635 }
636
637 void raptor_think()
638 {
639 }
640
641 void raptor_touch()
642 {
643     if(self.owner)
644     {
645         if(vlen(self.velocity) == 0)
646             return;
647
648         if(other.classname != "player")
649             return;
650
651         return;
652     }
653
654     if(other.classname != "player")
655         return;
656
657     if(other.deadflag != DEAD_NO)
658         return;
659
660     if(other.vehicle != world)
661         return;
662
663     raptor_enter();
664 }
665
666 void raptor_die()
667 {
668     self.health       = 0;
669     self.event_damage = SUB_Null;
670     self.iscreature   = FALSE;
671     self.solid        = SOLID_NOT;
672     self.takedamage   = DAMAGE_NO;
673     //self.touch        = racer_dietouch;
674     self.deadflag     = DEAD_DYING;
675     self.movetype     = MOVETYPE_BOUNCE;
676     self.wait = time;
677
678     pointparticles(particleeffectnum("rocket_explode"), findbetterlocation (self.origin, 16), '0 0 0', 1);
679
680     self.velocity     += '0 0 128';
681
682     if(random() < 0.5)
683         self.avelocity_z  = 45;
684     else
685         self.avelocity_z  = -45;
686
687     self.colormod = '-0.5 -0.5 -0.5';
688
689         self.think     = raptor_spawn;
690         self.nextthink = time + 5;
691 }
692
693 void raptor_spawn()
694 {
695     self.flags     = FL_NOTARGET;
696     self.effects   = 0;
697
698     self.vehicle_health = raptor_health_max;
699     self.vehicle_shield = raptor_shield_max;
700
701     self.event_damage = vehicle_stdproc_damage;
702     self.touch      = raptor_touch;
703
704     self.iscreature = TRUE;
705     self.movetype   = MOVETYPE_FLY;
706     self.solid      = SOLID_SLIDEBOX;
707     self.takedamage = DAMAGE_AIM;
708
709     self.alpha = 1;
710         self.colormap = 1024;
711         self.deadflag    = DEAD_NO;
712     self.bot_attack = TRUE;
713
714     self.colormod = '1 1 1';
715     self.avelocity = '0 0 0';
716     self.velocity = '0 0 0';
717
718     self.vehicle_energy = 1;
719     self.vehicle_hudmodel.viewmodelforclient = self;
720
721     setorigin(self, self.pos1);
722     self.angles = self.pos2;
723
724     setsize(self,RAPTOR_MIN ,RAPTOR_MAX );
725     pointparticles(particleeffectnum("teleport"), self.origin + '0 0 64', '0 0 0', 1);
726     self.delay = time;
727 }
728
729 float raptor_customizeentityforclient()
730 {
731     if(self.deadflag == DEAD_DEAD)
732         return FALSE;
733
734     /*
735     if(other == self.owner)
736         self.alpha = -1;
737     else
738         self.alpha = 1;
739     */
740
741     return TRUE;
742 }
743
744 void raptor_dinit()
745 {
746
747     if (self.netname == "")
748         self.netname     = "Raptor";
749
750     setorigin(self, self.origin);
751
752     self.frame = 0;
753
754     setmodel(self,"models/vehicles/raptor.dpm");
755
756     self.bomb1 = spawn();
757     self.bomb2 = spawn();
758
759     setmodel(self.bomb1,"models/vehicles/raptor_bomb.dpm");
760     setmodel(self.bomb2,"models/vehicles/raptor_bomb.dpm");
761
762     setattachment(self.bomb1, self,"bombmount_left");
763     setattachment(self.bomb2, self,"bombmount_right");
764
765
766     if not (self.vehicle_hudmodel)
767     {
768         self.vehicle_hudmodel   = spawn();
769         setmodel(self.vehicle_hudmodel, "models/vehicles/raptor_cockpit.dpm");
770         //setattachment(self.vehicle_hudmodel, self, "tag_viewport");
771         setattachment(self.vehicle_hudmodel, self, "tag_hud");
772     }
773
774     if not (self.vehicle_viewport)
775     {
776         self.vehicle_viewport   = spawn();
777         setmodel (self.vehicle_viewport, "null");
778         setattachment(self.vehicle_viewport, self.vehicle_hudmodel, "tag_camera");
779     }
780
781     if not (self.gun1)
782     {
783         self.gun1   = spawn();
784         setmodel(self.gun1, "models/vehicles/raptor_gun.dpm");
785         setattachment(self.gun1, self, "gunmount_left");
786     }
787
788     if not (self.gun2)
789     {
790         self.gun2   = spawn();
791         setmodel(self.gun2, "models/vehicles/raptor_gun.dpm");
792         setattachment(self.gun2, self, "gunmount_right");
793     }
794
795     self.tur_head     = spawn();
796     self.pos1         = self.origin;
797     self.pos2         = self.angles;
798
799     self.vehicle_hudmodel.viewmodelforclient = self;
800     self.customizeentityforclient            = raptor_customizeentityforclient;
801
802     self.vehicle_die  = raptor_die;
803     self.vehicle_exit = raptor_exit;
804
805
806     entity spinner;
807     spinner = spawn();
808     spinner.owner = self;
809     setmodel(spinner,"models/vehicles/spinner.dpm");
810     setattachment(spinner, self, "engine_left");
811     spinner.movetype = MOVETYPE_NOCLIP;
812     spinner.avelocity = '0 90 0';
813
814     spinner = spawn();
815     spinner.owner = self;
816     setmodel(spinner,"models/vehicles/spinner.dpm");
817     setattachment(spinner, self, "engine_right");
818     spinner.movetype = MOVETYPE_NOCLIP;
819     spinner.avelocity = '0 -90 0';
820
821     addstat(STAT_HUD, AS_INT,  hud);
822         addstat(STAT_VEHICLESTAT_HEALTH,  AS_FLOAT, vehicle_health);
823         addstat(STAT_VEHICLESTAT_SHIELD,  AS_FLOAT, vehicle_shield);
824         addstat(STAT_VEHICLESTAT_ENERGY,  AS_FLOAT, vehicle_energy);
825
826         addstat(STAT_VEHICLESTAT_AMMO1,   AS_INT,   vehicle_ammo1);
827         addstat(STAT_VEHICLESTAT_RELOAD1, AS_FLOAT, vehicle_reload1);
828
829         addstat(STAT_VEHICLESTAT_AMMO2,   AS_INT,   vehicle_ammo2);
830         addstat(STAT_VEHICLESTAT_RELOAD2, AS_FLOAT, vehicle_reload2);
831
832     raptor_spawn();
833 }
834
835 void spawnfunc_vehicle_raptor2()
836 {
837     self.cvar_basename      = "g_vehicle_raptor";
838     raptor_loadsettings();
839
840     self.vehicle_flags      = VHF_HASSHIELD | VHF_SHIELDREGEN;
841
842     traceline(self.origin, self.origin - '0 0 2048', MOVE_WORLDONLY, self);
843     if(trace_startsolid)
844     {
845         dprint("WARNING: vehicle_raptor placed in solid\n");
846         traceline(self.origin + '0 0 512' ,self.origin - '0 0 2048',MOVE_WORLDONLY,self);
847         if(trace_startsolid || trace_fraction == 1.0)
848         {
849             dprint("ERROR: vehicle_raptor placed in more then 512 units into solid\n");
850             remove(self);
851             return;
852         }
853     }
854
855     if(trace_fraction != 1.0)
856         setorigin(self,trace_endpos + '0 0 8');
857     else
858         dprint("WARNING: vehicle_racer placed more then 2048 units above ground.\n");
859
860     precache_model ("models/vehicles/raptor.dpm");
861     precache_model ("models/vehicles/raptor_gun.dpm");
862     precache_model ("models/vehicles/spinner.dpm");
863     precache_model ("models/vehicles/raptor_cockpit.dpm");
864     precache_model ("models/vehicles/raptor_bomb.dpm");
865
866
867     self.think = raptor_dinit;
868     self.nextthink = time + 1;
869 }
870
871
872 void spawnfunc_vehicle_raptor()
873 {
874     entity iqm,dpm,md3;
875
876     precache_model ("models/vehicles/test.iqm");
877     precache_model ("models/vehicles/test.dpm");
878     precache_model ("models/vehicles/test.md3");
879
880     iqm = spawn();
881     dpm = spawn();
882     md3 = spawn();
883     iqm.scale = md3.scale = dpm.scale = 10;
884
885     //setmodel(iqm,"models/vehicles/test.iqm");
886     //setmodel(dpm,"models/vehicles/test.dpm");
887     setmodel(md3,"models/vehicles/test.md3");
888
889     setorigin(iqm, self.origin + '0 0 16');
890     setorigin(dpm, self.origin + '0 20 32');
891     setorigin(iqm, self.origin + '0 40 48');
892 }