Skip to content

Commit

Permalink
PlayerBot: use new Relations API
Browse files Browse the repository at this point in the history
  • Loading branch information
cala committed Feb 20, 2018
1 parent 770ef0b commit 5a10031
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
18 changes: 9 additions & 9 deletions src/game/PlayerBot/Base/PlayerbotAI.cpp
Expand Up @@ -3175,7 +3175,7 @@ void PlayerbotAI::DoNextCombatManeuver()
Attack(); Attack();


// clear orders if current target for attacks doesn't make sense anymore // clear orders if current target for attacks doesn't make sense anymore
if (!m_targetCombat || m_targetCombat->isDead() || !m_targetCombat->IsInWorld() || !m_bot->IsHostileTo(m_targetCombat) || !m_bot->IsInMap(m_targetCombat)) if (!m_targetCombat || m_targetCombat->isDead() || !m_targetCombat->IsInWorld() || !m_bot->CanAttack(m_targetCombat) || !m_bot->IsInMap(m_targetCombat))
{ {
m_bot->AttackStop(); m_bot->AttackStop();
m_bot->SetSelectionGuid(ObjectGuid()); m_bot->SetSelectionGuid(ObjectGuid());
Expand Down Expand Up @@ -5314,12 +5314,12 @@ bool PlayerbotAI::CastSpell(uint32 spellId)


if (IsPositiveSpell(spellId)) if (IsPositiveSpell(spellId))
{ {
if (pTarget && !m_bot->IsFriendlyTo(pTarget)) if (pTarget && m_bot->CanAttack(pTarget))
pTarget = m_bot; pTarget = m_bot;
} }
else else
{ {
if (pTarget && m_bot->IsFriendlyTo(pTarget)) if (pTarget && m_bot->CanAssist(pTarget))
return false; return false;


m_bot->SetInFront(pTarget); m_bot->SetInFront(pTarget);
Expand Down Expand Up @@ -5451,12 +5451,12 @@ bool PlayerbotAI::CastPetSpell(uint32 spellId, Unit* target)


if (IsPositiveSpell(spellId)) if (IsPositiveSpell(spellId))
{ {
if (pTarget && !m_bot->IsFriendlyTo(pTarget)) if (pTarget && m_bot->CanAttack(pTarget))
pTarget = m_bot; pTarget = m_bot;
} }
else else
{ {
if (pTarget && m_bot->IsFriendlyTo(pTarget)) if (pTarget && m_bot->CanAssist(pTarget))
return false; return false;


if (!pet->isInFrontInMap(pTarget, 10)) // distance probably should be calculated if (!pet->isInFrontInMap(pTarget, 10)) // distance probably should be calculated
Expand Down Expand Up @@ -7241,7 +7241,7 @@ void PlayerbotAI::findNearbyCorpse()
if (!corpse) if (!corpse)
continue; continue;


if (!corpse->IsCorpse() || corpse->IsDespawned() || m_bot->IsFriendlyTo(corpse)) if (!corpse->IsCorpse() || corpse->IsDespawned() || m_bot->CanAssist(corpse))
continue; continue;


uint32 skillId = 0; uint32 skillId = 0;
Expand Down Expand Up @@ -9328,7 +9328,7 @@ void PlayerbotAI::_HandleCommandAttack(std::string& text, Player& fromPlayer)
{ {
if (Unit* thingToAttack = ObjectAccessor::GetUnit(*m_bot, attackOnGuid)) if (Unit* thingToAttack = ObjectAccessor::GetUnit(*m_bot, attackOnGuid))
{ {
if (!m_bot->IsFriendlyTo(thingToAttack)) if (m_bot->CanAttack(thingToAttack))
{ {
if (!m_bot->IsWithinLOSInMap(thingToAttack)) if (!m_bot->IsWithinLOSInMap(thingToAttack))
DoTeleport(*m_followTarget); DoTeleport(*m_followTarget);
Expand Down Expand Up @@ -9386,7 +9386,7 @@ void PlayerbotAI::_HandleCommandPull(std::string& text, Player& fromPlayer)
return; return;
} }


if (m_bot->IsFriendlyTo(thingToAttack)) if (m_bot->CanAssist(thingToAttack))
{ {
SendWhisper("Where I come from we don't attack our friends.", fromPlayer); SendWhisper("Where I come from we don't attack our friends.", fromPlayer);
return; return;
Expand Down Expand Up @@ -9482,7 +9482,7 @@ void PlayerbotAI::_HandleCommandNeutralize(std::string& text, Player& fromPlayer
return; return;
} }


if (m_bot->IsFriendlyTo(thingToNeutralize)) if (m_bot->CanAssist(thingToNeutralize))
{ {
SendWhisper("I can't neutralize that target: this is a friend to me.", fromPlayer); SendWhisper("I can't neutralize that target: this is a friend to me.", fromPlayer);
return; return;
Expand Down
2 changes: 1 addition & 1 deletion src/game/PlayerBot/Base/PlayerbotMgr.cpp
Expand Up @@ -319,7 +319,7 @@ void PlayerbotMgr::HandleMasterIncomingPacket(const WorldPacket& packet)
for (PlayerBotMap::iterator itr = m_playerBots.begin(); itr != m_playerBots.end(); ++itr) for (PlayerBotMap::iterator itr = m_playerBots.begin(); itr != m_playerBots.end(); ++itr)
{ {
bot = itr->second; bot = itr->second;
if (!bot->IsFriendlyTo(thingToAttack)) if (bot->CanAttack(thingToAttack))
{ {
if (!bot->IsWithinLOSInMap(thingToAttack)) if (!bot->IsWithinLOSInMap(thingToAttack))
bot->GetPlayerbotAI()->DoTeleport(*m_master); bot->GetPlayerbotAI()->DoTeleport(*m_master);
Expand Down

0 comments on commit 5a10031

Please sign in to comment.