Core/Combat: reduce differences between 4.x and 335
This commit is contained in:
1 parent
ea8d7093e9
commit
1ab7a9328f
6 files changed
+28
-19
No files matched your search
@@ -71,10 +71,12 @@ void CombatReference::EndCombat()
|
||||
bool const needSecondAI = second->GetCombatManager().UpdateOwnerCombatState();
|
||||
|
||||
// ...and if that happened, also notify the AI of it...
|
||||
if (needFirstAI && first->IsAIEnabled)
|
||||
first->GetAI()->JustExitedCombat();
|
||||
if (needSecondAI && second->IsAIEnabled)
|
||||
second->GetAI()->JustExitedCombat();
|
||||
if (needFirstAI)
|
||||
if (UnitAI* firstAI = first->GetAI())
|
||||
firstAI->JustExitedCombat();
|
||||
if (needSecondAI)
|
||||
if (UnitAI* secondAI = second->GetAI())
|
||||
secondAI->JustExitedCombat();
|
||||
|
||||
// ...and finally clean up the reference object
|
||||
delete this;
|
||||
@@ -114,8 +116,8 @@ void PvPCombatReference::SuppressFor(Unit* who)
|
||||
{
|
||||
Suppress(who);
|
||||
if (who->GetCombatManager().UpdateOwnerCombatState())
|
||||
if (who->IsAIEnabled)
|
||||
who->GetAI()->JustExitedCombat();
|
||||
if (UnitAI* ai = who->GetAI())
|
||||
ai->JustExitedCombat();
|
||||
}
|
||||
|
||||
CombatManager::~CombatManager()
|
||||
@@ -140,6 +142,15 @@ void CombatManager::Update(uint32 tdiff)
|
||||
}
|
||||
}
|
||||
|
||||
bool CombatManager::HasPvECombatWithPlayers() const
|
||||
{
|
||||
for (std::pair<ObjectGuid const, CombatReference*> const& reference : _pveRefs)
|
||||
if (reference.second->GetOther(_owner)->GetTypeId() == TYPEID_PLAYER)
|
||||
return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CombatManager::HasPvPCombat() const
|
||||
{
|
||||
for (auto const& pair : _pvpRefs)
|
||||
@@ -271,8 +282,8 @@ void CombatManager::SuppressPvPCombat()
|
||||
for (auto const& pair : _pvpRefs)
|
||||
pair.second->Suppress(_owner);
|
||||
if (UpdateOwnerCombatState())
|
||||
if (_owner->IsAIEnabled)
|
||||
_owner->GetAI()->JustExitedCombat();
|
||||
if (UnitAI* ownerAI = _owner->GetAI())
|
||||
ownerAI->JustExitedCombat();
|
||||
}
|
||||
|
||||
void CombatManager::EndAllPvECombat()
|
||||
@@ -330,14 +341,14 @@ bool CombatManager::UpdateOwnerCombatState() const
|
||||
{
|
||||
_owner->SetFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
_owner->AtEnterCombat();
|
||||
if (_owner->GetTypeId() == TYPEID_UNIT)
|
||||
if (_owner->GetTypeId() != TYPEID_UNIT)
|
||||
_owner->AtEngage(GetAnyTarget());
|
||||
}
|
||||
else
|
||||
{
|
||||
_owner->RemoveFlag(UNIT_FIELD_FLAGS, UNIT_FLAG_IN_COMBAT);
|
||||
_owner->AtExitCombat();
|
||||
if (_owner->GetTypeId() == TYPEID_UNIT)
|
||||
if (_owner->GetTypeId() != TYPEID_UNIT)
|
||||
_owner->AtDisengage();
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user