diff --git a/src/p_map.cpp b/src/p_map.cpp index fc29afb06..c1d50d453 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4859,38 +4859,13 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, } if (!(puffDefaults != NULL && puffDefaults->flags3&MF3_BLOODLESSIMPACT)) { - bool bloodsplatter = (t1->flags5 & MF5_BLOODSPLATTER) || - (t1->player != nullptr && t1->player->ReadyWeapon != nullptr && - (t1->player->ReadyWeapon->WeaponFlags & WIF_AXEBLOOD)); - - bool axeBlood = (t1->player != nullptr && - t1->player->ReadyWeapon != nullptr && - (t1->player->ReadyWeapon->WeaponFlags & WIF_AXEBLOOD)); - - if (!bloodsplatter && !axeBlood && - !(trace.Actor->flags & MF_NOBLOOD) && - !(trace.Actor->flags2 & (MF2_INVULNERABLE | MF2_DORMANT))) + IFVIRTUALPTR(trace.Actor, AActor, SpawnLineAttackBlood) { - P_SpawnBlood(bleedpos, trace.SrcAngleFromTarget, newdam > 0 ? newdam : damage, trace.Actor); + VMValue params[] = { trace.Actor, t1, bleedpos.X, bleedpos.Y, bleedpos.Z, trace.SrcAngleFromTarget.Degrees, damage, newdam }; + VMCall(func, params, countof(params), nullptr, 0); } - if (damage) { - if (bloodsplatter || axeBlood) - { - if (!(trace.Actor->flags&MF_NOBLOOD) && - !(trace.Actor->flags2&(MF2_INVULNERABLE | MF2_DORMANT))) - { - if (axeBlood) - { - P_BloodSplatter2(bleedpos, trace.Actor, trace.SrcAngleFromTarget); - } - if (pr_lineattack() < 192) - { - P_BloodSplatter(bleedpos, trace.Actor, trace.SrcAngleFromTarget); - } - } - } // [RH] Stick blood to walls P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos, trace.Actor, trace.SrcAngleFromTarget, pitch); } diff --git a/wadsrc/static/zscript/actor_attacks.txt b/wadsrc/static/zscript/actor_attacks.txt index 22a2a4386..d5dc1813f 100644 --- a/wadsrc/static/zscript/actor_attacks.txt +++ b/wadsrc/static/zscript/actor_attacks.txt @@ -705,4 +705,37 @@ extend class Actor } + //========================================================================== + // + // called with the victim as 'self' + // + //========================================================================== + + virtual void SpawnLineAttackBlood(Actor attacker, Vector3 bleedpos, double SrcAngleFromTarget, int originaldamage, int actualdamage) + { + if (!bNoBlood && !bDormant && !bInvulnerable) + { + let player = attacker.player; + let weapon = player? player.ReadyWeapon : null; + let axeBlood = (weapon && weapon.bAxeBlood); + let bloodsplatter = attacker.bBloodSplatter || axeBlood; + + if (!bloodsplatter) + { + SpawnBlood(bleedpos, SrcAngleFromTarget, actualdamage > 0 ? actualdamage : originaldamage); + } + else if (damage) + { + if (axeBlood) + { + BloodSplatter(bleedpos, SrcAngleFromTarget, true); + } + // No else here... + if (random[LineAttack]() < 192) + { + BloodSplatter(bleedpos, SrcAngleFromTarget, false); + } + } + } + } }