fix(Core): Impelement CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ (#7101)

This commit is contained in:
Shiroe
2021-08-01 18:37:49 +02:00
committed by GitHub
parent dc1945196a
commit 7f4c556148
3 changed files with 10 additions and 3 deletions

View File

@@ -83,6 +83,13 @@ uint32 Acore::XP::Gain(Player* player, Unit* unit, bool isBattleGround /*= false
}
xpMod *= isBattleGround ? sWorld->getRate(RATE_XP_BG_KILL) : sWorld->getRate(RATE_XP_KILL);
// if players dealt less than 50% of the damage and were credited anyway (due to CREATURE_FLAG_EXTRA_NO_PLAYER_DAMAGE_REQ), scale XP gained appropriately (linear scaling)
if (creature && creature->m_PlayerDamageReq)
{
xpMod *= 1.0f - 2.0f * creature->m_PlayerDamageReq / creature->GetMaxHealth();
}
gain = uint32(gain * xpMod);
}