]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/vehicles/raptor.qc
06392ec0db7978f515f6edc1d985ff8ffbf0f5fa
[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");
88     raptor_shield_regen  = CCVAR("_shield_regen");
89
90     raptor_health_max    = CCVAR("_health");
91     raptor_health_regen  = CCVAR("_health_regen");
92
93     raptor_energy_max    = CCVAR("_energy");
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     vector hitloc, force, endpoint, dir;
239     entity ent;
240
241     dir = normalize(end - start);
242     force = dir * bforce;
243
244     // go a little bit into the wall because we need to hit this wall later
245     end = end + dir;
246
247     // trace multiple times until we hit a wall, each obstacle will be made unsolid.
248     // note down which entities were hit so we can damage them later
249     while (1)
250     {
251         tracebox(start, smin, smax, end, FALSE, world);
252
253         // if it is world we can't hurt it so stop now
254         if (trace_ent == world || trace_fraction == 1)
255             break;
256
257         if (trace_ent.solid == SOLID_BSP)
258             break;
259
260         // make the entity non-solid so we can hit the next one
261         trace_ent.railgunhit = TRUE;
262         trace_ent.railgunhitloc = end;
263         trace_ent.railgunhitsolidbackup = trace_ent.solid;
264
265         // make the entity non-solid
266         trace_ent.solid = SOLID_NOT;
267     }
268
269     endpoint = trace_endpos;
270
271     // find all the entities the railgun hit and hurt them
272     ent = findchainfloat(railgunhit, TRUE);
273     while (ent)
274     {
275         // get the details we need to call the damage function
276         ent.solid = ent.railgunhitsolidbackup;
277         hitloc = ent.railgunhitloc;
278         ent.railgunhitloc = '0 0 0';
279         ent.railgunhitsolidbackup = SOLID_NOT;
280         ent.railgunhit = FALSE;
281
282         // apply the damage
283         if (ent.takedamage)
284             Damage (ent, self, self, f_dmg, deathtype, hitloc, force);
285
286         ent = ent.chain;
287     }
288     trace_endpos = endpoint;
289 }
290
291
292 void raptor_enter()
293 {
294     // Remove this when bots know how to use vehicles
295     if (clienttype(other) != CLIENTTYPE_REAL)
296         return;
297
298     if(teamplay)
299         if(self.team)
300             if(self.team != other.team)
301                 return;
302
303     self.owner = other;
304     self.switchweapon = other.switchweapon;
305
306     self.event_damage          = vehicle_stdproc_damage;
307     self.colormap              = self.owner.colormap;
308     self.vehicle_hudmodel.viewmodelforclient = self.owner;
309     self.nextthink             = 0;
310     self.owner.angles          = self.angles;
311     self.owner.takedamage      = DAMAGE_NO;
312     self.owner.solid           = SOLID_NOT;
313     self.owner.movetype        = MOVETYPE_NOCLIP;
314     self.owner.alpha           = -1;
315     self.owner.PlayerPhysplug  = raptor_takeoff;
316     self.owner.vehicle         = self;
317     self.owner.event_damage    = SUB_Null;
318     self.owner.hud             = HUD_RAPTOR;
319     self.owner.vehicle_health  = self.vehicle_health / raptor_health_max;
320     self.owner.vehicle_shield  = self.vehicle_shield / raptor_shield_max;
321     self.owner.view_ofs        = '0 0 1';
322     self.owner.vehicle_ammo1   = self.vehicle_ammo1;
323     self.owner.vehicle_ammo2   = self.vehicle_ammo2;
324     self.owner.vehicle_reload1 = self.vehicle_reload1;
325     self.owner.vehicle_reload2 = self.vehicle_reload2;
326
327     other.flags &~= FL_ONGROUND;
328     self.flags &~= FL_ONGROUND;
329
330     self.frame = 0;
331     raptor_setanim(0, 25, 1);
332
333     self.team                 = self.owner.team;
334     self.flags               -= FL_NOTARGET;
335
336     self.velocity = '0 0 1';
337
338     setorigin(other,self.origin + '0 0 32');
339     other.velocity = self.velocity;
340
341     other.flags &~= FL_ONGROUND;
342     msg_entity = other;
343     WriteByte (MSG_ONE, SVC_SETVIEWPORT);
344     WriteEntity( MSG_ONE, self.vehicle_viewport);
345
346     WriteByte (MSG_ONE, SVC_SETVIEWANGLES);     // 10 = SVC_SETVIEWANGLES
347     WriteAngle(MSG_ONE,  self.angles_x * -1);   // tilt
348     WriteAngle(MSG_ONE,  self.angles_y);        // yaw
349     WriteAngle(MSG_ONE,  0);                    // roll
350 }
351
352 void raptor_exit(float eject)
353 {
354         self.colormap   = 1024;
355         self.flags      = FL_NOTARGET;
356
357     if not (self.owner)
358         return;
359
360     msg_entity = self.owner;
361     WriteByte (MSG_ONE, SVC_SETVIEWPORT);
362     WriteEntity( MSG_ONE, self.owner);
363
364     WriteByte (MSG_ONE, SVC_SETVIEWANGLES);    // 10 = SVC_SETVIEWANGLES
365     WriteAngle(MSG_ONE,  0);                   // tilt
366     WriteAngle(MSG_ONE,  self.angles_y); // yaw
367     WriteAngle(MSG_ONE,  0);                   // roll
368
369     if (self.deadflag == DEAD_NO)
370     {
371         //self.think = racer_exitthink;
372         self.nextthink = time;
373     }
374
375     self.owner.takedamage     = DAMAGE_AIM;
376     self.owner.solid          = SOLID_SLIDEBOX;
377     self.owner.movetype       = MOVETYPE_WALK;
378
379     setsize(self.owner,PL_MIN,PL_MAX);
380
381     self.owner.effects        &~= EF_NODRAW;
382     self.owner.alpha          = 1;
383     self.owner.PlayerPhysplug = SUB_Null;
384     self.owner.vehicle        = world;
385         self.owner.view_ofs       = PL_VIEW_OFS;
386         self.owner.event_damage   = PlayerDamage;
387         self.owner.hud            = HUD_NORMAL;
388         //self.exteriormodeltoclient = self;
389
390     self.vehicle_hudmodel.viewmodelforclient = self;
391
392         if(eject)
393         {
394             makevectors(self.angles);
395             setorigin(self.owner,self.origin + v_forward * 100);
396             self.owner.velocity = (v_up + v_forward * 0.25) * 750;
397         }
398         else
399         {
400             self.owner.velocity = (v_forward) * -150;
401         setorigin(self.owner,self.origin - v_forward * 128);
402         }
403
404     self.owner = world;
405
406     if (self.deadflag != DEAD_NO)
407     {
408         entity ret;
409         ret = spawn();
410         ret.enemy = self;
411         ret.think = raptor_return;
412         ret.nextthink = time + cvar("g_vehicle_racer_respawntime");
413     }
414 }
415
416
417 float raptor_pplug()
418 {
419     entity player, vhic;
420     float ftmp, ftmp2, energy_used;
421     vector df;
422
423
424     if(cvar("g_vehicle_raptor_reload"))
425     {
426         raptor_loadsettings();
427         cvar_set("g_vehicle_raptor_reload","0");
428     }
429
430     player = self;
431     vhic   = self.vehicle;
432     self    = vhic;
433
434     if(player.BUTTON_USE)
435     {
436         self = vhic;
437         raptor_exit(0);
438         self = player;
439         return 0;
440     }
441
442     if(vhic.deadflag != DEAD_NO)
443     {
444         self = player;
445         player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
446         return 1;
447     }
448
449     vhic.angles_x *= -1;
450     // Rotate Body
451     ftmp = raptor_turnspeed * sys_frametime;
452
453     ftmp = bound(-ftmp, shortangle_f(player.v_angle_y - vhic.angles_y, vhic.angles_y), ftmp);
454
455     // Roll
456     //ftmp = bound(-90,shortangle_f(player.v_angle_z + ((vhic.angles_y - ftmp2) * raptor_turnroll), vhic.angles_z),90);
457     //ftmp = safeangle(vhic.angles_z + ftmp);
458     //vhic.angles_z = ftmp;
459
460     // Turn
461     vhic.angles_y = safeangle(vhic.angles_y + ftmp);
462
463     // Pitch Body
464     ftmp = raptor_pitchspeed  * sys_frametime;
465
466     ftmp = bound(-ftmp, shortangle_f(player.v_angle_x - vhic.angles_x,vhic.angles_x), ftmp);
467
468     vhic.angles_x = bound(-60,safeangle(vhic.angles_x + ftmp),60);
469     vhic.angles_x *= -1;
470
471     if(raptor_movestyle == 1)
472     {
473         ftmp = vhic.angles_z;
474         vhic.angles_z = 0;
475         ftmp2 = vhic.angles_x;
476         vhic.angles_x = 0;
477         fixedmakevectors(vhic.angles);
478         vhic.angles_z = ftmp;
479         vhic.angles_x = ftmp2;
480     }
481     else
482         fixedmakevectors(vhic.angles);
483
484     df = vhic.velocity * -1;
485
486     if(player.movement_x != 0)
487     {
488         if(player.movement_x > 0)
489             df += v_forward  * raptor_speed_forward;
490         else if(player.movement_x < 0)
491             df -= v_forward  * raptor_speed_forward;
492     }
493
494     if(player.movement_y != 0)
495     {
496         if(player.movement_y < 0)
497             df -= v_right * raptor_speed_strafe;
498         else if(player.movement_y > 0)
499             df += v_right * raptor_speed_strafe;
500
501         vhic.angles_z = bound(-30,vhic.angles_z + (player.movement_y / raptor_speed_strafe),30);
502     }
503     else
504     {
505         vhic.angles_z *= 0.95;
506         if(vhic.angles_z >= -1 && vhic.angles_z <= -1)
507             vhic.angles_z = 0;
508     }
509
510     if(player.BUTTON_CROUCH)
511         df -=   v_up * raptor_speed_down;
512     else if (player.BUTTON_JUMP)
513         df +=  v_up * raptor_speed_up;
514     //else
515         //df_z = vhic.velocity_z * -1;
516
517     vhic.velocity  += df * frametime;
518     player.velocity = player.movement  = vhic.velocity;
519     setorigin(player,vhic.origin + '0 0 32');
520
521     // Aim the gunz
522     /*
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_raptor()
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_raptor2()
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 }