From 8c79ffeea6057c22e10f314300bccda4fabdabf1 Mon Sep 17 00:00:00 2001 From: Mario Date: Tue, 14 Jul 2020 20:34:22 +1000 Subject: [PATCH] Fix racer rockets not showing a proper explosion effect --- qcsrc/common/effects/all.inc | 2 +- qcsrc/common/vehicles/vehicle/racer.qc | 2 +- qcsrc/common/vehicles/vehicle/racer_weapon.qc | 33 ++++++++++--------- qcsrc/common/vehicles/vehicle/racer_weapon.qh | 2 +- 4 files changed, 21 insertions(+), 18 deletions(-) diff --git a/qcsrc/common/effects/all.inc b/qcsrc/common/effects/all.inc index c25805c0b..019ae6139 100644 --- a/qcsrc/common/effects/all.inc +++ b/qcsrc/common/effects/all.inc @@ -122,7 +122,7 @@ EFFECT(0, RACER_BOOSTER, "wakizashi_booster_smoke") EFFECT(0, RACER_IMPACT, "wakizashi_gun_impact") EFFECT(0, RACER_MUZZLEFLASH, "wakizashi_gun_muzzleflash") EFFECT(0, RACER_ROCKETLAUNCH, "wakizashi_rocket_launch") -EFFECT(0, RACER_ROCKET_EXPLODE, "wakizashi_rocket_launch") +EFFECT(0, RACER_ROCKET_EXPLODE, "wakizashi_rocket_explode") EFFECT(1, RACER_ROCKET_TRAIL, "wakizashi_rocket_thrust") EFFECT(0, SPIDERBOT_ROCKETLAUNCH, "spiderbot_rocket_launch") diff --git a/qcsrc/common/vehicles/vehicle/racer.qc b/qcsrc/common/vehicles/vehicle/racer.qc index ff124d0b4..e59184dc8 100644 --- a/qcsrc/common/vehicles/vehicle/racer.qc +++ b/qcsrc/common/vehicles/vehicle/racer.qc @@ -142,7 +142,7 @@ void racer_align4point(entity this, entity player, float _delta) void racer_fire_rocket_aim(entity this, entity player, string tagname, entity trg) { vector v = gettaginfo(this, gettagindex(this, tagname)); - racer_fire_rocket(player, v, v_forward, trg); + racer_fire_rocket(this, player, v, v_forward, trg); } bool racer_frame(entity this, float dt) diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qc b/qcsrc/common/vehicles/vehicle/racer_weapon.qc index 473f9a757..e8c18ed2d 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qc +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qc @@ -2,7 +2,7 @@ #ifdef SVQC -void racer_fire_rocket(entity player, vector org, vector dir, entity trg); +void racer_fire_rocket(entity this, entity player, vector org, vector dir, entity trg); METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weaponentity, int fire)) { bool isPlayer = IS_PLAYER(actor); @@ -14,20 +14,23 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone veh.vehicle_energy -= autocvar_g_vehicle_racer_cannon_cost; veh.wait = time; } - string tagname = (veh.cnt) - ? (veh.cnt = 0, "tag_fire1") - : (veh.cnt = 1, "tag_fire2"); - vector vshotorg = gettaginfo(veh, gettagindex(veh, tagname)); - w_shotorg = vshotorg; - w_shotdir = v_forward; - // Fix z-aim (for chase mode) - crosshair_trace(player); - w_shotdir.z = normalize(trace_endpos - vshotorg).z * 0.5; - + if(!isPlayer) + { + string tagname = (veh.cnt) + ? (veh.cnt = 0, "tag_fire1") + : (veh.cnt = 1, "tag_fire2"); + vector vshotorg = gettaginfo(veh, gettagindex(veh, tagname)); + w_shotorg = vshotorg; + w_shotdir = v_forward; + + // Fix z-aim (for chase mode) + crosshair_trace(player); + w_shotdir.z = normalize(trace_endpos - vshotorg).z * 0.5; + } if (isPlayer) W_SetupShot_Dir(player, weaponentity, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0, DEATH_VH_WAKI_GUN.m_id); vector org = w_shotorg; vector dir = w_shotdir; - entity bolt = vehicles_projectile(veh, EFFECT_RACER_MUZZLEFLASH, SND_LASERGUN_FIRE, + entity bolt = vehicles_projectile(((veh) ? veh : player), EFFECT_RACER_MUZZLEFLASH, SND_LASERGUN_FIRE, org, normalize(v_forward + randomvec() * autocvar_g_vehicle_racer_cannon_spread) * autocvar_g_vehicle_racer_cannon_speed, autocvar_g_vehicle_racer_cannon_damage, autocvar_g_vehicle_racer_cannon_radius, autocvar_g_vehicle_racer_cannon_force, 0, DEATH_VH_WAKI_GUN.m_id, PROJECTILE_WAKICANNON, 0, true, true, player); @@ -37,7 +40,7 @@ METHOD(RacerAttack, wr_think, void(entity thiswep, entity actor, .entity weapone if (fire & 2) if (!isPlayer || weapon_prepareattack(thiswep, actor, weaponentity, false, 0.2)) { if (isPlayer) W_SetupShot_Dir(actor, weaponentity, v_forward, false, 0, SND_Null, CH_WEAPON_B, 0, DEATH_VH_WAKI_ROCKET.m_id); - racer_fire_rocket(player, w_shotorg, w_shotdir, NULL); + racer_fire_rocket(((veh) ? veh : player), player, w_shotorg, w_shotdir, NULL); weapon_thinkf(actor, weaponentity, WFRAME_FIRE2, 0, w_ready); } } @@ -53,9 +56,9 @@ METHOD(RacerAttack, wr_checkammo1, bool(RacerAttack thiswep, entity actor, .enti void racer_rocket_tracker(entity this); void racer_rocket_groundhugger(entity this); -void racer_fire_rocket(entity player, vector org, vector dir, entity trg) +void racer_fire_rocket(entity this, entity player, vector org, vector dir, entity trg) { - entity rocket = vehicles_projectile(player.vehicle, EFFECT_RACER_ROCKETLAUNCH, SND_ROCKET_FIRE, + entity rocket = vehicles_projectile(this, EFFECT_RACER_ROCKETLAUNCH, SND_ROCKET_FIRE, org, dir * autocvar_g_vehicle_racer_rocket_speed, autocvar_g_vehicle_racer_rocket_damage, autocvar_g_vehicle_racer_rocket_radius, autocvar_g_vehicle_racer_rocket_force, 3, DEATH_VH_WAKI_ROCKET.m_id, PROJECTILE_WAKIROCKET, 20, false, false, player); diff --git a/qcsrc/common/vehicles/vehicle/racer_weapon.qh b/qcsrc/common/vehicles/vehicle/racer_weapon.qh index ede81f6c5..f4f310412 100644 --- a/qcsrc/common/vehicles/vehicle/racer_weapon.qh +++ b/qcsrc/common/vehicles/vehicle/racer_weapon.qh @@ -12,7 +12,7 @@ REGISTER_WEAPON(RACER, NEW(RacerAttack)); // TODO: move into implementation #ifdef SVQC -void racer_fire_rocket(entity player, vector org, vector dir, entity trg); +void racer_fire_rocket(entity this, entity player, vector org, vector dir, entity trg); #endif #ifdef SVQC -- 2.39.2