- exported the blood spawning part of P_LineAttack as a virtual ZScript function.

This commit is contained in:
Christoph Oelckers 2018-11-24 22:35:50 +01:00
parent f260709e73
commit 4392b4e96d
2 changed files with 36 additions and 28 deletions

View file

@ -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);
}

View file

@ -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);
}
}
}
}
}