refactor(Core/ScriptedAI): few improvements with threat methods (#13146)

improve threat scripts

Co-authored-by: Maelthyrr <lynethris@protonmail.ch>
This commit is contained in:
Maelthyr
2022-11-12 13:29:28 +01:00
committed by GitHub
parent 758ed35db3
commit c1c9dc6105
50 changed files with 100 additions and 73 deletions

View File

@@ -384,11 +384,35 @@ SpellInfo const* ScriptedAI::SelectSpell(Unit* target, uint32 school, uint32 mec
return apSpell[urand(0, spellCount - 1)];
}
void ScriptedAI::DoResetThreat()
void ScriptedAI::DoAddThreat(Unit* unit, float amount)
{
if (!unit)
return;
me->GetThreatMgr().AddThreat(unit, amount);
}
void ScriptedAI::DoModifyThreatByPercent(Unit* unit, int32 pct)
{
if (!unit)
return;
me->GetThreatMgr().ModifyThreatByPercent(unit, pct);
}
void ScriptedAI::DoResetThreat(Unit* unit)
{
if (!unit)
return;
me->GetThreatMgr().ResetThreat(unit);
}
void ScriptedAI::DoResetThreatList()
{
if (!me->CanHaveThreatList() || me->GetThreatMgr().isThreatListEmpty())
{
LOG_ERROR("entities.unit.ai", "DoResetThreat called for creature that either cannot have threat list or has empty threat list (me entry = {})", me->GetEntry());
LOG_ERROR("entities.unit.ai", "DoResetThreatList called for creature that either cannot have threat list or has empty threat list (me entry = {})", me->GetEntry());
return;
}
@@ -399,14 +423,8 @@ float ScriptedAI::DoGetThreat(Unit* unit)
{
if (!unit)
return 0.0f;
return me->GetThreatMgr().GetThreat(unit);
}
void ScriptedAI::DoModifyThreatPercent(Unit* unit, int32 pct)
{
if (!unit)
return;
me->GetThreatMgr().ModifyThreatByPercent(unit, pct);
return me->GetThreatMgr().GetThreat(unit);
}
void ScriptedAI::DoTeleportPlayer(Unit* unit, float x, float y, float z, float o)