1 #ifndef VEHICLE_BUMBLEBEE
2 #define VEHICLE_BUMBLEBEE
3 #include "bumblebee.qh"
5 #include "bumblebee_weapons.qc"
7 CLASS(Bumblebee, Vehicle)
8 /* spawnflags */ ATTRIB(Bumblebee, spawnflags, int, VHF_DMGSHAKE);
9 /* mins */ ATTRIB(Bumblebee, mins, vector, '-245 -130 -130');
10 /* maxs */ ATTRIB(Bumblebee, maxs, vector, '230 130 130');
11 /* model */ ATTRIB(Bumblebee, mdl, string, "models/vehicles/bumblebee_body.dpm");
12 /* model */ ATTRIB(Bumblebee, model, string, "models/vehicles/bumblebee_body.dpm");
13 /* head_model */ ATTRIB(Bumblebee, head_model, string, "");
14 /* hud_model */ ATTRIB(Bumblebee, hud_model, string, "models/vehicles/spiderbot_cockpit.dpm");
15 /* tags */ ATTRIB(Bumblebee, tag_head, string, "");
16 /* tags */ ATTRIB(Bumblebee, tag_hud, string, "");
17 /* tags */ ATTRIB(Bumblebee, tag_view, string, "tag_viewport");
18 /* netname */ ATTRIB(Bumblebee, netname, string, "bumblebee");
19 /* fullname */ ATTRIB(Bumblebee, vehicle_name, string, _("Bumblebee"));
20 /* icon */ ATTRIB(Bumblebee, m_icon, string, "vehicle_bumble");
22 REGISTER_VEHICLE(BUMBLEBEE, NEW(Bumblebee));
28 const float BRG_SETUP = 2;
29 const float BRG_START = 4;
30 const float BRG_END = 8;
32 #include "bumblebee_weapons.qc"
35 float autocvar_g_vehicle_bumblebee_speed_forward;
36 float autocvar_g_vehicle_bumblebee_speed_strafe;
37 float autocvar_g_vehicle_bumblebee_speed_up;
38 float autocvar_g_vehicle_bumblebee_speed_down;
39 float autocvar_g_vehicle_bumblebee_turnspeed;
40 float autocvar_g_vehicle_bumblebee_pitchspeed;
41 float autocvar_g_vehicle_bumblebee_pitchlimit;
42 float autocvar_g_vehicle_bumblebee_friction;
44 float autocvar_g_vehicle_bumblebee_energy;
45 float autocvar_g_vehicle_bumblebee_energy_regen;
46 float autocvar_g_vehicle_bumblebee_energy_regen_pause;
48 float autocvar_g_vehicle_bumblebee_health;
49 float autocvar_g_vehicle_bumblebee_health_regen;
50 float autocvar_g_vehicle_bumblebee_health_regen_pause;
52 float autocvar_g_vehicle_bumblebee_shield;
53 float autocvar_g_vehicle_bumblebee_shield_regen;
54 float autocvar_g_vehicle_bumblebee_shield_regen_pause;
56 float autocvar_g_vehicle_bumblebee_cannon_ammo;
57 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen;
58 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause;
60 float autocvar_g_vehicle_bumblebee_cannon_lock = 0;
62 float autocvar_g_vehicle_bumblebee_cannon_turnspeed;
63 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down;
64 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up;
65 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
66 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
69 float autocvar_g_vehicle_bumblebee_raygun_turnspeed;
70 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down;
71 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up;
72 float autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides;
74 float autocvar_g_vehicle_bumblebee_raygun_range;
75 float autocvar_g_vehicle_bumblebee_raygun_dps;
76 float autocvar_g_vehicle_bumblebee_raygun_aps;
77 float autocvar_g_vehicle_bumblebee_raygun_fps;
79 float autocvar_g_vehicle_bumblebee_raygun;
80 float autocvar_g_vehicle_bumblebee_healgun_hps;
81 float autocvar_g_vehicle_bumblebee_healgun_hmax;
82 float autocvar_g_vehicle_bumblebee_healgun_aps;
83 float autocvar_g_vehicle_bumblebee_healgun_amax;
84 float autocvar_g_vehicle_bumblebee_healgun_sps;
85 float autocvar_g_vehicle_bumblebee_healgun_locktime;
87 float autocvar_g_vehicle_bumblebee_respawntime;
89 float autocvar_g_vehicle_bumblebee_blowup_radius;
90 float autocvar_g_vehicle_bumblebee_blowup_coredamage;
91 float autocvar_g_vehicle_bumblebee_blowup_edgedamage;
92 float autocvar_g_vehicle_bumblebee_blowup_forceintensity;
93 vector autocvar_g_vehicle_bumblebee_bouncepain;
95 bool autocvar_g_vehicle_bumblebee = 0;
97 float bumblebee_gunner_frame()
99 entity vehic = self.vehicle.owner;
100 entity gun = self.vehicle;
101 entity gunner = self;
104 vehic.solid = SOLID_NOT;
105 //setorigin(gunner, vehic.origin);
106 gunner.velocity = vehic.velocity;
109 vehic.angles_x *= -1;
110 makevectors(vehic.angles);
111 vehic.angles_x *= -1;
112 if(gun == vehic.gun1)
114 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
115 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
116 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * 128);
120 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
121 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
122 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);
125 crosshair_trace(gunner);
126 vector _ct = trace_endpos;
129 if(autocvar_g_vehicle_bumblebee_cannon_lock)
131 if(gun.lock_time < time)
135 if(trace_ent.movetype)
136 if(trace_ent.takedamage)
137 if(!trace_ent.deadflag)
139 if(DIFF_TEAM(trace_ent, gunner))
141 gun.enemy = trace_ent;
142 gun.lock_time = time + 5;
149 float distance, impact_time;
151 vector vf = real_origin(gun.enemy);
152 vector _vel = gun.enemy.velocity;
153 if(gun.enemy.movetype == MOVETYPE_WALK)
158 distance = vlen(ad - gunner.origin);
159 impact_time = distance / autocvar_g_vehicle_bumblebee_cannon_speed;
160 ad = vf + _vel * impact_time;
164 UpdateAuxiliaryXhair(gunner, ad, '1 0 1', 1);
165 vehicle_aimturret(vehic, trace_endpos, gun, "fire",
166 autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
167 _out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed);
171 vehicle_aimturret(vehic, _ct, gun, "fire",
172 autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
173 _out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed);
175 if(!forbidWeaponUse(gunner))
176 if(gunner.BUTTON_ATCK)
177 if(time > gun.attack_finished_single[0])
178 if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
180 gun.vehicle_energy -= autocvar_g_vehicle_bumblebee_cannon_cost;
181 bumblebee_fire_cannon(gun, "fire", gunner);
183 gun.attack_finished_single[0] = time + autocvar_g_vehicle_bumblebee_cannon_refire;
186 VEHICLE_UPDATE_PLAYER(gunner, health, bumblebee);
188 if(vehic.vehicle_flags & VHF_HASSHIELD)
189 VEHICLE_UPDATE_PLAYER(gunner, shield, bumblebee);
191 ad = gettaginfo(gun, gettagindex(gun, "fire"));
192 traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
194 UpdateAuxiliaryXhair(gunner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), 0);
197 UpdateAuxiliaryXhair(vehic.owner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), ((gunner == vehic.gunner1) ? 1 : 2));
199 vehic.solid = SOLID_BBOX;
200 gunner.BUTTON_ATCK = gunner.BUTTON_ATCK2 = gunner.BUTTON_CROUCH = 0;
201 gunner.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
207 vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity player)
212 tracebox(gunner.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, player);
213 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
216 mysize = 1.5 * vlen(PL_MAX - PL_MIN); // can't use gunner's size, as they don't have a size
219 v2 = 0.5 * (gunner.absmin + gunner.absmax);
220 for(i = 0; i < 100; ++i)
224 v = v2 + normalize(v) * mysize;
225 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, player);
226 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
230 return prefer_spot; // this should be considered a fallback?!
233 void bumblebee_gunner_exit(int _exitflag)
235 entity player = self;
236 entity gunner = player.vehicle;
237 entity vehic = gunner.owner;
239 if(IS_REAL_CLIENT(player))
242 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
243 WriteEntity(MSG_ONE, player);
245 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
246 WriteAngle(MSG_ONE, 0);
247 WriteAngle(MSG_ONE, vehic.angles.y);
248 WriteAngle(MSG_ONE, 0);
251 CSQCVehicleSetup(player, HUD_NORMAL);
252 setsize(player, PL_MIN, PL_MAX);
254 player.takedamage = DAMAGE_AIM;
255 player.solid = SOLID_SLIDEBOX;
256 player.movetype = MOVETYPE_WALK;
257 player.effects &= ~EF_NODRAW;
259 player.PlayerPhysplug = func_null;
260 player.view_ofs = PL_VIEW_OFS;
261 player.event_damage = PlayerDamage;
262 player.hud = HUD_NORMAL;
263 player.teleportable = TELEPORT_NORMAL;
264 player.switchweapon = gunner.switchweapon;
265 player.vehicle_enter_delay = time + 2;
267 fixedmakevectors(vehic.angles);
269 if(player == vehic.gunner1) { vehic.gunner1 = world; }
270 if(player == vehic.gunner2) { vehic.gunner2 = world; v_right *= -1; }
272 vector spot = real_origin(gunner);
273 spot = spot + v_up * 128 + v_forward * 300 + v_right * 150;
274 spot = bumblebee_gunner_findgoodexit(spot, gunner, player);
276 // TODO: figure a way to move player out of the gunner
278 player.velocity = 0.75 * vehic.velocity + normalize(spot - vehic.origin) * 200;
279 player.velocity_z += 10;
281 gunner.phase = time + 5;
282 gunner.vehicle_hudmodel.viewmodelforclient = gunner;
284 MUTATOR_CALLHOOK(VehicleExit, player, gunner);
286 player.vehicle = world;
289 bool bumblebee_gunner_enter()
292 entity player = other;
293 entity gunner = world;
295 if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2)
297 // we can have some fun
298 if(vlen(real_origin(vehic.gun2) - player.origin) < vlen(real_origin(vehic.gun1) - player.origin))
301 vehic.gunner2 = player;
306 vehic.gunner1 = player;
309 else if(!vehic.gunner1 && time >= vehic.gun1.phase) { gunner = vehic.gun1; vehic.gunner1 = player; }
310 else if(!vehic.gunner2 && time >= vehic.gun2.phase) { gunner = vehic.gun2; vehic.gunner2 = player; }
311 else { LOG_TRACE("Vehicle is full, fail\n"); return false; }
313 player.vehicle = gunner;
314 player.angles = vehic.angles;
315 player.takedamage = DAMAGE_NO;
316 player.solid = SOLID_NOT;
318 player.movetype = MOVETYPE_NOCLIP;
319 player.event_damage = func_null;
320 player.view_ofs = '0 0 0';
321 player.hud = gunner.hud;
322 player.teleportable = false;
323 player.PlayerPhysplug = gunner.PlayerPhysplug;
324 player.vehicle_ammo1 = vehic.vehicle_ammo1;
325 player.vehicle_ammo2 = vehic.vehicle_ammo2;
326 player.vehicle_reload1 = vehic.vehicle_reload1;
327 player.vehicle_reload2 = vehic.vehicle_reload2;
328 player.vehicle_energy = vehic.vehicle_energy;
329 player.flags &= ~FL_ONGROUND;
331 RemoveGrapplingHook(player);
333 gunner.switchweapon = player.switchweapon;
334 gunner.vehicle_exit = bumblebee_gunner_exit;
335 gunner.vehicle_hudmodel.viewmodelforclient = player;
337 if(IS_REAL_CLIENT(player))
340 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
341 WriteEntity(MSG_ONE, gunner.vehicle_viewport);
343 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
344 WriteAngle(MSG_ONE, gunner.angles_x + vehic.angles_x); // tilt
345 WriteAngle(MSG_ONE, gunner.angles_y + vehic.angles_y); // yaw
346 WriteAngle(MSG_ONE, 0); // roll
349 CSQCVehicleSetup(player, player.hud);
351 MUTATOR_CALLHOOK(VehicleEnter, player, gunner);
356 bool vehicles_valid_pilot()
358 if(IS_BOT_CLIENT(other) && !autocvar_g_vehicles_allow_bots)
361 if((!IS_PLAYER(other))
362 || (other.deadflag != DEAD_NO)
364 || (DIFF_TEAM(other, self))
370 void bumblebee_touch()
372 if(autocvar_g_vehicles_enter) { return; }
374 if(self.gunner1 != world && self.gunner2 != world)
380 if(vehicles_valid_pilot())
382 float phase_time = (time >= self.gun1.phase) + (time >= self.gun2.phase);
384 if(time >= other.vehicle_enter_delay && phase_time)
385 if(bumblebee_gunner_enter())
392 void bumblebee_regen()
394 if(self.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
395 self.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
396 self.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
398 if(self.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
399 self.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
400 self.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
402 if(self.vehicle_flags & VHF_SHIELDREGEN)
403 vehicles_regen(self.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, frametime, true);
405 if(self.vehicle_flags & VHF_HEALTHREGEN)
406 vehicles_regen(self.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, frametime, false);
408 if(self.vehicle_flags & VHF_ENERGYREGEN)
409 vehicles_regen(self.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, frametime, false);
413 float bumblebee_pilot_frame()
418 if(intermission_running)
420 self.vehicle.velocity = '0 0 0';
421 self.vehicle.avelocity = '0 0 0';
426 vehic = self.vehicle;
429 if(vehic.deadflag != DEAD_NO)
432 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = 0;
438 crosshair_trace(pilot);
444 newvel = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
447 if(newvel.x > 180) newvel.x -= 360;
448 if(newvel.x < -180) newvel.x += 360;
449 if(newvel.y > 180) newvel.y -= 360;
450 if(newvel.y < -180) newvel.y += 360;
452 ftmp = shortangle_f(pilot.v_angle.y - vang.y, vang.y);
453 if(ftmp > 180) ftmp -= 360;
454 if(ftmp < -180) ftmp += 360;
455 vehic.avelocity_y = bound(-autocvar_g_vehicle_bumblebee_turnspeed, ftmp + vehic.avelocity.y * 0.9, autocvar_g_vehicle_bumblebee_turnspeed);
459 if(pilot.movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit)
461 else if(pilot.movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit)
464 newvel.x = bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x , autocvar_g_vehicle_bumblebee_pitchlimit);
465 ftmp = vang.x - bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x + ftmp, autocvar_g_vehicle_bumblebee_pitchlimit);
466 vehic.avelocity_x = bound(-autocvar_g_vehicle_bumblebee_pitchspeed, ftmp + vehic.avelocity.x * 0.9, autocvar_g_vehicle_bumblebee_pitchspeed);
468 vehic.angles_x = anglemods(vehic.angles.x);
469 vehic.angles_y = anglemods(vehic.angles.y);
470 vehic.angles_z = anglemods(vehic.angles.z);
472 makevectors('0 1 0' * vehic.angles.y);
473 newvel = vehic.velocity * -autocvar_g_vehicle_bumblebee_friction;
475 if(pilot.movement.x != 0)
477 if(pilot.movement.x > 0)
478 newvel += v_forward * autocvar_g_vehicle_bumblebee_speed_forward;
479 else if(pilot.movement.x < 0)
480 newvel -= v_forward * autocvar_g_vehicle_bumblebee_speed_forward;
483 if(pilot.movement.y != 0)
485 if(pilot.movement.y < 0)
486 newvel -= v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
487 else if(pilot.movement.y > 0)
488 newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
489 ftmp = newvel * v_right;
490 ftmp *= frametime * 0.1;
491 vehic.angles_z = bound(-15, vehic.angles.z + ftmp, 15);
495 vehic.angles_z *= 0.95;
496 if(vehic.angles.z >= -1 && vehic.angles.z <= -1)
500 if(pilot.BUTTON_CROUCH)
501 newvel -= v_up * autocvar_g_vehicle_bumblebee_speed_down;
502 else if(pilot.BUTTON_JUMP)
503 newvel += v_up * autocvar_g_vehicle_bumblebee_speed_up;
505 vehic.velocity += newvel * frametime;
506 pilot.velocity = pilot.movement = vehic.velocity;
509 if(autocvar_g_vehicle_bumblebee_healgun_locktime)
511 if(vehic.tur_head.lock_time < time || vehic.tur_head.enemy.deadflag)
512 vehic.tur_head.enemy = world;
515 if(trace_ent.movetype)
516 if(trace_ent.takedamage)
517 if(!trace_ent.deadflag)
521 if(trace_ent.team == pilot.team)
523 vehic.tur_head.enemy = trace_ent;
524 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
529 vehic.tur_head.enemy = trace_ent;
530 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
534 if(vehic.tur_head.enemy)
536 trace_endpos = real_origin(vehic.tur_head.enemy);
537 UpdateAuxiliaryXhair(pilot, trace_endpos, '0 0.75 0', 0);
541 vang = vehicle_aimturret(vehic, trace_endpos, self.gun3, "fire",
542 autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up,
543 autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1, autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides, autocvar_g_vehicle_bumblebee_raygun_turnspeed);
545 if(!forbidWeaponUse(pilot))
546 if((pilot.BUTTON_ATCK || pilot.BUTTON_ATCK2) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
548 vehic.gun3.enemy.realowner = pilot;
549 vehic.gun3.enemy.effects &= ~EF_NODRAW;
551 vehic.gun3.enemy.hook_start = gettaginfo(vehic.gun3, gettagindex(vehic.gun3, "fire"));
552 vehic.gun3.enemy.SendFlags |= BRG_START;
554 traceline(vehic.gun3.enemy.hook_start, vehic.gun3.enemy.hook_start + v_forward * autocvar_g_vehicle_bumblebee_raygun_range, MOVE_NORMAL, vehic);
558 if(autocvar_g_vehicle_bumblebee_raygun)
560 Damage(trace_ent, vehic, pilot, autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime, DEATH_GENERIC.m_id, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * sys_frametime);
561 vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
565 if(trace_ent.deadflag == DEAD_NO)
566 if((teamplay && trace_ent.team == pilot.team) || !teamplay)
569 if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
571 if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.max_health)
572 trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.max_health);
574 if(autocvar_g_vehicle_bumblebee_healgun_hps)
575 trace_ent.vehicle_health = min(trace_ent.vehicle_health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
577 else if(IS_CLIENT(trace_ent))
579 if(trace_ent.health <= autocvar_g_vehicle_bumblebee_healgun_hmax && autocvar_g_vehicle_bumblebee_healgun_hps)
580 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
582 if(trace_ent.armorvalue <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
583 trace_ent.armorvalue = min(trace_ent.armorvalue + autocvar_g_vehicle_bumblebee_healgun_aps * frametime, autocvar_g_vehicle_bumblebee_healgun_amax);
585 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
587 else if(IS_TURRET(trace_ent))
589 if(trace_ent.health <= trace_ent.max_health && autocvar_g_vehicle_bumblebee_healgun_hps)
590 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
591 //else ..hmmm what? ammo?
593 trace_ent.SendFlags |= TNSF_STATUS;
599 vehic.gun3.enemy.hook_end = trace_endpos;
600 setorigin(vehic.gun3.enemy, trace_endpos);
601 vehic.gun3.enemy.SendFlags |= BRG_END;
603 vehic.wait = time + 1;
606 vehic.gun3.enemy.effects |= EF_NODRAW;
609 remove(vehic.gun3.enemy);
611 vehic.gun3.enemy = world;
615 VEHICLE_UPDATE_PLAYER(pilot, health, bumblebee);
616 VEHICLE_UPDATE_PLAYER(pilot, energy, bumblebee);
618 pilot.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
619 pilot.vehicle_ammo2 = (vehic.gun2.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
621 if(vehic.vehicle_flags & VHF_HASSHIELD)
622 VEHICLE_UPDATE_PLAYER(pilot, shield, bumblebee);
624 vehic.angles_x *= -1;
625 makevectors(vehic.angles);
626 vehic.angles_x *= -1;
627 setorigin(pilot, vehic.origin + v_up * 48 + v_forward * 160);
629 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = pilot.BUTTON_CROUCH = 0;
635 void bumblebee_land()
639 hgt = raptor_altitude(512);
640 self.velocity = (self.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
641 self.angles_x *= 0.95;
642 self.angles_z *= 0.95;
645 self.think = vehicles_think;
647 self.nextthink = time;
649 CSQCMODEL_AUTOUPDATE(self);
652 void bumblebee_exit(float eject)
654 if(self.owner.vehicleid == VEH_BUMBLEBEE.vehicleid)
656 bumblebee_gunner_exit(eject);
660 self.touch = vehicles_touch;
662 if(self.deadflag == DEAD_NO)
664 self.think = bumblebee_land;
665 self.nextthink = time;
668 self.movetype = MOVETYPE_TOSS;
673 fixedmakevectors(self.angles);
675 if(vlen(self.velocity) > autocvar_g_vehicle_bumblebee_speed_forward * 0.5)
676 spot = self.origin + v_up * 128 + v_forward * 300;
678 spot = self.origin + v_up * 128 - v_forward * 300;
680 spot = vehicles_findgoodexit(spot);
683 if(self.gun3.enemy || !wasfreed(self.gun3.enemy)) {
684 self.gun3.enemy.effects |= EF_NODRAW;
687 self.owner.velocity = 0.75 * self.vehicle.velocity + normalize(spot - self.vehicle.origin) * 200;
688 self.owner.velocity_z += 10;
689 setorigin(self.owner, spot);
691 antilag_clear(self.owner);
695 void bumblebee_blowup()
697 RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
698 autocvar_g_vehicle_bumblebee_blowup_edgedamage,
699 autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
700 autocvar_g_vehicle_bumblebee_blowup_forceintensity,
701 DEATH_VH_BUMB_DEATH.m_id, world);
703 sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
704 Send_Effect(EFFECT_EXPLOSION_BIG, (self.origin + '0 0 100') + (randomvec() * 80), '0 0 0', 1);
706 if(self.owner.deadflag == DEAD_DYING)
707 self.owner.deadflag = DEAD_DEAD;
712 void bumblebee_diethink()
714 if(time >= self.wait)
715 self.think = bumblebee_blowup;
719 sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
720 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
723 self.nextthink = time + 0.1;
726 spawnfunc(vehicle_bumblebee)
728 if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
729 if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
732 METHOD(Bumblebee, vr_impact, void(Bumblebee thisveh))
734 if(autocvar_g_vehicle_bumblebee_bouncepain)
735 vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z);
737 METHOD(Bumblebee, vr_enter, void(Bumblebee thisveh))
740 self.touch = bumblebee_touch;
742 self.movetype = MOVETYPE_BOUNCEMISSILE;
744 METHOD(Bumblebee, vr_think, void(Bumblebee thisveh))
747 self.angles_z *= 0.8;
748 self.angles_x *= 0.8;
750 self.nextthink = time;
754 entity oldself = self;
757 setself(self.gunner1);
758 oldself.gun1.vehicle_exit(VHEF_EJECT);
759 entity oldother = other;
770 setself(self.gunner2);
771 oldself.gun2.vehicle_exit(VHEF_EJECT);
772 entity oldother = other;
782 METHOD(Bumblebee, vr_death, void(Bumblebee thisveh))
785 entity oldself = self;
787 CSQCModel_UnlinkEntity(self);
790 if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
791 self.gun3.enemy.effects |= EF_NODRAW;
795 setself(self.gunner1);
796 oldself.gun1.vehicle_exit(VHEF_EJECT);
802 setself(self.gunner2);
803 oldself.gun2.vehicle_exit(VHEF_EJECT);
807 self.vehicle_exit(VHEF_EJECT);
809 fixedmakevectors(self.angles);
810 vehicle_tossgib(self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
811 vehicle_tossgib(self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
812 vehicle_tossgib(self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
814 entity _body = vehicle_tossgib(self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
817 _body.touch = bumblebee_blowup;
819 _body.touch = func_null;
821 _body.think = bumblebee_diethink;
822 _body.nextthink = time;
823 _body.wait = time + 2 + (random() * 8);
825 _body.enemy = self.enemy;
827 _body.angles = self.angles;
829 Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(self.origin, 16), '0 0 0', 1);
832 self.event_damage = func_null;
833 self.solid = SOLID_NOT;
834 self.takedamage = DAMAGE_NO;
835 self.deadflag = DEAD_DYING;
836 self.movetype = MOVETYPE_NONE;
837 self.effects = EF_NODRAW;
838 self.colormod = '0 0 0';
839 self.avelocity = '0 0 0';
840 self.velocity = '0 0 0';
841 self.touch = func_null;
844 setorigin(self, self.pos1);
846 METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh))
851 // for some reason, autosizing of the shield entity refuses to work for this one so set it up in advance.
852 self.vehicle_shieldent = spawn();
853 self.vehicle_shieldent.effects = EF_LOWPRECISION;
854 setmodel(self.vehicle_shieldent, MDL_VEH_BUMBLEBEE_SHIELD);
855 setattachment(self.vehicle_shieldent, self, "");
856 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
857 self.vehicle_shieldent.scale = 512 / vlen(self.maxs - self.mins);
858 self.vehicle_shieldent.think = shieldhit_think;
859 self.vehicle_shieldent.alpha = -1;
860 self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
862 self.gun1 = new(vehicle_playerslot);
863 self.gun2 = new(vehicle_playerslot);
864 self.gun3 = new(bumblebee_raygun);
866 self.vehicle_flags |= VHF_MULTISLOT;
868 self.gun1.owner = self;
869 self.gun2.owner = self;
870 self.gun3.owner = self;
872 setmodel(self.gun1, MDL_VEH_BUMBLEBEE_CANNON_RIGHT);
873 setmodel(self.gun2, MDL_VEH_BUMBLEBEE_CANNON_LEFT);
874 setmodel(self.gun3, MDL_VEH_BUMBLEBEE_CANNON_CENTER);
876 setattachment(self.gun1, self, "cannon_right");
877 setattachment(self.gun2, self, "cannon_left");
879 // Angled bones are no fun, messes up gun-aim; so work arround it.
880 self.gun3.pos1 = self.angles;
881 self.angles = '0 0 0';
882 vector ofs = gettaginfo(self, gettagindex(self, "raygun"));
884 setattachment(self.gun3, self, "");
885 setorigin(self.gun3, ofs);
886 self.angles = self.gun3.pos1;
888 vehicle_addplayerslot(self, self.gun1, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
889 vehicle_addplayerslot(self, self.gun2, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
891 setorigin(self.vehicle_hudmodel, '50 0 -5'); // Move cockpit forward - down.
892 setorigin(self.vehicle_viewport, '5 0 2'); // Move camera forward up
895 setorigin(self.gun1.vehicle_hudmodel, '90 -27 -23');
896 setorigin(self.gun1.vehicle_viewport, '-85 0 50');
898 setorigin(self.gun2.vehicle_hudmodel, '90 27 -23');
899 setorigin(self.gun2.vehicle_viewport, '-85 0 50');
904 if(self.gun3.enemy == world)
906 self.gun3.enemy = spawn();
907 Net_LinkEntity(self.gun3.enemy, true, 0, bumble_raygun_send);
908 self.gun3.enemy.SendFlags = BRG_SETUP;
909 self.gun3.enemy.cnt = autocvar_g_vehicle_bumblebee_raygun;
910 self.gun3.enemy.effects = EF_NODRAW | EF_LOWPRECISION;
914 self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
915 self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
916 self.solid = SOLID_BBOX;
917 self.movetype = MOVETYPE_TOSS;
918 self.damageforcescale = 0.025;
920 self.PlayerPhysplug = bumblebee_pilot_frame;
922 setorigin(self, self.origin + '0 0 25');
924 METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh))
927 if(autocvar_g_vehicle_bumblebee_energy)
928 if(autocvar_g_vehicle_bumblebee_energy_regen)
929 self.vehicle_flags |= VHF_ENERGYREGEN;
931 if(autocvar_g_vehicle_bumblebee_shield)
932 self.vehicle_flags |= VHF_HASSHIELD;
934 if(autocvar_g_vehicle_bumblebee_shield_regen)
935 self.vehicle_flags |= VHF_SHIELDREGEN;
937 if(autocvar_g_vehicle_bumblebee_health_regen)
938 self.vehicle_flags |= VHF_HEALTHREGEN;
940 self.vehicle_exit = bumblebee_exit;
941 self.respawntime = autocvar_g_vehicle_bumblebee_respawntime;
942 self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
943 self.max_health = self.vehicle_health;
944 self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
950 void CSQC_BUMBLE_GUN_HUD()
952 Vehicles_drawHUD("vehicle_gunner", "vehicle_gunner_weapon1", string_null,
953 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
954 string_null, '0 0 0');
957 METHOD(Bumblebee, vr_hud, void(Bumblebee thisveh))
959 Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
960 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
961 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color);
963 float hudAlpha = autocvar_hud_panel_fg_alpha;
964 float blinkValue = 0.55 + sin(time * 7) * 0.45;
965 vector tmpPos = '0 0 0';
966 vector tmpSize = '1 1 1' * hud_fontsize;
967 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (520/768);
969 if(!AuxiliaryXhair[1].draw2d)
971 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (96/256) - tmpSize.y;
972 drawstring(tmpPos, _("No right gunner!"), tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
975 if(!AuxiliaryXhair[2].draw2d)
977 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (160/256);
978 drawstring(tmpPos, _("No left gunner!"), tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
981 METHOD(Bumblebee, vr_crosshair, void(Bumblebee thisveh))
983 Vehicles_drawCrosshair(vCROSS_HEAL);
985 METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh))
987 AuxiliaryXhair[0].axh_image = vCROSS_LOCK; // Raygun-locked
988 AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Gunner1
989 AuxiliaryXhair[2].axh_image = vCROSS_BURST; // Gunner2