From 028b30a71ed6ad829899afb111dc107a62de4f02 Mon Sep 17 00:00:00 2001 From: Flekz Date: Sun, 3 Dec 2023 22:42:42 +0000 Subject: [PATCH] Fix hunter initialize pet action --- playerbot/strategy/actions/GenericActions.cpp | 17 +++++++++++++++- playerbot/strategy/hunter/HunterStrategy.cpp | 20 +++++++++++++------ 2 files changed, 30 insertions(+), 7 deletions(-) diff --git a/playerbot/strategy/actions/GenericActions.cpp b/playerbot/strategy/actions/GenericActions.cpp index 6e12c747c..52da70949 100644 --- a/playerbot/strategy/actions/GenericActions.cpp +++ b/playerbot/strategy/actions/GenericActions.cpp @@ -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 = 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) { diff --git a/playerbot/strategy/hunter/HunterStrategy.cpp b/playerbot/strategy/hunter/HunterStrategy.cpp index f81b3a647..976111958 100644 --- a/playerbot/strategy/hunter/HunterStrategy.cpp +++ b/playerbot/strategy/hunter/HunterStrategy.cpp @@ -96,11 +96,11 @@ void HunterStrategy::InitNonCombatTriggers(std::list& 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", @@ -531,11 +531,11 @@ void HunterStrategy::InitNonCombatTriggers(std::list& 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", @@ -549,6 +549,10 @@ void HunterStrategy::InitNonCombatTriggers(std::list& 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))); @@ -944,11 +948,11 @@ void HunterStrategy::InitNonCombatTriggers(std::list& 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", @@ -962,6 +966,10 @@ void HunterStrategy::InitNonCombatTriggers(std::list& 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)));