1 #ifndef VEHICLE_BUMBLEBEE
2 #define VEHICLE_BUMBLEBEE
3 #include "bumblebee.qh"
5 CLASS(Bumblebee, Vehicle)
6 /* spawnflags */ ATTRIB(Bumblebee, spawnflags, int, VHF_DMGSHAKE);
7 /* mins */ ATTRIB(Bumblebee, mins, vector, '-245 -130 -130');
8 /* maxs */ ATTRIB(Bumblebee, maxs, vector, '230 130 130');
9 /* model */ ATTRIB(Bumblebee, mdl, string, "models/vehicles/bumblebee_body.dpm");
10 /* model */ ATTRIB(Bumblebee, model, string, "models/vehicles/bumblebee_body.dpm");
11 /* head_model */ ATTRIB(Bumblebee, head_model, string, "");
12 /* hud_model */ ATTRIB(Bumblebee, hud_model, string, "models/vehicles/spiderbot_cockpit.dpm");
13 /* tags */ ATTRIB(Bumblebee, tag_head, string, "");
14 /* tags */ ATTRIB(Bumblebee, tag_hud, string, "");
15 /* tags */ ATTRIB(Bumblebee, tag_hview, string, "tag_viewport");
16 /* netname */ ATTRIB(Bumblebee, netname, string, "bumblebee");
17 /* fullname */ ATTRIB(Bumblebee, vehicle_name, string, _("Bumblebee"));
18 /* icon */ ATTRIB(Bumblebee, m_icon, string, "vehicle_bumble");
21 REGISTER_VEHICLE(BUMBLEBEE, NEW(Bumblebee));
26 const float BRG_SETUP = 2;
27 const float BRG_START = 4;
28 const float BRG_END = 8;
31 float autocvar_g_vehicle_bumblebee_speed_forward;
32 float autocvar_g_vehicle_bumblebee_speed_strafe;
33 float autocvar_g_vehicle_bumblebee_speed_up;
34 float autocvar_g_vehicle_bumblebee_speed_down;
35 float autocvar_g_vehicle_bumblebee_turnspeed;
36 float autocvar_g_vehicle_bumblebee_pitchspeed;
37 float autocvar_g_vehicle_bumblebee_pitchlimit;
38 float autocvar_g_vehicle_bumblebee_friction;
40 float autocvar_g_vehicle_bumblebee_energy;
41 float autocvar_g_vehicle_bumblebee_energy_regen;
42 float autocvar_g_vehicle_bumblebee_energy_regen_pause;
44 float autocvar_g_vehicle_bumblebee_health;
45 float autocvar_g_vehicle_bumblebee_health_regen;
46 float autocvar_g_vehicle_bumblebee_health_regen_pause;
48 float autocvar_g_vehicle_bumblebee_shield;
49 float autocvar_g_vehicle_bumblebee_shield_regen;
50 float autocvar_g_vehicle_bumblebee_shield_regen_pause;
52 float autocvar_g_vehicle_bumblebee_cannon_cost;
53 float autocvar_g_vehicle_bumblebee_cannon_damage;
54 float autocvar_g_vehicle_bumblebee_cannon_radius;
55 float autocvar_g_vehicle_bumblebee_cannon_refire;
56 float autocvar_g_vehicle_bumblebee_cannon_speed;
57 float autocvar_g_vehicle_bumblebee_cannon_spread;
58 float autocvar_g_vehicle_bumblebee_cannon_force;
60 float autocvar_g_vehicle_bumblebee_cannon_ammo;
61 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen;
62 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause;
64 float autocvar_g_vehicle_bumblebee_cannon_lock = 0;
66 float autocvar_g_vehicle_bumblebee_cannon_turnspeed;
67 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down;
68 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up;
69 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
70 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
73 float autocvar_g_vehicle_bumblebee_raygun_turnspeed;
74 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down;
75 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up;
76 float autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides;
78 float autocvar_g_vehicle_bumblebee_raygun_range;
79 float autocvar_g_vehicle_bumblebee_raygun_dps;
80 float autocvar_g_vehicle_bumblebee_raygun_aps;
81 float autocvar_g_vehicle_bumblebee_raygun_fps;
83 float autocvar_g_vehicle_bumblebee_raygun;
84 float autocvar_g_vehicle_bumblebee_healgun_hps;
85 float autocvar_g_vehicle_bumblebee_healgun_hmax;
86 float autocvar_g_vehicle_bumblebee_healgun_aps;
87 float autocvar_g_vehicle_bumblebee_healgun_amax;
88 float autocvar_g_vehicle_bumblebee_healgun_sps;
89 float autocvar_g_vehicle_bumblebee_healgun_locktime;
91 float autocvar_g_vehicle_bumblebee_respawntime;
93 float autocvar_g_vehicle_bumblebee_blowup_radius;
94 float autocvar_g_vehicle_bumblebee_blowup_coredamage;
95 float autocvar_g_vehicle_bumblebee_blowup_edgedamage;
96 float autocvar_g_vehicle_bumblebee_blowup_forceintensity;
97 vector autocvar_g_vehicle_bumblebee_bouncepain;
99 bool autocvar_g_vehicle_bumblebee = 0;
101 float bumble_raygun_send(entity to, int sf);
103 void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
105 vector v = gettaginfo(_gun, gettagindex(_gun, _tagname));
106 vehicles_projectile(EFFECT_BIGPLASMA_MUZZLEFLASH.eent_eff_name, SND(VEH_BUMBLEBEE_FIRE),
107 v, normalize(v_forward + randomvec() * autocvar_g_vehicle_bumblebee_cannon_spread) * autocvar_g_vehicle_bumblebee_cannon_speed,
108 autocvar_g_vehicle_bumblebee_cannon_damage, autocvar_g_vehicle_bumblebee_cannon_radius, autocvar_g_vehicle_bumblebee_cannon_force, 0,
109 DEATH_VH_BUMB_GUN, PROJECTILE_BUMBLE_GUN, 0, true, true, _owner);
112 float bumblebee_gunner_frame()
114 entity vehic = self.vehicle.owner;
115 entity gun = self.vehicle;
116 entity gunner = self;
119 vehic.solid = SOLID_NOT;
120 //setorigin(gunner, vehic.origin);
121 gunner.velocity = vehic.velocity;
124 vehic.angles_x *= -1;
125 makevectors(vehic.angles);
126 vehic.angles_x *= -1;
127 if(gun == vehic.gun1)
129 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
130 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
131 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * 128);
135 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
136 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
137 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);
140 crosshair_trace(gunner);
141 vector _ct = trace_endpos;
144 if(autocvar_g_vehicle_bumblebee_cannon_lock)
146 if(gun.lock_time < time)
150 if(trace_ent.movetype)
151 if(trace_ent.takedamage)
152 if(!trace_ent.deadflag)
154 if(DIFF_TEAM(trace_ent, gunner))
156 gun.enemy = trace_ent;
157 gun.lock_time = time + 5;
164 float distance, impact_time;
166 vector vf = real_origin(gun.enemy);
167 vector _vel = gun.enemy.velocity;
168 if(gun.enemy.movetype == MOVETYPE_WALK)
173 distance = vlen(ad - gunner.origin);
174 impact_time = distance / autocvar_g_vehicle_bumblebee_cannon_speed;
175 ad = vf + _vel * impact_time;
179 UpdateAuxiliaryXhair(gunner, ad, '1 0 1', 1);
180 vehicle_aimturret(vehic, trace_endpos, gun, "fire",
181 autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
182 _out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed);
186 vehicle_aimturret(vehic, _ct, gun, "fire",
187 autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
188 _out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed);
190 if(!forbidWeaponUse(gunner))
191 if(gunner.BUTTON_ATCK)
192 if(time > gun.attack_finished_single)
193 if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
195 gun.vehicle_energy -= autocvar_g_vehicle_bumblebee_cannon_cost;
196 bumblebee_fire_cannon(gun, "fire", gunner);
198 gun.attack_finished_single = time + autocvar_g_vehicle_bumblebee_cannon_refire;
201 VEHICLE_UPDATE_PLAYER(gunner, health, bumblebee);
203 if(vehic.vehicle_flags & VHF_HASSHIELD)
204 VEHICLE_UPDATE_PLAYER(gunner, shield, bumblebee);
206 ad = gettaginfo(gun, gettagindex(gun, "fire"));
207 traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
209 UpdateAuxiliaryXhair(gunner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), 0);
212 UpdateAuxiliaryXhair(vehic.owner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), ((gunner == vehic.gunner1) ? 1 : 2));
214 vehic.solid = SOLID_BBOX;
215 gunner.BUTTON_ATCK = gunner.BUTTON_ATCK2 = gunner.BUTTON_CROUCH = 0;
216 gunner.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
222 vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity player)
227 tracebox(gunner.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, player);
228 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
231 mysize = 1.5 * vlen(PL_MAX - PL_MIN); // can't use gunner's size, as they don't have a size
234 v2 = 0.5 * (gunner.absmin + gunner.absmax);
235 for(i = 0; i < 100; ++i)
239 v = v2 + normalize(v) * mysize;
240 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, player);
241 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
245 return prefer_spot; // this should be considered a fallback?!
248 void bumblebee_gunner_exit(int _exitflag)
250 entity player = self;
251 entity gunner = player.vehicle;
252 entity vehic = gunner.owner;
254 if(IS_REAL_CLIENT(player))
257 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
258 WriteEntity(MSG_ONE, player);
260 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
261 WriteAngle(MSG_ONE, 0);
262 WriteAngle(MSG_ONE, vehic.angles.y);
263 WriteAngle(MSG_ONE, 0);
266 CSQCVehicleSetup(player, HUD_NORMAL);
267 setsize(player, PL_MIN, PL_MAX);
269 player.takedamage = DAMAGE_AIM;
270 player.solid = SOLID_SLIDEBOX;
271 player.movetype = MOVETYPE_WALK;
272 player.effects &= ~EF_NODRAW;
274 player.PlayerPhysplug = func_null;
275 player.view_ofs = PL_VIEW_OFS;
276 player.event_damage = PlayerDamage;
277 player.hud = HUD_NORMAL;
278 player.teleportable = TELEPORT_NORMAL;
279 player.switchweapon = gunner.switchweapon;
280 player.vehicle_enter_delay = time + 2;
282 fixedmakevectors(vehic.angles);
284 if(player == vehic.gunner1) { vehic.gunner1 = world; }
285 if(player == vehic.gunner2) { vehic.gunner2 = world; v_right *= -1; }
287 vector spot = real_origin(gunner);
288 spot = spot + v_up * 128 + v_forward * 300 + v_right * 150;
289 spot = bumblebee_gunner_findgoodexit(spot, gunner, player);
291 // TODO: figure a way to move player out of the gunner
293 player.velocity = 0.75 * vehic.velocity + normalize(spot - vehic.origin) * 200;
294 player.velocity_z += 10;
296 gunner.phase = time + 5;
297 gunner.vehicle_hudmodel.viewmodelforclient = gunner;
299 MUTATOR_CALLHOOK(VehicleExit, player, gunner);
301 player.vehicle = world;
304 bool bumblebee_gunner_enter()
307 entity player = other;
308 entity gunner = world;
310 if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2)
312 // we can have some fun
313 if(vlen(real_origin(vehic.gun2) - player.origin) < vlen(real_origin(vehic.gun1) - player.origin))
316 vehic.gunner2 = player;
321 vehic.gunner1 = player;
324 else if(!vehic.gunner1 && time >= vehic.gun1.phase) { gunner = vehic.gun1; vehic.gunner1 = player; }
325 else if(!vehic.gunner2 && time >= vehic.gun2.phase) { gunner = vehic.gun2; vehic.gunner2 = player; }
326 else { LOG_TRACE("Vehicle is full, fail\n"); return false; }
328 player.vehicle = gunner;
329 player.angles = vehic.angles;
330 player.takedamage = DAMAGE_NO;
331 player.solid = SOLID_NOT;
333 player.movetype = MOVETYPE_NOCLIP;
334 player.event_damage = func_null;
335 player.view_ofs = '0 0 0';
336 player.hud = gunner.hud;
337 player.teleportable = false;
338 player.PlayerPhysplug = gunner.PlayerPhysplug;
339 player.vehicle_ammo1 = vehic.vehicle_ammo1;
340 player.vehicle_ammo2 = vehic.vehicle_ammo2;
341 player.vehicle_reload1 = vehic.vehicle_reload1;
342 player.vehicle_reload2 = vehic.vehicle_reload2;
343 player.vehicle_energy = vehic.vehicle_energy;
344 player.flags &= ~FL_ONGROUND;
346 RemoveGrapplingHook(player);
348 gunner.switchweapon = player.switchweapon;
349 gunner.vehicle_exit = bumblebee_gunner_exit;
350 gunner.vehicle_hudmodel.viewmodelforclient = player;
352 if(IS_REAL_CLIENT(player))
355 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
356 WriteEntity(MSG_ONE, gunner.vehicle_viewport);
358 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
359 WriteAngle(MSG_ONE, gunner.angles_x + vehic.angles_x); // tilt
360 WriteAngle(MSG_ONE, gunner.angles_y + vehic.angles_y); // yaw
361 WriteAngle(MSG_ONE, 0); // roll
364 CSQCVehicleSetup(player, player.hud);
366 MUTATOR_CALLHOOK(VehicleEnter, player, gunner);
371 bool vehicles_valid_pilot()
373 if(IS_BOT_CLIENT(other) && !autocvar_g_vehicles_allow_bots)
376 if((!IS_PLAYER(other))
377 || (other.deadflag != DEAD_NO)
379 || (DIFF_TEAM(other, self))
385 void bumblebee_touch()
387 if(autocvar_g_vehicles_enter) { return; }
389 if(self.gunner1 != world && self.gunner2 != world)
395 if(vehicles_valid_pilot())
397 float phase_time = (time >= self.gun1.phase) + (time >= self.gun2.phase);
399 if(time >= other.vehicle_enter_delay && phase_time)
400 if(bumblebee_gunner_enter())
407 void bumblebee_regen()
409 if(self.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
410 self.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
411 self.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
413 if(self.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
414 self.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
415 self.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
417 if(self.vehicle_flags & VHF_SHIELDREGEN)
418 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);
420 if(self.vehicle_flags & VHF_HEALTHREGEN)
421 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);
423 if(self.vehicle_flags & VHF_ENERGYREGEN)
424 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);
428 float bumblebee_pilot_frame()
433 if(intermission_running)
435 self.vehicle.velocity = '0 0 0';
436 self.vehicle.avelocity = '0 0 0';
441 vehic = self.vehicle;
444 if(vehic.deadflag != DEAD_NO)
447 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = 0;
453 crosshair_trace(pilot);
459 newvel = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
462 if(newvel.x > 180) newvel.x -= 360;
463 if(newvel.x < -180) newvel.x += 360;
464 if(newvel.y > 180) newvel.y -= 360;
465 if(newvel.y < -180) newvel.y += 360;
467 ftmp = shortangle_f(pilot.v_angle.y - vang.y, vang.y);
468 if(ftmp > 180) ftmp -= 360;
469 if(ftmp < -180) ftmp += 360;
470 vehic.avelocity_y = bound(-autocvar_g_vehicle_bumblebee_turnspeed, ftmp + vehic.avelocity.y * 0.9, autocvar_g_vehicle_bumblebee_turnspeed);
474 if(pilot.movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit)
476 else if(pilot.movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit)
479 newvel.x = bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x , autocvar_g_vehicle_bumblebee_pitchlimit);
480 ftmp = vang.x - bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x + ftmp, autocvar_g_vehicle_bumblebee_pitchlimit);
481 vehic.avelocity_x = bound(-autocvar_g_vehicle_bumblebee_pitchspeed, ftmp + vehic.avelocity.x * 0.9, autocvar_g_vehicle_bumblebee_pitchspeed);
483 vehic.angles_x = anglemods(vehic.angles.x);
484 vehic.angles_y = anglemods(vehic.angles.y);
485 vehic.angles_z = anglemods(vehic.angles.z);
487 makevectors('0 1 0' * vehic.angles.y);
488 newvel = vehic.velocity * -autocvar_g_vehicle_bumblebee_friction;
490 if(pilot.movement.x != 0)
492 if(pilot.movement.x > 0)
493 newvel += v_forward * autocvar_g_vehicle_bumblebee_speed_forward;
494 else if(pilot.movement.x < 0)
495 newvel -= v_forward * autocvar_g_vehicle_bumblebee_speed_forward;
498 if(pilot.movement.y != 0)
500 if(pilot.movement.y < 0)
501 newvel -= v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
502 else if(pilot.movement.y > 0)
503 newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
504 ftmp = newvel * v_right;
505 ftmp *= frametime * 0.1;
506 vehic.angles_z = bound(-15, vehic.angles.z + ftmp, 15);
510 vehic.angles_z *= 0.95;
511 if(vehic.angles.z >= -1 && vehic.angles.z <= -1)
515 if(pilot.BUTTON_CROUCH)
516 newvel -= v_up * autocvar_g_vehicle_bumblebee_speed_down;
517 else if(pilot.BUTTON_JUMP)
518 newvel += v_up * autocvar_g_vehicle_bumblebee_speed_up;
520 vehic.velocity += newvel * frametime;
521 pilot.velocity = pilot.movement = vehic.velocity;
524 if(autocvar_g_vehicle_bumblebee_healgun_locktime)
526 if(vehic.tur_head.lock_time < time || vehic.tur_head.enemy.deadflag)
527 vehic.tur_head.enemy = world;
530 if(trace_ent.movetype)
531 if(trace_ent.takedamage)
532 if(!trace_ent.deadflag)
536 if(trace_ent.team == pilot.team)
538 vehic.tur_head.enemy = trace_ent;
539 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
544 vehic.tur_head.enemy = trace_ent;
545 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
549 if(vehic.tur_head.enemy)
551 trace_endpos = real_origin(vehic.tur_head.enemy);
552 UpdateAuxiliaryXhair(pilot, trace_endpos, '0 0.75 0', 0);
556 vang = vehicle_aimturret(vehic, trace_endpos, self.gun3, "fire",
557 autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up,
558 autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1, autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides, autocvar_g_vehicle_bumblebee_raygun_turnspeed);
560 if(!forbidWeaponUse(pilot))
561 if((pilot.BUTTON_ATCK || pilot.BUTTON_ATCK2) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
563 vehic.gun3.enemy.realowner = pilot;
564 vehic.gun3.enemy.effects &= ~EF_NODRAW;
566 vehic.gun3.enemy.hook_start = gettaginfo(vehic.gun3, gettagindex(vehic.gun3, "fire"));
567 vehic.gun3.enemy.SendFlags |= BRG_START;
569 traceline(vehic.gun3.enemy.hook_start, vehic.gun3.enemy.hook_start + v_forward * autocvar_g_vehicle_bumblebee_raygun_range, MOVE_NORMAL, vehic);
573 if(autocvar_g_vehicle_bumblebee_raygun)
575 Damage(trace_ent, vehic, pilot, autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime, DEATH_GENERIC, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * sys_frametime);
576 vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
580 if(trace_ent.deadflag == DEAD_NO)
581 if((teamplay && trace_ent.team == pilot.team) || !teamplay)
584 if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
586 if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.max_health)
587 trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.max_health);
589 if(autocvar_g_vehicle_bumblebee_healgun_hps)
590 trace_ent.vehicle_health = min(trace_ent.vehicle_health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
592 else if(IS_CLIENT(trace_ent))
594 if(trace_ent.health <= autocvar_g_vehicle_bumblebee_healgun_hmax && autocvar_g_vehicle_bumblebee_healgun_hps)
595 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
597 if(trace_ent.armorvalue <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
598 trace_ent.armorvalue = min(trace_ent.armorvalue + autocvar_g_vehicle_bumblebee_healgun_aps * frametime, autocvar_g_vehicle_bumblebee_healgun_amax);
600 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
602 else if(IS_TURRET(trace_ent))
604 if(trace_ent.health <= trace_ent.max_health && autocvar_g_vehicle_bumblebee_healgun_hps)
605 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
606 //else ..hmmm what? ammo?
608 trace_ent.SendFlags |= TNSF_STATUS;
614 vehic.gun3.enemy.hook_end = trace_endpos;
615 setorigin(vehic.gun3.enemy, trace_endpos);
616 vehic.gun3.enemy.SendFlags |= BRG_END;
618 vehic.wait = time + 1;
621 vehic.gun3.enemy.effects |= EF_NODRAW;
624 remove(vehic.gun3.enemy);
626 vehic.gun3.enemy = world;
630 VEHICLE_UPDATE_PLAYER(pilot, health, bumblebee);
631 VEHICLE_UPDATE_PLAYER(pilot, energy, bumblebee);
633 pilot.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
634 pilot.vehicle_ammo2 = (vehic.gun2.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
636 if(vehic.vehicle_flags & VHF_HASSHIELD)
637 VEHICLE_UPDATE_PLAYER(pilot, shield, bumblebee);
639 vehic.angles_x *= -1;
640 makevectors(vehic.angles);
641 vehic.angles_x *= -1;
642 setorigin(pilot, vehic.origin + v_up * 48 + v_forward * 160);
644 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = pilot.BUTTON_CROUCH = 0;
650 void bumblebee_land()
654 hgt = raptor_altitude(512);
655 self.velocity = (self.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
656 self.angles_x *= 0.95;
657 self.angles_z *= 0.95;
660 self.think = vehicles_think;
662 self.nextthink = time;
664 CSQCMODEL_AUTOUPDATE(self);
667 void bumblebee_exit(float eject)
669 if(self.owner.vehicleid == VEH_BUMBLEBEE.vehicleid)
671 bumblebee_gunner_exit(eject);
675 self.touch = vehicles_touch;
677 if(self.deadflag == DEAD_NO)
679 self.think = bumblebee_land;
680 self.nextthink = time;
683 self.movetype = MOVETYPE_TOSS;
688 fixedmakevectors(self.angles);
690 if(vlen(self.velocity) > autocvar_g_vehicle_bumblebee_speed_forward * 0.5)
691 spot = self.origin + v_up * 128 + v_forward * 300;
693 spot = self.origin + v_up * 128 - v_forward * 300;
695 spot = vehicles_findgoodexit(spot);
698 if(self.gun3.enemy || !wasfreed(self.gun3.enemy)) {
699 self.gun3.enemy.effects |= EF_NODRAW;
702 self.owner.velocity = 0.75 * self.vehicle.velocity + normalize(spot - self.vehicle.origin) * 200;
703 self.owner.velocity_z += 10;
704 setorigin(self.owner, spot);
706 antilag_clear(self.owner);
710 void bumblebee_blowup()
712 RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
713 autocvar_g_vehicle_bumblebee_blowup_edgedamage,
714 autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
715 autocvar_g_vehicle_bumblebee_blowup_forceintensity,
716 DEATH_VH_BUMB_DEATH, world);
718 sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
719 Send_Effect(EFFECT_EXPLOSION_BIG, (self.origin + '0 0 100') + (randomvec() * 80), '0 0 0', 1);
721 if(self.owner.deadflag == DEAD_DYING)
722 self.owner.deadflag = DEAD_DEAD;
727 void bumblebee_diethink()
729 if(time >= self.wait)
730 self.think = bumblebee_blowup;
734 sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
735 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
738 self.nextthink = time + 0.1;
741 float bumble_raygun_send(entity to, float sf)
743 WriteByte(MSG_ENTITY, ENT_CLIENT_BUMBLE_RAYGUN);
745 WriteByte(MSG_ENTITY, sf);
748 WriteByte(MSG_ENTITY, num_for_edict(self.realowner));
749 WriteByte(MSG_ENTITY, self.realowner.team);
750 WriteByte(MSG_ENTITY, self.cnt);
755 WriteCoord(MSG_ENTITY, self.hook_start_x);
756 WriteCoord(MSG_ENTITY, self.hook_start_y);
757 WriteCoord(MSG_ENTITY, self.hook_start_z);
762 WriteCoord(MSG_ENTITY, self.hook_end_x);
763 WriteCoord(MSG_ENTITY, self.hook_end_y);
764 WriteCoord(MSG_ENTITY, self.hook_end_z);
770 void spawnfunc_vehicle_bumblebee()
772 if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
773 if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
776 METHOD(Bumblebee, vr_impact, bool(Bumblebee thisveh))
778 if(autocvar_g_vehicle_bumblebee_bouncepain)
779 vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z);
783 METHOD(Bumblebee, vr_enter, bool(Bumblebee thisveh))
786 self.touch = bumblebee_touch;
788 self.movetype = MOVETYPE_BOUNCEMISSILE;
791 METHOD(Bumblebee, vr_think, bool(Bumblebee thisveh))
794 self.angles_z *= 0.8;
795 self.angles_x *= 0.8;
797 self.nextthink = time;
801 entity oldself = self;
804 setself(self.gunner1);
805 oldself.gun1.vehicle_exit(VHEF_EJECT);
806 entity oldother = other;
817 setself(self.gunner2);
818 oldself.gun2.vehicle_exit(VHEF_EJECT);
819 entity oldother = other;
831 METHOD(Bumblebee, vr_death, bool(Bumblebee thisveh))
834 entity oldself = self;
836 CSQCModel_UnlinkEntity();
839 if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
840 self.gun3.enemy.effects |= EF_NODRAW;
844 setself(self.gunner1);
845 oldself.gun1.vehicle_exit(VHEF_EJECT);
851 setself(self.gunner2);
852 oldself.gun2.vehicle_exit(VHEF_EJECT);
856 self.vehicle_exit(VHEF_EJECT);
858 fixedmakevectors(self.angles);
859 vehicle_tossgib(self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
860 vehicle_tossgib(self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
861 vehicle_tossgib(self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
863 entity _body = vehicle_tossgib(self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
866 _body.touch = bumblebee_blowup;
868 _body.touch = func_null;
870 _body.think = bumblebee_diethink;
871 _body.nextthink = time;
872 _body.wait = time + 2 + (random() * 8);
874 _body.enemy = self.enemy;
876 _body.angles = self.angles;
878 Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(self.origin, 16), '0 0 0', 1);
881 self.event_damage = func_null;
882 self.solid = SOLID_NOT;
883 self.takedamage = DAMAGE_NO;
884 self.deadflag = DEAD_DYING;
885 self.movetype = MOVETYPE_NONE;
886 self.effects = EF_NODRAW;
887 self.colormod = '0 0 0';
888 self.avelocity = '0 0 0';
889 self.velocity = '0 0 0';
890 self.touch = func_null;
893 setorigin(self, self.pos1);
896 METHOD(Bumblebee, vr_spawn, bool(Bumblebee thisveh))
901 // for some reason, autosizing of the shield entity refuses to work for this one so set it up in advance.
902 self.vehicle_shieldent = spawn();
903 self.vehicle_shieldent.effects = EF_LOWPRECISION;
904 setmodel(self.vehicle_shieldent, MDL_VEH_BUMBLEBEE_SHIELD);
905 setattachment(self.vehicle_shieldent, self, "");
906 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
907 self.vehicle_shieldent.scale = 512 / vlen(self.maxs - self.mins);
908 self.vehicle_shieldent.think = shieldhit_think;
909 self.vehicle_shieldent.alpha = -1;
910 self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
916 self.vehicle_flags |= VHF_MULTISLOT;
918 self.gun1.owner = self;
919 self.gun2.owner = self;
920 self.gun3.owner = self;
922 self.gun1.classname = self.gun2.classname = "vehicle_playerslot";
924 setmodel(self.gun1, MDL_VEH_BUMBLEBEE_CANNON_RIGHT);
925 setmodel(self.gun2, MDL_VEH_BUMBLEBEE_CANNON_LEFT);
926 setmodel(self.gun3, MDL_VEH_BUMBLEBEE_CANNON_CENTER);
928 setattachment(self.gun1, self, "cannon_right");
929 setattachment(self.gun2, self, "cannon_left");
931 // Angled bones are no fun, messes up gun-aim; so work arround it.
932 self.gun3.pos1 = self.angles;
933 self.angles = '0 0 0';
934 vector ofs = gettaginfo(self, gettagindex(self, "raygun"));
936 setattachment(self.gun3, self, "");
937 setorigin(self.gun3, ofs);
938 self.angles = self.gun3.pos1;
940 vehicle_addplayerslot(self, self.gun1, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
941 vehicle_addplayerslot(self, self.gun2, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
943 setorigin(self.vehicle_hudmodel, '50 0 -5'); // Move cockpit forward - down.
944 setorigin(self.vehicle_viewport, '5 0 2'); // Move camera forward up
947 setorigin(self.gun1.vehicle_hudmodel, '90 -27 -23');
948 setorigin(self.gun1.vehicle_viewport, '-85 0 50');
950 setorigin(self.gun2.vehicle_hudmodel, '90 27 -23');
951 setorigin(self.gun2.vehicle_viewport, '-85 0 50');
956 if(self.gun3.enemy == world)
958 self.gun3.enemy = spawn();
959 Net_LinkEntity(self.gun3.enemy, true, 0, bumble_raygun_send);
960 self.gun3.enemy.SendFlags = BRG_SETUP;
961 self.gun3.enemy.cnt = autocvar_g_vehicle_bumblebee_raygun;
962 self.gun3.enemy.effects = EF_NODRAW | EF_LOWPRECISION;
966 self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
967 self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
968 self.solid = SOLID_BBOX;
969 self.movetype = MOVETYPE_TOSS;
970 self.damageforcescale = 0.025;
972 self.PlayerPhysplug = bumblebee_pilot_frame;
974 setorigin(self, self.origin + '0 0 25');
977 METHOD(Bumblebee, vr_setup, bool(Bumblebee thisveh))
980 if(autocvar_g_vehicle_bumblebee_energy)
981 if(autocvar_g_vehicle_bumblebee_energy_regen)
982 self.vehicle_flags |= VHF_ENERGYREGEN;
984 if(autocvar_g_vehicle_bumblebee_shield)
985 self.vehicle_flags |= VHF_HASSHIELD;
987 if(autocvar_g_vehicle_bumblebee_shield_regen)
988 self.vehicle_flags |= VHF_SHIELDREGEN;
990 if(autocvar_g_vehicle_bumblebee_health_regen)
991 self.vehicle_flags |= VHF_HEALTHREGEN;
993 self.vehicle_exit = bumblebee_exit;
994 self.respawntime = autocvar_g_vehicle_bumblebee_respawntime;
995 self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
996 self.max_health = self.vehicle_health;
997 self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
1001 METHOD(Bumblebee, vr_precache, bool(Bumblebee thisveh))
1009 void CSQC_BUMBLE_GUN_HUD()
1011 Vehicles_drawHUD("vehicle_gunner", "vehicle_gunner_weapon1", string_null,
1012 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1013 string_null, '0 0 0',
1017 void bumble_raygun_draw()
1021 vector _vtmp1, _vtmp2;
1023 _len = vlen(self.origin - self.move_origin);
1024 _dir = normalize(self.move_origin - self.origin);
1026 if(self.total_damages < time)
1028 boxparticles(self.traileffect, self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
1029 boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
1030 self.total_damages = time + 0.1;
1033 float i, df, sz, al;
1034 for(i = -0.1; i < 0.2; i += 0.1)
1036 df = DRAWFLAG_NORMAL; //((random() < 0.5) ? DRAWFLAG_ADDITIVE : DRAWFLAG_SCREEN);
1037 sz = 5 + random() * 5;
1038 al = 0.25 + random() * 0.5;
1039 _vtmp1 = self.origin + _dir * _len * (0.25 + i);
1040 _vtmp1 += (randomvec() * (_len * 0.2) * (frametime * 2)); //self.raygun_l1;
1041 Draw_CylindricLine(self.origin, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1043 _vtmp2 = self.origin + _dir * _len * (0.5 + i);
1044 _vtmp2 += (randomvec() * (_len * 0.2) * (frametime * 5)); //self.raygun_l2;
1045 Draw_CylindricLine(_vtmp1, _vtmp2, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1047 _vtmp1 = self.origin + _dir * _len * (0.75 + i);
1048 _vtmp1 += randomvec() * (_len * 0.2) * (frametime * 10); //self.raygun_l3;
1049 Draw_CylindricLine(_vtmp2, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1051 Draw_CylindricLine(_vtmp1, self.move_origin + randomvec() * 32, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1055 void bumble_raygun_read(bool bIsNew)
1057 int sf = ReadByte();
1061 self.cnt = ReadByte();
1062 self.team = ReadByte();
1063 self.cnt = ReadByte();
1066 self.colormod = '1 0 0';
1068 self.colormod = '0 1 0';
1070 self.traileffect = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_MUZZLEFLASH);
1071 self.lip = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_IMPACT);
1073 self.draw = bumble_raygun_draw;
1079 self.origin_x = ReadCoord();
1080 self.origin_y = ReadCoord();
1081 self.origin_z = ReadCoord();
1082 setorigin(self, self.origin);
1087 self.move_origin_x = ReadCoord();
1088 self.move_origin_y = ReadCoord();
1089 self.move_origin_z = ReadCoord();
1093 METHOD(Bumblebee, vr_hud, bool(Bumblebee thisveh))
1095 Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
1096 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1097 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1101 METHOD(Bumblebee, vr_setup, bool(Bumblebee thisveh))
1103 AuxiliaryXhair[0].axh_image = vCROSS_LOCK; // Raygun-locked
1104 AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Gunner1
1105 AuxiliaryXhair[2].axh_image = vCROSS_BURST; // Gunner2
1108 METHOD(Bumblebee, vr_precache, bool(Bumblebee thisveh))
1114 #endif // REGISTER_VEHICLE