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