1 #include "spiderbot.qh"
5 const int SBRM_FIRST = 1;
6 const int SBRM_VOLLY = 1;
7 const int SBRM_GUIDE = 2;
8 const int SBRM_ARTILLERY = 3;
9 const int SBRM_LAST = 3;
12 bool autocvar_g_vehicle_spiderbot = true;
14 float autocvar_g_vehicle_spiderbot_respawntime = 45;
16 float autocvar_g_vehicle_spiderbot_speed_stop = 50;
17 float autocvar_g_vehicle_spiderbot_speed_strafe = 400;
18 float autocvar_g_vehicle_spiderbot_speed_walk = 500;
19 float autocvar_g_vehicle_spiderbot_speed_run = 700;
20 float autocvar_g_vehicle_spiderbot_turnspeed = 90;
21 float autocvar_g_vehicle_spiderbot_turnspeed_strafe = 300;
22 float autocvar_g_vehicle_spiderbot_movement_inertia = 0.15;
24 float autocvar_g_vehicle_spiderbot_springlength = 150;
25 float autocvar_g_vehicle_spiderbot_springup = 20;
26 float autocvar_g_vehicle_spiderbot_springblend = 0.1;
27 float autocvar_g_vehicle_spiderbot_tiltlimit = 90;
29 float autocvar_g_vehicle_spiderbot_head_pitchlimit_down = -20;
30 float autocvar_g_vehicle_spiderbot_head_pitchlimit_up = 30;
31 float autocvar_g_vehicle_spiderbot_head_turnlimit = 90;
32 float autocvar_g_vehicle_spiderbot_head_turnspeed = 110;
34 int autocvar_g_vehicle_spiderbot_health = 800;
35 float autocvar_g_vehicle_spiderbot_health_regen = 10;
36 float autocvar_g_vehicle_spiderbot_health_regen_pause = 5;
38 int autocvar_g_vehicle_spiderbot_shield = 200;
39 float autocvar_g_vehicle_spiderbot_shield_regen = 25;
40 float autocvar_g_vehicle_spiderbot_shield_regen_pause = 0.35;
42 // 'minspeed_for_pain speedchange_to_pain_factor max_damage'
43 vector autocvar_g_vehicle_spiderbot_bouncepain = '0 0 0';
46 bool spiderbot_frame(entity this, float dt)
48 entity vehic = this.vehicle;
53 vehic.solid = SOLID_NOT;
54 vehic.takedamage = DAMAGE_NO;
55 set_movetype(vehic, MOVETYPE_NONE);
59 vehicles_frame(vehic, this);
61 PHYS_INPUT_BUTTON_ZOOM(this) = false;
62 PHYS_INPUT_BUTTON_CROUCH(this) = false;
63 for(int slot = 0; slot < MAX_WEAPONSLOTS; ++slot)
65 .entity weaponentity = weaponentities[slot];
66 this.(weaponentity).m_switchweapon = WEP_Null;
68 STAT(VEHICLESTAT_W2MODE, this) = STAT(VEHICLESTAT_W2MODE, vehic);
71 #if 1 // 0 to enable per-gun impact aux crosshairs
72 // Avarage gun impact point's -> aux cross
73 vector ad = gettaginfo(vehic.tur_head, gettagindex(vehic.tur_head, "tag_hardpoint01"));
74 vector vf = v_forward;
75 ad += gettaginfo(vehic.tur_head, gettagindex(vehic.tur_head, "tag_hardpoint02"));
79 traceline(ad, ad + v_forward * max_shot_distance, MOVE_NORMAL, vehic);
80 UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload1) + ('0 1 0' * (1 - this.vehicle_reload1)), 0);
82 vector ad = gettaginfo(vehic.gun1, gettagindex(vehic.gun1, "barrels"));
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 ad = gettaginfo(vehic.gun2, gettagindex(vehic.gun2, "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)), 1);
92 crosshair_trace(this);
93 ad = vectoangles(normalize(trace_endpos - ad));
94 ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(vehic.angles), AnglesTransform_FromAngles(ad))) - vehic.tur_head.angles;
95 ad = AnglesTransform_Normalize(ad, true);
96 //UpdateAuxiliaryXhair(this, trace_endpos, ('1 0 0' * this.vehicle_reload2) + ('0 1 0' * (1 - this.vehicle_reload2)), 2);
99 float ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * PHYS_INPUT_FRAMETIME;
100 ad_y = bound(-ftmp, ad_y, ftmp);
101 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);
104 ad_x = bound(ftmp * -1, ad_x, ftmp);
105 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);
108 //fixedmakevectors(vehic.angles);
109 makevectors(vehic.angles + '-2 0 0' * vehic.angles_x);
111 movelib_groundalign4point(vehic, autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
113 if(IS_ONGROUND(vehic))
114 vehic.jump_delay = time; // reset now so movement can begin
116 //if(IS_ONGROUND(vehic))
118 if(IS_ONGROUND(vehic))
119 if(vehic.frame == 4 && vehic.tur_head.wait != 0)
121 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_LAND, VOL_VEHICLEENGINE, ATTEN_NORM);
125 if (!PHYS_INPUT_BUTTON_JUMP(this))
126 vehic.button2 = false;
128 if((IS_ONGROUND(vehic)) && PHYS_INPUT_BUTTON_JUMP(this) && !vehic.button2 && vehic.tur_head.wait < time)
130 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_JUMP, VOL_VEHICLEENGINE, ATTEN_NORM);
131 //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
134 vehic.tur_head.wait = time + 2;
135 vehic.jump_delay = time + 2;
136 vehic.button2 = true; // set spider's jump
137 //PHYS_INPUT_BUTTON_JUMP(this) = false;
139 vector movefix = '0 0 0';
140 if(CS(this).movement_x > 0) movefix_x = 1;
141 if(CS(this).movement_x < 0) movefix_x = -1;
142 if(CS(this).movement_y > 0) movefix_y = 1;
143 if(CS(this).movement_y < 0) movefix_y = -1;
145 vector rt = movefix_y * v_right;
146 vector sd = movefix_x * v_forward;
147 if(movefix_y == 0 && movefix_x == 0)
148 sd = v_forward; // always do forward
150 UNSET_ONGROUND(vehic);
152 vehic.velocity = sd * 700 + rt * 600 + v_up * 600;
155 else if(time >= vehic.jump_delay)
157 if(!CS(this).movement)
159 if(IS_ONGROUND(vehic))
161 if(vehic.sound_nexttime < time || vehic.delay != 3)
164 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
165 //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
166 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_IDLE, VOL_VEHICLEENGINE, ATTEN_NORM);
168 movelib_brake_simple(vehic, autocvar_g_vehicle_spiderbot_speed_stop);
175 if(CS(this).movement_x == 0 && CS(this).movement_y != 0)
176 ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * PHYS_INPUT_FRAMETIME;
178 ftmp = autocvar_g_vehicle_spiderbot_turnspeed * PHYS_INPUT_FRAMETIME;
180 ftmp = bound(-ftmp, vehic.tur_head.angles_y, ftmp);
181 vehic.angles_y = anglemods(vehic.angles_y + ftmp);
182 vehic.tur_head.angles_y -= ftmp;
184 if(CS(this).movement_x != 0)
186 if(CS(this).movement_x > 0)
188 CS(this).movement_x = 1;
189 if(IS_ONGROUND(vehic))
192 else if(CS(this).movement_x < 0)
194 CS(this).movement_x = -1;
195 if(IS_ONGROUND(vehic))
198 CS(this).movement_y = 0;
199 float oldvelz = vehic.velocity_z;
200 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);
201 vehic.velocity_z = oldvelz;
202 float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
203 if(vehic.velocity_z <= 20) // not while jumping
204 vehic.velocity_z -= g * PHYS_INPUT_FRAMETIME * autocvar_sv_gravity;
205 if(IS_ONGROUND(vehic))
206 if(vehic.sound_nexttime < time || vehic.delay != 1)
209 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
210 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_WALK, VOL_VEHICLEENGINE, ATTEN_NORM);
211 //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
214 else if(CS(this).movement_y != 0)
216 if(CS(this).movement_y < 0)
218 CS(this).movement_y = -1;
219 if(IS_ONGROUND(vehic))
222 else if(CS(this).movement_y > 0)
224 CS(this).movement_y = 1;
225 if(IS_ONGROUND(vehic))
229 float oldvelz = vehic.velocity_z;
230 movelib_move_simple(vehic, normalize(v_right * CS(this).movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
231 vehic.velocity_z = oldvelz;
232 float g = ((autocvar_sv_gameplayfix_gravityunaffectedbyticrate) ? 0.5 : 1);
233 if(vehic.velocity_z <= 20) // not while jumping
234 vehic.velocity_z -= g * PHYS_INPUT_FRAMETIME * autocvar_sv_gravity;
235 if(IS_ONGROUND(vehic))
236 if(vehic.sound_nexttime < time || vehic.delay != 2)
239 vehic.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
240 sound (vehic, CH_TRIGGER_SINGLE, SND_VEH_SPIDERBOT_STRAFE, VOL_VEHICLEENGINE, ATTEN_NORM);
241 //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
248 vehic.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
249 vehic.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, vehic.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
251 if(!weaponLocked(this) && !weaponUseForbidden(this))
252 if(PHYS_INPUT_BUTTON_ATCK(this))
255 if(vehic.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && vehic.tur_head.attack_finished_single[0] <= time)
259 vehic.misc_bulletcounter += 1;
261 gun = (vehic.misc_bulletcounter % 2) ? vehic.gun1 : vehic.gun2;
263 v = gettaginfo(gun, gettagindex(gun, "barrels"));
264 v_forward = normalize(v_forward);
267 .entity weaponentity = weaponentities[0]; // TODO: unhardcode
268 fireBullet(this, weaponentity, v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
269 autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN.m_id, EFFECT_BULLET);
271 sound (gun, CH_WEAPON_A, SND_UZI_FIRE, VOL_BASE, ATTEN_NORM);
272 //trailparticles(this, _particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
273 Send_Effect(EFFECT_SPIDERBOT_MINIGUN_MUZZLEFLASH, v, v_forward * 2500, 1);
275 vehic.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
276 vehic.tur_head.attack_finished_single[0] = time + autocvar_g_vehicle_spiderbot_minigun_refire;
277 this.vehicle_ammo1 = (vehic.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
278 vehic.gun1.angles_z += 45;
279 vehic.gun2.angles_z -= 45;
280 if(vehic.gun1.angles_z >= 360)
282 vehic.gun1.angles_z = 0;
283 vehic.gun2.angles_z = 0;
288 vehicles_regen(vehic, vehic.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
289 autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
290 autocvar_g_vehicle_spiderbot_minigun_ammo_regen, dt, false);
293 spiderbot_rocket_do(vehic);
295 if(vehic.vehicle_flags & VHF_SHIELDREGEN)
296 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);
298 if(vehic.vehicle_flags & VHF_HEALTHREGEN)
299 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);
301 PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = false;
302 //this.vehicle_ammo2 = vehic.tur_head.frame;
303 this.vehicle_ammo2 = (9 - vehic.tur_head.frame) / 8 * 100; // Percentage, like ammo1
305 if(vehic.gun2.cnt <= time)
306 this.vehicle_reload2 = 100;
308 this.vehicle_reload2 = 100 - ((vehic.gun2.cnt - time) / vehic.attack_finished_single[0]) * 100;
310 setorigin(this, vehic.origin + '0 0 1' * vehic.maxs_z);
311 this.oldorigin = this.origin; // negate fall damage
312 this.velocity = vehic.velocity;
314 VEHICLE_UPDATE_PLAYER_RESOURCE(this, vehic, health, spiderbot, RES_HEALTH);
316 if(vehic.vehicle_flags & VHF_HASSHIELD)
317 VEHICLE_UPDATE_PLAYER(this, vehic, shield, spiderbot);
320 void spiderbot_exit(entity this, int eject)
322 entity player = this.owner;
324 IL_EACH(g_projectiles, it.owner == player && it.classname == "spiderbot_rocket",
326 it.realowner = player;
330 setthink(this, vehicles_think);
331 this.nextthink = time;
333 set_movetype(this, MOVETYPE_WALK);
337 this.owner = NULL; // reset owner anyway?
341 makevectors(this.angles);
345 spot = this.origin + v_forward * 100 + '0 0 64';
346 spot = vehicles_findgoodexit(this, player, spot);
347 setorigin(player, spot);
348 player.velocity = (v_up + v_forward * 0.25) * 750;
349 player.oldvelocity = player.velocity;
353 if(vdist(this.velocity, >, autocvar_g_vehicle_spiderbot_speed_strafe))
355 player.velocity = normalize(this.velocity) * vlen(this.velocity);
356 player.velocity_z += 200;
357 spot = this.origin + v_forward * 128 + '0 0 64';
358 spot = vehicles_findgoodexit(this, player, spot);
362 player.velocity = this.velocity * 0.5;
363 player.velocity_z += 10;
364 spot = this.origin + v_forward * 256 + '0 0 64';
365 spot = vehicles_findgoodexit(this, player, spot);
367 player.oldvelocity = player.velocity;
368 setorigin(player, spot);
371 antilag_clear(player, CS(player));
375 void spiderbot_headfade(entity this)
377 setthink(this, spiderbot_headfade);
378 this.nextthink = this.fade_time;
379 this.alpha = 1 - (time - this.fade_time) * this.fade_rate;
381 if(this.cnt < time || this.alpha < 0.1)
385 sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
386 Send_Effect(EFFECT_EXPLOSION_BIG, this.origin + '0 0 100', '0 0 0', 1);
392 void spiderbot_blowup(entity this)
398 sound (this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
399 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (this.origin + '0 0 100'), '0 0 0', 1);
401 this.nextthink = time + 0.1;
405 entity h = spawn(), g1 = spawn(), g2 = spawn(), b = spawn();
407 setmodel(b, MDL_VEH_SPIDERBOT_BODY);
408 setmodel(h, MDL_VEH_SPIDERBOT_TOP);
409 setmodel(g1, MDL_VEH_SPIDERBOT_GUN);
410 setmodel(g2, MDL_VEH_SPIDERBOT_GUN);
412 setorigin(b, this.origin);
414 b.angles = this.angles;
415 setsize(b, this.mins, this.maxs);
417 vector org = gettaginfo(this, gettagindex(this, "tag_head"));
419 set_movetype(h, MOVETYPE_BOUNCE);
420 h.solid = SOLID_BBOX;
421 h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
422 h.modelflags = MF_ROCKET;
423 h.effects = EF_FLAME | EF_LOWPRECISION;
424 h.avelocity = randomvec() * 360;
427 h.cnt = time + (3.5 * random());
428 h.fade_rate = 1 / min(this.respawntime, 10);
430 setthink(h, spiderbot_headfade);
433 org = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_hardpoint01"));
435 set_movetype(g1, MOVETYPE_TOSS);
436 g1.solid = SOLID_CORPSE;
437 g1.velocity = v_forward * 700 + (randomvec() * 32);
438 g1.avelocity = randomvec() * 180;
440 org = gettaginfo(this.tur_head, gettagindex(this.tur_head, "tag_hardpoint02"));
442 set_movetype(g2, MOVETYPE_TOSS);
443 g2.solid = SOLID_CORPSE;
444 g2.velocity = v_forward * 700 + (randomvec() * 32);
445 g2.avelocity = randomvec() * 180;
447 h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
449 SUB_SetFade(b, time + 5, min(this.respawntime, 1));
450 //SUB_SetFade(h, time, min(this.respawntime, 10));
451 SUB_SetFade(g1, time, min(this.respawntime, 10));
452 SUB_SetFade(g2, time, min(this.respawntime, 10));
454 RadiusDamage (this, this.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_SPID_DEATH.m_id, DMG_NOWEP, NULL);
456 this.alpha = this.tur_head.alpha = this.gun1.alpha = this.gun2.alpha = -1;
457 set_movetype(this, MOVETYPE_NONE);
458 this.deadflag = DEAD_DEAD;
459 this.solid = SOLID_NOT;
460 this.tur_head.effects &= ~EF_FLAME;
461 this.vehicle_hudmodel.viewmodelforclient = this;
464 bool spiderbot_impulse(entity this, int _imp)
468 case IMP_weapon_group_1.impulse:
469 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_VOLLY;
470 CSQCVehicleSetup(this, 0);
472 case IMP_weapon_group_2.impulse:
473 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_GUIDE;
474 CSQCVehicleSetup(this, 0);
476 case IMP_weapon_group_3.impulse:
477 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_ARTILLERY;
478 CSQCVehicleSetup(this, 0);
481 case IMP_weapon_next_byid.impulse:
482 case IMP_weapon_next_bypriority.impulse:
483 case IMP_weapon_next_bygroup.impulse:
484 STAT(VEHICLESTAT_W2MODE, this.vehicle) += 1;
485 if(STAT(VEHICLESTAT_W2MODE, this.vehicle) > SBRM_LAST)
486 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_FIRST;
488 //centerprint(this, strcat("Rocket mode is ", ftos(STAT(VEHICLESTAT_W2MODE, this.vehicle))));
489 CSQCVehicleSetup(this, 0);
491 case IMP_weapon_last.impulse:
492 case IMP_weapon_prev_byid.impulse:
493 case IMP_weapon_prev_bypriority.impulse:
494 case IMP_weapon_prev_bygroup.impulse:
495 STAT(VEHICLESTAT_W2MODE, this.vehicle) -= 1;
496 if(STAT(VEHICLESTAT_W2MODE, this.vehicle) < SBRM_FIRST)
497 STAT(VEHICLESTAT_W2MODE, this.vehicle) = SBRM_LAST;
499 //centerprint(this, strcat("Rocket mode is ", ftos(STAT(VEHICLESTAT_W2MODE, this.vehicle))));
500 CSQCVehicleSetup(this, 0);
504 case IMP_weapon_drop.impulse: // toss gun, could be used to exit?
506 case IMP_weapon_reload.impulse: // Manual minigun reload?
513 spawnfunc(vehicle_spiderbot)
515 if(!autocvar_g_vehicle_spiderbot) { delete(this); return; }
516 if(!vehicle_initialize(this, VEH_SPIDERBOT, false)) { delete(this); return; }
519 METHOD(Spiderbot, vr_impact, void(Spiderbot thisveh, entity instance))
521 if(autocvar_g_vehicle_spiderbot_bouncepain)
522 vehicles_impact(instance, autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
524 METHOD(Spiderbot, vr_enter, void(Spiderbot thisveh, entity instance))
526 STAT(VEHICLESTAT_W2MODE, instance) = SBRM_GUIDE;
527 set_movetype(instance, MOVETYPE_WALK);
528 CSQCVehicleSetup(instance.owner, 0);
529 instance.owner.vehicle_health = (GetResource(instance, RES_HEALTH) / autocvar_g_vehicle_spiderbot_health) * 100;
530 instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
532 if(instance.owner.flagcarried)
534 setattachment(instance.owner.flagcarried, instance.tur_head, "");
535 setorigin(instance.owner.flagcarried, '-20 0 120');
538 METHOD(Spiderbot, vr_think, void(Spiderbot thisveh, entity instance))
540 if(IS_ONGROUND(instance))
541 movelib_brake_simple(instance, autocvar_g_vehicle_spiderbot_speed_stop);
543 METHOD(Spiderbot, vr_death, void(Spiderbot thisveh, entity instance))
545 SetResourceExplicit(instance, RES_HEALTH, 0);
546 instance.event_damage = func_null;
547 instance.takedamage = DAMAGE_NO;
548 settouch(instance, func_null);
549 instance.cnt = 3.4 + time + random() * 2;
550 setthink(instance, spiderbot_blowup);
551 instance.nextthink = time;
552 instance.deadflag = DEAD_DYING;
554 instance.tur_head.effects |= EF_FLAME;
555 instance.colormod = instance.tur_head.colormod = '-1 -1 -1';
557 set_movetype(instance, MOVETYPE_TOSS);
559 CSQCModel_UnlinkEntity(instance); // networking the death scene would be a nightmare
561 METHOD(Spiderbot, vr_spawn, void(Spiderbot thisveh, entity instance))
565 instance.vehicles_impulse = spiderbot_impulse;
566 instance.gun1 = spawn();
567 instance.gun2 = spawn();
568 setmodel(instance.gun1, MDL_VEH_SPIDERBOT_GUN);
569 setmodel(instance.gun2, MDL_VEH_SPIDERBOT_GUN);
570 setattachment(instance.gun1, instance.tur_head, "tag_hardpoint01");
571 setattachment(instance.gun2, instance.tur_head, "tag_hardpoint02");
572 instance.gravity = 2;
573 instance.mass = 5000;
577 instance.tur_head.frame = 1;
578 set_movetype(instance, MOVETYPE_WALK);
579 instance.solid = SOLID_SLIDEBOX;
580 instance.alpha = instance.tur_head.alpha = instance.gun1.alpha = instance.gun2.alpha = 1;
581 instance.tur_head.angles = '0 0 0';
582 instance.vehicle_exit = spiderbot_exit;
584 setorigin(instance, instance.pos1 + '0 0 128');
585 instance.angles = instance.pos2;
586 instance.damageforcescale = 0.03;
587 SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
588 instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
590 instance.PlayerPhysplug = spiderbot_frame;
592 METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
594 if(autocvar_g_vehicle_spiderbot_shield)
595 instance.vehicle_flags |= VHF_HASSHIELD;
597 if(autocvar_g_vehicle_spiderbot_shield_regen)
598 instance.vehicle_flags |= VHF_SHIELDREGEN;
600 if(autocvar_g_vehicle_spiderbot_health_regen)
601 instance.vehicle_flags |= VHF_HEALTHREGEN;
603 instance.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
604 SetResourceExplicit(instance, RES_HEALTH, autocvar_g_vehicle_spiderbot_health);
605 instance.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
606 instance.max_health = GetResource(instance, RES_HEALTH);
607 instance.pushable = true; // spiderbot can use jumppads
612 //float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
613 //float autocvar_cl_vehicle_spiderbot_cross_size = 1;
615 METHOD(Spiderbot, vr_hud, void(Spiderbot thisveh))
617 Vehicles_drawHUD(VEH_SPIDERBOT.m_icon, "vehicle_spider_weapon1", "vehicle_spider_weapon2",
618 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
619 "vehicle_icon_ammo2", autocvar_hud_progressbar_vehicles_ammo2_color);
621 METHOD(Spiderbot, vr_crosshair, void(Spiderbot thisveh, entity player))
627 case SBRM_VOLLY: crosshair = vCROSS_BURST; break;
628 case SBRM_GUIDE: crosshair = vCROSS_GUIDE; break;
629 case SBRM_ARTILLERY: crosshair = vCROSS_RAIN; break;
630 default: crosshair = vCROSS_BURST;
633 Vehicles_drawCrosshair(crosshair);
635 METHOD(Spiderbot, vr_setup, void(Spiderbot thisveh, entity instance))
637 AuxiliaryXhair[0].axh_image = vCROSS_HINT; // Minigun1
638 AuxiliaryXhair[1].axh_image = vCROSS_HINT; // Minigun2