]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/vehicles/vehicle/spiderbot.qc
Merge branch 'master' into terencehill/tooltips_cleanup
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / vehicles / vehicle / spiderbot.qc
1 #ifndef VEHICLE_SPIDERBOT
2 #define VEHICLE_SPIDERBOT
3
4 #include "spiderbot_weapons.qc"
5
6 CLASS(Spiderbot, Vehicle)
7 /* spawnflags */ ATTRIB(Spiderbot, spawnflags, int, VHF_DMGSHAKE);
8 /* mins       */ ATTRIB(Spiderbot, mins, vector, '-75 -75 10');
9 /* maxs       */ ATTRIB(Spiderbot, maxs, vector, '75 75 125');
10 /* model          */ ATTRIB(Spiderbot, mdl, string, "models/vehicles/spiderbot.dpm");
11 /* model          */ ATTRIB(Spiderbot, model, string, "models/vehicles/spiderbot.dpm");
12 /* head_model */ ATTRIB(Spiderbot, head_model, string, "models/vehicles/spiderbot_top.dpm");
13 /* hud_model  */ ATTRIB(Spiderbot, hud_model, string, "models/vehicles/spiderbot_cockpit.dpm");
14 /* tags       */ ATTRIB(Spiderbot, tag_head, string, "tag_head");
15 /* tags       */ ATTRIB(Spiderbot, tag_hud, string, "tag_hud");
16 /* tags       */ ATTRIB(Spiderbot, tag_view, string, "");
17 /* netname    */ ATTRIB(Spiderbot, netname, string, "spiderbot");
18 /* fullname   */ ATTRIB(Spiderbot, vehicle_name, string, _("Spiderbot"));
19 /* icon       */ ATTRIB(Spiderbot, m_icon, string, "vehicle_spider");
20 ENDCLASS(Spiderbot)
21
22 REGISTER_VEHICLE(SPIDERBOT, NEW(Spiderbot));
23
24 #endif
25
26 #ifdef IMPLEMENTATION
27
28 const int SBRM_FIRST = 1;
29 const int SBRM_VOLLY = 1;
30 const int SBRM_GUIDE = 2;
31 const int SBRM_ARTILLERY = 3;
32 const int SBRM_LAST = 3;
33
34 #include "spiderbot_weapons.qc"
35
36 #ifdef SVQC
37 bool autocvar_g_vehicle_spiderbot;
38
39 float autocvar_g_vehicle_spiderbot_respawntime;
40
41 float autocvar_g_vehicle_spiderbot_speed_stop;
42 float autocvar_g_vehicle_spiderbot_speed_strafe;
43 float autocvar_g_vehicle_spiderbot_speed_walk;
44 float autocvar_g_vehicle_spiderbot_speed_run = 700;
45 float autocvar_g_vehicle_spiderbot_turnspeed;
46 float autocvar_g_vehicle_spiderbot_turnspeed_strafe;
47 float autocvar_g_vehicle_spiderbot_movement_inertia;
48
49 float autocvar_g_vehicle_spiderbot_springlength;
50 float autocvar_g_vehicle_spiderbot_springup;
51 float autocvar_g_vehicle_spiderbot_springblend;
52 float autocvar_g_vehicle_spiderbot_tiltlimit;
53
54 float autocvar_g_vehicle_spiderbot_head_pitchlimit_down;
55 float autocvar_g_vehicle_spiderbot_head_pitchlimit_up;
56 float autocvar_g_vehicle_spiderbot_head_turnlimit;
57 float autocvar_g_vehicle_spiderbot_head_turnspeed;
58
59 int autocvar_g_vehicle_spiderbot_health;
60 float autocvar_g_vehicle_spiderbot_health_regen;
61 float autocvar_g_vehicle_spiderbot_health_regen_pause;
62
63 int autocvar_g_vehicle_spiderbot_shield;
64 float autocvar_g_vehicle_spiderbot_shield_regen;
65 float autocvar_g_vehicle_spiderbot_shield_regen_pause;
66
67 vector autocvar_g_vehicle_spiderbot_bouncepain;
68
69 .float jump_delay;
70 float spiderbot_frame()
71 {SELFPARAM();
72         vector ad, vf;
73         entity player, spider;
74         float ftmp;
75
76         if(intermission_running)
77         {
78                 self.vehicle.velocity = '0 0 0';
79                 self.vehicle.avelocity = '0 0 0';
80                 return 1;
81         }
82
83         player = self;
84         spider = self.vehicle;
85         setself(spider);
86
87         vehicles_painframe();
88
89         player.BUTTON_ZOOM        = 0;
90         player.BUTTON_CROUCH    = 0;
91         player.switchweapon      = 0;
92         player.vehicle_weapon2mode = spider.vehicle_weapon2mode;
93
94
95 #if 1 // 0 to enable per-gun impact aux crosshairs
96         // Avarage gun impact point's -> aux cross
97         ad = gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint01"));
98         vf = v_forward;
99         ad += gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint02"));
100         vf += v_forward;
101         ad = ad * 0.5;
102         v_forward = vf * 0.5;
103         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
104         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
105 #else
106         ad = gettaginfo(spider.gun1, gettagindex(spider.gun1, "barrels"));
107         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
108         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
109         vf = ad;
110         ad = gettaginfo(spider.gun2, gettagindex(spider.gun2, "barrels"));
111         traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
112         UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 1);
113         ad = 0.5 * (ad + vf);
114 #endif
115
116         crosshair_trace(player);
117         ad = vectoangles(normalize(trace_endpos - ad));
118         ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
119         ad = AnglesTransform_Normalize(ad, true);
120         //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
121
122         // Rotate head
123         ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
124         ad_y = bound(-ftmp, ad_y, ftmp);
125         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);
126
127         // Pitch head
128         ad_x = bound(ftmp * -1, ad_x, ftmp);
129         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);
130
131
132         //fixedmakevectors(spider.angles);
133         makevectors(spider.angles + '-2 0 0' * spider.angles_x);
134
135         movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
136
137         if(spider.flags & FL_ONGROUND)
138                 spider.jump_delay = time; // reset now so movement can begin
139
140         //if(spider.flags & FL_ONGROUND)
141         {
142                 if(spider.flags & FL_ONGROUND)
143                 if(spider.frame == 4 && self.tur_head.wait != 0)
144                 {
145                         sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
146                         spider.frame = 5;
147                 }
148
149                 if(!player.BUTTON_JUMP)
150                         spider.BUTTON_JUMP = 0;
151
152                 if((spider.flags & FL_ONGROUND) && player.BUTTON_JUMP && !spider.BUTTON_JUMP && self.tur_head.wait < time)
153                 {
154                         sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
155                         //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
156                         self.delay = 0;
157
158                         self.tur_head.wait = time + 2;
159                         spider.jump_delay = time + 2;
160                         spider.BUTTON_JUMP = 1; // set spider's jump
161                         //player.BUTTON_JUMP = 0;
162
163                         vector movefix = '0 0 0';
164                         if(player.movement_x > 0) movefix_x = 1;
165                         if(player.movement_x < 0) movefix_x = -1;
166                         if(player.movement_y > 0) movefix_y = 1;
167                         if(player.movement_y < 0) movefix_y = -1;
168
169                         vector rt = movefix_y * v_right;
170                         vector sd = movefix_x * v_forward;
171                         if(movefix_y == 0 && movefix_x == 0)
172                                 sd = v_forward; // always do forward
173
174                         spider.flags &= ~FL_ONGROUND;
175
176                         spider.velocity = sd * 700 + rt * 600 + v_up * 600;
177                         spider.frame = 4;
178                 }
179                 else if(time >= spider.jump_delay)
180                 {
181                         if(vlen(player.movement) == 0)
182                         {
183                                 if(spider.flags & FL_ONGROUND)
184                                 {
185                                         if(self.sound_nexttime < time || self.delay != 3)
186                                         {
187                                                 self.delay = 3;
188                                                 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
189                                                 //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
190                                                 sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
191                                         }
192                                         movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
193                                         spider.frame = 5;
194                                 }
195                         }
196                         else
197                         {
198                                 // Turn Body
199                                 if(player.movement_x == 0 && player.movement_y != 0)
200                                         ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * sys_frametime;
201                                 else
202                                         ftmp = autocvar_g_vehicle_spiderbot_turnspeed * sys_frametime;
203
204                                 ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);
205                                 spider.angles_y = anglemods(spider.angles_y + ftmp);
206                                 spider.tur_head.angles_y -= ftmp;
207
208                                 if(player.movement_x != 0)
209                                 {
210                                         if(player.movement_x > 0)
211                                         {
212                                                 player.movement_x = 1;
213                                                 if(spider.flags & FL_ONGROUND)
214                                                         spider.frame = 0;
215                                         }
216                                         else if(player.movement_x < 0)
217                                         {
218                                                 player.movement_x = -1;
219                                                 if(spider.flags & FL_ONGROUND)
220                                                         spider.frame = 1;
221                                         }
222                                         player.movement_y = 0;
223                                         float oldvelz = spider.velocity_z;
224                                         movelib_move_simple(normalize(v_forward * player.movement_x),((player.BUTTON_JUMP) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia);
225                                         spider.velocity_z = oldvelz;
226                                         float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
227                                         if(spider.velocity_z <= 20) // not while jumping
228                                                 spider.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
229                                         if(spider.flags & FL_ONGROUND)
230                                         if(self.sound_nexttime < time || self.delay != 1)
231                                         {
232                                                 self.delay = 1;
233                                                 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
234                                                 sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_WALK, VOL_VEHICLEENGINE, ATTEN_NORM);
235                                                 //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
236                                         }
237                                 }
238                                 else if(player.movement_y != 0)
239                                 {
240                                         if(player.movement_y < 0)
241                                         {
242                                                 player.movement_y = -1;
243                                                 if(spider.flags & FL_ONGROUND)
244                                                         spider.frame = 2;
245                                         }
246                                         else if(player.movement_y > 0)
247                                         {
248                                                 player.movement_y = 1;
249                                                 if(spider.flags & FL_ONGROUND)
250                                                         spider.frame = 3;
251                                         }
252
253                                         float oldvelz = spider.velocity_z;
254                                         movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
255                                         spider.velocity_z = oldvelz;
256                                         float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
257                                         if(spider.velocity_z <= 20) // not while jumping
258                                                 spider.velocity_z -= g * sys_frametime * autocvar_sv_gravity;
259                                         if(spider.flags & FL_ONGROUND)
260                                         if(self.sound_nexttime < time || self.delay != 2)
261                                         {
262                                                 self.delay = 2;
263                                                 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
264                                                 sound (self, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_STRAFE, VOL_VEHICLEENGINE, ATTEN_NORM);
265                                                 //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
266                                         }
267                                 }
268                         }
269                 }
270         }
271
272         self.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
273         self.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
274
275         if(!forbidWeaponUse(player))
276         if(player.BUTTON_ATCK)
277         {
278                 spider.cnt = time;
279                 if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single <= time)
280                 {
281                         entity gun;
282                         vector v;
283                         spider.misc_bulletcounter += 1;
284
285                         setself(player);
286
287                         gun = (spider.misc_bulletcounter % 2) ? spider.gun1 : spider.gun2;
288
289                         v = gettaginfo(gun, gettagindex(gun, "barrels"));
290                         v_forward = normalize(v_forward);
291                         v += v_forward * 50;
292
293                         fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
294                                 autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, 0);
295
296                         sound (gun, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
297                         //trailparticles(self, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
298                         pointparticles(particleeffectnum(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH), v, v_forward * 2500, 1);
299
300                         setself(spider);
301
302                         spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
303                         spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
304                         player.vehicle_ammo1 = (spider.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
305                         spider.gun1.angles_z += 45;
306                         spider.gun2.angles_z -= 45;
307                         if(spider.gun1.angles_z >= 360)
308                         {
309                                 spider.gun1.angles_z = 0;
310                                 spider.gun2.angles_z = 0;
311                         }
312                 }
313         }
314         else
315                 vehicles_regen(spider.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
316                                                                                    autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
317                                                                                    autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, false);
318
319
320         spiderbot_rocket_do();
321
322         if(self.vehicle_flags  & VHF_SHIELDREGEN)
323                 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);
324
325         if(self.vehicle_flags  & VHF_HEALTHREGEN)
326                 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);
327
328         player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
329         //player.vehicle_ammo2 = spider.tur_head.frame;
330         player.vehicle_ammo2 = (9 - spider.tur_head.frame) / 8 * 100; // Percentage, like ammo1
331
332         if(spider.gun2.cnt <= time)
333                 player.vehicle_reload2 = 100;
334         else
335                 player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single) * 100;
336
337         setorigin(player, spider.origin + '0 0 1' * spider.maxs_z);
338         player.velocity = spider.velocity;
339
340         VEHICLE_UPDATE_PLAYER(player, health, spiderbot);
341
342         if(self.vehicle_flags & VHF_HASSHIELD)
343                 VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
344
345         setself(player);
346         return 1;
347 }
348
349 void spiderbot_exit(float eject)
350 {SELFPARAM();
351         entity e;
352         vector spot;
353
354         e = findchain(classname,"spiderbot_rocket");
355         while(e)
356         {
357                 if(e.owner == self.owner)
358                 {
359                         e.realowner = self.owner;
360                         e.owner = world;
361                 }
362                 e = e.chain;
363         }
364
365         self.think = vehicles_think;
366         self.nextthink = time;
367         self.frame = 5;
368         self.movetype = MOVETYPE_WALK;
369
370         if(!self.owner)
371                 return;
372
373         makevectors(self.angles);
374         if(eject)
375         {
376                 spot = self.origin + v_forward * 100 + '0 0 64';
377                 spot = vehicles_findgoodexit(spot);
378                 setorigin(self.owner , spot);
379                 self.owner.velocity = (v_up + v_forward * 0.25) * 750;
380                 self.owner.oldvelocity = self.owner.velocity;
381         }
382         else
383         {
384                 if(vlen(self.velocity) > autocvar_g_vehicle_spiderbot_speed_strafe)
385                 {
386                         self.owner.velocity = normalize(self.velocity) * vlen(self.velocity);
387                         self.owner.velocity_z += 200;
388                         spot = self.origin + v_forward * 128 + '0 0 64';
389                         spot = vehicles_findgoodexit(spot);
390                 }
391                 else
392                 {
393                         self.owner.velocity = self.velocity * 0.5;
394                         self.owner.velocity_z += 10;
395                         spot = self.origin + v_forward * 256 + '0 0 64';
396                         spot = vehicles_findgoodexit(spot);
397                 }
398                 self.owner.oldvelocity = self.owner.velocity;
399                 setorigin(self.owner , spot);
400         }
401
402         antilag_clear(self.owner);
403         self.owner = world;
404 }
405
406 void spiderbot_headfade()
407 {SELFPARAM();
408         self.think = spiderbot_headfade;
409         self.nextthink = self.fade_time;
410         self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
411
412         if(self.cnt < time || self.alpha < 0.1)
413         {
414                 if(self.alpha > 0.1)
415                 {
416                         sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
417                         Send_Effect(EFFECT_EXPLOSION_BIG, self.origin + '0 0 100', '0 0 0', 1);
418                 }
419                 remove(self);
420         }
421 }
422
423 void spiderbot_blowup()
424 {SELFPARAM();
425         if(self.cnt > time)
426         {
427                 if(random() < 0.1)
428                 {
429                         sound (self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
430                         Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
431                 }
432                 self.nextthink = time + 0.1;
433                 return;
434         }
435
436         entity h, g1, g2, b;
437         b = spawn();
438         h = spawn();
439         g1 = spawn();
440         g2 = spawn();
441
442         setmodel(b, MDL_VEH_SPIDERBOT_BODY);
443         setmodel(h, MDL_VEH_SPIDERBOT_TOP);
444         setmodel(g1, MDL_VEH_SPIDERBOT_GUN);
445         setmodel(g2, MDL_VEH_SPIDERBOT_GUN);
446
447         setorigin(b, self.origin);
448         b.frame = 11;
449         b.angles = self.angles;
450         setsize(b, self.mins, self.maxs);
451
452         setorigin(h, gettaginfo(self, gettagindex(self, "tag_head")));
453         h.movetype = MOVETYPE_BOUNCE;
454         h.solid = SOLID_BBOX;
455         h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
456         h.modelflags = MF_ROCKET;
457         h.effects = EF_FLAME | EF_LOWPRECISION;
458         h.avelocity = randomvec() * 360;
459
460         h.alpha = 1;
461         h.cnt = time + (3.5 * random());
462         h.fade_rate = 1 / min(self.respawntime, 10);
463         h.fade_time = time;
464         h.think = spiderbot_headfade;
465         h.nextthink = time;
466
467         setorigin(g1, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01")));
468         g1.movetype = MOVETYPE_TOSS;
469         g1.solid = SOLID_CORPSE;
470         g1.velocity = v_forward * 700 + (randomvec() * 32);
471         g1.avelocity = randomvec() * 180;
472
473         setorigin(g2, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02")));
474         g2.movetype = MOVETYPE_TOSS;
475         g2.solid = SOLID_CORPSE;
476         g2.velocity = v_forward * 700 + (randomvec() * 32);
477         g2.avelocity = randomvec() * 180;
478
479         h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
480
481         SUB_SetFade(b,  time + 5, min(self.respawntime, 1));
482         //SUB_SetFade(h,  time, min(self.respawntime, 10));
483         SUB_SetFade(g1, time, min(self.respawntime, 10));
484         SUB_SetFade(g2, time, min(self.respawntime, 10));
485
486         RadiusDamage (self, self.enemy, 250, 15, 250, world, world, 250, DEATH_VH_SPID_DEATH.m_id, world);
487
488         self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = -1;
489         self.movetype = MOVETYPE_NONE;
490         self.deadflag = DEAD_DEAD;
491         self.solid = SOLID_NOT;
492         self.tur_head.effects &= ~EF_FLAME;
493         self.vehicle_hudmodel.viewmodelforclient = self;
494 }
495
496 bool spiderbot_impulse(int _imp)
497 {SELFPARAM();
498         switch(_imp)
499         {
500                 case 1:
501                         self.vehicle.vehicle_weapon2mode = SBRM_VOLLY;
502                         CSQCVehicleSetup(self, 0);
503                         return true;
504                 case 2:
505                         self.vehicle.vehicle_weapon2mode = SBRM_GUIDE;
506                         CSQCVehicleSetup(self, 0);
507                         return true;
508                 case 3:
509                         self.vehicle.vehicle_weapon2mode = SBRM_ARTILLERY;
510                         CSQCVehicleSetup(self, 0);
511                         return true;
512
513                 case 10:
514                 case 15:
515                 case 18:
516                         self.vehicle.vehicle_weapon2mode += 1;
517                         if(self.vehicle.vehicle_weapon2mode > SBRM_LAST)
518                                 self.vehicle.vehicle_weapon2mode = SBRM_FIRST;
519
520                         //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
521                         CSQCVehicleSetup(self, 0);
522                         return true;
523                 case 11:
524                 case 12:
525                 case 16:
526                 case 19:
527                         self.vehicle.vehicle_weapon2mode -= 1;
528                         if(self.vehicle.vehicle_weapon2mode < SBRM_FIRST)
529                                 self.vehicle.vehicle_weapon2mode = SBRM_LAST;
530
531                         //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
532                         CSQCVehicleSetup(self, 0);
533                         return true;
534
535                 /*
536                 case 17: // toss gun, could be used to exit?
537                         break;
538                 case 20: // Manual minigun reload?
539                         break;
540                 */
541         }
542         return false;
543 }
544
545 spawnfunc(vehicle_spiderbot)
546 {
547         if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
548         if(!vehicle_initialize(VEH_SPIDERBOT, false)) { remove(self); return; }
549 }
550
551                 METHOD(Spiderbot, vr_impact, void(Spiderbot thisveh))
552                 {
553                         if(autocvar_g_vehicle_spiderbot_bouncepain)
554                                 vehicles_impact(autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
555                 }
556                 METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh))
557                 {
558                         self.vehicle_weapon2mode = SBRM_GUIDE;
559                         self.movetype = MOVETYPE_WALK;
560                         CSQCVehicleSetup(self.owner, 0);
561                         self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_spiderbot_health) * 100;
562                         self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
563
564                         if(self.owner.flagcarried)
565                         {
566                                 setattachment(self.owner.flagcarried, self.tur_head, "");
567                                 setorigin(self.owner.flagcarried, '-20 0 120');
568                         }
569                 }
570                 METHOD(Spiderbot, vr_think, void(Spiderbot thisveh))
571                 {
572                         if(self.flags & FL_ONGROUND)
573                                 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
574                 }
575                 METHOD(Spiderbot, vr_death, void(Spiderbot thisveh))
576                 {
577                         self.health                             = 0;
578                         self.event_damage               = func_null;
579                         self.takedamage                 = DAMAGE_NO;
580                         self.touch                              = func_null;
581                         self.cnt                                = 3.4 + time + random() * 2;
582                         self.think                              = spiderbot_blowup;
583                         self.nextthink                  = time;
584                         self.deadflag                   = DEAD_DYING;
585                         self.frame                              = 5;
586                         self.tur_head.effects  |= EF_FLAME;
587                         self.colormod                   = self.tur_head.colormod = '-1 -1 -1';
588                         self.frame                              = 10;
589                         self.movetype                   = MOVETYPE_TOSS;
590
591                         CSQCModel_UnlinkEntity(self); // networking the death scene would be a nightmare
592                 }
593                 METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh))
594                 {
595                         if(!self.gun1)
596                         {
597                                 self.vehicles_impulse = spiderbot_impulse;
598                                 self.gun1 = spawn();
599                                 self.gun2 = spawn();
600                                 setmodel(self.gun1, MDL_VEH_SPIDERBOT_GUN);
601                                 setmodel(self.gun2, MDL_VEH_SPIDERBOT_GUN);
602                                 setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
603                                 setattachment(self.gun2, self.tur_head, "tag_hardpoint02");
604                                 self.gravity = 2;
605                                 self.mass = 5000;
606                         }
607
608                         self.frame = 5;
609                         self.tur_head.frame = 1;
610                         self.movetype = MOVETYPE_WALK;
611                         self.solid = SOLID_SLIDEBOX;
612                         self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
613                         self.tur_head.angles = '0 0 0';
614                         self.vehicle_exit = spiderbot_exit;
615
616                         setorigin(self, self.pos1 + '0 0 128');
617                         self.angles = self.pos2;
618                         self.damageforcescale = 0.03;
619                         self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
620                         self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
621
622                         self.PlayerPhysplug = spiderbot_frame;
623                 }
624                 METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh))
625                 {
626                         if(autocvar_g_vehicle_spiderbot_shield)
627                                 self.vehicle_flags |= VHF_HASSHIELD;
628
629                         if(autocvar_g_vehicle_spiderbot_shield_regen)
630                                 self.vehicle_flags |= VHF_SHIELDREGEN;
631
632                         if(autocvar_g_vehicle_spiderbot_health_regen)
633                                 self.vehicle_flags |= VHF_HEALTHREGEN;
634
635                         self.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
636                         self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
637                         self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
638                         self.max_health = self.vehicle_health;
639                         self.pushable = true; // spiderbot can use jumppads
640                 }
641
642 #endif // SVQC
643 #ifdef CSQC
644 float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
645 float autocvar_cl_vehicle_spiderbot_cross_size = 1;
646
647                 METHOD(Spiderbot, vr_hud, void(Spiderbot thisveh))
648                 {
649                         string crosshair;
650
651                         switch(weapon2mode)
652                         {
653                                 case SBRM_VOLLY:     crosshair = vCROSS_BURST; break;
654                                 case SBRM_GUIDE:     crosshair = vCROSS_GUIDE; break;
655                                 case SBRM_ARTILLERY: crosshair = vCROSS_RAIN;  break;
656                                 default:             crosshair = vCROSS_BURST;
657                         }
658
659                         Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2",
660                                                          "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
661                                                          "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color,
662                                                          crosshair);
663                 }
664                 METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh))
665                 {
666                         AuxiliaryXhair[0].axh_image = vCROSS_HINT; // Minigun1
667                         AuxiliaryXhair[1].axh_image = vCROSS_HINT; // Minigun2
668                 }
669
670 #endif
671 #endif