]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/vehicles/unit/spiderbot.qc
Merge branch 'master' into Mario/vehicles
[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 float SBRM_FIRST = 1;
17 const float SBRM_VOLLY = 1;
18 const float SBRM_GUIDE = 2;
19 const float SBRM_ARTILLERY = 3;
20 const float SBRM_LAST = 3;
21
22 #ifdef SVQC
23 float 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 float autocvar_g_vehicle_spiderbot_health;
45 float autocvar_g_vehicle_spiderbot_health_regen;
46 float autocvar_g_vehicle_spiderbot_health_regen_pause;
47
48 float 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 float autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
56 float autocvar_g_vehicle_spiderbot_minigun_ammo_max;
57 float 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                 return 1;
333         }
334
335         player = self;
336         spider = self.vehicle;
337         self   = spider;
338
339         vehicles_painframe();
340
341         player.BUTTON_ZOOM        = 0;
342         player.BUTTON_CROUCH    = 0;
343         player.switchweapon      = 0;
344         player.vehicle_weapon2mode = spider.vehicle_weapon2mode;
345
346
347 #if 1 // 0 to enable per-gun impact aux crosshairs
348         // Avarage gun impact point's -> aux cross
349         ad = gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint01"));
350         vf = v_forward;
351         ad += gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint02"));
352         vf += v_forward;
353         ad = ad * 0.5;
354         v_forward = vf * 0.5;
355         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
356         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
357 #else
358         ad = gettaginfo(spider.gun1, gettagindex(spider.gun1, "barrels"));
359         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
360         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
361         vf = ad;
362         ad = gettaginfo(spider.gun2, gettagindex(spider.gun2, "barrels"));
363         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
364         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 1);
365         ad = 0.5 * (ad + vf);
366 #endif
367
368         crosshair_trace(player);
369         ad = vectoangles(normalize(trace_endpos - ad));
370         ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
371         ad = AnglesTransform_Normalize(ad, TRUE);
372         //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
373
374         // Rotate head
375         ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
376         ad_y = bound(-ftmp, ad_y, ftmp);
377         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);
378
379         // Pitch head
380         ad_x = bound(ftmp * -1, ad_x, ftmp);
381         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);
382
383
384         //fixedmakevectors(spider.angles);
385         makevectors(spider.angles + '-2 0 0' * spider.angles_x);
386
387         movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
388
389         if(spider.flags & FL_ONGROUND)
390         {
391                 if(spider.frame == 4 && self.tur_head.wait != 0)
392                 {
393                         sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_land.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
394                         spider.frame = 5;
395                 }
396
397                 if(player.BUTTON_JUMP && self.tur_head.wait < time)
398                 {
399                         sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_jump.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
400                         //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
401                         self.delay = 0;
402
403                         self.tur_head.wait = time + 2;
404                         player.BUTTON_JUMP = 0;
405                         spider.velocity   = v_forward * 700 + v_up * 600;
406                         spider.frame = 4;
407                 }
408                 else
409                 {
410                         if(vlen(player.movement) == 0)
411                         {
412                                 if(self.sound_nexttime < time || self.delay != 3)
413                                 {
414                                         self.delay = 3;
415                                         self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
416                                         //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
417                                         sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
418                                 }
419                                 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
420                                 spider.frame = 5;
421                         }
422                         else
423                         {
424                                 // Turn Body
425                                 if(player.movement_x == 0 && player.movement_y != 0)
426                                         ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * sys_frametime;
427                                 else
428                                         ftmp = autocvar_g_vehicle_spiderbot_turnspeed * sys_frametime;
429
430                                 ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);
431                                 spider.angles_y = anglemods(spider.angles_y + ftmp);
432                                 spider.tur_head.angles_y -= ftmp;
433
434                                 if(player.movement_x != 0)
435                                 {
436                                         if(player.movement_x > 0)
437                                         {
438                                                 player.movement_x = 1;
439                                                 spider.frame = 0;
440                                         }
441                                         else if(player.movement_x < 0)
442                                         {
443                                                 player.movement_x = -1;
444                                                 spider.frame = 1;
445                                         }
446                                         player.movement_y = 0;
447                                         movelib_move_simple(normalize(v_forward * player.movement_x),autocvar_g_vehicle_spiderbot_speed_walk,autocvar_g_vehicle_spiderbot_movement_inertia);
448
449                                         if(self.sound_nexttime < time || self.delay != 1)
450                                         {
451                                                 self.delay = 1;
452                                                 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
453                                                 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_walk.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
454                                                 //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
455                                         }
456                                 }
457                                 else if(player.movement_y != 0)
458                                 {
459                                         if(player.movement_y < 0)
460                                         {
461                                                 player.movement_y = -1;
462                                                 spider.frame = 2;
463                                         }
464                                         else if(player.movement_y > 0)
465                                         {
466                                                 player.movement_y = 1;
467                                                 spider.frame = 3;
468                                         }
469                                         movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
470                                         if(self.sound_nexttime < time || self.delay != 2)
471                                         {
472                                                 self.delay = 2;
473                                                 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
474                                                 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_strafe.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
475                                                 //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
476                                         }
477                                 }
478                         }
479                 }
480         }
481
482         self.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
483         self.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
484
485         if(!forbidWeaponUse(player))
486         if(player.BUTTON_ATCK)
487         {
488                 spider.cnt = time;
489                 if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single <= time)
490                 {
491                         entity gun;
492                         vector v;
493                         spider.misc_bulletcounter += 1;
494
495                         self = player;
496
497                         mod(spider.misc_bulletcounter, 2) ? gun = spider.gun1 : gun = spider.gun2;
498                         v = gettaginfo(gun, gettagindex(gun, "barrels"));
499                         v_forward = normalize(v_forward);
500                         v += v_forward * 50;
501
502                         fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
503                                 autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0);
504
505                         sound (gun, CH_WEAPON_A, "weapons/uzi_fire.wav", VOL_BASE, ATTEN_NORM);
506                         //trailparticles(self, particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
507                         pointparticles(particleeffectnum("spiderbot_minigun_muzzleflash"), v, v_forward * 2500, 1);
508
509                         self = spider;
510
511                         spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
512                         spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
513                         player.vehicle_ammo1 = (spider.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
514                         spider.gun1.angles_z += 45;
515                         spider.gun2.angles_z -= 45;
516                         if(spider.gun1.angles_z >= 360)
517                         {
518                                 spider.gun1.angles_z = 0;
519                                 spider.gun2.angles_z = 0;
520                         }
521                 }
522         }
523         else
524                 vehicles_regen(spider.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
525                                                                                    autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
526                                                                                    autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, FALSE);
527
528
529         spiderbot_rocket_do();
530
531         if(self.vehicle_flags  & VHF_SHIELDREGEN)
532                 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);
533
534         if(self.vehicle_flags  & VHF_HEALTHREGEN)
535                 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);
536
537         player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
538         player.vehicle_ammo2 = spider.tur_head.frame;
539
540         if(spider.gun2.cnt <= time)
541                 player.vehicle_reload2 = 100;
542         else
543                 player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single) * 100;
544
545         setorigin(player, spider.origin + '0 0 1' * spider.maxs_z);
546         player.velocity = spider.velocity;
547
548         VEHICLE_UPDATE_PLAYER(player, health, spiderbot);
549
550         if(self.vehicle_flags & VHF_HASSHIELD)
551                 VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
552
553         self = player;
554         return 1;
555 }
556
557 void spiderbot_exit(float eject)
558 {
559         entity e;
560         vector spot;
561
562         e = findchain(classname,"spiderbot_rocket");
563         while(e)
564         {
565                 if(e.owner == self.owner)
566                 {
567                         e.realowner = self.owner;
568                         e.owner = world;
569                 }
570                 e = e.chain;
571         }
572
573         self.think = vehicles_think;
574         self.nextthink = time;
575         self.frame = 5;
576         self.movetype = MOVETYPE_WALK;
577
578         if(!self.owner)
579                 return;
580
581         makevectors(self.angles);
582         if(eject)
583         {
584                 spot = self.origin + v_forward * 100 + '0 0 64';
585                 spot = vehicles_findgoodexit(spot);
586                 setorigin(self.owner , spot);
587                 self.owner.velocity = (v_up + v_forward * 0.25) * 750;
588                 self.owner.oldvelocity = self.owner.velocity;
589         }
590         else
591         {
592                 if(vlen(self.velocity) > autocvar_g_vehicle_spiderbot_speed_strafe)
593                 {
594                         self.owner.velocity = normalize(self.velocity) * vlen(self.velocity);
595                         self.owner.velocity_z += 200;
596                         spot = self.origin + v_forward * 128 + '0 0 64';
597                         spot = vehicles_findgoodexit(spot);
598                 }
599                 else
600                 {
601                         self.owner.velocity = self.velocity * 0.5;
602                         self.owner.velocity_z += 10;
603                         spot = self.origin + v_forward * 256 + '0 0 64';
604                         spot = vehicles_findgoodexit(spot);
605                 }
606                 self.owner.oldvelocity = self.owner.velocity;
607                 setorigin(self.owner , spot);
608         }
609
610         antilag_clear(self.owner);
611         self.owner = world;
612 }
613
614 void spiderbot_headfade()
615 {
616         self.think = spiderbot_headfade;
617         self.nextthink = self.fade_time;
618         self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
619
620         if(self.cnt < time || self.alpha < 0.1)
621         {
622                 if(self.alpha > 0.1)
623                 {
624                         sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
625                         pointparticles(particleeffectnum("explosion_big"), self.origin + '0 0 100', '0 0 0', 1);
626                 }
627                 remove(self);
628         }
629 }
630
631 void spiderbot_blowup()
632 {
633         if(self.cnt > time)
634         {
635                 if(random() < 0.1)
636                 {
637                         sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
638                         pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
639                 }
640                 self.nextthink = time + 0.1;
641                 return;
642         }
643
644         entity h, g1, g2, b;
645         b = spawn();
646         h = spawn();
647         g1 = spawn();
648         g2 = spawn();
649
650         setmodel(b, "models/vehicles/spiderbot.dpm");
651         setmodel(h, "models/vehicles/spiderbot_top.dpm");
652         setmodel(g1, "models/vehicles/spiderbot_barrels.dpm");
653         setmodel(g2, "models/vehicles/spiderbot_barrels.dpm");
654
655         setorigin(b, self.origin);
656         b.frame = 11;
657         b.angles = self.angles;
658         setsize(b, self.mins, self.maxs);
659
660         setorigin(h, gettaginfo(self, gettagindex(self, "tag_head")));
661         h.movetype = MOVETYPE_BOUNCE;
662         h.solid = SOLID_BBOX;
663         h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
664         h.modelflags = MF_ROCKET;
665         h.effects = EF_FLAME | EF_LOWPRECISION;
666         h.avelocity = randomvec() * 360;
667
668         h.alpha = 1;
669         h.cnt = time + (3.5 * random());
670         h.fade_rate = 1 / min(self.respawntime, 10);
671         h.fade_time = time;
672         h.think = spiderbot_headfade;
673         h.nextthink = time;
674
675         setorigin(g1, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01")));
676         g1.movetype = MOVETYPE_TOSS;
677         g1.solid = SOLID_CORPSE;
678         g1.velocity = v_forward * 700 + (randomvec() * 32);
679         g1.avelocity = randomvec() * 180;
680
681         setorigin(g2, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02")));
682         g2.movetype = MOVETYPE_TOSS;
683         g2.solid = SOLID_CORPSE;
684         g2.velocity = v_forward * 700 + (randomvec() * 32);
685         g2.avelocity = randomvec() * 180;
686
687         h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
688
689         SUB_SetFade(b,  time + 5, min(self.respawntime, 1));
690         //SUB_SetFade(h,  time, min(self.respawntime, 10));
691         SUB_SetFade(g1, time, min(self.respawntime, 10));
692         SUB_SetFade(g2, time, min(self.respawntime, 10));
693
694         RadiusDamage (self, self.enemy, 250, 15, 250, world, 250, DEATH_VH_SPID_DEATH, world);
695
696         self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = -1;
697         self.movetype = MOVETYPE_NONE;
698         self.deadflag = DEAD_DEAD;
699         self.solid = SOLID_NOT;
700         self.tur_head.effects &= ~EF_FLAME;
701         self.vehicle_hudmodel.viewmodelforclient = self;
702 }
703
704 float spiderbot_impulse(float _imp)
705 {
706         switch(_imp)
707         {
708                 case 10:
709                 case 15:
710                 case 18:
711                         self.vehicle.vehicle_weapon2mode += 1;
712                         if(self.vehicle.vehicle_weapon2mode > SBRM_LAST)
713                                 self.vehicle.vehicle_weapon2mode = SBRM_FIRST;
714
715                         //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
716                         CSQCVehicleSetup(self, 0);
717                         return TRUE;
718                 case 12:
719                 case 16:
720                 case 19:
721                         self.vehicle.vehicle_weapon2mode -= 1;
722                         if(self.vehicle.vehicle_weapon2mode < SBRM_FIRST)
723                                 self.vehicle.vehicle_weapon2mode = SBRM_LAST;
724
725                         //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
726                         CSQCVehicleSetup(self, 0);
727                         return TRUE;
728
729                 /*
730                 case 17: // toss gun, could be used to exit?
731                         break;
732                 case 20: // Manual minigun reload?
733                         break;
734                 */
735         }
736         return FALSE;
737 }
738
739 void spawnfunc_vehicle_spiderbot()
740 {
741         if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
742         if(!vehicle_initialize(VEH_SPIDERBOT, FALSE)) { remove(self); return; }
743 }
744
745 float v_spiderbot(float req)
746 {
747         switch(req)
748         {
749                 case VR_IMPACT:
750                 {
751                         if(autocvar_g_vehicle_spiderbot_bouncepain)
752                                 vehicles_impact(autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
753                 
754                         return TRUE;
755                 }
756                 case VR_ENTER:
757                 {
758                         self.vehicle_weapon2mode = SBRM_GUIDE;
759                         self.movetype = MOVETYPE_WALK;
760                         CSQCVehicleSetup(self.owner, 0);
761                         self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_spiderbot_health) * 100;
762                         self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
763
764                         if(self.owner.flagcarried)
765                         {
766                                 setattachment(self.owner.flagcarried, self.tur_head, "");
767                                 setorigin(self.owner.flagcarried, '-20 0 120');
768                         }
769                 
770                         return TRUE;
771                 }
772                 case VR_THINK:
773                 {
774                         if(self.flags & FL_ONGROUND)
775                                 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
776                         
777                         return TRUE;
778                 }
779                 case VR_DEATH:
780                 {
781                         self.health                             = 0;
782                         self.event_damage               = func_null;
783                         self.takedamage                 = DAMAGE_NO;
784                         self.touch                              = func_null;
785                         self.cnt                                = 3.4 + time + random() * 2;
786                         self.think                              = spiderbot_blowup;
787                         self.nextthink                  = time;
788                         self.deadflag                   = DEAD_DYING;
789                         self.frame                              = 5;
790                         self.tur_head.effects  |= EF_FLAME;
791                         self.colormod                   = self.tur_head.colormod = '-1 -1 -1';
792                         self.frame                              = 10;
793                         self.movetype                   = MOVETYPE_TOSS;
794                         
795                         CSQCModel_UnlinkEntity(); // networking the death scene would be a nightmare
796
797                         return TRUE;
798                 }
799                 case VR_SPAWN:
800                 {
801                         if(!self.gun1)
802                         {
803                                 self.vehicles_impulse = spiderbot_impulse;
804                                 self.gun1 = spawn();
805                                 self.gun2 = spawn();
806                                 setmodel(self.gun1, "models/vehicles/spiderbot_barrels.dpm");
807                                 setmodel(self.gun2, "models/vehicles/spiderbot_barrels.dpm");
808                                 setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
809                                 setattachment(self.gun2, self.tur_head, "tag_hardpoint02");
810                                 self.gravity = 2;
811                                 self.mass = 5000;
812                         }
813
814                         self.frame = 5;
815                         self.tur_head.frame = 1;
816                         self.movetype = MOVETYPE_WALK;
817                         self.solid = SOLID_SLIDEBOX;
818                         self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
819                         self.tur_head.angles = '0 0 0';
820                         self.vehicle_exit = spiderbot_exit;
821
822                         setorigin(self, self.pos1 + '0 0 128');
823                         self.angles = self.pos2;
824                         self.damageforcescale = 0.03;
825                         self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
826                         self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
827                         
828                         self.PlayerPhysplug = spiderbot_frame;
829
830                         return TRUE;
831                 }
832                 case VR_SETUP:
833                 {
834                         if(autocvar_g_vehicle_spiderbot_shield)
835                                 self.vehicle_flags |= VHF_HASSHIELD;
836
837                         if(autocvar_g_vehicle_spiderbot_shield_regen)
838                                 self.vehicle_flags |= VHF_SHIELDREGEN;
839
840                         if(autocvar_g_vehicle_spiderbot_health_regen)
841                                 self.vehicle_flags |= VHF_HEALTHREGEN;
842
843                         self.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
844                         self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
845                         self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
846                         self.max_health = self.vehicle_health;
847                         self.pushable = TRUE; // spiderbot can use jumppads
848
849                         return TRUE;
850                 }
851                 case VR_PRECACHE:
852                 {
853                         precache_model ("models/vhshield.md3");
854                         precache_model ("models/vehicles/spiderbot.dpm");
855                         precache_model ("models/vehicles/spiderbot_top.dpm");
856                         precache_model ("models/vehicles/spiderbot_barrels.dpm");
857                         precache_model ("models/vehicles/spiderbot_cockpit.dpm");
858                         precache_model ( "models/uziflash.md3");
859
860                         precache_sound ("weapons/uzi_fire.wav" );
861                         precache_sound ("weapons/rocket_impact.wav");
862
863                         precache_sound ("vehicles/spiderbot_die.wav");
864                         precache_sound ("vehicles/spiderbot_idle.wav");
865                         precache_sound ("vehicles/spiderbot_jump.wav");
866                         precache_sound ("vehicles/spiderbot_strafe.wav");
867                         precache_sound ("vehicles/spiderbot_walk.wav");
868                         precache_sound ("vehicles/spiderbot_land.wav");
869                         return TRUE;
870                 }
871         }
872
873         return TRUE;
874 }
875
876 #endif // SVQC
877 #ifdef CSQC
878 var float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
879 var float autocvar_cl_vehicle_spiderbot_cross_size = 1;
880
881 #define spider_ico  "gfx/vehicles/sbot.tga"
882 #define spider_rkt  "gfx/vehicles/sbot_rpods.tga"
883 #define spider_mgun "gfx/vehicles/sbot_mguns.tga"
884 string spider_xhair; // = "gfx/vehicles/axh-special1.tga";
885
886 float v_spiderbot(float req)
887 {
888         switch(req)
889         {
890                 case VR_HUD:
891                 {
892                         if(autocvar_r_letterbox)
893                                 return TRUE;
894
895                         vector picsize, hudloc = '0 0 0', pic2size, picloc;
896                         float i;
897
898                         // Fetch health & ammo stats
899                         HUD_GETVEHICLESTATS
900
901                         picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
902                         hudloc_y = vid_conheight - picsize_y;
903                         hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
904
905                         drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
906
907                         ammo1   *= 0.01;
908                         shield  *= 0.01;
909                         vh_health  *= 0.01;
910                         reload2 *= 0.01;
911
912                         pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
913                         picloc = picsize * 0.5 - pic2size * 0.5;
914                         if(vh_health < 0.25)
915                                 drawpic(hudloc + picloc, spider_ico, pic2size,  '1 0 0' + '0 1 1' * sin(time * 8),  1, DRAWFLAG_NORMAL);
916                         else
917                                 drawpic(hudloc + picloc, spider_ico, pic2size,  '1 1 1' * vh_health  + '1 0 0' * (1 - vh_health),  1, DRAWFLAG_NORMAL);
918                         drawpic(hudloc + picloc, spider_rkt, pic2size,  '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
919                         drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1   + '1 0 0' * (1 - ammo1),   1, DRAWFLAG_NORMAL);
920                         drawpic(hudloc + picloc, hud_sh, pic2size,  '1 1 1', shield, DRAWFLAG_NORMAL);
921
922                 // Health bar
923                         picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
924                         picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
925                         drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
926                         drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
927                         drawresetcliparea();
928                 // ..  and icon
929                         picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
930                         picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
931                         if(vh_health < 0.25)
932                         {
933                                 if(alarm1time < time)
934                                 {
935                                         alarm1time = time + 2;
936                                         vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
937                                 }
938                                 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
939                         }
940                         else
941                         {
942                                 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
943                                 if(alarm1time)
944                                 {
945                                         vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
946                                         alarm1time = 0;
947                                 }
948                         }
949                 // Shield bar
950                         picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
951                         picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
952                         drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
953                         drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
954                         drawresetcliparea();
955                 // ..  and icon
956                         picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
957                         picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
958                         if(shield < 0.25)
959                         {
960                                 if(alarm2time < time)
961                                 {
962                                         alarm2time = time + 1;
963                                         vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm_shield.wav");
964                                 }
965                                 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
966                         }
967                         else
968                         {
969                                 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
970                                 if(alarm2time)
971                                 {
972                                         vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
973                                         alarm2time = 0;
974                                 }
975                         }
976
977                 // Minigun bar
978                         picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
979                         picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
980                         drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
981                         drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
982                         drawresetcliparea();
983                 // ..  and icon
984                         picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
985                         picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
986                         if(ammo1 < 0.2)
987                                 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
988                         else
989                                 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
990
991                 // Rocket ammo bar
992                         picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
993                         ammo1 = picsize_x / 8;
994                         picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
995                         drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
996                         drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
997                         drawresetcliparea();
998
999                 // ..  and icons
1000                         pic2size = 0.35 * draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1001                         picloc_x -= pic2size_x;
1002                         picloc_y += pic2size_y * 2.25;
1003                         if(ammo2 == 9)
1004                         {
1005                                 for(i = 1; i < 9; ++i)
1006                                 {
1007                                         picloc_x += ammo1;
1008                                         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
1009                                 }
1010                         }
1011                         else
1012                         {
1013                                 for(i = 1; i < 9; ++i)
1014                                 {
1015                                         picloc_x += ammo1;
1016                                         drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
1017                                 }
1018                         }
1019                         pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1020                         picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
1021                         if(ammo2 == 9)
1022                                 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1023                         else
1024                                 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
1025
1026                         if (scoreboard_showscores)
1027                                 HUD_DrawScoreboard();
1028                         else
1029                         {
1030                                 switch(getstati(STAT_VEHICLESTAT_W2MODE))
1031                                 {
1032                                         case SBRM_VOLLY:
1033                                                 spider_xhair = "gfx/vehicles/axh-bracket.tga";
1034                                                 break;
1035                                         case SBRM_GUIDE:
1036                                                 spider_xhair = "gfx/vehicles/axh-cross.tga";
1037                                                 break;
1038                                         case SBRM_ARTILLERY:
1039                                                 spider_xhair = "gfx/vehicles/axh-tag.tga";
1040                                                 break;
1041                                         default:
1042                                                 spider_xhair= "gfx/vehicles/axh-tag.tga";
1043                                 }
1044
1045                                 picsize = draw_getimagesize(spider_xhair);
1046                                 picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
1047                                 picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
1048
1049                                 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);
1050                         }
1051                         
1052                         return TRUE;
1053                 }
1054                 case VR_SETUP:
1055                 {
1056                         // Minigun1
1057                         AuxiliaryXhair[0].axh_image   = "gfx/vehicles/axh-ring.tga";
1058                         AuxiliaryXhair[0].axh_scale   = 0.25;
1059                         // Minigun2
1060                         AuxiliaryXhair[1].axh_image   = "gfx/vehicles/axh-ring.tga";
1061                         AuxiliaryXhair[1].axh_scale   = 0.25;
1062                         // Rocket
1063                         AuxiliaryXhair[2].axh_image   = "gfx/vehicles/axh-special1.tga";
1064                         AuxiliaryXhair[2].axh_scale   = 0.5;
1065                 
1066                         return TRUE;
1067                 }
1068                 case VR_PRECACHE:
1069                 {
1070                         precache_model ("models/vhshield.md3");
1071                         precache_model ("models/vehicles/spiderbot.dpm");
1072                         precache_model ("models/vehicles/spiderbot_top.dpm");
1073                         precache_model ("models/vehicles/spiderbot_barrels.dpm");
1074                         precache_model ("models/vehicles/spiderbot_cockpit.dpm");
1075                         return TRUE;
1076                 }
1077         }
1078
1079         return TRUE;
1080 }
1081
1082 #endif // CSQC
1083 #endif // REGISTER_VEHICLE