From 3525e303058bd523b6a213427b37e6c1c6713fa8 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Mon, 25 Dec 2023 18:48:51 +0800 Subject: [PATCH] Hunter pet happiness set --- src/PlayerbotFactory.cpp | 2 +- src/strategy/actions/AttackAction.cpp | 9 +++++++-- src/strategy/hunter/HunterActions.cpp | 2 +- 3 files changed, 9 insertions(+), 4 deletions(-) diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index 473b0ea1..6901eb0c 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -679,7 +679,7 @@ void PlayerbotFactory::InitPet() { pet->InitStatsForLevel(bot->getLevel()); pet->SetLevel(bot->getLevel()); - pet->SetPower(POWER_HAPPINESS, HAPPINESS_LEVEL_SIZE * 2); + pet->SetPower(POWER_HAPPINESS, pet->GetMaxPower(Powers(POWER_HAPPINESS))); pet->SetHealth(pet->GetMaxHealth()); } else diff --git a/src/strategy/actions/AttackAction.cpp b/src/strategy/actions/AttackAction.cpp index 42731021..a1cd53fc 100644 --- a/src/strategy/actions/AttackAction.cpp +++ b/src/strategy/actions/AttackAction.cpp @@ -105,6 +105,11 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) context->GetValue("current target")->Set(target); context->GetValue("available loot")->Get()->Add(guid); + bool attacked = bot->Attack(target, true); + + if (!attacked) { + return false; + } /* prevent pet dead immediately in group */ if (bot->GetMap()->IsDungeon() && bot->GetGroup() && !target->IsInCombat()) { with_pet = false; @@ -130,10 +135,10 @@ bool AttackAction::Attack(Unit* target, bool with_pet /*true*/) } // bot->SetFacingToObject(target); - bool attacked = bot->Attack(target, true); + botAI->ChangeEngine(BOT_STATE_COMBAT); - return attacked; + return true; } bool AttackDuelOpponentAction::isUseful() diff --git a/src/strategy/hunter/HunterActions.cpp b/src/strategy/hunter/HunterActions.cpp index d322ef57..dbf85fab 100644 --- a/src/strategy/hunter/HunterActions.cpp +++ b/src/strategy/hunter/HunterActions.cpp @@ -31,7 +31,7 @@ bool FeedPetAction::Execute(Event event) { if (Pet* pet = bot->GetPet()) if (pet->getPetType() == HUNTER_PET && pet->GetHappinessState() != HAPPY) - pet->SetPower(POWER_HAPPINESS, HAPPINESS_LEVEL_SIZE * 2); + pet->SetPower(POWER_HAPPINESS, pet->GetMaxPower(Powers(POWER_HAPPINESS))); return true; }