]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/server/vehicles/spiderbot.qc
36863d8e2a65002383cc8b35bcd7a12a11f373ab
[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         if(intermission_running)
179                 return 1;
180                 
181     player = self;
182     spider = self.vehicle;
183     self   = spider;
184
185     vehicles_painframe();
186     
187     player.BUTTON_ZOOM      = 0;
188     player.BUTTON_CROUCH    = 0;
189     player.switchweapon     = 0;
190
191     crosshair_trace(player);
192     //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
193
194     player.v_angle_x *= -1;
195     gettaginfo(spider.tur_head, 0);
196     ad = player.v_angle - vectoangles2(v_forward, v_up);
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     self.movetype   = MOVETYPE_WALK;
420
421     self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_spiderbot_health);
422     self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_spiderbot_shield);
423
424     if(self.owner.flagcarried)
425     {
426         setattachment(self.owner.flagcarried, self.tur_head, ""); 
427         setorigin(self.owner.flagcarried, '-20 0 120'); 
428     }
429 }
430
431 void spiderbot_exit(float eject)
432 {
433     entity e;
434     vector spot;
435     
436     e = findchain(classname,"spiderbot_rocket");
437     while(e)
438     {
439         if(e.owner == self.owner)
440         {
441             e.realowner = self.owner;
442             e.owner = world;
443         }
444         e = e.chain;
445     }
446
447     self.velocity   = '0 0 0';
448     self.think      = spiderbot_think;
449     self.nextthink  = time;
450     self.frame      = 5;
451     self.movetype   = MOVETYPE_WALK;
452     
453     if not (self.owner)
454         return;
455
456         makevectors(self.angles);
457         if(eject)
458         {
459             spot = self.origin + v_forward * 100 + '0 0 64';
460             spot = vehicles_findgoodexit(spot);
461             setorigin(self.owner , spot);
462             self.owner.velocity = (v_up + v_forward * 0.25) * 750;
463         }
464         else
465         {
466             spot = self.origin - v_forward * 200 + '0 0 64';
467             spot = vehicles_findgoodexit(spot);
468             setorigin(self.owner , spot);
469         }
470         
471     self.owner = world;
472 }
473
474 void spiderbot_spawn()
475 {
476     self.frame              = 5;
477     self.tur_head.frame     = 1;
478     self.think              = spiderbot_think;
479     self.nextthink          = time;
480     self.vehicle_health     = autocvar_g_vehicle_spiderbot_health;
481     self.vehicle_shield     = autocvar_g_vehicle_spiderbot_shield;
482     self.movetype           = MOVETYPE_WALK;
483     self.solid              = SOLID_SLIDEBOX;
484     self.alpha              = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
485     self.tur_head.angles    = '0 0 0';
486
487     setorigin(self, self.pos1 + '0 0 128');
488     self.angles = self.pos2;
489 }
490
491 void spiderbot_headfade()
492 {
493         self.think = spiderbot_headfade;
494         self.nextthink = self.fade_time;
495         self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
496
497     if(self.cnt < time || self.alpha < 0.1)
498     {
499         if(self.alpha > 0.1)
500         {
501             sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
502             pointparticles(particleeffectnum("explosion_big"), self.origin + '0 0 100', '0 0 0', 1);
503         }
504         remove(self);
505     }
506 }
507
508 void spiderbot_blowup()
509 {
510     if(self.cnt > time)
511     {
512         if(random() < 0.1)
513         {
514             sound (self, CHAN_PROJECTILE, "weapons/rocket_impact.wav", VOL_BASE, ATTN_NORM);
515             pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
516         }
517         self.nextthink = time + 0.1;
518         return;
519     }
520     
521     entity h, g1, g2, b;
522     b = spawn();
523     h = spawn();
524     g1 = spawn();
525     g2 = spawn();
526
527     setmodel(b,  "models/vehicles/spiderbot.dpm");
528     setmodel(h,  "models/vehicles/spiderbot_top.dpm");
529     setmodel(g1, "models/vehicles/spiderbot_barrels.dpm");
530     setmodel(g2, "models/vehicles/spiderbot_barrels.dpm");
531
532     setorigin(b, self.origin);
533     b.frame         = 11;
534     b.angles        = self.angles;
535     setsize(b, self.mins, self.maxs);
536
537     setorigin(h, gettaginfo(self, gettagindex(self, "tag_head")));
538     h.movetype      = MOVETYPE_BOUNCE;
539     h.solid         = SOLID_BBOX;
540     h.velocity      = v_up * (500 + random() * 500) + randomvec() * 128;
541     h.modelflags    = MF_ROCKET;
542     h.effects       = EF_FLAME | EF_LOWPRECISION;
543     h.avelocity     = randomvec() * 360;
544
545     h.alpha         = 1;
546     h.cnt           = time + (3.5 * random());
547     h.fade_rate     = 1 / min(autocvar_g_vehicle_spiderbot_respawntime, 10);
548     h.fade_time     = time;
549     h.think         = spiderbot_headfade;
550     h.nextthink     = time;
551
552     setorigin(g1, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01")));
553     g1.movetype     = MOVETYPE_TOSS;
554     g1.solid        = SOLID_CORPSE;
555     g1.velocity     = v_forward * 700 + (randomvec() * 32);
556     g1.avelocity    = randomvec() * 180;
557
558     setorigin(g2, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02")));
559     g2.movetype     = MOVETYPE_TOSS;
560     g2.solid        = SOLID_CORPSE;
561     g2.velocity     = v_forward * 700 + (randomvec() * 32);
562     g2.avelocity    = randomvec() * 180;
563
564     h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
565
566     SUB_SetFade(b,  time + 5, min(autocvar_g_vehicle_spiderbot_respawntime, 1));
567     //SUB_SetFade(h,  time, min(autocvar_g_vehicle_spiderbot_respawntime, 10));
568     SUB_SetFade(g1, time, min(autocvar_g_vehicle_spiderbot_respawntime, 10));
569     SUB_SetFade(g2, time, min(autocvar_g_vehicle_spiderbot_respawntime, 10));
570
571     RadiusDamage (self, self, 250, 15, 250, world, 250, DEATH_SBBLOWUP, world);
572
573     self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = -1;
574     self.movetype   = MOVETYPE_NONE;
575     self.deadflag   = DEAD_DEAD;
576     self.solid      = SOLID_NOT;
577     self.tur_head.effects  &~=  EF_FLAME;
578         self.vehicle_hudmodel.viewmodelforclient = self;
579 }
580
581 void spiderbot_die()
582 {
583     sound (self, CHAN_TRIGGER, "vehicles/spiderbot_die.wav", VOL_BASE, ATTN_NORM);
584     pointparticles(particleeffectnum("explosion_medium"), self.origin + '0 0 100', '0 0 0', 1);
585
586     self.health             = 0;
587     self.event_damage       = SUB_Null;
588     self.takedamage         = DAMAGE_NO;
589     self.touch              = SUB_Null;
590     self.cnt                = 3.4 + time + random() * 2;
591     self.think              = spiderbot_blowup;
592     self.nextthink          = time;
593     self.deadflag           = DEAD_DYING;
594         self.frame              = 5;
595         self.tur_head.effects  |= EF_FLAME;
596         self.colormod           = self.tur_head.colormod = '-1 -1 -1';
597         self.frame              = 10;
598         self.movetype           = MOVETYPE_TOSS;
599 }
600
601 void vewhicle_spiderbot_dinit()
602 {
603     if not (vehicle_initialize(
604              "Spiderbot",
605              "models/vehicles/spiderbot.dpm",
606              "models/vehicles/spiderbot_top.dpm",
607              "models/vehicles/spiderbot_cockpit.dpm",
608              "tag_head", "tag_hud", "",
609              HUD_SPIDERBOT,
610              SPIDERBOT_MIN, SPIDERBOT_MAX,
611              FALSE,
612              spiderbot_spawn, autocvar_g_vehicle_spiderbot_respawntime,
613              spiderbot_frame,
614              spiderbot_enter, spiderbot_exit,
615              spiderbot_die,   spiderbot_think,
616              FALSE))
617     {
618         remove(self);
619         return;
620     }
621
622
623     self.gun1               = spawn();
624     self.gun2               = spawn();
625
626     setmodel(self.gun1, "models/vehicles/spiderbot_barrels.dpm");
627     setmodel(self.gun2, "models/vehicles/spiderbot_barrels.dpm");
628
629     setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
630     setattachment(self.gun2, self.tur_head, "tag_hardpoint02");
631
632     self.gravity            = 2;
633     self.mass               = 5000;
634 }
635
636 void spawnfunc_vehicle_spiderbot()
637 {
638     self.vehicle_flags |= VHF_DMGSHAKE;
639     //self.vehicle_flags |= VHF_DMGROLL;
640     //self.vehicle_flags |= VHF_DMGHEADROLL;
641     
642     precache_model ( "models/vhshield.md3");
643     precache_model ( "models/vehicles/spiderbot.dpm");
644     precache_model ( "models/vehicles/spiderbot_top.dpm");
645     precache_model ( "models/vehicles/spiderbot_barrels.dpm");
646     precache_model ( "models/vehicles/spiderbot_cockpit.dpm");
647     precache_model ( "models/uziflash.md3");
648
649     precache_sound ( "weapons/rocket_impact.wav" );
650     precache_sound ( "weapons/uzi_fire.wav" );
651     precache_sound ( "weapons/rocket_impact.wav");
652     
653     precache_sound ( "vehicles/spiderbot_die.wav");
654     precache_sound ( "vehicles/spiderbot_idle.wav");
655     precache_sound ( "vehicles/spiderbot_jump.wav");
656     precache_sound ( "vehicles/spiderbot_strafe.wav");
657     precache_sound ( "vehicles/spiderbot_walk.wav");
658     precache_sound ( "vehicles/spiderbot_land.wav");
659
660     vehicles_configcheck("vehicle_spiderbot.cfg", autocvar_g_vehicle_spiderbot_health);
661     if(autocvar_g_vehicle_spiderbot_shield)
662         self.vehicle_flags |= VHF_HASSHIELD;
663
664     if(autocvar_g_vehicle_spiderbot_shield_regen)
665         self.vehicle_flags |= VHF_SHIELDREGEN;
666
667     if(autocvar_g_vehicle_spiderbot_health_regen)
668         self.vehicle_flags |= VHF_HEALTHREGEN;
669     
670     self.think = vewhicle_spiderbot_dinit;    
671     self.nextthink = time + (autocvar_g_vehicles_delayspawn ? autocvar_g_vehicle_spiderbot_respawntime + (random() * autocvar_g_vehicles_delayspawn_jitter) : 0.5);
672 }
673 #endif // SVQC