Skip to content

Commit

Permalink
Fix bots not attacking when mounted
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Mar 22, 2024
1 parent 7c29262 commit 36cc175
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 10 deletions.
16 changes: 11 additions & 5 deletions playerbot/PlayerbotAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2898,12 +2898,12 @@ bool PlayerbotAI::HasSpell(uint32 spellid) const
return false;
}

bool PlayerbotAI::CanCastSpell(std::string name, Unit* target, uint8 effectMask, Item* itemTarget, bool ignoreRange, bool ignoreInCombat)
bool PlayerbotAI::CanCastSpell(std::string name, Unit* target, uint8 effectMask, Item* itemTarget, bool ignoreRange, bool ignoreInCombat, bool ignoreMount)
{
return CanCastSpell(aiObjectContext->GetValue<uint32>("spell id", name)->Get(), target, 0, true, itemTarget, ignoreRange, ignoreInCombat);
return CanCastSpell(aiObjectContext->GetValue<uint32>("spell id", name)->Get(), target, 0, true, itemTarget, ignoreRange, ignoreInCombat, ignoreMount);
}

bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, uint8 effectMask, bool checkHasSpell, Item* itemTarget, bool ignoreRange, bool ignoreInCombat)
bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, uint8 effectMask, bool checkHasSpell, Item* itemTarget, bool ignoreRange, bool ignoreInCombat, bool ignoreMount)
{
if (!spellid)
return false;
Expand Down Expand Up @@ -3027,12 +3027,14 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, Unit* target, uint8 effectMask, b
return ignoreReagents;
case SPELL_FAILED_AFFECTING_COMBAT:
return ignoreInCombat;
case SPELL_FAILED_NOT_MOUNTED:
return ignoreMount;
default:
return false;
}
}

bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell, bool ignoreRange, bool ignoreInCombat)
bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell, bool ignoreRange, bool ignoreInCombat, bool ignoreMount)
{
if (!spellid)
return false;
Expand Down Expand Up @@ -3103,12 +3105,14 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effec
return ignoreReagents;
case SPELL_FAILED_AFFECTING_COMBAT:
return ignoreInCombat;
case SPELL_FAILED_NOT_MOUNTED:
return ignoreMount;
default:
return false;
}
}

bool PlayerbotAI::CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell, Item* itemTarget, bool ignoreRange, bool ignoreInCombat)
bool PlayerbotAI::CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell, Item* itemTarget, bool ignoreRange, bool ignoreInCombat, bool ignoreMount)
{
if (!spellid)
return false;
Expand Down Expand Up @@ -3166,6 +3170,8 @@ bool PlayerbotAI::CanCastSpell(uint32 spellid, float x, float y, float z, uint8
return ignoreReagents;
case SPELL_FAILED_AFFECTING_COMBAT:
return ignoreInCombat;
case SPELL_FAILED_NOT_MOUNTED:
return ignoreMount;
default:
return false;
}
Expand Down
8 changes: 4 additions & 4 deletions playerbot/PlayerbotAI.h
Original file line number Diff line number Diff line change
Expand Up @@ -393,10 +393,10 @@ class PlayerbotAI : public PlayerbotAIBase
Aura* GetAura(std::string spellName, Unit* player, bool checkOwner = false);
std::vector<Aura*> GetAuras(Unit* player);

virtual bool CanCastSpell(std::string name, Unit* target, uint8 effectMask, Item* itemTarget = NULL, bool ignoreRange = false, bool ignoreInCombat = false);
bool CanCastSpell(uint32 spellid, Unit* target, uint8 effectMask, bool checkHasSpell = true, Item* itemTarget = NULL, bool ignoreRange = false, bool ignoreInCombat = false);
bool CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell = true, bool ignoreRange = false, bool ignoreInCombat = false);
bool CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell = true, Item* itemTarget = NULL, bool ignoreRange = false, bool ignoreInCombat = false);
virtual bool CanCastSpell(std::string name, Unit* target, uint8 effectMask, Item* itemTarget = NULL, bool ignoreRange = false, bool ignoreInCombat = false, bool ignoreMount = false);
bool CanCastSpell(uint32 spellid, Unit* target, uint8 effectMask, bool checkHasSpell = true, Item* itemTarget = NULL, bool ignoreRange = false, bool ignoreInCombat = false, bool ignoreMount = false);
bool CanCastSpell(uint32 spellid, GameObject* goTarget, uint8 effectMask, bool checkHasSpell = true, bool ignoreRange = false, bool ignoreInCombat = false, bool ignoreMount = false);
bool CanCastSpell(uint32 spellid, float x, float y, float z, uint8 effectMask, bool checkHasSpell = true, Item* itemTarget = NULL, bool ignoreRange = false, bool ignoreInCombat = false, bool ignoreMount = false);
bool CanCastVehicleSpell(uint32 spellid, Unit* target);

virtual bool CastSpell(std::string name, Unit* target, Item* itemTarget = NULL, bool waitForSpell = true, uint32* outSpellDuration = NULL, bool canUseReagentCheat = true);
Expand Down
2 changes: 1 addition & 1 deletion playerbot/strategy/actions/ReachTargetActions.h
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ namespace ai
if (!bot->IsNonMeleeSpellCasted(true, false, true))
{
// Check if the spell for which the reach action is used for can be casted
if (!spellName.empty() && !ai->CanCastSpell(spellName, target, true, nullptr, true, true))
if (!spellName.empty() && !ai->CanCastSpell(spellName, target, true, nullptr, true, true, true))
{
return false;
}
Expand Down

0 comments on commit 36cc175

Please sign in to comment.