Skip to content

Commit

Permalink
Fix hunter initialize pet action
Browse files Browse the repository at this point in the history
  • Loading branch information
davidonete committed Dec 3, 2023
1 parent e1f5a25 commit 028b30a
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 7 deletions.
17 changes: 16 additions & 1 deletion playerbot/strategy/actions/GenericActions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,22 @@ bool InitializePetAction::isUseful()
{
if (bot->getClass() == CLASS_HUNTER)
{
return !bot->GetPet();
bool hasTamedPet = bot->GetPet();
if (!hasTamedPet)
{
std::unique_ptr<QueryResult> queryResult = CharacterDatabase.PQuery("SELECT id, entry, owner, modelid, level, exp, Reactstate, loyaltypoints, loyalty, trainpoint, slot, name, renamed, curhealth, curmana, curhappiness, abdata, TeachSpelldata, savetime, resettalents_cost, resettalents_time, CreatedBySpell, PetType, xpForNextLoyalty "
"FROM character_pet WHERE owner = '%u' AND (slot = '%u' OR slot > '%u') ",
bot->GetGUIDLow(), PET_SAVE_AS_CURRENT, PET_SAVE_LAST_STABLE_SLOT);

if (queryResult)
{
Field* fields = queryResult->Fetch();
const uint32 entry = fields[1].GetUInt32();
hasTamedPet = ObjectMgr::GetCreatureTemplate(entry);
}
}

return !hasTamedPet;
}
else if (bot->getClass() == CLASS_WARLOCK)
{
Expand Down
20 changes: 14 additions & 6 deletions playerbot/strategy/hunter/HunterStrategy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,11 @@ void HunterStrategy::InitNonCombatTriggers(std::list<TriggerNode*>& triggers)

triggers.push_back(new TriggerNode(
"stealthed nearby",
NextAction::array(0, new NextAction("flare", ACTION_NORMAL + 2), NULL)));
NextAction::array(0, new NextAction("flare", ACTION_NORMAL + 3), NULL)));

triggers.push_back(new TriggerNode(
"no pet",
NextAction::array(0, new NextAction("call pet", ACTION_NORMAL + 1), NULL)));
NextAction::array(0, new NextAction("call pet", ACTION_NORMAL + 2), NULL)));

triggers.push_back(new TriggerNode(
"pet not happy",
Expand Down Expand Up @@ -531,11 +531,11 @@ void HunterStrategy::InitNonCombatTriggers(std::list<TriggerNode*>& triggers)

triggers.push_back(new TriggerNode(
"stealthed nearby",
NextAction::array(0, new NextAction("flare", ACTION_NORMAL + 1), NULL)));
NextAction::array(0, new NextAction("flare", ACTION_NORMAL + 3), NULL)));

triggers.push_back(new TriggerNode(
"no pet",
NextAction::array(0, new NextAction("call pet", ACTION_NORMAL + 1), NULL)));
NextAction::array(0, new NextAction("call pet", ACTION_NORMAL + 2), NULL)));

triggers.push_back(new TriggerNode(
"pet not happy",
Expand All @@ -549,6 +549,10 @@ void HunterStrategy::InitNonCombatTriggers(std::list<TriggerNode*>& triggers)
"hunters pet dead",
NextAction::array(0, new NextAction("revive pet", ACTION_NORMAL + 1), NULL)));

triggers.push_back(new TriggerNode(
"often",
NextAction::array(0, new NextAction("initialize pet", ACTION_NORMAL + 1), NULL)));

triggers.push_back(new TriggerNode(
"no ammo",
NextAction::array(0, new NextAction("say::no ammo", ACTION_NORMAL), NULL)));
Expand Down Expand Up @@ -944,11 +948,11 @@ void HunterStrategy::InitNonCombatTriggers(std::list<TriggerNode*>& triggers)

triggers.push_back(new TriggerNode(
"stealthed nearby",
NextAction::array(0, new NextAction("flare", ACTION_NORMAL + 1), NULL)));
NextAction::array(0, new NextAction("flare", ACTION_NORMAL + 3), NULL)));

triggers.push_back(new TriggerNode(
"no pet",
NextAction::array(0, new NextAction("call pet", ACTION_NORMAL + 1), NULL)));
NextAction::array(0, new NextAction("call pet", ACTION_NORMAL + 2), NULL)));

triggers.push_back(new TriggerNode(
"pet not happy",
Expand All @@ -962,6 +966,10 @@ void HunterStrategy::InitNonCombatTriggers(std::list<TriggerNode*>& triggers)
"hunters pet dead",
NextAction::array(0, new NextAction("revive pet", ACTION_NORMAL + 1), NULL)));

triggers.push_back(new TriggerNode(
"often",
NextAction::array(0, new NextAction("initialize pet", ACTION_NORMAL + 1), NULL)));

triggers.push_back(new TriggerNode(
"no ammo",
NextAction::array(0, new NextAction("say::no ammo", ACTION_NORMAL), NULL)));
Expand Down

0 comments on commit 028b30a

Please sign in to comment.