X-Git-Url: https://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fvehicles%2Fvehicle%2Fbumblebee.qc;h=3f5f40435819d6de9b7f748eeb7724af411623c6;hb=8a8b1cd92c5071bca66242c7cc75c7756a28fbdc;hp=2750621f2c5e427b11fc152ff01ad59e33ceca7a;hpb=281f8a0e6e5e8f49bda72eeeb864da2c0fa727f2;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/vehicles/vehicle/bumblebee.qc b/qcsrc/common/vehicles/vehicle/bumblebee.qc index 2750621f2c..3f5f404358 100644 --- a/qcsrc/common/vehicles/vehicle/bumblebee.qc +++ b/qcsrc/common/vehicles/vehicle/bumblebee.qc @@ -1,34 +1,5 @@ -#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; @@ -46,6 +17,7 @@ float autocvar_g_vehicle_bumblebee_turnspeed = 120; 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; @@ -98,7 +70,7 @@ vector autocvar_g_vehicle_bumblebee_bouncepain = '1 100 200'; 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; @@ -138,7 +110,7 @@ bool bumblebee_gunner_frame(entity this) 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)) { @@ -156,7 +128,7 @@ bool bumblebee_gunner_frame(entity this) 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; @@ -256,7 +228,7 @@ void bumblebee_gunner_exit(entity this, int _exitflag) 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; @@ -297,27 +269,29 @@ bool bumblebee_gunner_enter(entity this, entity player) 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; @@ -328,7 +302,7 @@ bool bumblebee_gunner_enter(entity this, entity player) 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); @@ -369,58 +343,59 @@ bool vehicles_valid_pilot(entity this, entity toucher) return true; } -void bumblebee_touch(entity this) +void bumblebee_touch(entity this, entity toucher) { if(autocvar_g_vehicles_enter) { return; } 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; if(intermission_running) { - vehic.velocity = '0 0 0'; - vehic.avelocity = '0 0 0'; + vehic.solid = SOLID_NOT; + vehic.takedamage = DAMAGE_NO; + set_movetype(vehic, MOVETYPE_NONE); return; } @@ -432,7 +407,7 @@ bool bumblebee_pilot_frame(entity this) return; } - bumblebee_regen(vehic); + bumblebee_regen(vehic, dt); crosshair_trace(this); @@ -483,7 +458,7 @@ bool bumblebee_pilot_frame(entity 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 @@ -498,7 +473,7 @@ bool bumblebee_pilot_frame(entity this) 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; @@ -508,7 +483,7 @@ bool bumblebee_pilot_frame(entity this) 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)) { @@ -539,7 +514,7 @@ bool bumblebee_pilot_frame(entity this) 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; @@ -553,8 +528,8 @@ bool bumblebee_pilot_frame(entity this) { 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 { @@ -565,25 +540,25 @@ bool bumblebee_pilot_frame(entity this) 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; @@ -630,7 +605,7 @@ void bumblebee_land(entity this) float hgt; hgt = vehicle_altitude(this, 512); - this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * sys_frametime); + this.velocity = (this.velocity * 0.9) + ('0 0 -1800' * (hgt / 256) * PHYS_INPUT_FRAMETIME); this.angles_x *= 0.95; this.angles_z *= 0.95; @@ -658,7 +633,7 @@ void bumblebee_exit(entity this, int eject) this.nextthink = time; } - this.movetype = MOVETYPE_TOSS; + set_movetype(this, MOVETYPE_TOSS); if(!this.owner) return; @@ -698,7 +673,12 @@ void bumblebee_blowup(entity this) 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) @@ -717,8 +697,8 @@ 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)) @@ -730,7 +710,21 @@ METHOD(Bumblebee, vr_enter, 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)) { @@ -745,11 +739,8 @@ METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance)) { entity e = instance.gunner1; instance.gun1.vehicle_exit(instance.gun1, VHEF_EJECT); - entity oldother = other; - other = e; instance.phase = 0; - gettouch(instance)(instance); - other = oldother; + gettouch(instance)(instance, e); return; } @@ -757,11 +748,8 @@ METHOD(Bumblebee, vr_think, void(Bumblebee thisveh, entity instance)) { entity e = instance.gunner2; instance.gun2.vehicle_exit(instance.gun2, VHEF_EJECT); - entity oldother = other; - other = e; instance.phase = 0; - gettouch(instance)(instance); - other = oldother; + gettouch(instance)(instance, e); return; } } @@ -790,7 +778,7 @@ METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance)) 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); @@ -809,7 +797,7 @@ METHOD(Bumblebee, vr_death, void(Bumblebee thisveh, entity instance)) 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'; @@ -886,10 +874,13 @@ METHOD(Bumblebee, vr_spawn, void(Bumblebee thisveh, entity instance)) } } + 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;