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 /* view offset*/ ATTRIB(Bumblebee, view_ofs, vector, '0 0 300');
12 /* view dist */ ATTRIB(Bumblebee, height, float, 450);
13 /* model */ ATTRIB(Bumblebee, mdl, string, "models/vehicles/bumblebee_body.dpm");
14 /* model */ ATTRIB(Bumblebee, model, string, "models/vehicles/bumblebee_body.dpm");
15 /* head_model */ ATTRIB(Bumblebee, head_model, string, "");
16 /* hud_model */ ATTRIB(Bumblebee, hud_model, string, "models/vehicles/spiderbot_cockpit.dpm");
17 /* tags */ ATTRIB(Bumblebee, tag_head, string, "");
18 /* tags */ ATTRIB(Bumblebee, tag_hud, string, "");
19 /* tags */ ATTRIB(Bumblebee, tag_view, string, "tag_viewport");
20 /* netname */ ATTRIB(Bumblebee, netname, string, "bumblebee");
21 /* fullname */ ATTRIB(Bumblebee, vehicle_name, string, _("Bumblebee"));
22 /* icon */ ATTRIB(Bumblebee, m_icon, string, "vehicle_bumble");
24 REGISTER_VEHICLE(BUMBLEBEE, NEW(Bumblebee));
30 const float BRG_SETUP = 2;
31 const float BRG_START = 4;
32 const float BRG_END = 8;
34 #include "bumblebee_weapons.qc"
37 float autocvar_g_vehicle_bumblebee_speed_forward;
38 float autocvar_g_vehicle_bumblebee_speed_strafe;
39 float autocvar_g_vehicle_bumblebee_speed_up;
40 float autocvar_g_vehicle_bumblebee_speed_down;
41 float autocvar_g_vehicle_bumblebee_turnspeed;
42 float autocvar_g_vehicle_bumblebee_pitchspeed;
43 float autocvar_g_vehicle_bumblebee_pitchlimit;
44 float autocvar_g_vehicle_bumblebee_friction;
46 float autocvar_g_vehicle_bumblebee_energy;
47 float autocvar_g_vehicle_bumblebee_energy_regen;
48 float autocvar_g_vehicle_bumblebee_energy_regen_pause;
50 float autocvar_g_vehicle_bumblebee_health;
51 float autocvar_g_vehicle_bumblebee_health_regen;
52 float autocvar_g_vehicle_bumblebee_health_regen_pause;
54 float autocvar_g_vehicle_bumblebee_shield;
55 float autocvar_g_vehicle_bumblebee_shield_regen;
56 float autocvar_g_vehicle_bumblebee_shield_regen_pause;
58 float autocvar_g_vehicle_bumblebee_cannon_ammo;
59 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen;
60 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause;
62 float autocvar_g_vehicle_bumblebee_cannon_lock = 0;
64 float autocvar_g_vehicle_bumblebee_cannon_turnspeed;
65 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down;
66 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up;
67 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
68 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
71 float autocvar_g_vehicle_bumblebee_raygun_turnspeed;
72 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down;
73 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up;
74 float autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides;
76 float autocvar_g_vehicle_bumblebee_raygun_range;
77 float autocvar_g_vehicle_bumblebee_raygun_dps;
78 float autocvar_g_vehicle_bumblebee_raygun_aps;
79 float autocvar_g_vehicle_bumblebee_raygun_fps;
81 float autocvar_g_vehicle_bumblebee_raygun;
82 float autocvar_g_vehicle_bumblebee_healgun_hps;
83 float autocvar_g_vehicle_bumblebee_healgun_hmax;
84 float autocvar_g_vehicle_bumblebee_healgun_aps;
85 float autocvar_g_vehicle_bumblebee_healgun_amax;
86 float autocvar_g_vehicle_bumblebee_healgun_sps;
87 float autocvar_g_vehicle_bumblebee_healgun_locktime;
89 float autocvar_g_vehicle_bumblebee_respawntime;
91 float autocvar_g_vehicle_bumblebee_blowup_radius;
92 float autocvar_g_vehicle_bumblebee_blowup_coredamage;
93 float autocvar_g_vehicle_bumblebee_blowup_edgedamage;
94 float autocvar_g_vehicle_bumblebee_blowup_forceintensity;
95 vector autocvar_g_vehicle_bumblebee_bouncepain;
97 bool autocvar_g_vehicle_bumblebee = 0;
99 float bumblebee_gunner_frame()
101 entity vehic = self.vehicle.owner;
102 entity gun = self.vehicle;
103 entity gunner = self;
106 // this isn't technically a vehicle (yet), let's not do frame functions on it (yet)
107 //vehicles_frame(gun, player);
109 vehic.solid = SOLID_NOT;
110 //setorigin(gunner, vehic.origin);
111 gunner.velocity = vehic.velocity;
114 vehic.angles_x *= -1;
115 makevectors(vehic.angles);
116 vehic.angles_x *= -1;
117 if(gun == vehic.gun1)
119 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
120 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
121 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * 128);
125 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
126 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
127 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);
130 crosshair_trace(gunner);
131 vector _ct = trace_endpos;
134 if(autocvar_g_vehicle_bumblebee_cannon_lock)
136 if(gun.lock_time < time)
140 if(trace_ent.movetype)
141 if(trace_ent.takedamage)
142 if(!IS_DEAD(trace_ent) && !STAT(FROZEN, trace_ent))
144 if(DIFF_TEAM(trace_ent, gunner))
146 gun.enemy = trace_ent;
147 gun.lock_time = time + 5;
154 float distance, impact_time;
156 vector vf = real_origin(gun.enemy);
157 vector _vel = gun.enemy.velocity;
158 if(gun.enemy.movetype == MOVETYPE_WALK)
163 distance = vlen(ad - gunner.origin);
164 impact_time = distance / autocvar_g_vehicle_bumblebee_cannon_speed;
165 ad = vf + _vel * impact_time;
169 UpdateAuxiliaryXhair(gunner, ad, '1 0 1', 1);
170 vehicle_aimturret(vehic, trace_endpos, gun, "fire",
171 autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
172 _out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed);
176 vehicle_aimturret(vehic, _ct, gun, "fire",
177 autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
178 _out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed);
180 if(!forbidWeaponUse(gunner))
181 if(gunner.BUTTON_ATCK)
182 if(time > gun.attack_finished_single[0])
183 if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
185 gun.vehicle_energy -= autocvar_g_vehicle_bumblebee_cannon_cost;
186 bumblebee_fire_cannon(gun, "fire", gunner);
188 gun.attack_finished_single[0] = time + autocvar_g_vehicle_bumblebee_cannon_refire;
191 VEHICLE_UPDATE_PLAYER(gunner, health, bumblebee);
193 if(vehic.vehicle_flags & VHF_HASSHIELD)
194 VEHICLE_UPDATE_PLAYER(gunner, shield, bumblebee);
196 ad = gettaginfo(gun, gettagindex(gun, "fire"));
197 traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
199 UpdateAuxiliaryXhair(gunner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), 0);
202 UpdateAuxiliaryXhair(vehic.owner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), ((gunner == vehic.gunner1) ? 1 : 2));
204 vehic.solid = SOLID_BBOX;
205 gunner.BUTTON_ATCK = gunner.BUTTON_ATCK2 = gunner.BUTTON_CROUCH = 0;
206 gunner.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
212 vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity player)
217 tracebox(gunner.origin + '0 0 32', STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), prefer_spot, MOVE_NORMAL, player);
218 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
221 mysize = 1.5 * vlen(STAT(PL_MAX, NULL) - STAT(PL_MIN, NULL)); // can't use gunner's size, as they don't have a size
224 v2 = 0.5 * (gunner.absmin + gunner.absmax);
225 for(i = 0; i < 100; ++i)
229 v = v2 + normalize(v) * mysize;
230 tracebox(v2, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL), v, MOVE_NORMAL, player);
231 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
235 return prefer_spot; // this should be considered a fallback?!
238 void bumblebee_gunner_exit(int _exitflag)
240 entity player = self;
241 entity gunner = player.vehicle;
242 entity vehic = gunner.owner;
244 if(IS_REAL_CLIENT(player))
247 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
248 WriteEntity(MSG_ONE, player);
250 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
251 WriteAngle(MSG_ONE, 0);
252 WriteAngle(MSG_ONE, vehic.angles.y);
253 WriteAngle(MSG_ONE, 0);
256 CSQCVehicleSetup(player, HUD_NORMAL);
257 setsize(player, STAT(PL_MIN, NULL), STAT(PL_MAX, NULL));
259 player.takedamage = DAMAGE_AIM;
260 player.solid = SOLID_SLIDEBOX;
261 player.movetype = MOVETYPE_WALK;
262 player.effects &= ~EF_NODRAW;
264 player.PlayerPhysplug = func_null;
265 player.view_ofs = STAT(PL_VIEW_OFS, NULL);
266 player.event_damage = PlayerDamage;
267 player.hud = HUD_NORMAL;
268 player.teleportable = TELEPORT_NORMAL;
269 PS(player).m_switchweapon = gunner.m_switchweapon;
270 player.vehicle_enter_delay = time + 2;
272 fixedmakevectors(vehic.angles);
274 if(player == vehic.gunner1) { vehic.gunner1 = world; }
275 if(player == vehic.gunner2) { vehic.gunner2 = world; v_right *= -1; }
277 vector spot = real_origin(gunner);
278 spot = spot + v_up * 128 + v_forward * 300 + v_right * 150;
279 spot = bumblebee_gunner_findgoodexit(spot, gunner, player);
281 // TODO: figure a way to move player out of the gunner
283 player.velocity = 0.75 * vehic.velocity + normalize(spot - vehic.origin) * 200;
284 player.velocity_z += 10;
286 gunner.phase = time + 5;
287 gunner.vehicle_hudmodel.viewmodelforclient = gunner;
289 MUTATOR_CALLHOOK(VehicleExit, player, gunner);
291 player.vehicle = world;
294 bool bumblebee_gunner_enter()
297 entity player = other;
298 entity gunner = world;
300 if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2)
302 // we can have some fun
303 if(vlen2(real_origin(vehic.gun2) - player.origin) < vlen2(real_origin(vehic.gun1) - player.origin))
306 vehic.gunner2 = player;
311 vehic.gunner1 = player;
314 else if(!vehic.gunner1 && time >= vehic.gun1.phase) { gunner = vehic.gun1; vehic.gunner1 = player; }
315 else if(!vehic.gunner2 && time >= vehic.gun2.phase) { gunner = vehic.gun2; vehic.gunner2 = player; }
316 else { LOG_TRACE("Vehicle is full, fail\n"); return false; }
318 player.vehicle = gunner;
319 player.angles = vehic.angles;
320 player.takedamage = DAMAGE_NO;
321 player.solid = SOLID_NOT;
323 player.movetype = MOVETYPE_NOCLIP;
324 player.event_damage = func_null;
325 player.view_ofs = '0 0 0';
326 player.hud = gunner.hud;
327 player.teleportable = false;
328 player.PlayerPhysplug = gunner.PlayerPhysplug;
329 player.vehicle_ammo1 = vehic.vehicle_ammo1;
330 player.vehicle_ammo2 = vehic.vehicle_ammo2;
331 player.vehicle_reload1 = vehic.vehicle_reload1;
332 player.vehicle_reload2 = vehic.vehicle_reload2;
333 player.vehicle_energy = vehic.vehicle_energy;
334 player.flags &= ~FL_ONGROUND;
336 RemoveGrapplingHook(player);
338 gunner.m_switchweapon = PS(player).m_switchweapon;
339 gunner.vehicle_exit = bumblebee_gunner_exit;
340 gunner.vehicle_hudmodel.viewmodelforclient = player;
342 if(IS_REAL_CLIENT(player))
345 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
346 WriteEntity(MSG_ONE, gunner.vehicle_viewport);
348 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
349 WriteAngle(MSG_ONE, gunner.angles_x + vehic.angles_x); // tilt
350 WriteAngle(MSG_ONE, gunner.angles_y + vehic.angles_y); // yaw
351 WriteAngle(MSG_ONE, 0); // roll
354 CSQCVehicleSetup(player, player.hud);
356 MUTATOR_CALLHOOK(VehicleEnter, player, gunner);
361 bool vehicles_valid_pilot()
363 if(IS_BOT_CLIENT(other) && !autocvar_g_vehicles_allow_bots)
366 if((!IS_PLAYER(other))
369 || (DIFF_TEAM(other, self))
375 void bumblebee_touch()
377 if(autocvar_g_vehicles_enter) { return; }
379 if(self.gunner1 != world && self.gunner2 != world)
385 if(vehicles_valid_pilot())
387 float phase_time = (time >= self.gun1.phase) + (time >= self.gun2.phase);
389 if(time >= other.vehicle_enter_delay && phase_time)
390 if(bumblebee_gunner_enter())
397 void bumblebee_regen()
399 if(self.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
400 self.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
401 self.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
403 if(self.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
404 self.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
405 self.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
407 if(self.vehicle_flags & VHF_SHIELDREGEN)
408 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);
410 if(self.vehicle_flags & VHF_HEALTHREGEN)
411 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);
413 if(self.vehicle_flags & VHF_ENERGYREGEN)
414 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);
418 float bumblebee_pilot_frame()
423 if(intermission_running)
425 self.vehicle.velocity = '0 0 0';
426 self.vehicle.avelocity = '0 0 0';
431 vehic = self.vehicle;
434 vehicles_frame(vehic, pilot);
439 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = 0;
445 crosshair_trace(pilot);
451 newvel = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
454 if(newvel.x > 180) newvel.x -= 360;
455 if(newvel.x < -180) newvel.x += 360;
456 if(newvel.y > 180) newvel.y -= 360;
457 if(newvel.y < -180) newvel.y += 360;
459 ftmp = shortangle_f(pilot.v_angle.y - vang.y, vang.y);
460 if(ftmp > 180) ftmp -= 360;
461 if(ftmp < -180) ftmp += 360;
462 vehic.avelocity_y = bound(-autocvar_g_vehicle_bumblebee_turnspeed, ftmp + vehic.avelocity.y * 0.9, autocvar_g_vehicle_bumblebee_turnspeed);
466 if(pilot.movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit)
468 else if(pilot.movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit)
471 newvel.x = bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x , autocvar_g_vehicle_bumblebee_pitchlimit);
472 ftmp = vang.x - bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x + ftmp, autocvar_g_vehicle_bumblebee_pitchlimit);
473 vehic.avelocity_x = bound(-autocvar_g_vehicle_bumblebee_pitchspeed, ftmp + vehic.avelocity.x * 0.9, autocvar_g_vehicle_bumblebee_pitchspeed);
475 vehic.angles_x = anglemods(vehic.angles.x);
476 vehic.angles_y = anglemods(vehic.angles.y);
477 vehic.angles_z = anglemods(vehic.angles.z);
479 makevectors('0 1 0' * vehic.angles.y);
480 newvel = vehic.velocity * -autocvar_g_vehicle_bumblebee_friction;
482 if(pilot.movement.x != 0)
484 if(pilot.movement.x > 0)
485 newvel += v_forward * autocvar_g_vehicle_bumblebee_speed_forward;
486 else if(pilot.movement.x < 0)
487 newvel -= v_forward * autocvar_g_vehicle_bumblebee_speed_forward;
490 if(pilot.movement.y != 0)
492 if(pilot.movement.y < 0)
493 newvel -= v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
494 else if(pilot.movement.y > 0)
495 newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
496 ftmp = newvel * v_right;
497 ftmp *= frametime * 0.1;
498 vehic.angles_z = bound(-15, vehic.angles.z + ftmp, 15);
502 vehic.angles_z *= 0.95;
503 if(vehic.angles.z >= -1 && vehic.angles.z <= -1)
507 if(pilot.BUTTON_CROUCH)
508 newvel -= v_up * autocvar_g_vehicle_bumblebee_speed_down;
509 else if(pilot.BUTTON_JUMP)
510 newvel += v_up * autocvar_g_vehicle_bumblebee_speed_up;
512 vehic.velocity += newvel * frametime;
513 pilot.velocity = pilot.movement = vehic.velocity;
516 if(autocvar_g_vehicle_bumblebee_healgun_locktime)
518 if(vehic.tur_head.lock_time < time || IS_DEAD(vehic.tur_head.enemy) || STAT(FROZEN, vehic.tur_head.enemy))
519 vehic.tur_head.enemy = world;
522 if(trace_ent.movetype)
523 if(trace_ent.takedamage)
524 if(!IS_DEAD(trace_ent) && !STAT(FROZEN, trace_ent))
528 if(trace_ent.team == pilot.team)
530 vehic.tur_head.enemy = trace_ent;
531 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
536 vehic.tur_head.enemy = trace_ent;
537 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
541 if(vehic.tur_head.enemy)
543 trace_endpos = real_origin(vehic.tur_head.enemy);
544 UpdateAuxiliaryXhair(pilot, trace_endpos, '0 0.75 0', 0);
548 vang = vehicle_aimturret(vehic, trace_endpos, self.gun3, "fire",
549 autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up,
550 autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1, autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides, autocvar_g_vehicle_bumblebee_raygun_turnspeed);
552 if(!forbidWeaponUse(pilot))
553 if((pilot.BUTTON_ATCK || pilot.BUTTON_ATCK2) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
555 vehic.gun3.enemy.realowner = pilot;
556 vehic.gun3.enemy.effects &= ~EF_NODRAW;
558 vehic.gun3.enemy.hook_start = gettaginfo(vehic.gun3, gettagindex(vehic.gun3, "fire"));
559 vehic.gun3.enemy.SendFlags |= BRG_START;
561 traceline(vehic.gun3.enemy.hook_start, vehic.gun3.enemy.hook_start + v_forward * autocvar_g_vehicle_bumblebee_raygun_range, MOVE_NORMAL, vehic);
565 if(autocvar_g_vehicle_bumblebee_raygun)
567 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);
568 vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
572 if(!IS_DEAD(trace_ent))
573 if((teamplay && trace_ent.team == pilot.team) || !teamplay)
576 if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
578 if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.max_health)
579 trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.max_health);
581 if(autocvar_g_vehicle_bumblebee_healgun_hps)
582 trace_ent.vehicle_health = min(trace_ent.vehicle_health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
584 else if(IS_CLIENT(trace_ent))
586 if(trace_ent.health <= autocvar_g_vehicle_bumblebee_healgun_hmax && autocvar_g_vehicle_bumblebee_healgun_hps)
587 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
589 if(trace_ent.armorvalue <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
590 trace_ent.armorvalue = min(trace_ent.armorvalue + autocvar_g_vehicle_bumblebee_healgun_aps * frametime, autocvar_g_vehicle_bumblebee_healgun_amax);
592 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
594 else if(IS_TURRET(trace_ent))
596 if(trace_ent.health <= trace_ent.max_health && autocvar_g_vehicle_bumblebee_healgun_hps)
597 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
598 //else ..hmmm what? ammo?
600 trace_ent.SendFlags |= TNSF_STATUS;
606 vehic.gun3.enemy.hook_end = trace_endpos;
607 setorigin(vehic.gun3.enemy, trace_endpos);
608 vehic.gun3.enemy.SendFlags |= BRG_END;
610 vehic.wait = time + 1;
613 vehic.gun3.enemy.effects |= EF_NODRAW;
616 remove(vehic.gun3.enemy);
618 vehic.gun3.enemy = world;
622 VEHICLE_UPDATE_PLAYER(pilot, health, bumblebee);
623 VEHICLE_UPDATE_PLAYER(pilot, energy, bumblebee);
625 pilot.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
626 pilot.vehicle_ammo2 = (vehic.gun2.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
628 if(vehic.vehicle_flags & VHF_HASSHIELD)
629 VEHICLE_UPDATE_PLAYER(pilot, shield, bumblebee);
631 vehic.angles_x *= -1;
632 makevectors(vehic.angles);
633 vehic.angles_x *= -1;
634 setorigin(pilot, vehic.origin + v_up * 48 + v_forward * 160);
636 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = pilot.BUTTON_CROUCH = 0;
642 void bumblebee_land()
646 hgt = raptor_altitude(512);
647 self.velocity = (self.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
648 self.angles_x *= 0.95;
649 self.angles_z *= 0.95;
652 self.think = vehicles_think;
654 self.nextthink = time;
656 CSQCMODEL_AUTOUPDATE(self);
659 void bumblebee_exit(float eject)
661 if(self.owner.vehicleid == VEH_BUMBLEBEE.vehicleid)
663 bumblebee_gunner_exit(eject);
667 self.touch = vehicles_touch;
671 self.think = bumblebee_land;
672 self.nextthink = time;
675 self.movetype = MOVETYPE_TOSS;
680 fixedmakevectors(self.angles);
682 if(vdist(self.velocity, >, autocvar_g_vehicle_bumblebee_speed_forward * 0.5))
683 spot = self.origin + v_up * 128 + v_forward * 300;
685 spot = self.origin + v_up * 128 - v_forward * 300;
687 spot = vehicles_findgoodexit(spot);
690 if(self.gun3.enemy || !wasfreed(self.gun3.enemy)) {
691 self.gun3.enemy.effects |= EF_NODRAW;
694 self.owner.velocity = 0.75 * self.vehicle.velocity + normalize(spot - self.vehicle.origin) * 200;
695 self.owner.velocity_z += 10;
696 setorigin(self.owner, spot);
698 antilag_clear(self.owner);
702 void bumblebee_blowup()
704 RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
705 autocvar_g_vehicle_bumblebee_blowup_edgedamage,
706 autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
707 autocvar_g_vehicle_bumblebee_blowup_forceintensity,
708 DEATH_VH_BUMB_DEATH.m_id, world);
710 sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
711 Send_Effect(EFFECT_EXPLOSION_BIG, (self.origin + '0 0 100') + (randomvec() * 80), '0 0 0', 1);
713 if(self.owner.deadflag == DEAD_DYING)
714 self.owner.deadflag = DEAD_DEAD;
719 void bumblebee_diethink()
721 if(time >= self.wait)
722 self.think = bumblebee_blowup;
726 sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
727 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
730 self.nextthink = time + 0.1;
733 spawnfunc(vehicle_bumblebee)
735 if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
736 if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
739 METHOD(Bumblebee, vr_impact, void(Bumblebee thisveh, entity instance))
741 if(autocvar_g_vehicle_bumblebee_bouncepain)
742 vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z);
744 METHOD(Bumblebee, vr_enter, void(Bumblebee thisveh, entity instance))
747 self.touch = bumblebee_touch;
749 self.movetype = MOVETYPE_BOUNCEMISSILE;
751 METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance))
754 self.angles_z *= 0.8;
755 self.angles_x *= 0.8;
757 self.nextthink = time;
761 entity oldself = self;
764 setself(self.gunner1);
765 oldself.gun1.vehicle_exit(VHEF_EJECT);
766 entity oldother = other;
777 setself(self.gunner2);
778 oldself.gun2.vehicle_exit(VHEF_EJECT);
779 entity oldother = other;
789 METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance))
791 entity oldself = self;
794 CSQCModel_UnlinkEntity(self);
797 if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
798 self.gun3.enemy.effects |= EF_NODRAW;
802 setself(self.gunner1);
803 oldself.gun1.vehicle_exit(VHEF_EJECT);
809 setself(self.gunner2);
810 oldself.gun2.vehicle_exit(VHEF_EJECT);
814 self.vehicle_exit(VHEF_EJECT);
816 fixedmakevectors(self.angles);
817 vehicle_tossgib(self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
818 vehicle_tossgib(self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
819 vehicle_tossgib(self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
821 entity _body = vehicle_tossgib(self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
824 _body.touch = bumblebee_blowup;
826 _body.touch = func_null;
828 _body.think = bumblebee_diethink;
829 _body.nextthink = time;
830 _body.wait = time + 2 + (random() * 8);
832 _body.enemy = self.enemy;
834 _body.angles = self.angles;
836 Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(self.origin, 16), '0 0 0', 1);
839 self.event_damage = func_null;
840 self.solid = SOLID_NOT;
841 self.takedamage = DAMAGE_NO;
842 self.deadflag = DEAD_DYING;
843 self.movetype = MOVETYPE_NONE;
844 self.effects = EF_NODRAW;
845 self.colormod = '0 0 0';
846 self.avelocity = '0 0 0';
847 self.velocity = '0 0 0';
848 self.touch = func_null;
851 setorigin(self, self.pos1);
855 METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance))
860 // for some reason, autosizing of the shield entity refuses to work for this one so set it up in advance.
861 self.vehicle_shieldent = spawn();
862 self.vehicle_shieldent.effects = EF_LOWPRECISION;
863 setmodel(self.vehicle_shieldent, MDL_VEH_BUMBLEBEE_SHIELD);
864 setattachment(self.vehicle_shieldent, self, "");
865 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
866 self.vehicle_shieldent.scale = 512 / vlen(self.maxs - self.mins);
867 self.vehicle_shieldent.think = shieldhit_think;
868 self.vehicle_shieldent.alpha = -1;
869 self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
871 self.gun1 = new(vehicle_playerslot);
872 self.gun2 = new(vehicle_playerslot);
873 self.gun3 = new(bumblebee_raygun);
875 self.vehicle_flags |= VHF_MULTISLOT;
877 self.gun1.owner = self;
878 self.gun2.owner = self;
879 self.gun3.owner = self;
881 setmodel(self.gun1, MDL_VEH_BUMBLEBEE_CANNON_RIGHT);
882 setmodel(self.gun2, MDL_VEH_BUMBLEBEE_CANNON_LEFT);
883 setmodel(self.gun3, MDL_VEH_BUMBLEBEE_CANNON_CENTER);
885 setattachment(self.gun1, self, "cannon_right");
886 setattachment(self.gun2, self, "cannon_left");
888 // Angled bones are no fun, messes up gun-aim; so work arround it.
889 self.gun3.pos1 = self.angles;
890 self.angles = '0 0 0';
891 vector ofs = gettaginfo(self, gettagindex(self, "raygun"));
893 setattachment(self.gun3, self, "");
894 setorigin(self.gun3, ofs);
895 self.angles = self.gun3.pos1;
897 vehicle_addplayerslot(self, self.gun1, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
898 vehicle_addplayerslot(self, self.gun2, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
900 setorigin(self.vehicle_hudmodel, '50 0 -5'); // Move cockpit forward - down.
901 setorigin(self.vehicle_viewport, '5 0 2'); // Move camera forward up
904 setorigin(self.gun1.vehicle_hudmodel, '90 -27 -23');
905 setorigin(self.gun1.vehicle_viewport, '-85 0 50');
907 setorigin(self.gun2.vehicle_hudmodel, '90 27 -23');
908 setorigin(self.gun2.vehicle_viewport, '-85 0 50');
913 if(self.gun3.enemy == world)
915 self.gun3.enemy = spawn();
916 Net_LinkEntity(self.gun3.enemy, true, 0, bumble_raygun_send);
917 self.gun3.enemy.SendFlags = BRG_SETUP;
918 self.gun3.enemy.cnt = autocvar_g_vehicle_bumblebee_raygun;
919 self.gun3.enemy.effects = EF_NODRAW | EF_LOWPRECISION;
923 self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
924 self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
925 self.solid = SOLID_BBOX;
926 self.movetype = MOVETYPE_TOSS;
927 self.damageforcescale = 0.025;
929 self.PlayerPhysplug = bumblebee_pilot_frame;
931 setorigin(self, self.origin + '0 0 25');
933 METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh, entity instance))
936 if(autocvar_g_vehicle_bumblebee_energy)
937 if(autocvar_g_vehicle_bumblebee_energy_regen)
938 self.vehicle_flags |= VHF_ENERGYREGEN;
940 if(autocvar_g_vehicle_bumblebee_shield)
941 self.vehicle_flags |= VHF_HASSHIELD;
943 if(autocvar_g_vehicle_bumblebee_shield_regen)
944 self.vehicle_flags |= VHF_SHIELDREGEN;
946 if(autocvar_g_vehicle_bumblebee_health_regen)
947 self.vehicle_flags |= VHF_HEALTHREGEN;
949 self.vehicle_exit = bumblebee_exit;
950 self.respawntime = autocvar_g_vehicle_bumblebee_respawntime;
951 self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
952 self.max_health = self.vehicle_health;
953 self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
959 void CSQC_BUMBLE_GUN_HUD()
961 Vehicles_drawHUD("vehicle_gunner", "vehicle_gunner_weapon1", string_null,
962 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
963 string_null, '0 0 0');
966 METHOD(Bumblebee, vr_hud, void(Bumblebee thisveh))
968 Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
969 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
970 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color);
972 float hudAlpha = autocvar_hud_panel_fg_alpha;
973 float blinkValue = 0.55 + sin(time * 7) * 0.45;
974 vector tmpPos = '0 0 0';
975 vector tmpSize = '1 1 1' * hud_fontsize;
976 tmpPos.x = vehicleHud_Pos.x + vehicleHud_Size.x * (520/768);
978 if(!AuxiliaryXhair[1].draw2d)
980 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (96/256) - tmpSize.y;
981 drawstring(tmpPos, _("No right gunner!"), tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
984 if(!AuxiliaryXhair[2].draw2d)
986 tmpPos.y = vehicleHud_Pos.y + vehicleHud_Size.y * (160/256);
987 drawstring(tmpPos, _("No left gunner!"), tmpSize, '1 1 1', hudAlpha * blinkValue, DRAWFLAG_NORMAL);
990 METHOD(Bumblebee, vr_crosshair, void(Bumblebee thisveh))
992 Vehicles_drawCrosshair(vCROSS_HEAL);
994 METHOD(Bumblebee, vr_setup, void(Bumblebee thisveh, entity instance))
996 AuxiliaryXhair[0].axh_image = vCROSS_LOCK; // Raygun-locked
997 AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Gunner1
998 AuxiliaryXhair[2].axh_image = vCROSS_BURST; // Gunner2