1 #ifdef REGISTER_VEHICLE
3 /* VEH_##id */ SPIDERBOT,
4 /* function */ v_spiderbot,
5 /* spawnflags */ VHF_DMGSHAKE,
6 /* mins,maxs */ '-75 -75 10', '75 75 125',
7 /* model */ "models/vehicles/spiderbot.dpm",
8 /* head_model */ "models/vehicles/spiderbot_top.dpm",
9 /* hud_model */ "models/vehicles/spiderbot_cockpit.dpm",
10 /* tags */ "tag_head", "tag_hud", "",
11 /* netname */ "spiderbot",
12 /* fullname */ _("Spiderbot")
16 const float SBRM_FIRST = 1;
17 const float SBRM_VOLLY = 1;
18 const float SBRM_GUIDE = 2;
19 const float SBRM_ARTILLERY = 3;
20 const float SBRM_LAST = 3;
23 float autocvar_g_vehicle_spiderbot;
25 float autocvar_g_vehicle_spiderbot_respawntime;
27 float autocvar_g_vehicle_spiderbot_speed_stop;
28 float autocvar_g_vehicle_spiderbot_speed_strafe;
29 float autocvar_g_vehicle_spiderbot_speed_walk;
30 float autocvar_g_vehicle_spiderbot_turnspeed;
31 float autocvar_g_vehicle_spiderbot_turnspeed_strafe;
32 float autocvar_g_vehicle_spiderbot_movement_inertia;
34 float autocvar_g_vehicle_spiderbot_springlength;
35 float autocvar_g_vehicle_spiderbot_springup;
36 float autocvar_g_vehicle_spiderbot_springblend;
37 float autocvar_g_vehicle_spiderbot_tiltlimit;
39 float autocvar_g_vehicle_spiderbot_head_pitchlimit_down;
40 float autocvar_g_vehicle_spiderbot_head_pitchlimit_up;
41 float autocvar_g_vehicle_spiderbot_head_turnlimit;
42 float autocvar_g_vehicle_spiderbot_head_turnspeed;
44 float autocvar_g_vehicle_spiderbot_health;
45 float autocvar_g_vehicle_spiderbot_health_regen;
46 float autocvar_g_vehicle_spiderbot_health_regen_pause;
48 float autocvar_g_vehicle_spiderbot_shield;
49 float autocvar_g_vehicle_spiderbot_shield_regen;
50 float autocvar_g_vehicle_spiderbot_shield_regen_pause;
52 float autocvar_g_vehicle_spiderbot_minigun_damage;
53 float autocvar_g_vehicle_spiderbot_minigun_refire;
54 float autocvar_g_vehicle_spiderbot_minigun_spread;
55 float autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
56 float autocvar_g_vehicle_spiderbot_minigun_ammo_max;
57 float autocvar_g_vehicle_spiderbot_minigun_ammo_regen;
58 float autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause;
59 float autocvar_g_vehicle_spiderbot_minigun_force;
60 float autocvar_g_vehicle_spiderbot_minigun_solidpenetration;
62 float autocvar_g_vehicle_spiderbot_rocket_damage;
63 float autocvar_g_vehicle_spiderbot_rocket_force;
64 float autocvar_g_vehicle_spiderbot_rocket_radius;
65 float autocvar_g_vehicle_spiderbot_rocket_speed;
66 float autocvar_g_vehicle_spiderbot_rocket_spread;
67 float autocvar_g_vehicle_spiderbot_rocket_refire;
68 float autocvar_g_vehicle_spiderbot_rocket_refire2;
69 float autocvar_g_vehicle_spiderbot_rocket_reload;
70 float autocvar_g_vehicle_spiderbot_rocket_health;
71 float autocvar_g_vehicle_spiderbot_rocket_noise;
72 float autocvar_g_vehicle_spiderbot_rocket_turnrate;
73 float autocvar_g_vehicle_spiderbot_rocket_lifetime;
75 vector autocvar_g_vehicle_spiderbot_bouncepain;
77 void spiderbot_rocket_artillery()
79 self.nextthink = time;
80 UpdateCSQCProjectile(self);
83 void spiderbot_rocket_unguided()
85 vector newdir, olddir;
87 self.nextthink = time;
89 olddir = normalize(self.velocity);
90 newdir = normalize(self.pos1 - self.origin) + randomvec() * autocvar_g_vehicle_spiderbot_rocket_noise;
91 self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_spiderbot_rocket_turnrate) * autocvar_g_vehicle_spiderbot_rocket_speed;
93 UpdateCSQCProjectile(self);
95 if (self.owner.deadflag != DEAD_NO || self.cnt < time || vlen(self.pos1 - self.origin) < 16)
99 void spiderbot_rocket_guided()
101 vector newdir, olddir;
103 self.nextthink = time;
105 if(!self.realowner.vehicle)
106 self.think = spiderbot_rocket_unguided;
108 crosshair_trace(self.realowner);
109 olddir = normalize(self.velocity);
110 newdir = normalize(trace_endpos - self.origin) + randomvec() * autocvar_g_vehicle_spiderbot_rocket_noise;
111 self.velocity = normalize(olddir + newdir * autocvar_g_vehicle_spiderbot_rocket_turnrate) * autocvar_g_vehicle_spiderbot_rocket_speed;
113 UpdateCSQCProjectile(self);
115 if (self.owner.deadflag != DEAD_NO || self.cnt < time)
119 void spiderbot_guide_release()
122 rkt = findchainentity(realowner, self.owner);
126 crosshair_trace(self.owner);
129 if(rkt.think == spiderbot_rocket_guided)
131 rkt.pos1 = trace_endpos;
132 rkt.think = spiderbot_rocket_unguided;
138 float spiberbot_calcartillery_flighttime;
139 vector spiberbot_calcartillery(vector org, vector tgt, float ht)
141 float grav, sdist, zdist, vs, vz, jumpheight;
144 grav = autocvar_sv_gravity;
145 zdist = tgt_z - org_z;
146 sdist = vlen(tgt - org - zdist * '0 0 1');
147 sdir = normalize(tgt - org - zdist * '0 0 1');
149 // how high do we need to go?
150 jumpheight = fabs(ht);
152 jumpheight = jumpheight + zdist;
155 vz = sqrt(2 * grav * jumpheight); // NOTE: sqrt(positive)!
157 // we start with downwards velocity only if it's a downjump and the jump apex should be outside the jump!
163 solution = solve_quadratic(0.5 * grav, -vz, zdist); // equation "z(ti) = zdist"
164 // ALWAYS solvable because jumpheight >= zdist
166 solution_y = solution_x; // just in case it is not solvable due to roundoff errors, assume two equal solutions at their center (this is mainly for the usual case with ht == 0)
168 solution_x = solution_y; // solution_x is 0 in this case, so don't use it, but rather use solution_y (which will be sqrt(0.5 * jumpheight / grav), actually)
175 // almost straight line type
176 // jump apex is before the jump
177 // we must take the larger one
178 spiberbot_calcartillery_flighttime = solution_y;
183 // jump apex is during the jump
184 // we must take the larger one too
185 spiberbot_calcartillery_flighttime = solution_y;
193 // almost straight line type
194 // jump apex is after the jump
195 // we must take the smaller one
196 spiberbot_calcartillery_flighttime = solution_x;
201 // jump apex is during the jump
202 // we must take the larger one
203 spiberbot_calcartillery_flighttime = solution_y;
206 vs = sdist / spiberbot_calcartillery_flighttime;
208 // finally calculate the velocity
209 return sdir * vs + '0 0 1' * vz;
212 void spiderbot_rocket_do()
215 entity rocket = world;
217 if (self.wait != -10)
219 if (self.owner.BUTTON_ATCK2 && self.vehicle_weapon2mode == SBRM_GUIDE)
222 if (self.tur_head.frame == 9 || self.tur_head.frame == 1)
224 if(self.gun2.cnt < time && self.tur_head.frame == 9)
225 self.tur_head.frame = 1;
234 spiderbot_guide_release();
240 if(self.gun2.cnt > time)
243 if (self.tur_head.frame >= 9)
245 self.tur_head.frame = 1;
250 if(!self.owner.BUTTON_ATCK2)
253 if(forbidWeaponUse(self.owner))
256 v = gettaginfo(self.tur_head,gettagindex(self.tur_head,"tag_fire"));
258 switch(self.vehicle_weapon2mode)
261 rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
262 v, normalize(randomvec() * autocvar_g_vehicle_spiderbot_rocket_spread + v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
263 autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
264 DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, TRUE, self.owner);
265 crosshair_trace(self.owner);
266 float _dist = (random() * autocvar_g_vehicle_spiderbot_rocket_radius) + vlen(v - trace_endpos);
267 _dist -= (random() * autocvar_g_vehicle_spiderbot_rocket_radius) ;
268 rocket.nextthink = time + (_dist / autocvar_g_vehicle_spiderbot_rocket_speed);
269 rocket.think = vehicles_projectile_explode;
271 if(self.owner.BUTTON_ATCK2 && self.tur_head.frame == 1)
275 rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
276 v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
277 autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
278 DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, FALSE, self.owner);
279 crosshair_trace(self.owner);
280 rocket.pos1 = trace_endpos;
281 rocket.nextthink = time;
282 rocket.think = spiderbot_rocket_guided;
287 rocket = vehicles_projectile("spiderbot_rocket_launch", "weapons/rocket_fire.wav",
288 v, normalize(v_forward) * autocvar_g_vehicle_spiderbot_rocket_speed,
289 autocvar_g_vehicle_spiderbot_rocket_damage, autocvar_g_vehicle_spiderbot_rocket_radius, autocvar_g_vehicle_spiderbot_rocket_force, 1,
290 DEATH_VH_SPID_ROCKET, PROJECTILE_SPIDERROCKET, autocvar_g_vehicle_spiderbot_rocket_health, FALSE, TRUE, self.owner);
292 crosshair_trace(self.owner);
294 rocket.pos1 = trace_endpos + randomvec() * (0.75 * autocvar_g_vehicle_spiderbot_rocket_radius);
295 rocket.pos1_z = trace_endpos_z;
297 traceline(v, v + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
298 float h1 = 0.75 * vlen(v - trace_endpos);
301 traceline(v , rocket.pos1 + '0 0 1' * MAX_SHOT_DISTANCE, MOVE_WORLDONLY, self);
302 float h2 = 0.75 * vlen(rocket.pos1 - v);
304 rocket.velocity = spiberbot_calcartillery(v, rocket.pos1, ((h1 < h2) ? h1 : h2));
305 rocket.movetype = MOVETYPE_TOSS;
307 //rocket.think = spiderbot_rocket_artillery;
310 rocket.classname = "spiderbot_rocket";
312 rocket.cnt = time + autocvar_g_vehicle_spiderbot_rocket_lifetime;
314 self.tur_head.frame += 1;
315 if (self.tur_head.frame == 9)
316 self.attack_finished_single = autocvar_g_vehicle_spiderbot_rocket_reload;
318 self.attack_finished_single = ((self.vehicle_weapon2mode == SBRM_VOLLY) ? autocvar_g_vehicle_spiderbot_rocket_refire2 : autocvar_g_vehicle_spiderbot_rocket_refire);
320 self.gun2.cnt = time + self.attack_finished_single;
323 float spiderbot_frame()
326 entity player, spider;
329 if(intermission_running)
331 self.vehicle.velocity = '0 0 0';
336 spider = self.vehicle;
339 vehicles_painframe();
341 player.BUTTON_ZOOM = 0;
342 player.BUTTON_CROUCH = 0;
343 player.switchweapon = 0;
344 player.vehicle_weapon2mode = spider.vehicle_weapon2mode;
347 #if 1 // 0 to enable per-gun impact aux crosshairs
348 // Avarage gun impact point's -> aux cross
349 ad = gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint01"));
351 ad += gettaginfo(spider.tur_head, gettagindex(spider.tur_head, "tag_hardpoint02"));
354 v_forward = vf * 0.5;
355 traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
356 UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
358 ad = gettaginfo(spider.gun1, gettagindex(spider.gun1, "barrels"));
359 traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
360 UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 0);
362 ad = gettaginfo(spider.gun2, gettagindex(spider.gun2, "barrels"));
363 traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, spider);
364 UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload1) + ('0 1 0' * (1 - player.vehicle_reload1)), 1);
365 ad = 0.5 * (ad + vf);
368 crosshair_trace(player);
369 ad = vectoangles(normalize(trace_endpos - ad));
370 ad = AnglesTransform_ToAngles(AnglesTransform_LeftDivide(AnglesTransform_FromAngles(spider.angles), AnglesTransform_FromAngles(ad))) - spider.tur_head.angles;
371 ad = AnglesTransform_Normalize(ad, TRUE);
372 //UpdateAuxiliaryXhair(player, trace_endpos, ('1 0 0' * player.vehicle_reload2) + ('0 1 0' * (1 - player.vehicle_reload2)), 2);
375 ftmp = autocvar_g_vehicle_spiderbot_head_turnspeed * sys_frametime;
376 ad_y = bound(-ftmp, ad_y, ftmp);
377 spider.tur_head.angles_y = bound(autocvar_g_vehicle_spiderbot_head_turnlimit * -1, spider.tur_head.angles_y + ad_y, autocvar_g_vehicle_spiderbot_head_turnlimit);
380 ad_x = bound(ftmp * -1, ad_x, ftmp);
381 spider.tur_head.angles_x = bound(autocvar_g_vehicle_spiderbot_head_pitchlimit_down, spider.tur_head.angles_x + ad_x, autocvar_g_vehicle_spiderbot_head_pitchlimit_up);
384 //fixedmakevectors(spider.angles);
385 makevectors(spider.angles + '-2 0 0' * spider.angles_x);
387 movelib_groundalign4point(autocvar_g_vehicle_spiderbot_springlength, autocvar_g_vehicle_spiderbot_springup, autocvar_g_vehicle_spiderbot_springblend, autocvar_g_vehicle_spiderbot_tiltlimit);
389 if(spider.flags & FL_ONGROUND)
391 if(spider.frame == 4 && self.tur_head.wait != 0)
393 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_land.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
397 if(player.BUTTON_JUMP && self.tur_head.wait < time)
399 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_jump.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
400 //dprint("spiderbot_jump:", ftos(soundlength("vehicles/spiderbot_jump.wav")), "\n");
403 self.tur_head.wait = time + 2;
404 player.BUTTON_JUMP = 0;
405 spider.velocity = v_forward * 700 + v_up * 600;
410 if(vlen(player.movement) == 0)
412 if(self.sound_nexttime < time || self.delay != 3)
415 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_idle.wav");
416 //dprint("spiderbot_idle:", ftos(soundlength("vehicles/spiderbot_idle.wav")), "\n");
417 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_idle.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
419 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
425 if(player.movement_x == 0 && player.movement_y != 0)
426 ftmp = autocvar_g_vehicle_spiderbot_turnspeed_strafe * sys_frametime;
428 ftmp = autocvar_g_vehicle_spiderbot_turnspeed * sys_frametime;
430 ftmp = bound(-ftmp, spider.tur_head.angles_y, ftmp);
431 spider.angles_y = anglemods(spider.angles_y + ftmp);
432 spider.tur_head.angles_y -= ftmp;
434 if(player.movement_x != 0)
436 if(player.movement_x > 0)
438 player.movement_x = 1;
441 else if(player.movement_x < 0)
443 player.movement_x = -1;
446 player.movement_y = 0;
447 movelib_move_simple(normalize(v_forward * player.movement_x),autocvar_g_vehicle_spiderbot_speed_walk,autocvar_g_vehicle_spiderbot_movement_inertia);
449 if(self.sound_nexttime < time || self.delay != 1)
452 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_walk.wav");
453 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_walk.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
454 //dprint("spiderbot_walk:", ftos(soundlength("vehicles/spiderbot_walk.wav")), "\n");
457 else if(player.movement_y != 0)
459 if(player.movement_y < 0)
461 player.movement_y = -1;
464 else if(player.movement_y > 0)
466 player.movement_y = 1;
469 movelib_move_simple(normalize(v_right * player.movement_y),autocvar_g_vehicle_spiderbot_speed_strafe,autocvar_g_vehicle_spiderbot_movement_inertia);
470 if(self.sound_nexttime < time || self.delay != 2)
473 self.sound_nexttime = time + 6.486500; //soundlength("vehicles/spiderbot_strafe.wav");
474 sound (self, CH_TRIGGER_SINGLE, "vehicles/spiderbot_strafe.wav", VOL_VEHICLEENGINE, ATTEN_NORM);
475 //dprint("spiderbot_strafe:", ftos(soundlength("vehicles/spiderbot_strafe.wav")), "\n");
482 self.angles_x = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_x, autocvar_g_vehicle_spiderbot_tiltlimit);
483 self.angles_z = bound(-autocvar_g_vehicle_spiderbot_tiltlimit, self.angles_z, autocvar_g_vehicle_spiderbot_tiltlimit);
485 if(!forbidWeaponUse(player))
486 if(player.BUTTON_ATCK)
489 if(spider.vehicle_ammo1 >= autocvar_g_vehicle_spiderbot_minigun_ammo_cost && spider.tur_head.attack_finished_single <= time)
493 spider.misc_bulletcounter += 1;
497 mod(spider.misc_bulletcounter, 2) ? gun = spider.gun1 : gun = spider.gun2;
498 v = gettaginfo(gun, gettagindex(gun, "barrels"));
499 v_forward = normalize(v_forward);
502 fireBullet(v, v_forward, autocvar_g_vehicle_spiderbot_minigun_spread, autocvar_g_vehicle_spiderbot_minigun_solidpenetration,
503 autocvar_g_vehicle_spiderbot_minigun_damage, autocvar_g_vehicle_spiderbot_minigun_force, DEATH_VH_SPID_MINIGUN, 0);
505 sound (gun, CH_WEAPON_A, "weapons/uzi_fire.wav", VOL_BASE, ATTEN_NORM);
506 //trailparticles(self, particleeffectnum("spiderbot_minigun_trail"), v, trace_endpos);
507 pointparticles(particleeffectnum("spiderbot_minigun_muzzleflash"), v, v_forward * 2500, 1);
511 spider.vehicle_ammo1 -= autocvar_g_vehicle_spiderbot_minigun_ammo_cost;
512 spider.tur_head.attack_finished_single = time + autocvar_g_vehicle_spiderbot_minigun_refire;
513 player.vehicle_ammo1 = (spider.vehicle_ammo1 / autocvar_g_vehicle_spiderbot_minigun_ammo_max) * 100;
514 spider.gun1.angles_z += 45;
515 spider.gun2.angles_z -= 45;
516 if(spider.gun1.angles_z >= 360)
518 spider.gun1.angles_z = 0;
519 spider.gun2.angles_z = 0;
524 vehicles_regen(spider.cnt, vehicle_ammo1, autocvar_g_vehicle_spiderbot_minigun_ammo_max,
525 autocvar_g_vehicle_spiderbot_minigun_ammo_regen_pause,
526 autocvar_g_vehicle_spiderbot_minigun_ammo_regen, frametime, FALSE);
529 spiderbot_rocket_do();
531 if(self.vehicle_flags & VHF_SHIELDREGEN)
532 vehicles_regen(spider.dmg_time, vehicle_shield, autocvar_g_vehicle_spiderbot_shield, autocvar_g_vehicle_spiderbot_shield_regen_pause, autocvar_g_vehicle_spiderbot_shield_regen, frametime, TRUE);
534 if(self.vehicle_flags & VHF_HEALTHREGEN)
535 vehicles_regen(spider.dmg_time, vehicle_health, autocvar_g_vehicle_spiderbot_health, autocvar_g_vehicle_spiderbot_health_regen_pause, autocvar_g_vehicle_spiderbot_health_regen, frametime, FALSE);
537 player.BUTTON_ATCK = player.BUTTON_ATCK2 = 0;
538 player.vehicle_ammo2 = spider.tur_head.frame;
540 if(spider.gun2.cnt <= time)
541 player.vehicle_reload2 = 100;
543 player.vehicle_reload2 = 100 - ((spider.gun2.cnt - time) / spider.attack_finished_single) * 100;
545 setorigin(player, spider.origin + '0 0 1' * spider.maxs_z);
546 player.velocity = spider.velocity;
548 VEHICLE_UPDATE_PLAYER(player, health, spiderbot);
550 if(self.vehicle_flags & VHF_HASSHIELD)
551 VEHICLE_UPDATE_PLAYER(player, shield, spiderbot);
557 void spiderbot_exit(float eject)
562 e = findchain(classname,"spiderbot_rocket");
565 if(e.owner == self.owner)
567 e.realowner = self.owner;
573 self.think = vehicles_think;
574 self.nextthink = time;
576 self.movetype = MOVETYPE_WALK;
581 makevectors(self.angles);
584 spot = self.origin + v_forward * 100 + '0 0 64';
585 spot = vehicles_findgoodexit(spot);
586 setorigin(self.owner , spot);
587 self.owner.velocity = (v_up + v_forward * 0.25) * 750;
588 self.owner.oldvelocity = self.owner.velocity;
592 if(vlen(self.velocity) > autocvar_g_vehicle_spiderbot_speed_strafe)
594 self.owner.velocity = normalize(self.velocity) * vlen(self.velocity);
595 self.owner.velocity_z += 200;
596 spot = self.origin + v_forward * 128 + '0 0 64';
597 spot = vehicles_findgoodexit(spot);
601 self.owner.velocity = self.velocity * 0.5;
602 self.owner.velocity_z += 10;
603 spot = self.origin + v_forward * 256 + '0 0 64';
604 spot = vehicles_findgoodexit(spot);
606 self.owner.oldvelocity = self.owner.velocity;
607 setorigin(self.owner , spot);
610 antilag_clear(self.owner);
614 void spiderbot_headfade()
616 self.think = spiderbot_headfade;
617 self.nextthink = self.fade_time;
618 self.alpha = 1 - (time - self.fade_time) * self.fade_rate;
620 if(self.cnt < time || self.alpha < 0.1)
624 sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
625 pointparticles(particleeffectnum("explosion_big"), self.origin + '0 0 100', '0 0 0', 1);
631 void spiderbot_blowup()
637 sound (self, CH_SHOTS, "weapons/rocket_impact.wav", VOL_BASE, ATTEN_NORM);
638 pointparticles(particleeffectnum("explosion_small"), randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
640 self.nextthink = time + 0.1;
650 setmodel(b, "models/vehicles/spiderbot.dpm");
651 setmodel(h, "models/vehicles/spiderbot_top.dpm");
652 setmodel(g1, "models/vehicles/spiderbot_barrels.dpm");
653 setmodel(g2, "models/vehicles/spiderbot_barrels.dpm");
655 setorigin(b, self.origin);
657 b.angles = self.angles;
658 setsize(b, self.mins, self.maxs);
660 setorigin(h, gettaginfo(self, gettagindex(self, "tag_head")));
661 h.movetype = MOVETYPE_BOUNCE;
662 h.solid = SOLID_BBOX;
663 h.velocity = v_up * (500 + random() * 500) + randomvec() * 128;
664 h.modelflags = MF_ROCKET;
665 h.effects = EF_FLAME | EF_LOWPRECISION;
666 h.avelocity = randomvec() * 360;
669 h.cnt = time + (3.5 * random());
670 h.fade_rate = 1 / min(self.respawntime, 10);
672 h.think = spiderbot_headfade;
675 setorigin(g1, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint01")));
676 g1.movetype = MOVETYPE_TOSS;
677 g1.solid = SOLID_CORPSE;
678 g1.velocity = v_forward * 700 + (randomvec() * 32);
679 g1.avelocity = randomvec() * 180;
681 setorigin(g2, gettaginfo(self.tur_head, gettagindex(self.tur_head, "tag_hardpoint02")));
682 g2.movetype = MOVETYPE_TOSS;
683 g2.solid = SOLID_CORPSE;
684 g2.velocity = v_forward * 700 + (randomvec() * 32);
685 g2.avelocity = randomvec() * 180;
687 h.colormod = b.colormod = g1.colormod = g2.colormod = '-2 -2 -2';
689 SUB_SetFade(b, time + 5, min(self.respawntime, 1));
690 //SUB_SetFade(h, time, min(self.respawntime, 10));
691 SUB_SetFade(g1, time, min(self.respawntime, 10));
692 SUB_SetFade(g2, time, min(self.respawntime, 10));
694 RadiusDamage (self, self.enemy, 250, 15, 250, world, 250, DEATH_VH_SPID_DEATH, world);
696 self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = -1;
697 self.movetype = MOVETYPE_NONE;
698 self.deadflag = DEAD_DEAD;
699 self.solid = SOLID_NOT;
700 self.tur_head.effects &= ~EF_FLAME;
701 self.vehicle_hudmodel.viewmodelforclient = self;
704 float spiderbot_impulse(float _imp)
711 self.vehicle.vehicle_weapon2mode += 1;
712 if(self.vehicle.vehicle_weapon2mode > SBRM_LAST)
713 self.vehicle.vehicle_weapon2mode = SBRM_FIRST;
715 //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
716 CSQCVehicleSetup(self, 0);
721 self.vehicle.vehicle_weapon2mode -= 1;
722 if(self.vehicle.vehicle_weapon2mode < SBRM_FIRST)
723 self.vehicle.vehicle_weapon2mode = SBRM_LAST;
725 //centerprint(self, strcat("Rocket mode is ", ftos(self.vehicle.vehicle_weapon2mode)));
726 CSQCVehicleSetup(self, 0);
730 case 17: // toss gun, could be used to exit?
732 case 20: // Manual minigun reload?
739 void spawnfunc_vehicle_spiderbot()
741 if(!autocvar_g_vehicle_spiderbot) { remove(self); return; }
742 if(!vehicle_initialize(VEH_SPIDERBOT, FALSE)) { remove(self); return; }
745 float v_spiderbot(float req)
751 if(autocvar_g_vehicle_spiderbot_bouncepain)
752 vehicles_impact(autocvar_g_vehicle_spiderbot_bouncepain_x, autocvar_g_vehicle_spiderbot_bouncepain_y, autocvar_g_vehicle_spiderbot_bouncepain_z);
758 self.vehicle_weapon2mode = SBRM_GUIDE;
759 self.movetype = MOVETYPE_WALK;
760 CSQCVehicleSetup(self.owner, 0);
761 self.owner.vehicle_health = (self.vehicle_health / autocvar_g_vehicle_spiderbot_health) * 100;
762 self.owner.vehicle_shield = (self.vehicle_shield / autocvar_g_vehicle_spiderbot_shield) * 100;
764 if(self.owner.flagcarried)
766 setattachment(self.owner.flagcarried, self.tur_head, "");
767 setorigin(self.owner.flagcarried, '-20 0 120');
774 if(self.flags & FL_ONGROUND)
775 movelib_beak_simple(autocvar_g_vehicle_spiderbot_speed_stop);
782 self.event_damage = func_null;
783 self.takedamage = DAMAGE_NO;
784 self.touch = func_null;
785 self.cnt = 3.4 + time + random() * 2;
786 self.think = spiderbot_blowup;
787 self.nextthink = time;
788 self.deadflag = DEAD_DYING;
790 self.tur_head.effects |= EF_FLAME;
791 self.colormod = self.tur_head.colormod = '-1 -1 -1';
793 self.movetype = MOVETYPE_TOSS;
795 CSQCModel_UnlinkEntity(); // networking the death scene would be a nightmare
803 self.vehicles_impulse = spiderbot_impulse;
806 setmodel(self.gun1, "models/vehicles/spiderbot_barrels.dpm");
807 setmodel(self.gun2, "models/vehicles/spiderbot_barrels.dpm");
808 setattachment(self.gun1, self.tur_head, "tag_hardpoint01");
809 setattachment(self.gun2, self.tur_head, "tag_hardpoint02");
815 self.tur_head.frame = 1;
816 self.movetype = MOVETYPE_WALK;
817 self.solid = SOLID_SLIDEBOX;
818 self.alpha = self.tur_head.alpha = self.gun1.alpha = self.gun2.alpha = 1;
819 self.tur_head.angles = '0 0 0';
820 self.vehicle_exit = spiderbot_exit;
822 setorigin(self, self.pos1 + '0 0 128');
823 self.angles = self.pos2;
824 self.damageforcescale = 0.03;
825 self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
826 self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
828 self.PlayerPhysplug = spiderbot_frame;
834 if(autocvar_g_vehicle_spiderbot_shield)
835 self.vehicle_flags |= VHF_HASSHIELD;
837 if(autocvar_g_vehicle_spiderbot_shield_regen)
838 self.vehicle_flags |= VHF_SHIELDREGEN;
840 if(autocvar_g_vehicle_spiderbot_health_regen)
841 self.vehicle_flags |= VHF_HEALTHREGEN;
843 self.respawntime = autocvar_g_vehicle_spiderbot_respawntime;
844 self.vehicle_health = autocvar_g_vehicle_spiderbot_health;
845 self.vehicle_shield = autocvar_g_vehicle_spiderbot_shield;
846 self.max_health = self.vehicle_health;
847 self.pushable = TRUE; // spiderbot can use jumppads
853 precache_model ("models/vhshield.md3");
854 precache_model ("models/vehicles/spiderbot.dpm");
855 precache_model ("models/vehicles/spiderbot_top.dpm");
856 precache_model ("models/vehicles/spiderbot_barrels.dpm");
857 precache_model ("models/vehicles/spiderbot_cockpit.dpm");
858 precache_model ( "models/uziflash.md3");
860 precache_sound ("weapons/uzi_fire.wav" );
861 precache_sound ("weapons/rocket_impact.wav");
863 precache_sound ("vehicles/spiderbot_die.wav");
864 precache_sound ("vehicles/spiderbot_idle.wav");
865 precache_sound ("vehicles/spiderbot_jump.wav");
866 precache_sound ("vehicles/spiderbot_strafe.wav");
867 precache_sound ("vehicles/spiderbot_walk.wav");
868 precache_sound ("vehicles/spiderbot_land.wav");
878 var float autocvar_cl_vehicle_spiderbot_cross_alpha = 0.6;
879 var float autocvar_cl_vehicle_spiderbot_cross_size = 1;
881 #define spider_ico "gfx/vehicles/sbot.tga"
882 #define spider_rkt "gfx/vehicles/sbot_rpods.tga"
883 #define spider_mgun "gfx/vehicles/sbot_mguns.tga"
884 string spider_xhair; // = "gfx/vehicles/axh-special1.tga";
886 float v_spiderbot(float req)
892 if(autocvar_r_letterbox)
895 vector picsize, hudloc = '0 0 0', pic2size, picloc;
898 // Fetch health & ammo stats
901 picsize = draw_getimagesize(hud_bg) * autocvar_cl_vehicles_hudscale;
902 hudloc_y = vid_conheight - picsize_y;
903 hudloc_x = vid_conwidth * 0.5 - picsize_x * 0.5;
905 drawpic(hudloc, hud_bg, picsize, '1 1 1', autocvar_cl_vehicles_hudalpha, DRAWFLAG_NORMAL);
912 pic2size = draw_getimagesize(spider_ico) * (autocvar_cl_vehicles_hudscale * 0.8);
913 picloc = picsize * 0.5 - pic2size * 0.5;
915 drawpic(hudloc + picloc, spider_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
917 drawpic(hudloc + picloc, spider_ico, pic2size, '1 1 1' * vh_health + '1 0 0' * (1 - vh_health), 1, DRAWFLAG_NORMAL);
918 drawpic(hudloc + picloc, spider_rkt, pic2size, '1 1 1' * reload2 + '1 0 0' * (1 - reload2), 1, DRAWFLAG_NORMAL);
919 drawpic(hudloc + picloc, spider_mgun, pic2size, '1 1 1' * ammo1 + '1 0 0' * (1 - ammo1), 1, DRAWFLAG_NORMAL);
920 drawpic(hudloc + picloc, hud_sh, pic2size, '1 1 1', shield, DRAWFLAG_NORMAL);
923 picsize = draw_getimagesize(hud_hp_bar) * autocvar_cl_vehicles_hudscale;
924 picloc = '69 69 0' * autocvar_cl_vehicles_hudscale;
925 drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - vh_health)), 0, vid_conwidth, vid_conheight);
926 drawpic(hudloc + picloc, hud_hp_bar, picsize, '1 1 1', 1 , DRAWFLAG_NORMAL);
929 picsize = draw_getimagesize(hud_hp_ico) * autocvar_cl_vehicles_hudscale;
930 picloc = '37 65 0' * autocvar_cl_vehicles_hudscale;
933 if(alarm1time < time)
935 alarm1time = time + 2;
936 vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm.wav");
938 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
942 drawpic(hudloc + picloc, hud_hp_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
945 vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
950 picsize = draw_getimagesize(hud_sh_bar) * autocvar_cl_vehicles_hudscale;
951 picloc = '69 140 0' * autocvar_cl_vehicles_hudscale;
952 drawsetcliparea(hudloc_x + picloc_x + (picsize_x * (1 - shield)), 0, vid_conwidth, vid_conheight);
953 drawpic(hudloc + picloc, hud_sh_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
956 picloc = '40 136 0' * autocvar_cl_vehicles_hudscale;
957 picsize = draw_getimagesize(hud_sh_ico) * autocvar_cl_vehicles_hudscale;
960 if(alarm2time < time)
962 alarm2time = time + 1;
963 vehicle_alarm(self, CH_PAIN_SINGLE, "vehicles/alarm_shield.wav");
965 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
969 drawpic(hudloc + picloc, hud_sh_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
972 vehicle_alarm(self, CH_PAIN_SINGLE, "misc/null.wav");
978 picsize = draw_getimagesize(hud_ammo1_bar) * autocvar_cl_vehicles_hudscale;
979 picloc = '450 69 0' * autocvar_cl_vehicles_hudscale;
980 drawsetcliparea(hudloc_x + picloc_x, picloc_y, picsize_x * ammo1, vid_conheight);
981 drawpic(hudloc + picloc, hud_ammo1_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
984 picsize = draw_getimagesize(hud_ammo1_ico) * autocvar_cl_vehicles_hudscale;
985 picloc = '664 60 0' * autocvar_cl_vehicles_hudscale;
987 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
989 drawpic(hudloc + picloc, hud_ammo1_ico, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
992 picsize = draw_getimagesize(hud_ammo2_bar) * autocvar_cl_vehicles_hudscale;
993 ammo1 = picsize_x / 8;
994 picloc = '450 140 0' * autocvar_cl_vehicles_hudscale;
995 drawsetcliparea(hudloc_x + picloc_x, hudloc_y + picloc_y, picsize_x * reload2, vid_conheight);
996 drawpic(hudloc + picloc, hud_ammo2_bar, picsize, '1 1 1', 1, DRAWFLAG_NORMAL);
1000 pic2size = 0.35 * draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1001 picloc_x -= pic2size_x;
1002 picloc_y += pic2size_y * 2.25;
1005 for(i = 1; i < 9; ++i)
1008 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((8 * reload2 <= i) ? '0 0 0' : '1 1 1'), 0.75, DRAWFLAG_NORMAL);
1013 for(i = 1; i < 9; ++i)
1016 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, ((i >= ammo2) ? '1 1 1' : '0 0 0'), 0.75, DRAWFLAG_NORMAL);
1019 pic2size = draw_getimagesize(hud_ammo2_ico) * autocvar_cl_vehicles_hudscale;
1020 picloc = '664 130 0' * autocvar_cl_vehicles_hudscale;
1022 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 0 0' + '0 1 1' * sin(time * 8), 1, DRAWFLAG_NORMAL);
1024 drawpic(hudloc + picloc, hud_ammo2_ico, pic2size, '1 1 1', 1, DRAWFLAG_NORMAL);
1026 if (scoreboard_showscores)
1027 HUD_DrawScoreboard();
1030 switch(getstati(STAT_VEHICLESTAT_W2MODE))
1033 spider_xhair = "gfx/vehicles/axh-bracket.tga";
1036 spider_xhair = "gfx/vehicles/axh-cross.tga";
1038 case SBRM_ARTILLERY:
1039 spider_xhair = "gfx/vehicles/axh-tag.tga";
1042 spider_xhair= "gfx/vehicles/axh-tag.tga";
1045 picsize = draw_getimagesize(spider_xhair);
1046 picsize_x *= autocvar_cl_vehicle_spiderbot_cross_size;
1047 picsize_y *= autocvar_cl_vehicle_spiderbot_cross_size;
1049 drawpic('0.5 0 0' * (vid_conwidth - picsize_x) + '0 0.5 0' * (vid_conheight - picsize_y), spider_xhair, picsize, '1 1 1', autocvar_cl_vehicle_spiderbot_cross_alpha, DRAWFLAG_ADDITIVE);
1057 AuxiliaryXhair[0].axh_image = "gfx/vehicles/axh-ring.tga";
1058 AuxiliaryXhair[0].axh_scale = 0.25;
1060 AuxiliaryXhair[1].axh_image = "gfx/vehicles/axh-ring.tga";
1061 AuxiliaryXhair[1].axh_scale = 0.25;
1063 AuxiliaryXhair[2].axh_image = "gfx/vehicles/axh-special1.tga";
1064 AuxiliaryXhair[2].axh_scale = 0.5;
1070 precache_model ("models/vhshield.md3");
1071 precache_model ("models/vehicles/spiderbot.dpm");
1072 precache_model ("models/vehicles/spiderbot_top.dpm");
1073 precache_model ("models/vehicles/spiderbot_barrels.dpm");
1074 precache_model ("models/vehicles/spiderbot_cockpit.dpm");
1083 #endif // REGISTER_VEHICLE