X-Git-Url: https://git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fvehicles%2Fvehicle%2Fraptor.qc;h=5dbd4f4ccb8adc8726f6022949e83348d1fe3305;hb=ff5abbe10f6a0542cc40e931d0f61aafa359eff9;hp=c5d1e5c9470d28a3cbea11f8f6643c4b6567f31e;hpb=c34ce256dad53ee55c890a98ea42469ce2ee4401;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/vehicles/vehicle/raptor.qc b/qcsrc/common/vehicles/vehicle/raptor.qc index c5d1e5c94..5dbd4f4cc 100644 --- a/qcsrc/common/vehicles/vehicle/raptor.qc +++ b/qcsrc/common/vehicles/vehicle/raptor.qc @@ -1,30 +1,5 @@ -#ifndef VEHICLE_RAPTOR -#define VEHICLE_RAPTOR #include "raptor.qh" -#include "raptor_weapons.qh" - -CLASS(Raptor, Vehicle) -/* spawnflags */ ATTRIB(Raptor, spawnflags, int, VHF_DMGSHAKE | VHF_DMGROLL); -/* mins */ ATTRIB(Raptor, mins, vector, '-80 -80 0'); -/* maxs */ ATTRIB(Raptor, maxs, vector, '80 80 70'); -/* view offset*/ ATTRIB(Raptor, view_ofs, vector, '0 0 160'); -/* view dist */ ATTRIB(Raptor, height, float, 200); -/* model */ ATTRIB(Raptor, mdl, string, "models/vehicles/raptor.dpm"); -/* model */ ATTRIB(Raptor, model, string, "models/vehicles/raptor.dpm"); -/* head_model */ ATTRIB(Raptor, head_model, string, ""); -/* hud_model */ ATTRIB(Raptor, hud_model, string, "models/vehicles/raptor_cockpit.dpm"); -/* tags */ ATTRIB(Raptor, tag_head, string, ""); -/* tags */ ATTRIB(Raptor, tag_hud, string, "tag_hud"); -/* tags */ ATTRIB(Raptor, tag_view, string, "tag_camera"); -/* netname */ ATTRIB(Raptor, netname, string, "raptor"); -/* fullname */ ATTRIB(Raptor, vehicle_name, string, _("Raptor")); -/* icon */ ATTRIB(Raptor, m_icon, string, "vehicle_raptor"); -ENDCLASS(Raptor) -REGISTER_VEHICLE(RAPTOR, NEW(Raptor)); - -#endif - #ifdef IMPLEMENTATION #ifdef SVQC @@ -47,6 +22,8 @@ float autocvar_g_vehicle_raptor_speed_up = 1700; float autocvar_g_vehicle_raptor_speed_down = 1700; float autocvar_g_vehicle_raptor_friction = 2; +bool autocvar_g_vehicle_raptor_swim = false; + float autocvar_g_vehicle_raptor_cannon_turnspeed = 120; float autocvar_g_vehicle_raptor_cannon_turnlimit = 20; float autocvar_g_vehicle_raptor_cannon_pitchlimit_up = 12; @@ -82,7 +59,7 @@ void raptor_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; @@ -94,7 +71,7 @@ void raptor_land(entity this) if(hgt < 16) { - this.movetype = MOVETYPE_TOSS; + set_movetype(this, MOVETYPE_TOSS); setthink(this, vehicles_think); this.frame = 0; } @@ -151,15 +128,16 @@ void raptor_exit(entity this, int eject) this.owner = NULL; } -bool raptor_frame(entity this) +bool raptor_frame(entity this, float dt) { entity vehic = this.vehicle; return = true; - if(intermission_running) + if(gameover) { - vehic.velocity = '0 0 0'; - vehic.avelocity = '0 0 0'; + vehic.solid = SOLID_NOT; + vehic.takedamage = DAMAGE_NO; + set_movetype(vehic, MOVETYPE_NONE); return; } @@ -271,7 +249,7 @@ bool raptor_frame(entity this) else if (PHYS_INPUT_BUTTON_JUMP(this)) df += v_up * autocvar_g_vehicle_raptor_speed_up; - vehic.velocity += df * frametime; + vehic.velocity += df * dt; this.velocity = this.movement = vehic.velocity; setorigin(this, vehic.origin + '0 0 32'); @@ -285,7 +263,7 @@ bool raptor_frame(entity this) vehic.gun1.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)) { @@ -311,7 +289,7 @@ bool raptor_frame(entity this) vf = real_origin(vehic.gun1.enemy); UpdateAuxiliaryXhair(this, vf, '1 0 0', 1); vector _vel = vehic.gun1.enemy.velocity; - if(vehic.gun1.enemy.movetype == MOVETYPE_WALK) + if(vehic.gun1.enemy.move_movetype == MOVETYPE_WALK) _vel_z *= 0.1; if(autocvar_g_vehicle_raptor_cannon_predicttarget) @@ -329,8 +307,8 @@ bool raptor_frame(entity this) else if(autocvar_g_vehicle_raptor_cannon_locktarget == 1) { - vehicles_locktarget(vehic, (1 / autocvar_g_vehicle_raptor_cannon_locking_time) * frametime, - (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * frametime, + vehicles_locktarget(vehic, (1 / autocvar_g_vehicle_raptor_cannon_locking_time) * dt, + (1 / autocvar_g_vehicle_raptor_cannon_locking_releasetime) * dt, autocvar_g_vehicle_raptor_cannon_locked_time); if(vehic.lock_target != NULL) @@ -378,22 +356,22 @@ bool raptor_frame(entity this) */ Weapon wep1 = WEP_RAPTOR; + .entity weaponentity = weaponentities[0]; if(!forbidWeaponUse(this)) if(PHYS_INPUT_BUTTON_ATCK(this)) - if (wep1.wr_checkammo1(wep1, vehic)) + if (wep1.wr_checkammo1(wep1, vehic, weaponentity)) { - .entity weaponentity = weaponentities[0]; wep1.wr_think(wep1, vehic, weaponentity, 1); } if(vehic.vehicle_flags & VHF_SHIELDREGEN) - vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, true); + vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, dt, true); if(vehic.vehicle_flags & VHF_HEALTHREGEN) - vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, false); + vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false); if(vehic.vehicle_flags & VHF_ENERGYREGEN) - vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, false); + vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false); Weapon wep2a = WEP_RAPTOR_BOMB; if(!forbidWeaponUse(this)) @@ -428,9 +406,8 @@ bool raptor_frame(entity this) if(vehic.bomb1.cnt < time) { bool incoming = false; - FOREACH_ENTITY_ENT(enemy, vehic, + IL_EACH(g_projectiles, it.enemy == vehic, { - if(it.flags & FL_PROJECTILE) if(MISSILE_IS_TRACKING(it)) if(vdist(vehic.origin - it.origin, <, 2 * autocvar_g_vehicle_raptor_flare_range)) { @@ -457,7 +434,7 @@ bool raptor_frame(entity this) PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false; } -bool raptor_takeoff(entity this) +bool raptor_takeoff(entity this, float dt) { entity vehic = this.vehicle; return = true; @@ -475,7 +452,7 @@ bool raptor_takeoff(entity this) // Takeoff sequense if(vehic.frame < 25) { - vehic.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / sys_frametime); + vehic.frame += 25 / (autocvar_g_vehicle_raptor_takeofftime / PHYS_INPUT_FRAMETIME); vehic.velocity_z = min(vehic.velocity_z * 1.5, 256); vehic.bomb1.gun1.avelocity_y = 90 + ((vehic.frame / 25) * 25000); vehic.bomb1.gun2.avelocity_y = -vehic.bomb1.gun1.avelocity_y; @@ -487,13 +464,13 @@ bool raptor_takeoff(entity this) this.PlayerPhysplug = raptor_frame; if(vehic.vehicle_flags & VHF_SHIELDREGEN) - vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, frametime, true); + vehicles_regen(vehic, vehic.dmg_time, vehicle_shield, autocvar_g_vehicle_raptor_shield, autocvar_g_vehicle_raptor_shield_regen_pause, autocvar_g_vehicle_raptor_shield_regen, dt, true); if(vehic.vehicle_flags & VHF_HEALTHREGEN) - vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, frametime, false); + vehicles_regen(vehic, vehic.dmg_time, vehicle_health, autocvar_g_vehicle_raptor_health, autocvar_g_vehicle_raptor_health_regen_pause, autocvar_g_vehicle_raptor_health_regen, dt, false); if(vehic.vehicle_flags & VHF_ENERGYREGEN) - vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, frametime, false); + vehicles_regen(vehic, vehic.cnt, vehicle_energy, autocvar_g_vehicle_raptor_energy, autocvar_g_vehicle_raptor_energy_regen_pause, autocvar_g_vehicle_raptor_energy_regen, dt, false); vehic.bomb1.alpha = vehic.bomb2.alpha = (time - vehic.lip) / (vehic.delay - vehic.lip); @@ -508,14 +485,14 @@ bool raptor_takeoff(entity this) PHYS_INPUT_BUTTON_ATCK(this) = PHYS_INPUT_BUTTON_ATCK2(this) = PHYS_INPUT_BUTTON_CROUCH(this) = false; } -void raptor_blowup(entity this) +void raptor_blowup(entity this, entity toucher) { this.deadflag = DEAD_DEAD; this.vehicle_exit(this, VHEF_NORMAL); RadiusDamage (this, this.enemy, 250, 15, 250, NULL, NULL, 250, DEATH_VH_RAPT_DEATH.m_id, NULL); this.alpha = -1; - this.movetype = MOVETYPE_NONE; + set_movetype(this, MOVETYPE_NONE); this.effects = EF_NODRAW; this.colormod = '0 0 0'; this.avelocity = '0 0 0'; @@ -529,7 +506,10 @@ void raptor_blowup(entity this) void raptor_diethink(entity this) { if(time >= this.wait) - setthink(this, raptor_blowup); + { + raptor_blowup(this, NULL); + return; + } if(random() < 0.05) { @@ -595,8 +575,8 @@ bool raptor_impulse(entity this, int _imp) spawnfunc(vehicle_raptor) { - if(!autocvar_g_vehicle_raptor) { remove(this); return; } - if(!vehicle_initialize(this, VEH_RAPTOR, false)) { remove(this); return; } + if(!autocvar_g_vehicle_raptor) { delete(this); return; } + if(!vehicle_initialize(this, VEH_RAPTOR, false)) { delete(this); return; } } METHOD(Raptor, vr_impact, void(Raptor thisveh, entity instance)) @@ -608,7 +588,7 @@ METHOD(Raptor, vr_enter, void(Raptor thisveh, entity instance)) { instance.vehicle_weapon2mode = RSM_BOMB; instance.owner.PlayerPhysplug = raptor_takeoff; - instance.movetype = MOVETYPE_BOUNCEMISSILE; + set_movetype(instance, MOVETYPE_BOUNCEMISSILE); instance.solid = SOLID_SLIDEBOX; instance.owner.vehicle_health = (instance.vehicle_health / autocvar_g_vehicle_raptor_health) * 100; instance.owner.vehicle_shield = (instance.vehicle_shield / autocvar_g_vehicle_raptor_shield) * 100; @@ -630,7 +610,7 @@ METHOD(Raptor, vr_death, void(Raptor thisveh, entity instance)) instance.solid = SOLID_CORPSE; instance.takedamage = DAMAGE_NO; instance.deadflag = DEAD_DYING; - instance.movetype = MOVETYPE_BOUNCE; + set_movetype(instance, MOVETYPE_BOUNCE); setthink(instance, raptor_diethink); instance.nextthink = time; instance.wait = time + 5 + (random() * 5); @@ -697,7 +677,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance)) spinner.owner = instance; setmodel(spinner, MDL_VEH_RAPTOR_PROP); setattachment(spinner, instance, "engine_left"); - spinner.movetype = MOVETYPE_NOCLIP; + set_movetype(spinner, MOVETYPE_NOCLIP); spinner.avelocity = '0 90 0'; instance.bomb1.gun1 = spinner; @@ -705,7 +685,7 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance)) spinner.owner = instance; setmodel(spinner, MDL_VEH_RAPTOR_PROP); setattachment(spinner, instance, "engine_right"); - spinner.movetype = MOVETYPE_NOCLIP; + set_movetype(spinner, MOVETYPE_NOCLIP); spinner.avelocity = '0 -90 0'; instance.bomb1.gun2 = spinner; @@ -719,10 +699,13 @@ METHOD(Raptor, vr_spawn, void(Raptor thisveh, entity instance)) instance.frame = 0; instance.vehicle_health = autocvar_g_vehicle_raptor_health; instance.vehicle_shield = autocvar_g_vehicle_raptor_shield; - instance.movetype = MOVETYPE_TOSS; + set_movetype(instance, MOVETYPE_TOSS); instance.solid = SOLID_SLIDEBOX; instance.vehicle_energy = 1; + if(!autocvar_g_vehicle_raptor_swim) + instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK; + instance.PlayerPhysplug = raptor_frame; instance.bomb1.gun1.avelocity_y = 90; @@ -755,6 +738,9 @@ METHOD(Raptor, vr_setup, void(Raptor thisveh, entity instance)) instance.vehicle_health = autocvar_g_vehicle_raptor_health; instance.vehicle_shield = autocvar_g_vehicle_raptor_shield; instance.max_health = instance.vehicle_health; + + if(!autocvar_g_vehicle_raptor_swim) + instance.dphitcontentsmask |= DPCONTENTS_LIQUIDSMASK; } #endif @@ -778,7 +764,7 @@ METHOD(Raptor, vr_crosshair, void(Raptor thisveh, entity player)) } vector tmpSize = '0 0 0'; - if(weapon2mode != RSM_FLARE) + if(weapon2mode != RSM_FLARE && !spectatee_status) { vector where;