-#ifndef VEHICLE_BUMBLEBEE
-#define VEHICLE_BUMBLEBEE
#include "bumblebee.qh"
-#include "bumblebee_weapons.qh"
-
-CLASS(Bumblebee, Vehicle)
-/* spawnflags */ ATTRIB(Bumblebee, spawnflags, int, VHF_DMGSHAKE);
-/* mins */ ATTRIB(Bumblebee, mins, vector, '-245 -130 -130');
-/* maxs */ ATTRIB(Bumblebee, maxs, vector, '230 130 130');
-/* view offset*/ ATTRIB(Bumblebee, view_ofs, vector, '0 0 300');
-/* view dist */ ATTRIB(Bumblebee, height, float, 450);
-/* model */ ATTRIB(Bumblebee, mdl, string, "models/vehicles/bumblebee_body.dpm");
-/* model */ ATTRIB(Bumblebee, model, string, "models/vehicles/bumblebee_body.dpm");
-/* head_model */ ATTRIB(Bumblebee, head_model, string, "");
-/* hud_model */ ATTRIB(Bumblebee, hud_model, string, "models/vehicles/spiderbot_cockpit.dpm");
-/* tags */ ATTRIB(Bumblebee, tag_head, string, "");
-/* tags */ ATTRIB(Bumblebee, tag_hud, string, "");
-/* tags */ ATTRIB(Bumblebee, tag_view, string, "tag_viewport");
-/* netname */ ATTRIB(Bumblebee, netname, string, "bumblebee");
-/* fullname */ ATTRIB(Bumblebee, vehicle_name, string, _("Bumblebee"));
-/* icon */ ATTRIB(Bumblebee, m_icon, string, "vehicle_bumble");
-ENDCLASS(Bumblebee)
-REGISTER_VEHICLE(BUMBLEBEE, NEW(Bumblebee));
-
-#ifndef MENUQC
- MODEL(VEH_BUMBLEBEE_GUNCOCKPIT, "models/vehicles/wakizashi_cockpit.dpm");
-#endif
-
-#endif
-
#ifdef IMPLEMENTATION
const float BRG_SETUP = 2;
float autocvar_g_vehicle_bumblebee_pitchspeed = 60;
float autocvar_g_vehicle_bumblebee_pitchlimit = 60;
float autocvar_g_vehicle_bumblebee_friction = 0.5;
+bool autocvar_g_vehicle_bumblebee_swim = false;
float autocvar_g_vehicle_bumblebee_energy = 500;
float autocvar_g_vehicle_bumblebee_energy_regen = 50;
bool autocvar_g_vehicle_bumblebee = true;
-bool bumblebee_gunner_frame(entity this)
+bool bumblebee_gunner_frame(entity this, float dt)
{
entity vehic = this.vehicle.owner;
entity gun = this.vehicle;
if(autocvar_g_vehicle_bumblebee_cannon_lock)
{
if(gun.lock_time < time)
- gun.enemy = world;
+ gun.enemy = NULL;
if(trace_ent)
- if(trace_ent.movetype)
+ if(trace_ent.move_movetype)
if(trace_ent.takedamage)
if(!IS_DEAD(trace_ent) && !STAT(FROZEN, trace_ent))
{
vector vf = real_origin(gun.enemy);
vector _vel = gun.enemy.velocity;
- if(gun.enemy.movetype == MOVETYPE_WALK)
+ if(gun.enemy.move_movetype == MOVETYPE_WALK)
_vel.z *= 0.1;
void bumblebee_gunner_exit(entity this, int _exitflag)
{
- entity player = this;
- entity gunner = player.vehicle;
+ entity player = ((this.owner.gun1 == this) ? this.owner.gunner1 : this.owner.gunner2);
+ entity gunner = this;
entity vehic = gunner.owner;
if(IS_REAL_CLIENT(player))
player.takedamage = DAMAGE_AIM;
player.solid = SOLID_SLIDEBOX;
- player.movetype = MOVETYPE_WALK;
+ set_movetype(player, MOVETYPE_WALK);
player.effects &= ~EF_NODRAW;
player.alpha = 1;
player.PlayerPhysplug = func_null;
fixedmakevectors(vehic.angles);
- if(player == vehic.gunner1) { vehic.gunner1 = world; }
- if(player == vehic.gunner2) { vehic.gunner2 = world; v_right *= -1; }
+ if(player == vehic.gunner1) { vehic.gunner1 = NULL; }
+ if(player == vehic.gunner2) { vehic.gunner2 = NULL; v_right *= -1; }
vector spot = real_origin(gunner);
spot = spot + v_up * 128 + v_forward * 300 + v_right * 150;
MUTATOR_CALLHOOK(VehicleExit, player, gunner);
- player.vehicle = world;
+ player.vehicle = NULL;
}
bool bumblebee_gunner_enter(entity this, entity player)
{
entity vehic = this;
- entity gunner = world;
+ entity gunner = NULL;
if(!vehic.gunner1 && !vehic.gunner2 && ((time >= vehic.gun1.phase) + (time >= vehic.gun2.phase)) == 2)
{
// we can have some fun
- if(vlen2(real_origin(vehic.gun2) - player.origin) < vlen2(real_origin(vehic.gun1) - player.origin))
+ vector v1 = gettaginfo(vehic, gettagindex(vehic, "cannon_right"));
+ vector v2 = gettaginfo(vehic, gettagindex(vehic, "cannon_left"));
+ if(vlen2(player.origin - v1) < vlen2(player.origin - v2))
{
- gunner = vehic.gun2;
- vehic.gunner2 = player;
+ gunner = vehic.gun1;
+ vehic.gunner1 = player;
}
else
{
- gunner = vehic.gun1;
- vehic.gunner1 = player;
+ gunner = vehic.gun2;
+ vehic.gunner2 = player;
}
}
else if(!vehic.gunner1 && time >= vehic.gun1.phase) { gunner = vehic.gun1; vehic.gunner1 = player; }
else if(!vehic.gunner2 && time >= vehic.gun2.phase) { gunner = vehic.gun2; vehic.gunner2 = player; }
- else { LOG_TRACE("Vehicle is full, fail\n"); return false; }
+ else { LOG_TRACE("Vehicle is full, fail"); return false; }
player.vehicle = gunner;
player.angles = vehic.angles;
player.takedamage = DAMAGE_NO;
player.solid = SOLID_NOT;
player.alpha = -1;
- player.movetype = MOVETYPE_NOCLIP;
+ set_movetype(player, MOVETYPE_NOCLIP);
player.event_damage = func_null;
player.view_ofs = '0 0 0';
player.hud = gunner.hud;
player.vehicle_reload1 = vehic.vehicle_reload1;
player.vehicle_reload2 = vehic.vehicle_reload2;
player.vehicle_energy = vehic.vehicle_energy;
- player.flags &= ~FL_ONGROUND;
+ UNSET_ONGROUND(player);
RemoveGrapplingHook(player);
return true;
}
-void bumblebee_touch(entity this)
+void bumblebee_touch(entity this, entity toucher)
{
if(autocvar_g_vehicles_enter) { return; }
- if(this.gunner1 != world && this.gunner2 != world)
+ if(this.gunner1 != NULL && this.gunner2 != NULL)
{
- vehicles_touch(this);
+ vehicles_touch(this, toucher);
return;
}
- if(vehicles_valid_pilot(this, other))
+ if(vehicles_valid_pilot(this, toucher))
{
float phase_time = (time >= this.gun1.phase) + (time >= this.gun2.phase);
- if(time >= other.vehicle_enter_delay && phase_time)
- if(bumblebee_gunner_enter(this, other))
+ if(time >= toucher.vehicle_enter_delay && phase_time)
+ if(bumblebee_gunner_enter(this, toucher))
return;
}
- vehicles_touch(this);
+ vehicles_touch(this, toucher);
}
-void bumblebee_regen(entity this)
+void bumblebee_regen(entity this, float dt)
{
if(this.gun1.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
this.gun1.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
- this.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
+ this.gun1.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * dt);
if(this.gun2.delay + autocvar_g_vehicle_bumblebee_cannon_ammo_regen_pause < time)
this.gun2.vehicle_energy = min(autocvar_g_vehicle_bumblebee_cannon_ammo,
- this.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * frametime);
+ this.gun2.vehicle_energy + autocvar_g_vehicle_bumblebee_cannon_ammo_regen * dt);
if(this.vehicle_flags & VHF_SHIELDREGEN)
- vehicles_regen(this, this.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, frametime, true);
+ vehicles_regen(this, this.dmg_time, vehicle_shield, autocvar_g_vehicle_bumblebee_shield, autocvar_g_vehicle_bumblebee_shield_regen_pause, autocvar_g_vehicle_bumblebee_shield_regen, dt, true);
if(this.vehicle_flags & VHF_HEALTHREGEN)
- vehicles_regen(this, this.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, frametime, false);
+ vehicles_regen(this, this.dmg_time, vehicle_health, autocvar_g_vehicle_bumblebee_health, autocvar_g_vehicle_bumblebee_health_regen_pause, autocvar_g_vehicle_bumblebee_health_regen, dt, false);
if(this.vehicle_flags & VHF_ENERGYREGEN)
- vehicles_regen(this, this.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, frametime, false);
+ vehicles_regen(this, this.wait, vehicle_energy, autocvar_g_vehicle_bumblebee_energy, autocvar_g_vehicle_bumblebee_energy_regen_pause, autocvar_g_vehicle_bumblebee_energy_regen, dt, false);
}
-bool bumblebee_pilot_frame(entity this)
+bool bumblebee_pilot_frame(entity this, float dt)
{
entity vehic = this.vehicle;
return = true;
return;
}
- bumblebee_regen(vehic);
+ bumblebee_regen(vehic, dt);
crosshair_trace(this);
else if(this.movement.y > 0)
newvel += v_right * autocvar_g_vehicle_bumblebee_speed_strafe;
ftmp = newvel * v_right;
- ftmp *= frametime * 0.1;
+ ftmp *= dt * 0.1;
vehic.angles_z = bound(-15, vehic.angles.z + ftmp, 15);
}
else
else if(PHYS_INPUT_BUTTON_JUMP(this))
newvel += v_up * autocvar_g_vehicle_bumblebee_speed_up;
- vehic.velocity += newvel * frametime;
+ vehic.velocity += newvel * dt;
this.velocity = this.movement = vehic.velocity;
if(autocvar_g_vehicle_bumblebee_healgun_locktime)
{
if(vehic.tur_head.lock_time < time || IS_DEAD(vehic.tur_head.enemy) || STAT(FROZEN, vehic.tur_head.enemy))
- vehic.tur_head.enemy = world;
+ vehic.tur_head.enemy = NULL;
if(trace_ent)
- if(trace_ent.movetype)
+ if(trace_ent.move_movetype)
if(trace_ent.takedamage)
if(!IS_DEAD(trace_ent) && !STAT(FROZEN, trace_ent))
{
autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides * -1, autocvar_g_vehicle_bumblebee_raygun_turnlimit_sides, autocvar_g_vehicle_bumblebee_raygun_turnspeed);
if(!forbidWeaponUse(this))
- if((PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this)) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime || autocvar_g_vehicle_bumblebee_raygun == 0))
+ if((PHYS_INPUT_BUTTON_ATCK(this) || PHYS_INPUT_BUTTON_ATCK2(this)) && (vehic.vehicle_energy > autocvar_g_vehicle_bumblebee_raygun_dps * PHYS_INPUT_FRAMETIME || autocvar_g_vehicle_bumblebee_raygun == 0))
{
vehic.gun3.enemy.realowner = this;
vehic.gun3.enemy.effects &= ~EF_NODRAW;
{
if(autocvar_g_vehicle_bumblebee_raygun)
{
- Damage(trace_ent, vehic, this, autocvar_g_vehicle_bumblebee_raygun_dps * sys_frametime, DEATH_GENERIC.m_id, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * sys_frametime);
- vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * sys_frametime;
+ Damage(trace_ent, vehic, this, autocvar_g_vehicle_bumblebee_raygun_dps * PHYS_INPUT_FRAMETIME, DEATH_GENERIC.m_id, trace_endpos, v_forward * autocvar_g_vehicle_bumblebee_raygun_fps * PHYS_INPUT_FRAMETIME);
+ vehic.vehicle_energy -= autocvar_g_vehicle_bumblebee_raygun_aps * PHYS_INPUT_FRAMETIME;
}
else
{
if((teamplay && trace_ent.team == this.team) || !teamplay)
{
- if(trace_ent.vehicle_flags & VHF_ISVEHICLE)
+ if(IS_VEHICLE(trace_ent))
{
if(autocvar_g_vehicle_bumblebee_healgun_sps && trace_ent.vehicle_health <= trace_ent.max_health)
- trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * frametime, trace_ent.tur_head.max_health);
+ trace_ent.vehicle_shield = min(trace_ent.vehicle_shield + autocvar_g_vehicle_bumblebee_healgun_sps * dt, trace_ent.tur_head.max_health);
if(autocvar_g_vehicle_bumblebee_healgun_hps)
- trace_ent.vehicle_health = min(trace_ent.vehicle_health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
+ trace_ent.vehicle_health = min(trace_ent.vehicle_health + autocvar_g_vehicle_bumblebee_healgun_hps * dt, trace_ent.max_health);
}
else if(IS_CLIENT(trace_ent))
{
if(trace_ent.health <= autocvar_g_vehicle_bumblebee_healgun_hmax && autocvar_g_vehicle_bumblebee_healgun_hps)
- trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
+ trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * dt, autocvar_g_vehicle_bumblebee_healgun_hmax);
if(trace_ent.armorvalue <= autocvar_g_vehicle_bumblebee_healgun_amax && autocvar_g_vehicle_bumblebee_healgun_aps)
- trace_ent.armorvalue = min(trace_ent.armorvalue + autocvar_g_vehicle_bumblebee_healgun_aps * frametime, autocvar_g_vehicle_bumblebee_healgun_amax);
+ trace_ent.armorvalue = min(trace_ent.armorvalue + autocvar_g_vehicle_bumblebee_healgun_aps * dt, autocvar_g_vehicle_bumblebee_healgun_amax);
- trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, autocvar_g_vehicle_bumblebee_healgun_hmax);
+ trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * dt, autocvar_g_vehicle_bumblebee_healgun_hmax);
}
else if(IS_TURRET(trace_ent))
{
if(trace_ent.health <= trace_ent.max_health && autocvar_g_vehicle_bumblebee_healgun_hps)
- trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * frametime, trace_ent.max_health);
+ trace_ent.health = min(trace_ent.health + autocvar_g_vehicle_bumblebee_healgun_hps * dt, trace_ent.max_health);
//else ..hmmm what? ammo?
trace_ent.SendFlags |= TNSF_STATUS;
if(vehic.gun3.enemy)
remove(vehic.gun3.enemy);
- vehic.gun3.enemy = world;
+ vehic.gun3.enemy = NULL;
}
*/
{
float hgt;
- hgt = raptor_altitude(this, 512);
- this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime);
+ hgt = vehicle_altitude(this, 512);
+ this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * PHYS_INPUT_FRAMETIME);
this.angles_x *= 0.95;
this.angles_z *= 0.95;
this.nextthink = time;
}
- this.movetype = MOVETYPE_TOSS;
+ set_movetype(this, MOVETYPE_TOSS);
if(!this.owner)
return;
setorigin(this.owner, spot);
antilag_clear(this.owner, CS(this.owner));
- this.owner = world;
+ this.owner = NULL;
}
void bumblebee_blowup(entity this)
{
RadiusDamage(this, this.enemy, autocvar_g_vehicle_bumblebee_blowup_coredamage,
autocvar_g_vehicle_bumblebee_blowup_edgedamage,
- autocvar_g_vehicle_bumblebee_blowup_radius, this, world,
+ autocvar_g_vehicle_bumblebee_blowup_radius, this, NULL,
autocvar_g_vehicle_bumblebee_blowup_forceintensity,
- DEATH_VH_BUMB_DEATH.m_id, world);
+ DEATH_VH_BUMB_DEATH.m_id, NULL);
sound(this, CH_SHOTS, SND_ROCKET_IMPACT, VOL_BASE, ATTEN_NORM);
Send_Effect(EFFECT_EXPLOSION_BIG, (this.origin + '0 0 100') + (randomvec() * 80), '0 0 0', 1);
if(this.owner.deadflag == DEAD_DYING)
this.owner.deadflag = DEAD_DEAD;
- remove(this);
+ delete(this);
+}
+
+void bumblebee_dead_touch(entity this, entity toucher)
+{
+ bumblebee_blowup(this);
}
void bumblebee_diethink(entity this)
spawnfunc(vehicle_bumblebee)
{
- if(!autocvar_g_vehicle_bumblebee) { remove(this); return; }
- if(!vehicle_initialize(this, VEH_BUMBLEBEE, false)) { remove(this); return; }
+ if(!autocvar_g_vehicle_bumblebee) { delete(this); return; }
+ if(!vehicle_initialize(this, VEH_BUMBLEBEE, false)) { delete(this); return; }
}
METHOD(Bumblebee, vr_impact, void(Bumblebee thisveh, entity instance))
{
settouch(instance, bumblebee_touch);
instance.nextthink = 0;
- instance.movetype = MOVETYPE_BOUNCEMISSILE;
+ set_movetype(instance, MOVETYPE_BOUNCEMISSILE);
+}
+METHOD(Bumblebee, vr_gunner_enter, void(Bumblebee thisveh, entity instance, entity actor))
+{
+ if(!instance.gunner1)
+ if(time >= instance.gun1.phase)
+ if(instance.gun1.vehicle_enter)
+ if(instance.gun1.vehicle_enter(instance, actor))
+ return;
+
+ if(!instance.gunner2)
+ if(time >= instance.gun2.phase)
+ if(instance.gun2.vehicle_enter)
+ if(instance.gun2.vehicle_enter(instance, actor))
+ return;
}
METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance))
{
if(instance.gunner1)
{
entity e = instance.gunner1;
- instance.gun1.vehicle_exit(e, VHEF_EJECT);
- entity oldother = other;
- other = e;
+ instance.gun1.vehicle_exit(instance.gun1, VHEF_EJECT);
instance.phase = 0;
- gettouch(instance)(instance);
- other = oldother;
+ gettouch(instance)(instance, e);
return;
}
if(instance.gunner2)
{
entity e = instance.gunner2;
- instance.gun2.vehicle_exit(e, VHEF_EJECT);
- entity oldother = other;
- other = e;
+ instance.gun2.vehicle_exit(instance.gun2, VHEF_EJECT);
instance.phase = 0;
- gettouch(instance)(instance);
- other = oldother;
+ gettouch(instance)(instance, e);
return;
}
}
instance.gun3.enemy.effects |= EF_NODRAW;
if(instance.gunner1)
- instance.gun1.vehicle_exit(instance.gunner1, VHEF_EJECT);
+ instance.gun1.vehicle_exit(instance.gun1, VHEF_EJECT);
if(instance.gunner2)
- instance.gun2.vehicle_exit(instance.gunner2, VHEF_EJECT);
+ instance.gun2.vehicle_exit(instance.gun2, VHEF_EJECT);
instance.vehicle_exit(instance, VHEF_EJECT);
entity _body = vehicle_tossgib(instance, instance, instance.velocity + randomvec() * 200, "", rint(random()), rint(random()), 6, randomvec() * 100);
if(random() > 0.5)
- settouch(_body, bumblebee_blowup);
+ settouch(_body, bumblebee_dead_touch);
else
settouch(_body, func_null);
instance.solid = SOLID_NOT;
instance.takedamage = DAMAGE_NO;
instance.deadflag = DEAD_DYING;
- instance.movetype = MOVETYPE_NONE;
+ set_movetype(instance, MOVETYPE_NONE);
instance.effects = EF_NODRAW;
instance.colormod = '0 0 0';
instance.avelocity = '0 0 0';
instance.scale = 1.5;
// Raygun beam
- if(instance.gun3.enemy == world)
+ if(instance.gun3.enemy == NULL)
{
instance.gun3.enemy = spawn();
Net_LinkEntity(instance.gun3.enemy, true, 0, bumble_raygun_send);
}
}
+ if(!autocvar_g_vehicle_bumblebee_swim)
+ instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK;
+
instance.vehicle_health = autocvar_g_vehicle_bumblebee_health;
instance.vehicle_shield = autocvar_g_vehicle_bumblebee_shield;
instance.solid = SOLID_BBOX;
- instance.movetype = MOVETYPE_TOSS;
+ set_movetype(instance, MOVETYPE_TOSS);
instance.damageforcescale = 0.025;
instance.PlayerPhysplug = bumblebee_pilot_frame;