01c0caeacf898a8aafe6bb3e28a68da4ef110557
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / unit / spiderbot.qc
1 #ifdef REGISTER_VEHICLE
2 REGISTER_VEHICLE(
3 /* VEH_##id   */ SPIDERBOT,
4 /* function   */ v_spiderbot,
5 /* spawnflags */ VHF_DMGSHAKE,
6 /* mins,maxs  */ '-75 -75 10', '75 75 125',
7 /* model          */ "models/vehicles/spiderbot.dpm",
8 /* head_model */ "models/vehicles/spiderbot_top.dpm",
9 /* hud_model  */ "models/vehicles/spiderbot_cockpit.dpm",
10 /* tags           */ "tag_head", "tag_hud", "",
11 /* netname        */ "spiderbot",
12 /* fullname   */ _("Spiderbot")
13 );
14 #else
15
16 const int SBRM_FIRST = 1;
17 const int SBRM_VOLLY = 1;
18 const int SBRM_GUIDE = 2;
19 const int SBRM_ARTILLERY = 3;
20 const int SBRM_LAST = 3;
21
22 #ifdef SVQC
23 bool autocvar_g_vehicle_spiderbot;
24
25 float autocvar_g_vehicle_spiderbot_respawntime;
26
27 float autocvar_g_vehicle_spiderbot_speed_stop;
28 float autocvar_g_vehicle_spiderbot_speed_strafe;
29 float autocvar_g_vehicle_spiderbot_speed_walk;
30 float autocvar_g_vehicle_spiderbot_turnspeed;
31 float autocvar_g_vehicle_spiderbot_turnspeed_strafe;
32 float autocvar_g_vehicle_spiderbot_movement_inertia;
33
34 float autocvar_g_vehicle_spiderbot_springlength;
35 float autocvar_g_vehicle_spiderbot_springup;
36 float autocvar_g_vehicle_spiderbot_springblend;
37 float autocvar_g_vehicle_spiderbot_tiltlimit;
38
39 float autocvar_g_vehicle_spiderbot_head_pitchlimit_down;
40 float autocvar_g_vehicle_spiderbot_head_pitchlimit_up;
41 float autocvar_g_vehicle_spiderbot_head_turnlimit;
42 float autocvar_g_vehicle_spiderbot_head_turnspeed;
43
44 int autocvar_g_vehicle_spiderbot_health;
45 float autocvar_g_vehicle_spiderbot_health_regen;
46 float autocvar_g_vehicle_spiderbot_health_regen_pause;
47
48 int autocvar_g_vehicle_spiderbot_shield;
49 float autocvar_g_vehicle_spiderbot_shield_regen;
50 float autocvar_g_vehicle_spiderbot_shield_regen_pause;
51
52 float autocvar_g_vehicle_spiderbot_minigun_damage;
53 float autocvar_g_vehicle_spiderbot_minigun_refire;
54 float autocvar_g_vehicle_spiderbot_minigun_spread;
55 int autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
56 int autocvar_g_vehicle_spiderbot_minigun_ammo_max;
57 int autocvar_g_vehicle_spiderbot_minigun_ammo_regen;
58 float autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause;
59 float autocvar_g_vehicle_spiderbot_minigun_force;
60 float autocvar_g_vehicle_spiderbot_minigun_solidpenetration;
61
62 float autocvar_g_vehicle_spiderbot_rocket_damage;
63 float autocvar_g_vehicle_spiderbot_rocket_force;
64 float autocvar_g_vehicle_spiderbot_rocket_radius;
65 float autocvar_g_vehicle_spiderbot_rocket_speed;
66 float autocvar_g_vehicle_spiderbot_rocket_spread;
67 float autocvar_g_vehicle_spiderbot_rocket_refire;
68 float autocvar_g_vehicle_spiderbot_rocket_refire2;
69 float autocvar_g_vehicle_spiderbot_rocket_reload;
70 float autocvar_g_vehicle_spiderbot_rocket_health;
71 float autocvar_g_vehicle_spiderbot_rocket_noise;
72 float autocvar_g_vehicle_spiderbot_rocket_turnrate;
73 float autocvar_g_vehicle_spiderbot_rocket_lifetime;
74
75 vector autocvar_g_vehicle_spiderbot_bouncepain;
76
77 void spiderbot_rocket_artillery()
78 {
79         self.nextthink = time;
80         UpdateCSQCProjectile(self);
81 }
82
83 void spiderbot_rocket_unguided()
84 {
85         vector newdir, olddir;
86
87         self.nextthink  = time;
88
89         olddir = normalize(self.velocity);
90         newdir = normalize(self.pos1 - self.origin) + randomvec() * autocvar_g_vehicle_spiderbot_rocket_noise;
91         self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_spiderbot_rocket_turnrate) * autocvar_g_vehicle_spiderbot_rocket_speed;
92
93         UpdateCSQCProjectile(self);
94
95         if (self.owner.deadflag != DEAD_NO || self.cnt < time || vlen(self.pos1 - self.origin) < 16)
96                 self.use();
97 }
98
99 void spiderbot_rocket_guided()
100 {
101         vector newdir, olddir;
102
103         self.nextthink  = time;
104
105         if(!self.realowner.vehicle)
106                 self.think = spiderbot_rocket_unguided;
107
108         crosshair_trace(self.realowner);
109         olddir = normalize(self.velocity);
110         newdir = normalize(trace_endpos - self.origin) + randomvec() * autocvar_g_vehicle_spiderbot_rocket_noise;
111         self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_spiderbot_rocket_turnrate) * autocvar_g_vehicle_spiderbot_rocket_speed;
112
113         UpdateCSQCProjectile(self);
114
115         if (self.owner.deadflag != DEAD_NO || self.cnt < time)
116                 self.use();
117 }
118
119 void spiderbot_guide_release()
120 {
121         entity rkt;
122         rkt = findchainentity(realowner, self.owner);
123         if(!rkt)
124                 return;
125
126         crosshair_trace(self.owner);
127         while(rkt)
128         {
129                 if(rkt.think == spiderbot_rocket_guided)
130                 {
131                         rkt.pos1 = trace_endpos;
132                         rkt.think = spiderbot_rocket_unguided;
133                 }
134                 rkt = rkt.chain;
135         }
136 }
137
138 float spiberbot_calcartillery_flighttime;
139 vector spiberbot_calcartillery(vector org, vector tgt, float ht)
140 {
141         float grav, sdist, zdist, vs, vz, jumpheight;
142         vector sdir;
143
144         grav  = autocvar_sv_gravity;
145         zdist = tgt_z - org_z;
146         sdist = vlen(tgt - org - zdist * '0 0 1');
147         sdir  = normalize(tgt - org - zdist * '0 0 1');
148
149         // how high do we need to go?
150         jumpheight = fabs(ht);
151         if(zdist > 0)
152                 jumpheight = jumpheight + zdist;
153
154         // push so high...
155         vz = sqrt(2 * grav * jumpheight); // NOTE: sqrt(positive)!
156
157         // we start with downwards velocity only if it's a downjump and the jump apex should be outside the jump!
158         if(ht < 0)
159                 if(zdist < 0)
160                         vz = -vz;
161
162         vector solution;
163         solution = solve_quadratic(0.5 * grav, -vz, zdist); // equation "z(ti) = zdist"
164         // ALWAYS solvable because jumpheight >= zdist
165         if(!solution_z)
166                 solution_y = solution_x; // just in case it is not solvable due to roundoff errors, assume two equal solutions at their center (this is mainly for the usual case with ht == 0)
167         if(zdist == 0)
168                 solution_x = solution_y; // solution_x is 0 in this case, so don't use it, but rather use solution_y (which will be sqrt(0.5 * jumpheight / grav), actually)
169
170         if(zdist < 0)
171         {
172                 // down-jump
173                 if(ht < 0)
174                 {
175                         // almost straight line type
176                         // jump apex is before the jump
177                         // we must take the larger one
178                         spiberbot_calcartillery_flighttime = solution_y;
179                 }
180                 else
181                 {
182                         // regular jump
183                         // jump apex is during the jump
184                         // we must take the larger one too
185                         spiberbot_calcartillery_flighttime = solution_y;
186                 }
187         }
188         else
189         {
190                 // up-jump
191                 if(ht < 0)
192                 {
193                         // almost straight line type
194                         // jump apex is after the jump
195                         // we must take the smaller one
196                         spiberbot_calcartillery_flighttime = solution_x;
197                 }
198                 else
199                 {
200                         // regular jump
201                         // jump apex is during the jump
202                         // we must take the larger one
203                         spiberbot_calcartillery_flighttime = solution_y;
204                 }
205         }
206         vs = sdist / spiberbot_calcartillery_flighttime;
207
208         // finally calculate the velocity
209         return sdir * vs + '0 0 1' * vz;
210 }
211
212 void spiderbot_rocket_do()
213 {
214         vector v;
215         entity rocket = world;
216
217         if (self.wait != -10)
218         {
219                 if (self.owner.BUTTON_ATCK2 && self.vehicle_weapon2mode == SBRM_GUIDE)
220                 {
221                         if (self.wait == 1)
222                         if (self.tur_head.frame == 9 || self.tur_head.frame == 1)
223                         {
224                                 if(self.gun2.cnt < time && self.tur_head.frame == 9)
225                                         self.tur_head.frame = 1;
226
227                                 return;
228                         }
229                         self.wait = 1;
230                 }
231                 else
232                 {
233                         if(self.wait)
234                                 spiderbot_guide_release();
235
236                         self.wait = 0;
237                 }
238         }
239
240         if(self.gun2.cnt > time)
241                 return;
242
243         if (self.tur_head.frame >= 9)
244         {
245                 self.tur_head.frame = 1;
246                 self.wait = 0;
247         }
248
249         if(self.wait != -10)
250         if(!self.owner.BUTTON_ATCK2)
251                 return;
252                 
253         if(forbidWeaponUse(self.owner))
254                 return;
255
256         v = gettaginfo(self.tur_head,gettagindex(self.tur_head,"tag_fire"));
257
258         switch(self.vehicle_weapon2mode)
259         {
260                 case SBRM_VOLLY:
261                         rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
262                                                                    v, normalize(randomvec() * autocvar_g_vehicle_spiderbot_rocket_spread + v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
263                                                                    autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
264                                                                    DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
265                         crosshair_trace(self.owner);
266                         float _dist = (random() * autocvar_g_vehicle_spiderbot_rocket_radius) + vlen(v - trace_endpos);
267                         _dist -= (random() * autocvar_g_vehicle_spiderbot_rocket_radius) ;
268                         rocket.nextthink  = time + (_dist / autocvar_g_vehicle_spiderbot_rocket_speed);
269                         rocket.think     = vehicles_projectile_explode;
270
271                         if(self.owner.BUTTON_ATCK2 && self.tur_head.frame == 1)
272                                 self.wait = -10;
273                         break;
274                 case SBRM_GUIDE:
275                         rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
276                                                                    v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
277                                                                    autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
278                                                                    DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, false, self.owner);
279                         crosshair_trace(self.owner);
280                         rocket.pos1        = trace_endpos;
281                         rocket.nextthink  = time;
282                         rocket.think      = spiderbot_rocket_guided;
283
284
285                 break;
286                 case SBRM_ARTILLERY:
287                         rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
288                                                                    v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
289                                                                    autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
290                                                                    DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, false, true, self.owner);
291
292                         crosshair_trace(self.owner);
293
294                         rocket.pos1        = trace_endpos + randomvec() * (0.75 * autocvar_g_vehicle_spiderbot_rocket_radius);
295                         rocket.pos1_z      = trace_endpos_z;
296
297                         traceline(v, v + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
298                         float h1 = 0.75 * vlen(v - trace_endpos);
299
300                         //v = trace_endpos;
301                         traceline(v , rocket.pos1 + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
302                         float h2 = 0.75 * vlen(rocket.pos1 - v);
303
304                         rocket.velocity  = spiberbot_calcartillery(v, rocket.pos1, ((h1 < h2) ? h1 : h2));
305                         rocket.movetype  = MOVETYPE_TOSS;
306                         rocket.gravity   = 1;
307                         //rocket.think   = spiderbot_rocket_artillery;
308                 break;
309         }
310         rocket.classname  = "spiderbot_rocket";
311
312         rocket.cnt = time + autocvar_g_vehicle_spiderbot_rocket_lifetime;
313
314         self.tur_head.frame += 1;
315         if (self.tur_head.frame == 9)
316                 self.attack_finished_single = autocvar_g_vehicle_spiderbot_rocket_reload;
317         else
318                 self.attack_finished_single = ((self.vehicle_weapon2mode ==  SBRM_VOLLY) ? autocvar_g_vehicle_spiderbot_rocket_refire2 : autocvar_g_vehicle_spiderbot_rocket_refire);
319
320         self.gun2.cnt = time + self.attack_finished_single;
321 }
322
323 float spiderbot_frame()
324 {
325         vector ad, vf;
326         entity player, spider;
327         float ftmp;
328
329         if(intermission_running)
330         {
331                 self.vehicle.velocity = '0 0 0';
332                 self.vehicle.avelocity = '0 0 0';
333                 return 1;
334         }
335
336         player = self;
337         spider = self.vehicle;
338         self   = spider;
339
340         vehicles_painframe();
341
342         player.BUTTON_ZOOM        = 0;
343         player.BUTTON_CROUCH    = 0;
344         player.switchweapon      = 0;
345         player.vehicle_weapon2mode = spider.vehicle_weapon2mode;
346
347
348 #if 1 // 0 to enable per-gun impact aux crosshairs
349         // Avarage gun impact point's -> aux cross
350         ad = gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint01"));
351         vf = v_forward;
352         ad += gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint02"));
353         vf += v_forward;
354         ad = ad * 0.5;
355         v_forward = vf * 0.5;
356         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
357         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
358 #else
359         ad = gettaginfo(spider.gun1, gettagindex(spider.gun1, "barrels"));
360         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
361         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
362         vf = ad;
363         ad = gettaginfo(spider.gun2, gettagindex(spider.gun2, "barrels"));
364         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
365         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 1);
366         ad = 0.5 * (ad + vf);
367 #endif
368
369         crosshair_trace(player);
370         ad = vectoangles(normalize(trace_endpos - ad));
371         ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
372         ad = AnglesTransform_Normalize(ad, true);
373         //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
374
375         // Rotate head
376         ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
377         ad_y = bound(-ftmp, ad_y, ftmp);
378         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);
379
380         // Pitch head
381         ad_x = bound(ftmp * -1, ad_x, ftmp);
382         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);
383
384
385         //fixedmakevectors(spider.angles);
386         makevectors(spider.angles + '-2 0 0' * spider.angles_x);
387
388         movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
389
390         if(spider.flags & FL_ONGROUND)
391         {
392                 if(spider.frame == 4 && self.tur_head.wait != 0)
393                 {
394                         sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_land.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
395                         spider.frame = 5;
396                 }
397
398                 if(player.BUTTON_JUMP && self.tur_head.wait < time)
399                 {
400                         sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_jump.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
401                         //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
402                         self.delay = 0;
403
404                         self.tur_head.wait = time + 2;
405                         player.BUTTON_JUMP = 0;
406                         spider.velocity   = v_forward * 700 + v_up * 600;
407                         spider.frame = 4;
408                 }
409                 else
410                 {
411                         if(vlen(player.movement) == 0)
412                         {
413                                 if(self.sound_nexttime < time || self.delay != 3)
414                                 {
415                                         self.delay = 3;
416                                         self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
417                                         //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
418                                         sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
419                                 }
420                                 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
421                                 spider.frame = 5;
422                         }
423                         else
424                         {
425                                 // Turn Body
426                                 if(player.movement_x == 0 && player.movement_y != 0)
427                                         ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * sys_frametime;
428                                 else
429                                         ftmp = autocvar_g_vehicle_spiderbot_turnspeed * sys_frametime;
430
431                                 ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);
432                                 spider.angles_y = anglemods(spider.angles_y + ftmp);
433                                 spider.tur_head.angles_y -= ftmp;
434
435                                 if(player.movement_x != 0)
436                                 {
437                                         if(player.movement_x > 0)
438                                         {
439                                                 player.movement_x = 1;
440                                                 spider.frame = 0;
441                                         }
442                                         else if(player.movement_x < 0)
443                                         {
444                                                 player.movement_x = -1;
445                                                 spider.frame = 1;
446                                         }
447                                         player.movement_y = 0;
448                                         movelib_move_simple(normalize(v_forward * player.movement_x),autocvar_g_vehicle_spiderbot_speed_walk,autocvar_g_vehicle_spiderbot_movement_inertia);
449
450                                         if(self.sound_nexttime < time || self.delay != 1)
451                                         {
452                                                 self.delay = 1;
453                                                 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
454                                                 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_walk.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
455                                                 //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
456                                         }
457                                 }
458                                 else if(player.movement_y != 0)
459                                 {
460                                         if(player.movement_y < 0)
461                                         {
462                                                 player.movement_y = -1;
463                                                 spider.frame = 2;
464                                         }
465                                         else if(player.movement_y > 0)
466                                         {
467                                                 player.movement_y = 1;
468                                                 spider.frame = 3;
469                                         }
470                                         movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
471                                         if(self.sound_nexttime < time || self.delay != 2)
472                                         {
473                                                 self.delay = 2;
474                                                 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
475                                                 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_strafe.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
476                                                 //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
477                                         }
478                                 }
479                         }
480                 }
481         }
482
483         self.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
484         self.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
485
486         if(!forbidWeaponUse(player))
487         if(player.BUTTON_ATCK)
488         {
489                 spider.cnt = time;
490                 if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single <= time)
491                 {
492                         entity gun;
493                         vector v;
494                         spider.misc_bulletcounter += 1;
495
496                         self = player;
497
498                         gun = (spider.misc_bulletcounter % 2) ? spider.gun1 : spider.gun2;
499
500                         v = gettaginfo(gun, gettagindex(gun, "barrels"));
501                         v_forward = normalize(v_forward);
502                         v += v_forward * 50;
503
504                         fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
505                                 autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0);
506
507                         sound (gun, CH_WEAPON_A, "weapons/uzi_fire.wav", VOL_BASE, ATTEN_NORM);
508                         //trailparticles(self, particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
509                         pointparticles(particleeffectnum("spiderbot_minigun_muzzleflash"), v, v_forward * 2500, 1);
510
511                         self = spider;
512
513                         spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
514                         spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
515                         player.vehicle_ammo1 = (spider.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
516                         spider.gun1.angles_z += 45;
517                         spider.gun2.angles_z -= 45;
518                         if(spider.gun1.angles_z >= 360)
519                         {
520                                 spider.gun1.angles_z = 0;
521                                 spider.gun2.angles_z = 0;
522                         }
523                 }
524         }
525         else
526                 vehicles_regen(spider.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
527                                                                                    autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
528                                                                                    autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, false);
529
530
531         spiderbot_rocket_do();
532
533         if(self.vehicle_flags  & VHF_SHIELDREGEN)
534                 vehicles_regen(spider.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, frametime, true);
535
536         if(self.vehicle_flags  & VHF_HEALTHREGEN)
537                 vehicles_regen(spider.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, frametime, false);
538
539         player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
540         player.vehicle_ammo2 = spider.tur_head.frame;
541
542         if(spider.gun2.cnt <= time)
543                 player.vehicle_reload2 = 100;
544         else
545                 player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single) * 100;
546
547         setorigin(player, spider.origin + '0 0 1' * spider.maxs_z);
548         player.velocity = spider.velocity;
549
550         VEHICLE_UPDATE_PLAYER(player, health, spiderbot);
551
552         if(self.vehicle_flags & VHF_HASSHIELD)
553                 VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
554
555         self = player;
556         return 1;
557 }
558
559 void spiderbot_exit(float eject)
560 {
561         entity e;
562         vector spot;
563
564         e = findchain(classname,"spiderbot_rocket");
565         while(e)
566         {
567                 if(e.owner == self.owner)
568                 {
569                         e.realowner = self.owner;
570                         e.owner = world;
571                 }
572                 e = e.chain;
573         }
574
575         self.think = vehicles_think;
576         self.nextthink = time;
577         self.frame = 5;
578         self.movetype = MOVETYPE_WALK;
579
580         if(!self.owner)
581                 return;
582
583         makevectors(self.angles);
584         if(eject)
585         {
586                 spot = self.origin + v_forward * 100 + '0 0 64';
587                 spot = vehicles_findgoodexit(spot);
588                 setorigin(self.owner , spot);
589                 self.owner.velocity = (v_up + v_forward * 0.25) * 750;
590                 self.owner.oldvelocity = self.owner.velocity;
591         }
592         else
593         {
594                 if(vlen(self.velocity) > autocvar_g_vehicle_spiderbot_speed_strafe)
595                 {
596                         self.owner.velocity = normalize(self.velocity) * vlen(self.velocity);
597                         self.owner.velocity_z += 200;
598                         spot = self.origin + v_forward * 128 + '0 0 64';
599                         spot = vehicles_findgoodexit(spot);
600                 }
601                 else
602                 {
603                         self.owner.velocity = self.velocity * 0.5;
604                         self.owner.velocity_z += 10;
605                         spot = self.origin + v_forward * 256 + '0 0 64';
606                         spot = vehicles_findgoodexit(spot);
607                 }
608                 self.owner.oldvelocity = self.owner.velocity;
609                 setorigin(self.owner , spot);
610         }
611
612         antilag_clear(self.owner);
613         self.owner = world;
614 }
615
616 void spiderbot_headfade()
617 {
618         self.think = spiderbot_headfade;
619         self.nextthink = self.fade_time;
620         self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
621
622         if(self.cnt < time || self.alpha < 0.1)
623         {
624                 if(self.alpha > 0.1)
625                 {
626                         sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
627                         pointparticles(particleeffectnum("explosion_big"), self.origin + '0 0 100', '0 0 0', 1);
628                 }
629                 remove(self);
630         }
631 }
632
633 void spiderbot_blowup()
634 {
635         if(self.cnt > time)
636         {
637                 if(random() < 0.1)
638                 {
639                         sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
640                         pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
641                 }
642                 self.nextthink = time + 0.1;
643                 return;
644         }
645
646         entity h, g1, g2, b;
647         b = spawn();
648         h = spawn();
649         g1 = spawn();
650         g2 = spawn();
651
652         setmodel(b, "models/vehicles/spiderbot.dpm");
653         setmodel(h, "models/vehicles/spiderbot_top.dpm");
654         setmodel(g1, "models/vehicles/spiderbot_barrels.dpm");
655         setmodel(g2, "models/vehicles/spiderbot_barrels.dpm");
656
657         setorigin(b, self.origin);
658         b.frame = 11;
659         b.angles = self.angles;
660         setsize(b, self.mins, self.maxs);
661
662         setorigin(h, gettaginfo(self, gettagindex(self, "tag_head")));
663         h.movetype = MOVETYPE_BOUNCE;
664         h.solid = SOLID_BBOX;
665         h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
666         h.modelflags = MF_ROCKET;
667         h.effects = EF_FLAME | EF_LOWPRECISION;
668         h.avelocity = randomvec() * 360;
669
670         h.alpha = 1;
671         h.cnt = time + (3.5 * random());
672         h.fade_rate = 1 / min(self.respawntime, 10);
673         h.fade_time = time;
674         h.think = spiderbot_headfade;
675         h.nextthink = time;
676
677         setorigin(g1, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01")));
678         g1.movetype = MOVETYPE_TOSS;
679         g1.solid = SOLID_CORPSE;
680         g1.velocity = v_forward * 700 + (randomvec() * 32);
681         g1.avelocity = randomvec() * 180;
682
683         setorigin(g2, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02")));
684         g2.movetype = MOVETYPE_TOSS;
685         g2.solid = SOLID_CORPSE;
686         g2.velocity = v_forward * 700 + (randomvec() * 32);
687         g2.avelocity = randomvec() * 180;
688
689         h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
690
691         SUB_SetFade(b,  time + 5, min(self.respawntime, 1));
692         //SUB_SetFade(h,  time, min(self.respawntime, 10));
693         SUB_SetFade(g1, time, min(self.respawntime, 10));
694         SUB_SetFade(g2, time, min(self.respawntime, 10));
695
696         RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_SPID_DEATH, world);
697
698         self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = -1;
699         self.movetype = MOVETYPE_NONE;
700         self.deadflag = DEAD_DEAD;
701         self.solid = SOLID_NOT;
702         self.tur_head.effects &= ~EF_FLAME;
703         self.vehicle_hudmodel.viewmodelforclient = self;
704 }
705
706 float spiderbot_impulse(float _imp)
707 {
708         switch(_imp)
709         {
710                 case 10:
711                 case 15:
712                 case 18:
713                         self.vehicle.vehicle_weapon2mode += 1;
714                         if(self.vehicle.vehicle_weapon2mode > SBRM_LAST)
715                                 self.vehicle.vehicle_weapon2mode = SBRM_FIRST;
716
717                         //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
718                         CSQCVehicleSetup(self, 0);
719                         return true;
720                 case 12:
721                 case 16:
722                 case 19:
723                         self.vehicle.vehicle_weapon2mode -= 1;
724                         if(self.vehicle.vehicle_weapon2mode < SBRM_FIRST)
725                                 self.vehicle.vehicle_weapon2mode = SBRM_LAST;
726
727                         //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
728                         CSQCVehicleSetup(self, 0);
729                         return true;
730
731                 /*
732                 case 17: // toss gun, could be used to exit?
733                         break;
734                 case 20: // Manual minigun reload?
735                         break;
736                 */
737         }
738         return false;
739 }
740
741 void spawnfunc_vehicle_spiderbot()
742 {
743         if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
744         if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
745 }
746
747 float v_spiderbot(float req)
748 {
749         switch(req)
750         {
751                 case VR_IMPACT:
752                 {
753                         if(autocvar_g_vehicle_spiderbot_bouncepain)
754                                 vehicles_impact(autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
755                 
756                         return true;
757                 }
758                 case VR_ENTER:
759                 {
760                         self.vehicle_weapon2mode = SBRM_GUIDE;
761                         self.movetype = MOVETYPE_WALK;
762                         CSQCVehicleSetup(self.owner, 0);
763                         self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_spiderbot_health) * 100;
764                         self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
765
766                         if(self.owner.flagcarried)
767                         {
768                                 setattachment(self.owner.flagcarried, self.tur_head, "");
769                                 setorigin(self.owner.flagcarried, '-20 0 120');
770                         }
771                 
772                         return true;
773                 }
774                 case VR_THINK:
775                 {
776                         if(self.flags & FL_ONGROUND)
777                                 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
778                         
779                         return true;
780                 }
781                 case VR_DEATH:
782                 {
783                         self.health                             = 0;
784                         self.event_damage               = func_null;
785                         self.takedamage                 = DAMAGE_NO;
786                         self.touch                              = func_null;
787                         self.cnt                                = 3.4 + time + random() * 2;
788                         self.think                              = spiderbot_blowup;
789                         self.nextthink                  = time;
790                         self.deadflag                   = DEAD_DYING;
791                         self.frame                              = 5;
792                         self.tur_head.effects  |= EF_FLAME;
793                         self.colormod                   = self.tur_head.colormod = '-1 -1 -1';
794                         self.frame                              = 10;
795                         self.movetype                   = MOVETYPE_TOSS;
796                         
797                         CSQCModel_UnlinkEntity(); // networking the death scene would be a nightmare
798
799                         return true;
800                 }
801                 case VR_SPAWN:
802                 {
803                         if(!self.gun1)
804                         {
805                                 self.vehicles_impulse = spiderbot_impulse;
806                                 self.gun1 = spawn();
807                                 self.gun2 = spawn();
808                                 setmodel(self.gun1, "models/vehicles/spiderbot_barrels.dpm");
809                                 setmodel(self.gun2, "models/vehicles/spiderbot_barrels.dpm");
810                                 setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
811                                 setattachment(self.gun2, self.tur_head, "tag_hardpoint02");
812                                 self.gravity = 2;
813                                 self.mass = 5000;
814                         }
815
816                         self.frame = 5;
817                         self.tur_head.frame = 1;
818                         self.movetype = MOVETYPE_WALK;
819                         self.solid = SOLID_SLIDEBOX;
820                         self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
821                         self.tur_head.angles = '0 0 0';
822                         self.vehicle_exit = spiderbot_exit;
823
824                         setorigin(self, self.pos1 + '0 0 128');
825                         self.angles = self.pos2;
826                         self.damageforcescale = 0.03;
827                         self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
828                         self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
829                         
830                         self.PlayerPhysplug = spiderbot_frame;
831
832                         return true;
833                 }
834                 case VR_SETUP:
835                 {
836                         if(autocvar_g_vehicle_spiderbot_shield)
837                                 self.vehicle_flags |= VHF_HASSHIELD;
838
839                         if(autocvar_g_vehicle_spiderbot_shield_regen)
840                                 self.vehicle_flags |= VHF_SHIELDREGEN;
841
842                         if(autocvar_g_vehicle_spiderbot_health_regen)
843                                 self.vehicle_flags |= VHF_HEALTHREGEN;
844
845                         self.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
846                         self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
847                         self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
848                         self.max_health = self.vehicle_health;
849                         self.pushable = true; // spiderbot can use jumppads
850
851                         return true;
852                 }
853                 case VR_PRECACHE:
854                 {
855                         precache_model ("models/vhshield.md3");
856                         precache_model ("models/vehicles/spiderbot.dpm");
857                         precache_model ("models/vehicles/spiderbot_top.dpm");
858                         precache_model ("models/vehicles/spiderbot_barrels.dpm");
859                         precache_model ("models/vehicles/spiderbot_cockpit.dpm");
860                         precache_model ( "models/uziflash.md3");
861
862                         precache_sound ("weapons/uzi_fire.wav" );
863                         precache_sound ("weapons/rocket_impact.wav");
864
865                         precache_sound ("vehicles/spiderbot_die.wav");
866                         precache_sound ("vehicles/spiderbot_idle.wav");
867                         precache_sound ("vehicles/spiderbot_jump.wav");
868                         precache_sound ("vehicles/spiderbot_strafe.wav");
869                         precache_sound ("vehicles/spiderbot_walk.wav");
870                         precache_sound ("vehicles/spiderbot_land.wav");
871                         return true;
872                 }
873         }
874
875         return true;
876 }
877
878 #endif // SVQC
879 #ifdef CSQC
880 float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
881 float autocvar_cl_vehicle_spiderbot_cross_size = 1;
882
883 #define spider_ico  "gfx/vehicles/sbot.tga"
884 #define spider_rkt  "gfx/vehicles/sbot_rpods.tga"
885 #define spider_mgun "gfx/vehicles/sbot_mguns.tga"
886 string spider_xhair; // = "gfx/vehicles/axh-special1.tga";
887
888 float v_spiderbot(float req)
889 {
890         switch(req)
891         {
892                 case VR_HUD:
893                 {
894                         if(autocvar_r_letterbox)
895                                 return true;
896
897                         vector picsize, hudloc = '0 0 0', pic2size, picloc;
898                         float i;
899
900                         // Fetch health & ammo stats
901                         HUD_GETVEHICLESTATS
902
903                         picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
904                         hudloc_y = vid_conheight - picsize_y;
905                         hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
906
907                         drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
908
909                         ammo1   *= 0.01;
910                         shield  *= 0.01;
911                         vh_health  *= 0.01;
912                         reload2 *= 0.01;
913
914                         pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
915                         picloc = picsize * 0.5 - pic2size * 0.5;
916                         if(vh_health < 0.25)
917                                 drawpic(hudloc + picloc, spider_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
918                         else
919                                 drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
920                         drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
921                         drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
922                         drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
923
924                 // Health bar
925                         picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
926                         picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
927                         drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
928                         drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
929                         drawresetcliparea();
930                 // ..  and icon
931                         picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
932                         picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
933                         if(vh_health < 0.25)
934                         {
935                                 if(alarm1time < time)
936                                 {
937                                         alarm1time = time + 2;
938                                         vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
939                                 }
940                                 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
941                         }
942                         else
943                         {
944                                 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
945                                 if(alarm1time)
946                                 {
947                                         vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
948                                         alarm1time = 0;
949                                 }
950                         }
951                 // Shield bar
952                         picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
953                         picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
954                         drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
955                         drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
956                         drawresetcliparea();
957                 // ..  and icon
958                         picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
959                         picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
960                         if(shield < 0.25)
961                         {
962                                 if(alarm2time < time)
963                                 {
964                                         alarm2time = time + 1;
965                                         vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm_shield.wav");
966                                 }
967                                 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
968                         }
969                         else
970                         {
971                                 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
972                                 if(alarm2time)
973                                 {
974                                         vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
975                                         alarm2time = 0;
976                                 }
977                         }
978
979                 // Minigun bar
980                         picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
981                         picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
982                         drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
983                         drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
984                         drawresetcliparea();
985                 // ..  and icon
986                         picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
987                         picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
988                         if(ammo1 < 0.2)
989                                 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
990                         else
991                                 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
992
993                 // Rocket ammo bar
994                         picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
995                         ammo1 = picsize_x / 8;
996                         picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
997                         drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
998                         drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
999                         drawresetcliparea();
1000
1001                 // ..  and icons
1002                         pic2size = 0.35 * draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1003                         picloc_x -= pic2size_x;
1004                         picloc_y += pic2size_y * 2.25;
1005                         if(ammo2 == 9)
1006                         {
1007                                 for(i = 1; i < 9; ++i)
1008                                 {
1009                                         picloc_x += ammo1;
1010                                         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
1011                                 }
1012                         }
1013                         else
1014                         {
1015                                 for(i = 1; i < 9; ++i)
1016                                 {
1017                                         picloc_x += ammo1;
1018                                         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
1019                                 }
1020                         }
1021                         pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1022                         picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
1023                         if(ammo2 == 9)
1024                                 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1025                         else
1026                                 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
1027
1028                         if (scoreboard_showscores)
1029                                 HUD_DrawScoreboard();
1030                         else
1031                         {
1032                                 switch(getstati(STAT_VEHICLESTAT_W2MODE))
1033                                 {
1034                                         case SBRM_VOLLY:
1035                                                 spider_xhair = "gfx/vehicles/axh-bracket.tga";
1036                                                 break;
1037                                         case SBRM_GUIDE:
1038                                                 spider_xhair = "gfx/vehicles/axh-cross.tga";
1039                                                 break;
1040                                         case SBRM_ARTILLERY:
1041                                                 spider_xhair = "gfx/vehicles/axh-tag.tga";
1042                                                 break;
1043                                         default:
1044                                                 spider_xhair= "gfx/vehicles/axh-tag.tga";
1045                                 }
1046
1047                                 picsize = draw_getimagesize(spider_xhair);
1048                                 picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
1049                                 picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
1050
1051                                 drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), spider_xhair, picsize, '1 1 1', autocvar_cl_vehicle_spiderbot_cross_alpha, DRAWFLAG_ADDITIVE);
1052                         }
1053                         
1054                         return true;
1055                 }
1056                 case VR_SETUP:
1057                 {
1058                         // Minigun1
1059                         AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
1060                         AuxiliaryXhair[0].axh_scale   = 0.25;
1061                         // Minigun2
1062                         AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
1063                         AuxiliaryXhair[1].axh_scale   = 0.25;
1064                         // Rocket
1065                         AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
1066                         AuxiliaryXhair[2].axh_scale   = 0.5;
1067                 
1068                         return true;
1069                 }
1070                 case VR_PRECACHE:
1071                 {
1072                         return true;
1073                 }
1074         }
1075
1076         return true;
1077 }
1078
1079 #endif // CSQC
1080 #endif // REGISTER_VEHICLE