1 #ifndef VEHICLE_BUMBLEBEE
2 #define VEHICLE_BUMBLEBEE
3 #include "bumblebee.qh"
5 int v_bumblebee(entity, int);
7 REGISTER_VEHICLE_SIMPLE(
8 /* VEH_##id */ BUMBLEBEE,
9 /* spawnflags */ VHF_DMGSHAKE,
10 /* mins,maxs */ '-245 -130 -130', '230 130 130',
11 /* model */ "models/vehicles/bumblebee_body.dpm",
13 /* hud_model */ "models/vehicles/spiderbot_cockpit.dpm",
14 /* tags */ "", "", "tag_viewport",
15 /* netname */ "bumblebee",
16 /* fullname */ _("Bumblebee")
18 this.m_icon = "vehicle_bumble";
20 this.vehicle_func = v_bumblebee;
27 const float BRG_SETUP = 2;
28 const float BRG_START = 4;
29 const float BRG_END = 8;
32 float autocvar_g_vehicle_bumblebee_speed_forward;
33 float autocvar_g_vehicle_bumblebee_speed_strafe;
34 float autocvar_g_vehicle_bumblebee_speed_up;
35 float autocvar_g_vehicle_bumblebee_speed_down;
36 float autocvar_g_vehicle_bumblebee_turnspeed;
37 float autocvar_g_vehicle_bumblebee_pitchspeed;
38 float autocvar_g_vehicle_bumblebee_pitchlimit;
39 float autocvar_g_vehicle_bumblebee_friction;
41 float autocvar_g_vehicle_bumblebee_energy;
42 float autocvar_g_vehicle_bumblebee_energy_regen;
43 float autocvar_g_vehicle_bumblebee_energy_regen_pause;
45 float autocvar_g_vehicle_bumblebee_health;
46 float autocvar_g_vehicle_bumblebee_health_regen;
47 float autocvar_g_vehicle_bumblebee_health_regen_pause;
49 float autocvar_g_vehicle_bumblebee_shield;
50 float autocvar_g_vehicle_bumblebee_shield_regen;
51 float autocvar_g_vehicle_bumblebee_shield_regen_pause;
53 float autocvar_g_vehicle_bumblebee_cannon_cost;
54 float autocvar_g_vehicle_bumblebee_cannon_damage;
55 float autocvar_g_vehicle_bumblebee_cannon_radius;
56 float autocvar_g_vehicle_bumblebee_cannon_refire;
57 float autocvar_g_vehicle_bumblebee_cannon_speed;
58 float autocvar_g_vehicle_bumblebee_cannon_spread;
59 float autocvar_g_vehicle_bumblebee_cannon_force;
61 float autocvar_g_vehicle_bumblebee_cannon_ammo;
62 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen;
63 float autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause;
65 float autocvar_g_vehicle_bumblebee_cannon_lock = 0;
67 float autocvar_g_vehicle_bumblebee_cannon_turnspeed;
68 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down;
69 float autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up;
70 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
71 float autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
74 float autocvar_g_vehicle_bumblebee_raygun_turnspeed;
75 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down;
76 float autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up;
77 float autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides;
79 float autocvar_g_vehicle_bumblebee_raygun_range;
80 float autocvar_g_vehicle_bumblebee_raygun_dps;
81 float autocvar_g_vehicle_bumblebee_raygun_aps;
82 float autocvar_g_vehicle_bumblebee_raygun_fps;
84 float autocvar_g_vehicle_bumblebee_raygun;
85 float autocvar_g_vehicle_bumblebee_healgun_hps;
86 float autocvar_g_vehicle_bumblebee_healgun_hmax;
87 float autocvar_g_vehicle_bumblebee_healgun_aps;
88 float autocvar_g_vehicle_bumblebee_healgun_amax;
89 float autocvar_g_vehicle_bumblebee_healgun_sps;
90 float autocvar_g_vehicle_bumblebee_healgun_locktime;
92 float autocvar_g_vehicle_bumblebee_respawntime;
94 float autocvar_g_vehicle_bumblebee_blowup_radius;
95 float autocvar_g_vehicle_bumblebee_blowup_coredamage;
96 float autocvar_g_vehicle_bumblebee_blowup_edgedamage;
97 float autocvar_g_vehicle_bumblebee_blowup_forceintensity;
98 vector autocvar_g_vehicle_bumblebee_bouncepain;
100 bool autocvar_g_vehicle_bumblebee = 0;
102 float bumble_raygun_send(entity to, int sf);
104 void bumblebee_fire_cannon(entity _gun, string _tagname, entity _owner)
106 vector v = gettaginfo(_gun, gettagindex(_gun, _tagname));
107 vehicles_projectile(EFFECT_BIGPLASMA_MUZZLEFLASH.eent_eff_name, SND(VEH_BUMBLEBEE_FIRE),
108 v, normalize(v_forward + randomvec() * autocvar_g_vehicle_bumblebee_cannon_spread) * autocvar_g_vehicle_bumblebee_cannon_speed,
109 autocvar_g_vehicle_bumblebee_cannon_damage, autocvar_g_vehicle_bumblebee_cannon_radius, autocvar_g_vehicle_bumblebee_cannon_force, 0,
110 DEATH_VH_BUMB_GUN, PROJECTILE_BUMBLE_GUN, 0, true, true, _owner);
113 float bumblebee_gunner_frame()
115 entity vehic = self.vehicle.owner;
116 entity gun = self.vehicle;
117 entity gunner = self;
120 vehic.solid = SOLID_NOT;
121 //setorigin(gunner, vehic.origin);
122 gunner.velocity = vehic.velocity;
125 vehic.angles_x *= -1;
126 makevectors(vehic.angles);
127 vehic.angles_x *= -1;
128 if(gun == vehic.gun1)
130 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
131 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
132 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * 128);
136 _in = autocvar_g_vehicle_bumblebee_cannon_turnlimit_out;
137 _out = autocvar_g_vehicle_bumblebee_cannon_turnlimit_in;
138 setorigin(gunner, vehic.origin + v_up * -16 + v_forward * -16 + v_right * -128);
141 crosshair_trace(gunner);
142 vector _ct = trace_endpos;
145 if(autocvar_g_vehicle_bumblebee_cannon_lock)
147 if(gun.lock_time < time)
151 if(trace_ent.movetype)
152 if(trace_ent.takedamage)
153 if(!trace_ent.deadflag)
155 if(DIFF_TEAM(trace_ent, gunner))
157 gun.enemy = trace_ent;
158 gun.lock_time = time + 5;
165 float distance, impact_time;
167 vector vf = real_origin(gun.enemy);
168 vector _vel = gun.enemy.velocity;
169 if(gun.enemy.movetype == MOVETYPE_WALK)
174 distance = vlen(ad - gunner.origin);
175 impact_time = distance / autocvar_g_vehicle_bumblebee_cannon_speed;
176 ad = vf + _vel * impact_time;
180 UpdateAuxiliaryXhair(gunner, ad, '1 0 1', 1);
181 vehicle_aimturret(vehic, trace_endpos, gun, "fire",
182 autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
183 _out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed);
187 vehicle_aimturret(vehic, _ct, gun, "fire",
188 autocvar_g_vehicle_bumblebee_cannon_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_cannon_pitchlimit_up,
189 _out * -1, _in, autocvar_g_vehicle_bumblebee_cannon_turnspeed);
191 if(!forbidWeaponUse(gunner))
192 if(gunner.BUTTON_ATCK)
193 if(time > gun.attack_finished_single)
194 if(gun.vehicle_energy >= autocvar_g_vehicle_bumblebee_cannon_cost)
196 gun.vehicle_energy -= autocvar_g_vehicle_bumblebee_cannon_cost;
197 bumblebee_fire_cannon(gun, "fire", gunner);
199 gun.attack_finished_single = time + autocvar_g_vehicle_bumblebee_cannon_refire;
202 VEHICLE_UPDATE_PLAYER(gunner, health, bumblebee);
204 if(vehic.vehicle_flags & VHF_HASSHIELD)
205 VEHICLE_UPDATE_PLAYER(gunner, shield, bumblebee);
207 ad = gettaginfo(gun, gettagindex(gun, "fire"));
208 traceline(ad, ad + v_forward * MAX_SHOT_DISTANCE, MOVE_NORMAL, gun);
210 UpdateAuxiliaryXhair(gunner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), 0);
213 UpdateAuxiliaryXhair(vehic.owner, trace_endpos, ('1 0 0' * gunner.vehicle_reload1) + ('0 1 0' *(1 - gunner.vehicle_reload1)), ((gunner == vehic.gunner1) ? 1 : 2));
215 vehic.solid = SOLID_BBOX;
216 gunner.BUTTON_ATCK = gunner.BUTTON_ATCK2 = gunner.BUTTON_CROUCH = 0;
217 gunner.vehicle_energy = (gun.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
223 vector bumblebee_gunner_findgoodexit(vector prefer_spot, entity gunner, entity player)
228 tracebox(gunner.origin + '0 0 32', PL_MIN, PL_MAX, prefer_spot, MOVE_NORMAL, player);
229 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
232 mysize = 1.5 * vlen(PL_MAX - PL_MIN); // can't use gunner's size, as they don't have a size
235 v2 = 0.5 * (gunner.absmin + gunner.absmax);
236 for(i = 0; i < 100; ++i)
240 v = v2 + normalize(v) * mysize;
241 tracebox(v2, PL_MIN, PL_MAX, v, MOVE_NORMAL, player);
242 if(trace_fraction == 1.0 && !trace_startsolid && !trace_allsolid)
246 return prefer_spot; // this should be considered a fallback?!
249 void bumblebee_gunner_exit(int _exitflag)
251 entity player = self;
252 entity gunner = player.vehicle;
253 entity vehic = gunner.owner;
255 if(IS_REAL_CLIENT(player))
258 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
259 WriteEntity(MSG_ONE, player);
261 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
262 WriteAngle(MSG_ONE, 0);
263 WriteAngle(MSG_ONE, vehic.angles.y);
264 WriteAngle(MSG_ONE, 0);
267 CSQCVehicleSetup(player, HUD_NORMAL);
268 setsize(player, PL_MIN, PL_MAX);
270 player.takedamage = DAMAGE_AIM;
271 player.solid = SOLID_SLIDEBOX;
272 player.movetype = MOVETYPE_WALK;
273 player.effects &= ~EF_NODRAW;
275 player.PlayerPhysplug = func_null;
276 player.view_ofs = PL_VIEW_OFS;
277 player.event_damage = PlayerDamage;
278 player.hud = HUD_NORMAL;
279 player.teleportable = TELEPORT_NORMAL;
280 player.switchweapon = gunner.switchweapon;
281 player.vehicle_enter_delay = time + 2;
283 fixedmakevectors(vehic.angles);
285 if(player == vehic.gunner1) { vehic.gunner1 = world; }
286 if(player == vehic.gunner2) { vehic.gunner2 = world; v_right *= -1; }
288 vector spot = real_origin(gunner);
289 spot = spot + v_up * 128 + v_forward * 300 + v_right * 150;
290 spot = bumblebee_gunner_findgoodexit(spot, gunner, player);
292 // TODO: figure a way to move player out of the gunner
294 player.velocity = 0.75 * vehic.velocity + normalize(spot - vehic.origin) * 200;
295 player.velocity_z += 10;
297 gunner.phase = time + 5;
298 gunner.vehicle_hudmodel.viewmodelforclient = gunner;
300 MUTATOR_CALLHOOK(VehicleExit, player, gunner);
302 player.vehicle = world;
305 bool bumblebee_gunner_enter()
308 entity player = other;
309 entity gunner = world;
311 if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2)
313 // we can have some fun
314 if(vlen(real_origin(vehic.gun2) - player.origin) < vlen(real_origin(vehic.gun1) - player.origin))
317 vehic.gunner2 = player;
322 vehic.gunner1 = player;
325 else if(!vehic.gunner1 && time >= vehic.gun1.phase) { gunner = vehic.gun1; vehic.gunner1 = player; }
326 else if(!vehic.gunner2 && time >= vehic.gun2.phase) { gunner = vehic.gun2; vehic.gunner2 = player; }
327 else { LOG_TRACE("Vehicle is full, fail\n"); return false; }
329 player.vehicle = gunner;
330 player.angles = vehic.angles;
331 player.takedamage = DAMAGE_NO;
332 player.solid = SOLID_NOT;
334 player.movetype = MOVETYPE_NOCLIP;
335 player.event_damage = func_null;
336 player.view_ofs = '0 0 0';
337 player.hud = gunner.hud;
338 player.teleportable = false;
339 player.PlayerPhysplug = gunner.PlayerPhysplug;
340 player.vehicle_ammo1 = vehic.vehicle_ammo1;
341 player.vehicle_ammo2 = vehic.vehicle_ammo2;
342 player.vehicle_reload1 = vehic.vehicle_reload1;
343 player.vehicle_reload2 = vehic.vehicle_reload2;
344 player.vehicle_energy = vehic.vehicle_energy;
345 player.flags &= ~FL_ONGROUND;
347 RemoveGrapplingHook(player);
349 gunner.switchweapon = player.switchweapon;
350 gunner.vehicle_exit = bumblebee_gunner_exit;
351 gunner.vehicle_hudmodel.viewmodelforclient = player;
353 if(IS_REAL_CLIENT(player))
356 WriteByte(MSG_ONE, SVC_SETVIEWPORT);
357 WriteEntity(MSG_ONE, gunner.vehicle_viewport);
359 WriteByte(MSG_ONE, SVC_SETVIEWANGLES);
360 WriteAngle(MSG_ONE, gunner.angles_x + vehic.angles_x); // tilt
361 WriteAngle(MSG_ONE, gunner.angles_y + vehic.angles_y); // yaw
362 WriteAngle(MSG_ONE, 0); // roll
365 CSQCVehicleSetup(player, player.hud);
367 MUTATOR_CALLHOOK(VehicleEnter, player, gunner);
372 bool vehicles_valid_pilot()
374 if(IS_BOT_CLIENT(other) && !autocvar_g_vehicles_allow_bots)
377 if((!IS_PLAYER(other))
378 || (other.deadflag != DEAD_NO)
380 || (DIFF_TEAM(other, self))
386 void bumblebee_touch()
388 if(autocvar_g_vehicles_enter) { return; }
390 if(self.gunner1 != world && self.gunner2 != world)
396 if(vehicles_valid_pilot())
398 float phase_time = (time >= self.gun1.phase) + (time >= self.gun2.phase);
400 if(time >= other.vehicle_enter_delay && phase_time)
401 if(bumblebee_gunner_enter())
408 void bumblebee_regen()
410 if(self.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
411 self.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
412 self.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
414 if(self.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
415 self.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
416 self.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
418 if(self.vehicle_flags & VHF_SHIELDREGEN)
419 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);
421 if(self.vehicle_flags & VHF_HEALTHREGEN)
422 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);
424 if(self.vehicle_flags & VHF_ENERGYREGEN)
425 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);
429 float bumblebee_pilot_frame()
434 if(intermission_running)
436 self.vehicle.velocity = '0 0 0';
437 self.vehicle.avelocity = '0 0 0';
442 vehic = self.vehicle;
445 if(vehic.deadflag != DEAD_NO)
448 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = 0;
454 crosshair_trace(pilot);
460 newvel = vectoangles(normalize(trace_endpos - self.origin + '0 0 32'));
463 if(newvel.x > 180) newvel.x -= 360;
464 if(newvel.x < -180) newvel.x += 360;
465 if(newvel.y > 180) newvel.y -= 360;
466 if(newvel.y < -180) newvel.y += 360;
468 ftmp = shortangle_f(pilot.v_angle.y - vang.y, vang.y);
469 if(ftmp > 180) ftmp -= 360;
470 if(ftmp < -180) ftmp += 360;
471 vehic.avelocity_y = bound(-autocvar_g_vehicle_bumblebee_turnspeed, ftmp + vehic.avelocity.y * 0.9, autocvar_g_vehicle_bumblebee_turnspeed);
475 if(pilot.movement.x > 0 && vang.x < autocvar_g_vehicle_bumblebee_pitchlimit)
477 else if(pilot.movement.x < 0 && vang.x > -autocvar_g_vehicle_bumblebee_pitchlimit)
480 newvel.x = bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x , autocvar_g_vehicle_bumblebee_pitchlimit);
481 ftmp = vang.x - bound(-autocvar_g_vehicle_bumblebee_pitchlimit, newvel.x + ftmp, autocvar_g_vehicle_bumblebee_pitchlimit);
482 vehic.avelocity_x = bound(-autocvar_g_vehicle_bumblebee_pitchspeed, ftmp + vehic.avelocity.x * 0.9, autocvar_g_vehicle_bumblebee_pitchspeed);
484 vehic.angles_x = anglemods(vehic.angles.x);
485 vehic.angles_y = anglemods(vehic.angles.y);
486 vehic.angles_z = anglemods(vehic.angles.z);
488 makevectors('0 1 0' * vehic.angles.y);
489 newvel = vehic.velocity * -autocvar_g_vehicle_bumblebee_friction;
491 if(pilot.movement.x != 0)
493 if(pilot.movement.x > 0)
494 newvel += v_forward * autocvar_g_vehicle_bumblebee_speed_forward;
495 else if(pilot.movement.x < 0)
496 newvel -= v_forward * autocvar_g_vehicle_bumblebee_speed_forward;
499 if(pilot.movement.y != 0)
501 if(pilot.movement.y < 0)
502 newvel -= v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
503 else if(pilot.movement.y > 0)
504 newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
505 ftmp = newvel * v_right;
506 ftmp *= frametime * 0.1;
507 vehic.angles_z = bound(-15, vehic.angles.z + ftmp, 15);
511 vehic.angles_z *= 0.95;
512 if(vehic.angles.z >= -1 && vehic.angles.z <= -1)
516 if(pilot.BUTTON_CROUCH)
517 newvel -= v_up * autocvar_g_vehicle_bumblebee_speed_down;
518 else if(pilot.BUTTON_JUMP)
519 newvel += v_up * autocvar_g_vehicle_bumblebee_speed_up;
521 vehic.velocity += newvel * frametime;
522 pilot.velocity = pilot.movement = vehic.velocity;
525 if(autocvar_g_vehicle_bumblebee_healgun_locktime)
527 if(vehic.tur_head.lock_time < time || vehic.tur_head.enemy.deadflag)
528 vehic.tur_head.enemy = world;
531 if(trace_ent.movetype)
532 if(trace_ent.takedamage)
533 if(!trace_ent.deadflag)
537 if(trace_ent.team == pilot.team)
539 vehic.tur_head.enemy = trace_ent;
540 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
545 vehic.tur_head.enemy = trace_ent;
546 vehic.tur_head.lock_time = time + autocvar_g_vehicle_bumblebee_healgun_locktime;
550 if(vehic.tur_head.enemy)
552 trace_endpos = real_origin(vehic.tur_head.enemy);
553 UpdateAuxiliaryXhair(pilot, trace_endpos, '0 0.75 0', 0);
557 vang = vehicle_aimturret(vehic, trace_endpos, self.gun3, "fire",
558 autocvar_g_vehicle_bumblebee_raygun_pitchlimit_down * -1, autocvar_g_vehicle_bumblebee_raygun_pitchlimit_up,
559 autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1, autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides, autocvar_g_vehicle_bumblebee_raygun_turnspeed);
561 if(!forbidWeaponUse(pilot))
562 if((pilot.BUTTON_ATCK || pilot.BUTTON_ATCK2) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
564 vehic.gun3.enemy.realowner = pilot;
565 vehic.gun3.enemy.effects &= ~EF_NODRAW;
567 vehic.gun3.enemy.hook_start = gettaginfo(vehic.gun3, gettagindex(vehic.gun3, "fire"));
568 vehic.gun3.enemy.SendFlags |= BRG_START;
570 traceline(vehic.gun3.enemy.hook_start, vehic.gun3.enemy.hook_start + v_forward * autocvar_g_vehicle_bumblebee_raygun_range, MOVE_NORMAL, vehic);
574 if(autocvar_g_vehicle_bumblebee_raygun)
576 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);
577 vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
581 if(trace_ent.deadflag == DEAD_NO)
582 if((teamplay && trace_ent.team == pilot.team) || !teamplay)
585 if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
587 if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.max_health)
588 trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.max_health);
590 if(autocvar_g_vehicle_bumblebee_healgun_hps)
591 trace_ent.vehicle_health = min(trace_ent.vehicle_health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
593 else if(IS_CLIENT(trace_ent))
595 if(trace_ent.health <= autocvar_g_vehicle_bumblebee_healgun_hmax && autocvar_g_vehicle_bumblebee_healgun_hps)
596 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
598 if(trace_ent.armorvalue <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
599 trace_ent.armorvalue = min(trace_ent.armorvalue + autocvar_g_vehicle_bumblebee_healgun_aps * frametime, autocvar_g_vehicle_bumblebee_healgun_amax);
601 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
603 else if(IS_TURRET(trace_ent))
605 if(trace_ent.health <= trace_ent.max_health && autocvar_g_vehicle_bumblebee_healgun_hps)
606 trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
607 //else ..hmmm what? ammo?
609 trace_ent.SendFlags |= TNSF_STATUS;
615 vehic.gun3.enemy.hook_end = trace_endpos;
616 setorigin(vehic.gun3.enemy, trace_endpos);
617 vehic.gun3.enemy.SendFlags |= BRG_END;
619 vehic.wait = time + 1;
622 vehic.gun3.enemy.effects |= EF_NODRAW;
625 remove(vehic.gun3.enemy);
627 vehic.gun3.enemy = world;
631 VEHICLE_UPDATE_PLAYER(pilot, health, bumblebee);
632 VEHICLE_UPDATE_PLAYER(pilot, energy, bumblebee);
634 pilot.vehicle_ammo1 = (vehic.gun1.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
635 pilot.vehicle_ammo2 = (vehic.gun2.vehicle_energy / autocvar_g_vehicle_bumblebee_cannon_ammo) * 100;
637 if(vehic.vehicle_flags & VHF_HASSHIELD)
638 VEHICLE_UPDATE_PLAYER(pilot, shield, bumblebee);
640 vehic.angles_x *= -1;
641 makevectors(vehic.angles);
642 vehic.angles_x *= -1;
643 setorigin(pilot, vehic.origin + v_up * 48 + v_forward * 160);
645 pilot.BUTTON_ATCK = pilot.BUTTON_ATCK2 = pilot.BUTTON_CROUCH = 0;
651 void bumblebee_land()
655 hgt = raptor_altitude(512);
656 self.velocity = (self.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
657 self.angles_x *= 0.95;
658 self.angles_z *= 0.95;
661 self.think = vehicles_think;
663 self.nextthink = time;
665 CSQCMODEL_AUTOUPDATE(self);
668 void bumblebee_exit(float eject)
670 if(self.owner.vehicleid == VEH_BUMBLEBEE.vehicleid)
672 bumblebee_gunner_exit(eject);
676 self.touch = vehicles_touch;
678 if(self.deadflag == DEAD_NO)
680 self.think = bumblebee_land;
681 self.nextthink = time;
684 self.movetype = MOVETYPE_TOSS;
689 fixedmakevectors(self.angles);
691 if(vlen(self.velocity) > autocvar_g_vehicle_bumblebee_speed_forward * 0.5)
692 spot = self.origin + v_up * 128 + v_forward * 300;
694 spot = self.origin + v_up * 128 - v_forward * 300;
696 spot = vehicles_findgoodexit(spot);
699 if(self.gun3.enemy || !wasfreed(self.gun3.enemy)) {
700 self.gun3.enemy.effects |= EF_NODRAW;
703 self.owner.velocity = 0.75 * self.vehicle.velocity + normalize(spot - self.vehicle.origin) * 200;
704 self.owner.velocity_z += 10;
705 setorigin(self.owner, spot);
707 antilag_clear(self.owner);
711 void bumblebee_blowup()
713 RadiusDamage(self, self.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
714 autocvar_g_vehicle_bumblebee_blowup_edgedamage,
715 autocvar_g_vehicle_bumblebee_blowup_radius, self, world,
716 autocvar_g_vehicle_bumblebee_blowup_forceintensity,
717 DEATH_VH_BUMB_DEATH, world);
719 sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
720 Send_Effect(EFFECT_EXPLOSION_BIG, (self.origin + '0 0 100') + (randomvec() * 80), '0 0 0', 1);
722 if(self.owner.deadflag == DEAD_DYING)
723 self.owner.deadflag = DEAD_DEAD;
728 void bumblebee_diethink()
730 if(time >= self.wait)
731 self.think = bumblebee_blowup;
735 sound(self, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
736 Send_Effect(EFFECT_EXPLOSION_SMALL, randomvec() * 80 + (self.origin + '0 0 100'), '0 0 0', 1);
739 self.nextthink = time + 0.1;
742 float bumble_raygun_send(entity to, float sf)
744 WriteByte(MSG_ENTITY, ENT_CLIENT_BUMBLE_RAYGUN);
746 WriteByte(MSG_ENTITY, sf);
749 WriteByte(MSG_ENTITY, num_for_edict(self.realowner));
750 WriteByte(MSG_ENTITY, self.realowner.team);
751 WriteByte(MSG_ENTITY, self.cnt);
756 WriteCoord(MSG_ENTITY, self.hook_start_x);
757 WriteCoord(MSG_ENTITY, self.hook_start_y);
758 WriteCoord(MSG_ENTITY, self.hook_start_z);
763 WriteCoord(MSG_ENTITY, self.hook_end_x);
764 WriteCoord(MSG_ENTITY, self.hook_end_y);
765 WriteCoord(MSG_ENTITY, self.hook_end_z);
771 void spawnfunc_vehicle_bumblebee()
773 if(!autocvar_g_vehicle_bumblebee) { remove(self); return; }
774 if(!vehicle_initialize(VEH_BUMBLEBEE, false)) { remove(self); return; }
777 float v_bumblebee(Vehicle thisveh, float req)
783 if(autocvar_g_vehicle_bumblebee_bouncepain)
784 vehicles_impact(autocvar_g_vehicle_bumblebee_bouncepain_x, autocvar_g_vehicle_bumblebee_bouncepain_y, autocvar_g_vehicle_bumblebee_bouncepain_z);
790 self.touch = bumblebee_touch;
792 self.movetype = MOVETYPE_BOUNCEMISSILE;
797 self.angles_z *= 0.8;
798 self.angles_x *= 0.8;
800 self.nextthink = time;
804 entity oldself = self;
807 setself(self.gunner1);
808 oldself.gun1.vehicle_exit(VHEF_EJECT);
809 entity oldother = other;
820 setself(self.gunner2);
821 oldself.gun2.vehicle_exit(VHEF_EJECT);
822 entity oldother = other;
836 entity oldself = self;
838 CSQCModel_UnlinkEntity();
841 if(self.gun3.enemy || !wasfreed(self.gun3.enemy))
842 self.gun3.enemy.effects |= EF_NODRAW;
846 setself(self.gunner1);
847 oldself.gun1.vehicle_exit(VHEF_EJECT);
853 setself(self.gunner2);
854 oldself.gun2.vehicle_exit(VHEF_EJECT);
858 self.vehicle_exit(VHEF_EJECT);
860 fixedmakevectors(self.angles);
861 vehicle_tossgib(self.gun1, self.velocity + v_right * 300 + v_up * 100 + randomvec() * 200, "cannon_right", rint(random()), rint(random()), 6, randomvec() * 200);
862 vehicle_tossgib(self.gun2, self.velocity + v_right * -300 + v_up * 100 + randomvec() * 200, "cannon_left", rint(random()), rint(random()), 6, randomvec() * 200);
863 vehicle_tossgib(self.gun3, self.velocity + v_forward * 300 + v_up * -100 + randomvec() * 200, "raygun", rint(random()), rint(random()), 6, randomvec() * 300);
865 entity _body = vehicle_tossgib(self, self.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
868 _body.touch = bumblebee_blowup;
870 _body.touch = func_null;
872 _body.think = bumblebee_diethink;
873 _body.nextthink = time;
874 _body.wait = time + 2 + (random() * 8);
876 _body.enemy = self.enemy;
878 _body.angles = self.angles;
880 Send_Effect(EFFECT_EXPLOSION_MEDIUM, findbetterlocation(self.origin, 16), '0 0 0', 1);
883 self.event_damage = func_null;
884 self.solid = SOLID_NOT;
885 self.takedamage = DAMAGE_NO;
886 self.deadflag = DEAD_DYING;
887 self.movetype = MOVETYPE_NONE;
888 self.effects = EF_NODRAW;
889 self.colormod = '0 0 0';
890 self.avelocity = '0 0 0';
891 self.velocity = '0 0 0';
892 self.touch = func_null;
895 setorigin(self, self.pos1);
902 // for some reason, autosizing of the shield entity refuses to work for this one so set it up in advance.
903 self.vehicle_shieldent = spawn();
904 self.vehicle_shieldent.effects = EF_LOWPRECISION;
905 setmodel(self.vehicle_shieldent, MDL_VEH_BUMBLEBEE_SHIELD);
906 setattachment(self.vehicle_shieldent, self, "");
907 setorigin(self.vehicle_shieldent, real_origin(self) - self.origin);
908 self.vehicle_shieldent.scale = 512 / vlen(self.maxs - self.mins);
909 self.vehicle_shieldent.think = shieldhit_think;
910 self.vehicle_shieldent.alpha = -1;
911 self.vehicle_shieldent.effects = EF_LOWPRECISION | EF_NODRAW;
917 self.vehicle_flags |= VHF_MULTISLOT;
919 self.gun1.owner = self;
920 self.gun2.owner = self;
921 self.gun3.owner = self;
923 self.gun1.classname = self.gun2.classname = "vehicle_playerslot";
925 setmodel(self.gun1, MDL_VEH_BUMBLEBEE_CANNON_RIGHT);
926 setmodel(self.gun2, MDL_VEH_BUMBLEBEE_CANNON_LEFT);
927 setmodel(self.gun3, MDL_VEH_BUMBLEBEE_CANNON_CENTER);
929 setattachment(self.gun1, self, "cannon_right");
930 setattachment(self.gun2, self, "cannon_left");
932 // Angled bones are no fun, messes up gun-aim; so work arround it.
933 self.gun3.pos1 = self.angles;
934 self.angles = '0 0 0';
935 vector ofs = gettaginfo(self, gettagindex(self, "raygun"));
937 setattachment(self.gun3, self, "");
938 setorigin(self.gun3, ofs);
939 self.angles = self.gun3.pos1;
941 vehicle_addplayerslot(self, self.gun1, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
942 vehicle_addplayerslot(self, self.gun2, HUD_BUMBLEBEE_GUN, "models/vehicles/wakizashi_cockpit.dpm", bumblebee_gunner_frame, bumblebee_gunner_exit, bumblebee_gunner_enter);
944 setorigin(self.vehicle_hudmodel, '50 0 -5'); // Move cockpit forward - down.
945 setorigin(self.vehicle_viewport, '5 0 2'); // Move camera forward up
948 setorigin(self.gun1.vehicle_hudmodel, '90 -27 -23');
949 setorigin(self.gun1.vehicle_viewport, '-85 0 50');
951 setorigin(self.gun2.vehicle_hudmodel, '90 27 -23');
952 setorigin(self.gun2.vehicle_viewport, '-85 0 50');
957 if(self.gun3.enemy == world)
959 self.gun3.enemy = spawn();
960 Net_LinkEntity(self.gun3.enemy, true, 0, bumble_raygun_send);
961 self.gun3.enemy.SendFlags = BRG_SETUP;
962 self.gun3.enemy.cnt = autocvar_g_vehicle_bumblebee_raygun;
963 self.gun3.enemy.effects = EF_NODRAW | EF_LOWPRECISION;
967 self.vehicle_health = autocvar_g_vehicle_bumblebee_health;
968 self.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
969 self.solid = SOLID_BBOX;
970 self.movetype = MOVETYPE_TOSS;
971 self.damageforcescale = 0.025;
973 self.PlayerPhysplug = bumblebee_pilot_frame;
975 setorigin(self, self.origin + '0 0 25');
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;
1013 void CSQC_BUMBLE_GUN_HUD()
1015 Vehicles_drawHUD("vehicle_gunner", "vehicle_gunner_weapon1", string_null,
1016 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1017 string_null, '0 0 0',
1021 void bumble_raygun_draw()
1025 vector _vtmp1, _vtmp2;
1027 _len = vlen(self.origin - self.move_origin);
1028 _dir = normalize(self.move_origin - self.origin);
1030 if(self.total_damages < time)
1032 boxparticles(self.traileffect, self, self.origin, self.origin + _dir * -64, _dir * -_len , _dir * -_len, 1, PARTICLES_USEALPHA);
1033 boxparticles(self.lip, self, self.move_origin, self.move_origin + _dir * -64, _dir * -200 , _dir * -200, 1, PARTICLES_USEALPHA);
1034 self.total_damages = time + 0.1;
1037 float i, df, sz, al;
1038 for(i = -0.1; i < 0.2; i += 0.1)
1040 df = DRAWFLAG_NORMAL; //((random() < 0.5) ? DRAWFLAG_ADDITIVE : DRAWFLAG_SCREEN);
1041 sz = 5 + random() * 5;
1042 al = 0.25 + random() * 0.5;
1043 _vtmp1 = self.origin + _dir * _len * (0.25 + i);
1044 _vtmp1 += (randomvec() * (_len * 0.2) * (frametime * 2)); //self.raygun_l1;
1045 Draw_CylindricLine(self.origin, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1047 _vtmp2 = self.origin + _dir * _len * (0.5 + i);
1048 _vtmp2 += (randomvec() * (_len * 0.2) * (frametime * 5)); //self.raygun_l2;
1049 Draw_CylindricLine(_vtmp1, _vtmp2, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1051 _vtmp1 = self.origin + _dir * _len * (0.75 + i);
1052 _vtmp1 += randomvec() * (_len * 0.2) * (frametime * 10); //self.raygun_l3;
1053 Draw_CylindricLine(_vtmp2, _vtmp1, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1055 Draw_CylindricLine(_vtmp1, self.move_origin + randomvec() * 32, sz, "gfx/colors/white.tga", 1, 1, self.colormod, al, df, view_origin);
1059 void bumble_raygun_read(bool bIsNew)
1061 int sf = ReadByte();
1065 self.cnt = ReadByte();
1066 self.team = ReadByte();
1067 self.cnt = ReadByte();
1070 self.colormod = '1 0 0';
1072 self.colormod = '0 1 0';
1074 self.traileffect = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_MUZZLEFLASH);
1075 self.lip = particleeffectnum(EFFECT_BUMBLEBEE_HEAL_IMPACT);
1077 self.draw = bumble_raygun_draw;
1083 self.origin_x = ReadCoord();
1084 self.origin_y = ReadCoord();
1085 self.origin_z = ReadCoord();
1086 setorigin(self, self.origin);
1091 self.move_origin_x = ReadCoord();
1092 self.move_origin_y = ReadCoord();
1093 self.move_origin_z = ReadCoord();
1097 float v_bumblebee(Vehicle thisveh, float req)
1103 Vehicles_drawHUD(VEH_BUMBLEBEE.m_icon, "vehicle_bumble_weapon1", "vehicle_bumble_weapon2",
1104 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1105 "vehicle_icon_ammo1", autocvar_hud_progressbar_vehicles_ammo1_color,
1111 AuxiliaryXhair[0].axh_image = vCROSS_LOCK; // Raygun-locked
1112 AuxiliaryXhair[1].axh_image = vCROSS_BURST; // Gunner1
1113 AuxiliaryXhair[2].axh_image = vCROSS_BURST; // Gunner2
1126 #endif // REGISTER_VEHICLE