mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-14 01:29:07 +00:00
feat(Core/Creatures): implement a sparring system (#19824)
This commit is contained in:
@@ -1032,6 +1032,17 @@ uint32 Unit::DealDamage(Unit* attacker, Unit* victim, uint32 damage, CleanDamage
|
||||
}
|
||||
}
|
||||
|
||||
// Sparring
|
||||
if (victim->CanSparringWith(attacker))
|
||||
{
|
||||
if (damage >= victim->GetHealth())
|
||||
damage = 0;
|
||||
|
||||
uint32 sparringHealth = victim->GetHealth() * (victim->ToCreature()->GetSparringPct() / 100);
|
||||
if (victim->GetHealth() - damage <= sparringHealth)
|
||||
damage = 0;
|
||||
}
|
||||
|
||||
if (health <= damage)
|
||||
{
|
||||
LOG_DEBUG("entities.unit", "DealDamage: victim just died");
|
||||
@@ -2635,6 +2646,10 @@ void Unit::AttackerStateUpdate(Unit* victim, WeaponAttackType attType /*= BASE_A
|
||||
Unit::DealDamageMods(victim, damageInfo.damages[i].damage, &damageInfo.damages[i].absorb);
|
||||
}
|
||||
|
||||
// Related to sparring system. Allow attack animations even if there are no damages
|
||||
if (victim->CanSparringWith(damageInfo.attacker))
|
||||
damageInfo.HitInfo |= HITINFO_FAKE_DAMAGE;
|
||||
|
||||
SendAttackStateUpdate(&damageInfo);
|
||||
|
||||
//TriggerAurasProcOnEvent(damageInfo);
|
||||
@@ -3954,6 +3969,24 @@ void Unit::_UpdateAutoRepeatSpell()
|
||||
}
|
||||
}
|
||||
|
||||
bool Unit::CanSparringWith(Unit const* attacker) const
|
||||
{
|
||||
if (!IsCreature() || IsCharmedOwnedByPlayerOrPlayer())
|
||||
return false;
|
||||
|
||||
if (!attacker)
|
||||
return false;
|
||||
|
||||
if (!attacker->IsCreature() || attacker->IsCharmedOwnedByPlayerOrPlayer())
|
||||
return false;
|
||||
|
||||
if (Creature const* creature = ToCreature())
|
||||
if (!creature->GetSparringPct())
|
||||
return false;
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void Unit::SetCurrentCastedSpell(Spell* pSpell)
|
||||
{
|
||||
ASSERT(pSpell); // nullptr may be never passed here, use InterruptSpell or InterruptNonMeleeSpells
|
||||
|
||||
Reference in New Issue
Block a user