1 #include "spiderbot.qh"
4 #include <common/gamemodes/gamemode/ctf/sv_ctf.qh>
9 const int SBRM_FIRST = 1;
10 const int SBRM_VOLLY = 1;
11 const int SBRM_GUIDE = 2;
12 const int SBRM_ARTILLERY = 3;
13 const int SBRM_LAST = 3;
16 bool autocvar_g_vehicle_spiderbot = true;
18 float autocvar_g_vehicle_spiderbot_respawntime = 45;
20 float autocvar_g_vehicle_spiderbot_speed_stop = 50;
21 float autocvar_g_vehicle_spiderbot_speed_strafe = 400;
22 float autocvar_g_vehicle_spiderbot_speed_walk = 500;
23 float autocvar_g_vehicle_spiderbot_speed_run = 700;
24 float autocvar_g_vehicle_spiderbot_turnspeed = 90;
25 float autocvar_g_vehicle_spiderbot_turnspeed_strafe = 300;
26 float autocvar_g_vehicle_spiderbot_movement_inertia = 0.15;
28 float autocvar_g_vehicle_spiderbot_springlength = 150;
29 float autocvar_g_vehicle_spiderbot_springup = 20;
30 float autocvar_g_vehicle_spiderbot_springblend = 0.1;
31 float autocvar_g_vehicle_spiderbot_tiltlimit = 90;
33 float autocvar_g_vehicle_spiderbot_head_pitchlimit_down = -20;
34 float autocvar_g_vehicle_spiderbot_head_pitchlimit_up = 30;
35 float autocvar_g_vehicle_spiderbot_head_turnlimit = 90;
36 float autocvar_g_vehicle_spiderbot_head_turnspeed = 110;
38 int autocvar_g_vehicle_spiderbot_health = 800;
39 float autocvar_g_vehicle_spiderbot_health_regen = 10;
40 float autocvar_g_vehicle_spiderbot_health_regen_pause = 5;
42 int autocvar_g_vehicle_spiderbot_shield = 200;
43 float autocvar_g_vehicle_spiderbot_shield_regen = 25;
44 float autocvar_g_vehicle_spiderbot_shield_regen_pause = 0.35;
46 // 'minspeed_for_pain speedchange_to_pain_factor max_damage'
47 vector autocvar_g_vehicle_spiderbot_bouncepain = '0 0 0';
50 bool spiderbot_frame(entity this, float dt)
52 entity vehic = this.vehicle;
57 vehic.solid = SOLID_NOT;
58 vehic.takedamage = DAMAGE_NO;
59 set_movetype(vehic, MOVETYPE_NONE);
63 vehicles_frame(vehic, this);
65 PHYS_INPUT_BUTTON_ZOOM(this) = false;
66 PHYS_INPUT_BUTTON_CROUCH(this) = false;
67 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
69 .entity weaponentity = weaponentities[slot];
70 this.(weaponentity).m_switchweapon = WEP_Null;
72 STAT(VEHICLESTAT_W2MODE, this) = STAT(VEHICLESTAT_W2MODE, vehic);
75 #if 1 // 0 to enable per-gun impact aux crosshairs
76 // Avarage gun impact point's -> aux cross
77 vector ad = gettaginfo(vehic.tur_head, gettagindex(vehic.tur_head, "tag_hardpoint01"));
78 vector vf = v_forward;
79 ad += gettaginfo(vehic.tur_head, gettagindex(vehic.tur_head, "tag_hardpoint02"));
83 traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
84 UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
86 vector ad = gettaginfo(vehic.gun1, gettagindex(vehic.gun1, "barrels"));
87 traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
88 UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
90 ad = gettaginfo(vehic.gun2, gettagindex(vehic.gun2, "barrels"));
91 traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
92 UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 1);
96 crosshair_trace(this);
97 ad = vectoangles(normalize(trace_endpos - ad));
98 ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(vehic.angles), AnglesTransform_FromAngles(ad))) - vehic.tur_head.angles;
99 ad = AnglesTransform_Normalize(ad, true);
100 //UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload2) + ('0 1 0' * (1 - this.vehicle_reload2)), 2);
103 float ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * PHYS_INPUT_FRAMETIME;
104 ad_y = bound(-ftmp, ad_y, ftmp);
105 vehic.tur_head.angles_y = bound(autocvar_g_vehicle_spiderbot_head_turnlimit * -1, vehic.tur_head.angles_y + ad_y, autocvar_g_vehicle_spiderbot_head_turnlimit);
108 ad_x = bound(ftmp * -1, ad_x, ftmp);
109 vehic.tur_head.angles_x = bound(autocvar_g_vehicle_spiderbot_head_pitchlimit_down, vehic.tur_head.angles_x + ad_x, autocvar_g_vehicle_spiderbot_head_pitchlimit_up);
112 //fixedmakevectors(vehic.angles);
113 makevectors(vehic.angles + '-2 0 0' * vehic.angles_x);
115 movelib_groundalign4point(vehic, autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
117 if(IS_ONGROUND(vehic))
118 vehic.jump_delay = time; // reset now so movement can begin
120 //if(IS_ONGROUND(vehic))
122 if(IS_ONGROUND(vehic))
123 if(vehic.frame == 4 && vehic.tur_head.wait != 0)
125 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
129 if (!PHYS_INPUT_BUTTON_JUMP(this))
130 vehic.button2 = false;
132 if((IS_ONGROUND(vehic)) && PHYS_INPUT_BUTTON_JUMP(this) && !vehic.button2 && vehic.tur_head.wait < time)
134 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
135 //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
138 vehic.tur_head.wait = time + 2;
139 vehic.jump_delay = time + 2;
140 vehic.button2 = true; // set spider's jump
141 //PHYS_INPUT_BUTTON_JUMP(this) = false;
143 vector movefix = '0 0 0';
144 if(CS(this).movement_x > 0) movefix_x = 1;
145 if(CS(this).movement_x < 0) movefix_x = -1;
146 if(CS(this).movement_y > 0) movefix_y = 1;
147 if(CS(this).movement_y < 0) movefix_y = -1;
149 vector rt = movefix_y * v_right;
150 vector sd = movefix_x * v_forward;
151 if(movefix_y == 0 && movefix_x == 0)
152 sd = v_forward; // always do forward
154 UNSET_ONGROUND(vehic);
156 vehic.velocity = sd * 700 + rt * 600 + v_up * 600;
159 else if(time >= vehic.jump_delay)
161 if(!CS(this).movement)
163 if(IS_ONGROUND(vehic))
165 if(vehic.sound_nexttime < time || vehic.delay != 3)
168 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
169 //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
170 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
172 movelib_brake_simple(vehic, autocvar_g_vehicle_spiderbot_speed_stop);
179 if(CS(this).movement_x == 0 && CS(this).movement_y != 0)
180 ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * PHYS_INPUT_FRAMETIME;
182 ftmp = autocvar_g_vehicle_spiderbot_turnspeed * PHYS_INPUT_FRAMETIME;
184 ftmp = bound(-ftmp, vehic.tur_head.angles_y, ftmp);
185 vehic.angles_y = anglemods(vehic.angles_y + ftmp);
186 vehic.tur_head.angles_y -= ftmp;
188 if(CS(this).movement_x != 0)
190 if(CS(this).movement_x > 0)
192 CS(this).movement_x = 1;
193 if(IS_ONGROUND(vehic))
196 else if(CS(this).movement_x < 0)
198 CS(this).movement_x = -1;
199 if(IS_ONGROUND(vehic))
202 CS(this).movement_y = 0;
203 float oldvelz = vehic.velocity_z;
204 movelib_move_simple(vehic, normalize(v_forward * CS(this).movement_x),((PHYS_INPUT_BUTTON_JUMP(this)) ? autocvar_g_vehicle_spiderbot_speed_run : autocvar_g_vehicle_spiderbot_speed_walk),autocvar_g_vehicle_spiderbot_movement_inertia);
205 vehic.velocity_z = oldvelz;
206 float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
207 if(vehic.velocity_z <= 20) // not while jumping
208 vehic.velocity_z -= g * PHYS_INPUT_FRAMETIME * autocvar_sv_gravity;
209 if(IS_ONGROUND(vehic))
210 if(vehic.sound_nexttime < time || vehic.delay != 1)
213 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
214 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_WALK, VOL_VEHICLEENGINE, ATTEN_NORM);
215 //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
218 else if(CS(this).movement_y != 0)
220 if(CS(this).movement_y < 0)
222 CS(this).movement_y = -1;
223 if(IS_ONGROUND(vehic))
226 else if(CS(this).movement_y > 0)
228 CS(this).movement_y = 1;
229 if(IS_ONGROUND(vehic))
233 float oldvelz = vehic.velocity_z;
234 movelib_move_simple(vehic, normalize(v_right * CS(this).movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
235 vehic.velocity_z = oldvelz;
236 float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
237 if(vehic.velocity_z <= 20) // not while jumping
238 vehic.velocity_z -= g * PHYS_INPUT_FRAMETIME * autocvar_sv_gravity;
239 if(IS_ONGROUND(vehic))
240 if(vehic.sound_nexttime < time || vehic.delay != 2)
243 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
244 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_STRAFE, VOL_VEHICLEENGINE, ATTEN_NORM);
245 //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
252 vehic.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
253 vehic.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
255 if(!weaponLocked(this) && !weaponUseForbidden(this))
256 if(PHYS_INPUT_BUTTON_ATCK(this))
259 if(vehic.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && vehic.tur_head.attack_finished_single[0] <= time)
263 vehic.misc_bulletcounter += 1;
265 gun = (vehic.misc_bulletcounter % 2) ? vehic.gun1 : vehic.gun2;
267 v = gettaginfo(gun, gettagindex(gun, "barrels"));
268 v_forward = normalize(v_forward);
271 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
272 fireBullet(this, weaponentity, v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
273 autocvar_g_vehicle_spiderbot_minigun_damage, 0, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, EFFECT_BULLET);
275 sound (gun, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
276 //trailparticles(this, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
277 Send_Effect(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH, v, v_forward * 2500, 1);
279 vehic.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
280 vehic.tur_head.attack_finished_single[0] = time + autocvar_g_vehicle_spiderbot_minigun_refire;
281 this.vehicle_ammo1 = (vehic.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
282 vehic.gun1.angles_z += 45;
283 vehic.gun2.angles_z -= 45;
284 if(vehic.gun1.angles_z >= 360)
286 vehic.gun1.angles_z = 0;
287 vehic.gun2.angles_z = 0;
292 vehicles_regen(vehic, vehic.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
293 autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
294 autocvar_g_vehicle_spiderbot_minigun_ammo_regen, dt, false);
297 spiderbot_rocket_do(vehic);
299 if(vehic.vehicle_flags & VHF_SHIELDREGEN)
300 vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, dt, true);
302 if(vehic.vehicle_flags & VHF_HEALTHREGEN)
303 vehicles_regen_resource(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, dt, false, RES_HEALTH);
305 PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
306 //this.vehicle_ammo2 = vehic.tur_head.frame;
307 this.vehicle_ammo2 = (9 - vehic.tur_head.frame) / 8 * 100; // Percentage, like ammo1
309 if(vehic.gun2.cnt <= time)
310 this.vehicle_reload2 = 100;
312 this.vehicle_reload2 = 100 - ((vehic.gun2.cnt - time) / vehic.attack_finished_single[0]) * 100;
314 setorigin(this, vehic.origin + '0 0 1' * vehic.maxs_z);
315 this.oldorigin = this.origin; // negate fall damage
316 this.velocity = vehic.velocity;
318 VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, spiderbot, RES_HEALTH);
320 if(vehic.vehicle_flags & VHF_HASSHIELD)
321 VEHICLE_UPDATE_PLAYER(this, vehic, shield, spiderbot);
324 void spiderbot_exit(entity this, int eject)
326 entity player = this.owner;
328 IL_EACH(g_projectiles, it.owner == player && it.classname == "spiderbot_rocket",
330 it.realowner = player;
334 setthink(this, vehicles_think);
335 this.nextthink = time;
337 set_movetype(this, MOVETYPE_WALK);
341 this.owner = NULL; // reset owner anyway?
345 makevectors(this.angles);
349 spot = this.origin + v_forward * 100 + '0 0 64';
350 spot = vehicles_findgoodexit(this, player, spot);
351 setorigin(player, spot);
352 player.velocity = (v_up + v_forward * 0.25) * 750;
353 player.oldvelocity = player.velocity;
357 if(vdist(this.velocity, >, autocvar_g_vehicle_spiderbot_speed_strafe))
359 player.velocity = normalize(this.velocity) * vlen(this.velocity);
360 player.velocity_z += 200;
361 spot = this.origin + v_forward * 128 + '0 0 64';
362 spot = vehicles_findgoodexit(this, player, spot);
366 player.velocity = this.velocity * 0.5;
367 player.velocity_z += 10;
368 spot = this.origin + v_forward * 256 + '0 0 64';
369 spot = vehicles_findgoodexit(this, player, spot);
371 player.oldvelocity = player.velocity;
372 setorigin(player, spot);
375 antilag_clear(player, CS(player));
379 void spiderbot_headfade(entity this)
381 setthink(this, spiderbot_headfade);
382 this.nextthink = this.fade_time;
383 this.alpha = 1 - (time - this.fade_time) * this.fade_rate;
385 if(this.cnt < time || this.alpha < 0.1)
389 sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
390 Send_Effect(EFFECT_EXPLOSION_BIG, this.origin + '0 0 100', '0 0 0', 1);
396 void spiderbot_blowup(entity this)
402 sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
403 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1);
405 this.nextthink = time + 0.1;
409 entity h = new(spiderbot_top), g1 = new(spiderbot_gun), g2 = new(spiderbot_gun), b = new(spiderbot_body);
411 setmodel(b, MDL_VEH_SPIDERBOT_BODY);
412 setmodel(h, MDL_VEH_SPIDERBOT_TOP);
413 setmodel(g1, MDL_VEH_SPIDERBOT_GUN);
414 setmodel(g2, MDL_VEH_SPIDERBOT_GUN);
416 setorigin(b, this.origin);
418 b.angles = this.angles;
419 setsize(b, this.mins, this.maxs);
421 h.solid = SOLID_BBOX; // before setorigin for immediate area grid linking
422 vector org = gettaginfo(this, gettagindex(this, "tag_head"));
424 set_movetype(h, MOVETYPE_BOUNCE);
425 h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
426 h.modelflags = MF_ROCKET;
427 h.effects = EF_FLAME | EF_LOWPRECISION;
428 h.avelocity = randomvec() * 360;
431 h.cnt = time + (3.5 * random());
432 h.fade_rate = 1 / min(this.respawntime, 10);
434 setthink(h, spiderbot_headfade);
437 g1.solid = SOLID_CORPSE; // before setorigin for immediate area grid linking
438 org = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_hardpoint01"));
440 set_movetype(g1, MOVETYPE_TOSS);
441 g1.velocity = v_forward * 700 + (randomvec() * 32);
442 g1.avelocity = randomvec() * 180;
444 g2.solid = SOLID_CORPSE; // before setorigin for immediate area grid linking
445 org = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_hardpoint02"));
447 set_movetype(g2, MOVETYPE_TOSS);
448 g2.velocity = v_forward * 700 + (randomvec() * 32);
449 g2.avelocity = randomvec() * 180;
451 h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
453 SUB_SetFade(b, time + 5, min(this.respawntime, 1));
454 //SUB_SetFade(h, time, min(this.respawntime, 10));
455 SUB_SetFade(g1, time, min(this.respawntime, 10));
456 SUB_SetFade(g2, time, min(this.respawntime, 10));
458 RadiusDamage (this, this.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_SPID_DEATH.m_id, DMG_NOWEP, NULL);
460 this.alpha = this.tur_head.alpha = this.gun1.alpha = this.gun2.alpha = -1;
461 set_movetype(this, MOVETYPE_NONE);
462 this.deadflag = DEAD_DEAD;
463 this.solid = SOLID_NOT;
464 this.tur_head.effects &= ~EF_FLAME;
465 this.vehicle_hudmodel.viewmodelforclient = this;
468 bool spiderbot_impulse(entity this, int _imp)
472 case IMP_weapon_group_1.impulse:
473 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_VOLLY;
474 CSQCVehicleSetup(this, 0);
476 case IMP_weapon_group_2.impulse:
477 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_GUIDE;
478 CSQCVehicleSetup(this, 0);
480 case IMP_weapon_group_3.impulse:
481 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_ARTILLERY;
482 CSQCVehicleSetup(this, 0);
485 case IMP_weapon_next_byid.impulse:
486 case IMP_weapon_next_bypriority.impulse:
487 case IMP_weapon_next_bygroup.impulse:
488 STAT(VEHICLESTAT_W2MODE, this.vehicle) += 1;
489 if(STAT(VEHICLESTAT_W2MODE, this.vehicle) > SBRM_LAST)
490 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_FIRST;
492 //centerprint(this, strcat("Rocket mode is ", ftos(STAT(VEHICLESTAT_W2MODE, this.vehicle))));
493 CSQCVehicleSetup(this, 0);
495 case IMP_weapon_last.impulse:
496 case IMP_weapon_prev_byid.impulse:
497 case IMP_weapon_prev_bypriority.impulse:
498 case IMP_weapon_prev_bygroup.impulse:
499 STAT(VEHICLESTAT_W2MODE, this.vehicle) -= 1;
500 if(STAT(VEHICLESTAT_W2MODE, this.vehicle) < SBRM_FIRST)
501 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_LAST;
503 //centerprint(this, strcat("Rocket mode is ", ftos(STAT(VEHICLESTAT_W2MODE, this.vehicle))));
504 CSQCVehicleSetup(this, 0);
508 case IMP_weapon_drop.impulse: // toss gun, could be used to exit?
510 case IMP_weapon_reload.impulse: // Manual minigun reload?
517 spawnfunc(vehicle_spiderbot)
519 if(!autocvar_g_vehicle_spiderbot) { delete(this); return; }
520 if(!vehicle_initialize(this, VEH_SPIDERBOT, false)) { delete(this); return; }
523 METHOD(Spiderbot, vr_impact, void(Spiderbot thisveh, entity instance))
525 if(autocvar_g_vehicle_spiderbot_bouncepain)
526 vehicles_impact(instance, autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
528 METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh, entity instance))
530 STAT(VEHICLESTAT_W2MODE, instance) = SBRM_GUIDE;
531 set_movetype(instance, MOVETYPE_WALK);
532 CSQCVehicleSetup(instance.owner, 0);
533 instance.owner.vehicle_health = (GetResource(instance, RES_HEALTH) / autocvar_g_vehicle_spiderbot_health) * 100;
534 instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
536 if(instance.owner.flagcarried)
538 setattachment(instance.owner.flagcarried, instance.tur_head, "");
539 setorigin(instance.owner.flagcarried, '-20 0 120');
542 METHOD(Spiderbot, vr_think, void(Spiderbot thisveh, entity instance))
544 if(IS_ONGROUND(instance))
545 movelib_brake_simple(instance, autocvar_g_vehicle_spiderbot_speed_stop);
547 METHOD(Spiderbot, vr_death, void(Spiderbot thisveh, entity instance))
549 SetResourceExplicit(instance, RES_HEALTH, 0);
550 instance.event_damage = func_null;
551 instance.takedamage = DAMAGE_NO;
552 settouch(instance, func_null);
553 instance.cnt = 3.4 + time + random() * 2;
554 setthink(instance, spiderbot_blowup);
555 instance.nextthink = time;
556 instance.deadflag = DEAD_DYING;
558 instance.tur_head.effects |= EF_FLAME;
559 instance.colormod = instance.tur_head.colormod = '-1 -1 -1';
561 set_movetype(instance, MOVETYPE_TOSS);
563 CSQCModel_UnlinkEntity(instance); // networking the death scene would be a nightmare
565 METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh, entity instance))
569 instance.vehicles_impulse = spiderbot_impulse;
570 instance.gun1 = new(spiderbot_gun);
571 instance.gun2 = new(spiderbot_gun);
572 setmodel(instance.gun1, MDL_VEH_SPIDERBOT_GUN);
573 setmodel(instance.gun2, MDL_VEH_SPIDERBOT_GUN);
574 setattachment(instance.gun1, instance.tur_head, "tag_hardpoint01");
575 setattachment(instance.gun2, instance.tur_head, "tag_hardpoint02");
576 instance.gravity = 2;
577 instance.mass = 5000;
581 instance.tur_head.frame = 1;
582 set_movetype(instance, MOVETYPE_WALK);
583 instance.solid = SOLID_SLIDEBOX;
584 instance.alpha = instance.tur_head.alpha = instance.gun1.alpha = instance.gun2.alpha = 1;
585 instance.tur_head.angles = '0 0 0';
586 instance.vehicle_exit = spiderbot_exit;
588 setorigin(instance, instance.pos1 + '0 0 128');
589 instance.angles = instance.pos2;
590 instance.damageforcescale = 0.03;
591 SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
592 instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
594 instance.PlayerPhysplug = spiderbot_frame;
596 METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
598 if(autocvar_g_vehicle_spiderbot_shield)
599 instance.vehicle_flags |= VHF_HASSHIELD;
601 if(autocvar_g_vehicle_spiderbot_shield_regen)
602 instance.vehicle_flags |= VHF_SHIELDREGEN;
604 if(autocvar_g_vehicle_spiderbot_health_regen)
605 instance.vehicle_flags |= VHF_HEALTHREGEN;
607 instance.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
608 SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
609 instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
610 instance.max_health = GetResource(instance, RES_HEALTH);
611 instance.pushable = true; // spiderbot can use jumppads
616 //float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
617 //float autocvar_cl_vehicle_spiderbot_cross_size = 1;
619 METHOD(Spiderbot, vr_hud, void(Spiderbot thisveh))
621 Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2",
622 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
623 "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color);
625 METHOD(Spiderbot, vr_crosshair, void(Spiderbot thisveh, entity player))
631 case SBRM_VOLLY: crosshair = vCROSS_BURST; break;
632 case SBRM_GUIDE: crosshair = vCROSS_GUIDE; break;
633 case SBRM_ARTILLERY: crosshair = vCROSS_RAIN; break;
634 default: crosshair = vCROSS_BURST;
637 Vehicles_drawCrosshair(crosshair);
639 METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
641 AuxiliaryXhair[0].axh_image = vCROSS_HINT; // Minigun1
642 AuxiliaryXhair[1].axh_image = vCROSS_HINT; // Minigun2