]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/vehicles/spiderbot.qc
Merge remote branch 'origin/master' into tzork/vehicles-2
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / vehicles / spiderbot.qc
1 const vector SPIDERBOT_MIN = '-75 -75 10';
2 const vector SPIDERBOT_MAX  = '75 75 125';
3
4 #ifdef SVQC
5 float autocvar_g_vehicle_spiderbot_respawntime;
6
7 float autocvar_g_vehicle_spiderbot_speed_stop;
8 float autocvar_g_vehicle_spiderbot_speed_strafe;
9 float autocvar_g_vehicle_spiderbot_speed_walk;
10 float autocvar_g_vehicle_spiderbot_turnspeed;
11 float autocvar_g_vehicle_spiderbot_movement_inertia;
12
13 float autocvar_g_vehicle_spiderbot_springlength;
14 float autocvar_g_vehicle_spiderbot_springup;
15 float autocvar_g_vehicle_spiderbot_springblend;
16
17 float autocvar_g_vehicle_spiderbot_head_pitchlimit_down;
18 float autocvar_g_vehicle_spiderbot_head_pitchlimit_up;
19 float autocvar_g_vehicle_spiderbot_head_pitchspeed;
20 float autocvar_g_vehicle_spiderbot_head_turnlimit;
21 float autocvar_g_vehicle_spiderbot_head_turnspeed;
22
23 //float autocvar_g_vehicle_spiderbot_energy;
24 //float autocvar_g_vehicle_spiderbot_energy_regen;
25 //float autocvar_g_vehicle_spiderbot_energy_regen_pause;
26
27 float autocvar_g_vehicle_spiderbot_health;
28 float autocvar_g_vehicle_spiderbot_health_regen;
29 float autocvar_g_vehicle_spiderbot_health_regen_pause;
30
31 float autocvar_g_vehicle_spiderbot_shield;
32 float autocvar_g_vehicle_spiderbot_shield_regen;
33 float autocvar_g_vehicle_spiderbot_shield_regen_pause;
34
35 float autocvar_g_vehicle_spiderbot_minigun_damage;
36 float autocvar_g_vehicle_spiderbot_minigun_refire;
37 float autocvar_g_vehicle_spiderbot_minigun_spread;
38 float autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
39 float autocvar_g_vehicle_spiderbot_minigun_ammo_max;
40 float autocvar_g_vehicle_spiderbot_minigun_ammo_regen;
41 float autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause;
42
43 float autocvar_g_vehicle_spiderbot_rocket_damage;
44 float autocvar_g_vehicle_spiderbot_rocket_force;
45 float autocvar_g_vehicle_spiderbot_rocket_radius;
46 float autocvar_g_vehicle_spiderbot_rocket_speed;
47 float autocvar_g_vehicle_spiderbot_rocket_refire;
48 float autocvar_g_vehicle_spiderbot_rocket_reload;
49 float autocvar_g_vehicle_spiderbot_rocket_health;
50 float autocvar_g_vehicle_spiderbot_rocket_noise;
51 float autocvar_g_vehicle_spiderbot_rocket_turnrate;
52 float autocvar_g_vehicle_spiderbot_rocket_lifetime;
53
54 void spiderbot_exit(float eject);
55 void spiderbot_enter();
56 void spiderbot_spawn();
57
58 void spiderbot_rocket_unguided()
59 {
60     vector newdir, olddir;
61
62     self.nextthink  = time;
63
64     olddir = normalize(self.velocity);
65     newdir = normalize(self.pos1 - self.origin) + randomvec() * autocvar_g_vehicle_spiderbot_rocket_noise;
66     self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_spiderbot_rocket_turnrate) * autocvar_g_vehicle_spiderbot_rocket_speed;
67
68     UpdateCSQCProjectile(self);
69
70     if (self.owner.deadflag != DEAD_NO || self.cnt < time || vlen(self.pos1 - self.origin) < 16)
71         self.use();
72 }
73
74 void spiderbot_rocket_guided()
75 {
76     vector newdir, olddir;
77
78     self.nextthink  = time;
79
80     if not (self.realowner.vehicle)
81         self.think = spiderbot_rocket_unguided;
82
83     crosshair_trace(self.realowner);
84     olddir = normalize(self.velocity);
85     newdir = normalize(trace_endpos - self.origin) + randomvec() * autocvar_g_vehicle_spiderbot_rocket_noise;
86     self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_spiderbot_rocket_turnrate) * autocvar_g_vehicle_spiderbot_rocket_speed;
87
88     UpdateCSQCProjectile(self);
89
90     if (self.owner.deadflag != DEAD_NO || self.cnt < time)
91         self.use();
92 }
93
94 void spiderbot_guide_release()
95 {
96     entity rkt;
97     rkt = findchainentity(realowner, self.owner);
98     if not (rkt)
99         return;
100
101     crosshair_trace(self.owner);
102     while(rkt)
103     {
104         if(rkt.think == spiderbot_rocket_guided)
105         {
106             rkt.pos1 = trace_endpos;
107             rkt.think = spiderbot_rocket_unguided;
108         }
109         rkt = rkt.chain;
110     }
111 }
112
113 void spiderbot_rocket_do()
114 {
115
116     vector v;
117     entity rocket;
118
119     if (self.owner.BUTTON_ATCK2)
120     {
121         if (self.wait == 1)
122         if (self.tur_head.frame == 9 || self.tur_head.frame == 1)
123         {
124             if(self.gun2.cnt < time && self.tur_head.frame == 9)
125                 self.tur_head.frame = 1;
126
127             return;
128         }
129         self.wait = 1;
130     }
131     else
132     {
133         if(self.wait)
134             spiderbot_guide_release();
135
136         self.wait = 0;
137     }
138
139     if(self.gun2.cnt > time)
140         return;
141
142     if (self.tur_head.frame >= 9)
143         self.tur_head.frame = 1;
144
145     if not (self.owner.BUTTON_ATCK2)
146         return;
147
148     crosshair_trace(self.owner);
149
150     v = gettaginfo(self.tur_head,gettagindex(self.tur_head,"tag_fire"));
151     rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
152                            v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
153                            autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
154                            DEATH_SBROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, FALSE);
155
156     rocket.cnt        = time + 15;
157     rocket.classname  = "spiderbot_rocket";
158     rocket.pos1       = trace_endpos;
159     rocket.think      = spiderbot_rocket_guided;
160     rocket.nextthink  = time;
161     rocket.cnt        = time + autocvar_g_vehicle_spiderbot_rocket_lifetime;
162
163     self.tur_head.frame += 1;
164     if (self.tur_head.frame == 9)
165         self.attack_finished_single = autocvar_g_vehicle_spiderbot_rocket_reload;
166     else
167         self.attack_finished_single = autocvar_g_vehicle_spiderbot_rocket_refire;
168
169     self.gun2.cnt = time + self.attack_finished_single;
170 }
171
172 float spiderbot_frame()
173 {
174     vector ad;
175     entity player, spider;
176     float ftmp;
177
178     player = self;
179     spider = self.vehicle;
180     self   = spider;
181
182     player.BUTTON_ZOOM      = 0;
183     player.BUTTON_CROUCH    = 0;
184     player.switchweapon     = 0;
185
186     if(player.BUTTON_USE)
187     {
188         vehicles_exit(VHEF_NORMAL);
189         self = player;
190         return 0;
191     }
192
193     crosshair_trace(player);
194     //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
195
196     player.v_angle_x *= -1;
197     ad = player.v_angle - (spider.tur_head.angles + spider.angles);
198     player.v_angle_x *= -1;
199     if(ad_x > 180)  ad_x -= 360;
200     if(ad_x < -180) ad_x += 360;
201     if(ad_y > 180)  ad_y -= 360;
202     if(ad_y < -180) ad_y += 360;
203
204     // Rotate head
205     ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
206     ad_y = bound(-ftmp, ad_y, ftmp);
207     spider.tur_head.angles_y = bound(autocvar_g_vehicle_spiderbot_head_turnlimit * -1, spider.tur_head.angles_y + ad_y, autocvar_g_vehicle_spiderbot_head_turnlimit);
208
209     // Pitch head
210 #if 0 // Enable to pich by cross-trace (more precise in chase, but less predictable)
211     ad = vectoangles(normalize(trace_endpos - gettaginfo(spider.tur_head,gettagindex(spider.tur_head,"tag_hud")))) - (spider.tur_head.angles + spider.angles);
212     if(ad_x > 180) ad_x -= 360;
213     if(ad_x < -180) ad_x += 360;
214 #endif
215     ftmp = autocvar_g_vehicle_spiderbot_head_pitchspeed * sys_frametime;
216     ad_x = bound(ftmp * -1, ad_x, ftmp);
217     spider.tur_head.angles_x = bound(autocvar_g_vehicle_spiderbot_head_pitchlimit_down, spider.tur_head.angles_x + ad_x, autocvar_g_vehicle_spiderbot_head_pitchlimit_up);
218
219     // Turn Body
220     ftmp = autocvar_g_vehicle_spiderbot_turnspeed * sys_frametime;
221     ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);
222
223     makevectors(spider.angles + '-2 0 0' * spider.angles_x);
224
225 /*
226     vector ofs;
227     ofs = self.origin + v_up * 128;
228     te_lightning1(world, ofs, ofs + v_up * 32);
229     te_lightning1(world, ofs, ofs + v_right * 128);
230     te_lightning1(world, ofs, ofs + v_forward * 256);
231 */
232
233     movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend);
234
235     if(spider.flags & FL_ONGROUND)
236     {
237         if(spider.frame == 4 && self.tur_head.wait != 0)
238         {
239             sound (self, CHAN_TRIGGER, "vehicles/spiderbot_land.wav", VOL_VEHICLEENGINE, ATTN_NORM);
240             spider.frame = 5;            
241         }
242         
243         if(player.BUTTON_JUMP && self.tur_head.wait < time)
244         {        
245             sound (self, CHAN_TRIGGER, "vehicles/spiderbot_jump.wav", VOL_VEHICLEENGINE, ATTN_NORM);
246             //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
247             self.delay = 0;
248
249             self.tur_head.wait = time + 2;
250             player.BUTTON_JUMP = 0;
251             spider.velocity   = v_forward * 700 + v_up * 600;
252             spider.frame = 4;
253         }
254         else
255         {
256             if(vlen(player.movement) == 0)
257             {
258                 if(self.sound_nexttime < time || self.delay != 3)
259                 {                        
260                     self.delay = 3;
261                     self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
262                     //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
263                     sound (self, CHAN_TRIGGER, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTN_NORM);
264                 }                
265                 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
266                 spider.frame = 5;
267             }
268             else
269             {
270                 spider.angles_y = anglemods(spider.angles_y + ftmp);
271                 spider.tur_head.angles_y -= ftmp;
272
273                 if(player.movement_x != 0)
274                 {
275                     if(player.movement_x > 0)
276                     {
277                         player.movement_x = 1;
278                         spider.frame = 0;
279                     }
280                     else if(player.movement_x < 0)
281                     {
282                         player.movement_x = -1;
283                         spider.frame = 1;
284                     }
285                     player.movement_y = 0;
286                     movelib_move_simple(normalize(v_forward * player.movement_x),autocvar_g_vehicle_spiderbot_speed_walk,autocvar_g_vehicle_spiderbot_movement_inertia);
287
288                     if(self.sound_nexttime < time || self.delay != 1)
289                     {                        
290                         self.delay = 1;
291                         self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
292                         sound (self, CHAN_TRIGGER, "vehicles/spiderbot_walk.wav", VOL_VEHICLEENGINE, ATTN_NORM);
293                         //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
294                     }
295                 }
296                 else if(player.movement_y != 0)
297                 {
298                     if(player.movement_y < 0)
299                     {
300                         player.movement_y = -1;
301                         spider.frame = 2;
302                     }
303                     else if(player.movement_y > 0)
304                     {
305                         player.movement_y = 1;
306                         spider.frame = 3;
307                     }
308                     movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
309                     if(self.sound_nexttime < time || self.delay != 2)
310                     {                        
311                         self.delay = 2;
312                         self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
313                         sound (self, CHAN_TRIGGER, "vehicles/spiderbot_strafe.wav", VOL_VEHICLEENGINE, ATTN_NORM);
314                         //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
315                     }
316                 }
317             }
318         }
319     }
320
321     self.angles_x = bound(-45, self.angles_x, 45);
322     self.angles_z = bound(-45, self.angles_z, 45);
323
324     if(player.BUTTON_ATCK)
325     {
326         spider.cnt = time;
327         if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single <= time)
328         {
329             entity gun;
330             vector v;
331             spider.misc_bulletcounter += 1;
332
333             self = player;
334
335             mod(spider.misc_bulletcounter, 2) ? gun = spider.gun1 : gun = spider.gun2;
336             v = gettaginfo(gun, gettagindex(gun, "barrels"));
337             v_forward = normalize(v_forward);
338             v += v_forward * 50;
339
340             fireBullet (v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_damage,
341                 autocvar_g_vehicle_spiderbot_minigun_spread, DEATH_SBMINIGUN, 0);
342
343             sound (gun, CHAN_WEAPON, "weapons/uzi_fire.wav", VOL_BASE, ATTN_NORM);
344             trailparticles(self, particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
345             pointparticles(particleeffectnum("spiderbot_minigun_muzzleflash"), v, v_forward * 2500, 1);
346
347             self = spider;
348
349             spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
350             spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
351             player.vehicle_ammo1 = (spider.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
352         }
353     }
354     else
355         vehicles_regen(cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
356                                            autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
357                                            autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime);
358
359     spiderbot_rocket_do();
360
361     if(self.vehicle_flags  & VHF_SHIELDREGEN)
362         vehicles_regen(dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, frametime);
363
364     if(self.vehicle_flags  & VHF_HEALTHREGEN)
365         vehicles_regen(dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, frametime);
366
367     player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
368     player.vehicle_ammo2 = spider.tur_head.frame;
369
370     if(spider.gun2.cnt <= time)
371         player.vehicle_reload2 = 100;
372     else
373         player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single) * 100;
374
375     setorigin(player, spider.origin + '0 0 1' * SPIDERBOT_MAX_z);
376     player.velocity = spider.velocity;
377
378     VEHICLE_UPDATE_PLAYER(health, spiderbot);
379
380     if(self.vehicle_flags & VHF_HASSHIELD)
381         VEHICLE_UPDATE_PLAYER(shield, spiderbot);
382
383 #if 1 // 0 to enable per-gun impact aux crosshairs
384     // Avarage gun impact point's -> aux cross
385     vector vf;
386     ad = gettaginfo(spider.gun1, gettagindex(spider.gun1, "barrels"));
387     vf = v_forward;
388     ad += gettaginfo(spider.gun2, gettagindex(spider.gun2, "barrels"));
389     vf += v_forward;
390     ad = ad * 0.5;
391     v_forward = vf * 0.5;
392     traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
393     UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
394
395 #else
396     ad = gettaginfo(spider.gun1, gettagindex(spider.gun1, "barrels"));
397     traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
398     UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
399
400     ad = gettaginfo(spider.gun2, gettagindex(spider.gun2, "barrels"));
401     traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
402     UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 1);
403 #endif
404
405     self = player;
406     return 1;
407 }
408
409 void spiderbot_think()
410 {
411     if(self.flags & FL_ONGROUND)
412         movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
413
414     self.nextthink = time;
415 }
416
417 void spiderbot_enter()
418 {
419
420     self.movetype   = MOVETYPE_WALK;
421
422     self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_spiderbot_health);
423     self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_spiderbot_shield);
424 }
425
426 void spiderbot_exit(float eject)
427 {
428     entity e;
429     vector spot;
430     
431     e = findchain(classname,"spiderbot_rocket");
432     while(e)
433     {
434         if(e.owner == self.owner)
435         {
436             e.realowner = self.owner;
437             e.owner = world;
438         }
439         e = e.chain;
440     }
441
442     self.velocity   = '0 0 0';
443     self.think      = spiderbot_think;
444     self.nextthink  = time;
445     self.frame      = 5;
446     self.movetype   = MOVETYPE_WALK;
447     
448     if not (self.owner)
449         return;
450
451         makevectors(self.angles);
452         if(eject)
453         {
454             spot = self.origin + v_forward * 100 + '0 0 64';
455             spot = vehicles_findgoodexit(spot);
456             setorigin(self.owner , spot);
457             self.owner.velocity = (v_up + v_forward * 0.25) * 750;
458         }
459         else
460         {
461             spot = self.origin - v_forward * 200 + '0 0 64';
462             spot = vehicles_findgoodexit(spot);
463             setorigin(self.owner , spot);
464         }
465         
466     self.owner = world;
467 }
468
469 void spiderbot_spawn()
470 {
471     self.frame              = 5;
472     self.tur_head.frame     = 1;
473     self.think              = spiderbot_think;
474     self.nextthink          = time;
475     self.vehicle_health     = autocvar_g_vehicle_spiderbot_health;
476     self.vehicle_shield     = autocvar_g_vehicle_spiderbot_shield;
477     self.movetype           = MOVETYPE_WALK;
478     self.solid              = SOLID_SLIDEBOX;
479     self.alpha              = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
480     self.tur_head.angles    = '0 0 0';
481
482     setorigin(self, self.pos1 + '0 0 128');
483     self.angles = self.pos2;
484 }
485
486 void spiderbot_headfade()
487 {
488         self.think = spiderbot_headfade;
489         self.nextthink = self.fade_time;
490         self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
491
492     if(self.cnt < time || self.alpha < 0.1)
493     {
494         if(self.alpha > 0.1)
495         {
496             sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
497             pointparticles(particleeffectnum("explosion_big"), self.origin + '0 0 100', '0 0 0', 1);
498         }
499         remove(self);
500     }
501 }
502
503 void spiderbot_blowup()
504 {
505     if(self.cnt > time)
506     {
507         if(random() < 0.1)
508         {
509             sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
510             pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
511         }
512         self.nextthink = time + 0.1;
513         return;
514     }
515     
516     entity h, g1, g2, b;
517     b = spawn();
518     h = spawn();
519     g1 = spawn();
520     g2 = spawn();
521
522     setmodel(b,  "models/vehicles/spiderbot.dpm");
523     setmodel(h,  "models/vehicles/spiderbot_top.dpm");
524     setmodel(g1, "models/vehicles/spiderbot_barrels.dpm");
525     setmodel(g2, "models/vehicles/spiderbot_barrels.dpm");
526
527     setorigin(b, self.origin);
528     b.frame         = 11;
529     b.angles        = self.angles;
530     setsize(b, self.mins, self.maxs);
531
532     setorigin(h, gettaginfo(self, gettagindex(self, "tag_head")));
533     h.movetype      = MOVETYPE_BOUNCE;
534     h.solid         = SOLID_BBOX;
535     h.velocity      = v_up * (500 + random() * 500) + randomvec() * 128;
536     h.modelflags    = MF_ROCKET;
537     h.effects       = EF_FLAME | EF_LOWPRECISION;
538     h.avelocity     = randomvec() * 360;
539
540     h.alpha         = 1;
541     h.cnt           = time + (3.5 * random());
542     h.fade_rate     = 1 / min(autocvar_g_vehicle_spiderbot_respawntime, 10);
543     h.fade_time     = time;
544     h.think         = spiderbot_headfade;
545     h.nextthink     = time;
546
547     setorigin(g1, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01")));
548     g1.movetype     = MOVETYPE_TOSS;
549     g1.solid        = SOLID_CORPSE;
550     g1.velocity     = v_forward * 700 + (randomvec() * 32);
551     g1.avelocity    = randomvec() * 180;
552
553     setorigin(g2, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02")));
554     g2.movetype     = MOVETYPE_TOSS;
555     g2.solid        = SOLID_CORPSE;
556     g2.velocity     = v_forward * 700 + (randomvec() * 32);
557     g2.avelocity    = randomvec() * 180;
558
559     h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
560
561     SUB_SetFade(b,  time + 5, min(autocvar_g_vehicle_spiderbot_respawntime, 1));
562     //SUB_SetFade(h,  time, min(autocvar_g_vehicle_spiderbot_respawntime, 10));
563     SUB_SetFade(g1, time, min(autocvar_g_vehicle_spiderbot_respawntime, 10));
564     SUB_SetFade(g2, time, min(autocvar_g_vehicle_spiderbot_respawntime, 10));
565
566     RadiusDamage (self, self, 250, 15, 250, world, 250, DEATH_SBBLOWUP, world);
567
568     self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = -1;
569     self.movetype   = MOVETYPE_NONE;
570     self.deadflag   = DEAD_DEAD;
571     self.solid      = SOLID_NOT;
572     self.tur_head.effects  &~=  EF_FLAME;
573         self.vehicle_hudmodel.viewmodelforclient = self;
574 }
575
576 void spiderbot_die()
577 {
578     sound (self, CHAN_TRIGGER, "vehicles/spiderbot_die.wav", VOL_BASE, ATTN_NORM);
579     pointparticles(particleeffectnum("explosion_medium"), self.origin + '0 0 100', '0 0 0', 1);
580
581     self.health             = 0;
582     self.event_damage       = SUB_Null;
583     self.takedamage         = DAMAGE_NO;
584     self.touch              = SUB_Null;
585     self.cnt                = 3.4 + time + random() * 2;
586     self.think              = spiderbot_blowup;
587     self.nextthink          = time;
588     self.deadflag           = DEAD_DYING;
589         self.frame              = 5;
590         self.tur_head.effects  |= EF_FLAME;
591         self.colormod           = self.tur_head.colormod = '-1 -1 -1';
592         self.frame              = 10;
593         self.movetype           = MOVETYPE_TOSS;
594 }
595
596 void vewhicle_spiderbot_dinit()
597 {
598     if not (vehicle_initialize(
599              "Spiderbot",
600              "models/vehicles/spiderbot.dpm",
601              "models/vehicles/spiderbot_top.dpm",
602              "models/vehicles/spiderbot_cockpit.dpm",
603              "tag_head", "tag_hud", "",
604              HUD_SPIDERBOT,
605              SPIDERBOT_MIN, SPIDERBOT_MAX,
606              FALSE,
607              spiderbot_spawn, autocvar_g_vehicle_spiderbot_respawntime,
608              spiderbot_frame,
609              spiderbot_enter, spiderbot_exit,
610              spiderbot_die,   spiderbot_think,
611              FALSE))
612     {
613         remove(self);
614         return;
615     }
616
617
618     self.gun1               = spawn();
619     self.gun2               = spawn();
620
621     setmodel(self.gun1, "models/vehicles/spiderbot_barrels.dpm");
622     setmodel(self.gun2, "models/vehicles/spiderbot_barrels.dpm");
623
624     setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
625     setattachment(self.gun2, self.tur_head, "tag_hardpoint02");
626
627     self.gravity            = 2;
628     self.mass               = 5000;
629 }
630
631 void spawnfunc_vehicle_spiderbot()
632 {
633     precache_model ( "models/vhshield.md3");
634     precache_model ( "models/vehicles/spiderbot.dpm");
635     precache_model ( "models/vehicles/spiderbot_top.dpm");
636     precache_model ( "models/vehicles/spiderbot_barrels.dpm");
637     precache_model ( "models/vehicles/spiderbot_cockpit.dpm");
638     precache_model ( "models/uziflash.md3");
639
640     precache_sound ( "weapons/rocket_impact.wav" );
641     precache_sound ( "weapons/uzi_fire.wav" );
642     precache_sound ( "weapons/rocket_impact.wav");
643     
644     precache_sound ( "vehicles/spiderbot_die.wav");
645     precache_sound ( "vehicles/spiderbot_idle.wav");
646     precache_sound ( "vehicles/spiderbot_jump.wav");
647     precache_sound ( "vehicles/spiderbot_strafe.wav");
648     precache_sound ( "vehicles/spiderbot_walk.wav");
649     precache_sound ( "vehicles/spiderbot_land.wav");
650
651     vehicles_configcheck("vehicle_spiderbot.cfg", autocvar_g_vehicle_spiderbot_health);
652     if(autocvar_g_vehicle_spiderbot_shield)
653         self.vehicle_flags |= VHF_HASSHIELD;
654
655     if(autocvar_g_vehicle_spiderbot_shield_regen)
656         self.vehicle_flags |= VHF_SHIELDREGEN;
657
658     if(autocvar_g_vehicle_spiderbot_health_regen)
659         self.vehicle_flags |= VHF_HEALTHREGEN;
660     
661     self.think = vewhicle_spiderbot_dinit;    
662     self.nextthink = time + (autocvar_g_vehicles_delayspawn ? autocvar_g_vehicle_spiderbot_respawntime + (random() * autocvar_g_vehicles_delayspawn_jitter) : 0.5);
663 }
664 #endif // SVQC