From df43d7dff72376cb4c7f48acdc867013af597997 Mon Sep 17 00:00:00 2001 From: Yunfan Li Date: Sun, 11 Jun 2023 21:15:02 +0800 Subject: [PATCH] miscs(triggers): spell range, fury warrior equip --- src/PlayerbotAI.cpp | 13 +++++++++---- src/PlayerbotFactory.cpp | 1 + .../druid/GenericDruidNonCombatStrategy.cpp | 17 ++++++++++++++++- src/strategy/triggers/GenericTriggers.cpp | 8 -------- src/strategy/triggers/RangeTriggers.cpp | 16 ++++++++-------- src/strategy/triggers/RangeTriggers.h | 2 -- src/strategy/values/AttackerCountValues.cpp | 8 ++++---- src/strategy/values/PartyMemberValue.h | 2 +- 8 files changed, 39 insertions(+), 28 deletions(-) diff --git a/src/PlayerbotAI.cpp b/src/PlayerbotAI.cpp index 3ec22c1e..fd2b1d39 100644 --- a/src/PlayerbotAI.cpp +++ b/src/PlayerbotAI.cpp @@ -264,6 +264,7 @@ void PlayerbotAI::UpdateAI(uint32 elapsed, bool minimal) UpdateAIInternal(elapsed, min); + inCombat = bot->IsInCombat(); // test fix lags because of BG if (bot && !inCombat) min = true; @@ -3672,16 +3673,20 @@ Item* PlayerbotAI::FindStoneFor(Item* weapon) const { for (uint8 i = 0; i < std::size(uPriorizedSharpStoneIds); ++i) { - if (stone = FindConsumable(uPriorizedSharpStoneIds[i])) - return stone; + stone = FindConsumable(uPriorizedSharpStoneIds[i]); + if (stone) { + return stone; + } } } else if (pProto && (pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE || pProto->SubClass == ITEM_SUBCLASS_WEAPON_MACE2)) { for (uint8 i = 0; i < std::size(uPriorizedWeightStoneIds); ++i) { - if (stone = FindConsumable(uPriorizedWeightStoneIds[i])) - return stone; + stone = FindConsumable(uPriorizedWeightStoneIds[i]); + if (stone) { + return stone; + } } } diff --git a/src/PlayerbotFactory.cpp b/src/PlayerbotFactory.cpp index d448352d..68b36ac5 100644 --- a/src/PlayerbotFactory.cpp +++ b/src/PlayerbotFactory.cpp @@ -3007,6 +3007,7 @@ float PlayerbotFactory::CalculateItemScore(uint32 item_id) ((cls == CLASS_SHAMAN && tab == 1 && bot->HasSpell(674)) || (cls == CLASS_ROGUE) || (cls == CLASS_DEATH_KNIGHT && tab == 1) || + (cls == CLASS_WARRIOR && tab == 1 && !bot->HasSpell(46917)) || IsShieldTank())) { score *= 0.1; } diff --git a/src/strategy/druid/GenericDruidNonCombatStrategy.cpp b/src/strategy/druid/GenericDruidNonCombatStrategy.cpp index 36e8c6d7..2f93a181 100644 --- a/src/strategy/druid/GenericDruidNonCombatStrategy.cpp +++ b/src/strategy/druid/GenericDruidNonCombatStrategy.cpp @@ -15,6 +15,8 @@ class GenericDruidNonCombatStrategyActionNodeFactory : public NamedObjectFactory creators["mark of the wild"] = &mark_of_the_wild; creators["mark of the wild on party"] = &mark_of_the_wild_on_party; // creators["innervate"] = &innervate; + creators["regrowth_on_party"] = ®rowth_on_party; + creators["rejuvenation on party"] = &rejuvenation_on_party; } private: @@ -49,7 +51,20 @@ class GenericDruidNonCombatStrategyActionNodeFactory : public NamedObjectFactory /*A*/ nullptr, /*C*/ nullptr); } - + static ActionNode* regrowth_on_party(PlayerbotAI* ai) + { + return new ActionNode ("regrowth on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } + static ActionNode* rejuvenation_on_party(PlayerbotAI* ai) + { + return new ActionNode ("rejuvenation on party", + /*P*/ NextAction::array(0, new NextAction("caster form"), NULL), + /*A*/ NULL, + /*C*/ NULL); + } // static ActionNode* innervate([[maybe_unused]] PlayerbotAI* botAI) // { // return new ActionNode ("innervate", diff --git a/src/strategy/triggers/GenericTriggers.cpp b/src/strategy/triggers/GenericTriggers.cpp index c12d966c..44781524 100644 --- a/src/strategy/triggers/GenericTriggers.cpp +++ b/src/strategy/triggers/GenericTriggers.cpp @@ -60,14 +60,6 @@ bool ComboPointsAvailableTrigger::IsActive() bool LoseAggroTrigger::IsActive() { - // Unit* mt = AI_VALUE(Unit*, "main tank"); - // if (mt) { - // botAI->TellMasterNoFacing("Has aggro: " + std::to_string(AI_VALUE2(bool, "has aggro", "current target")) - // + " My main tank is: " + mt->GetName()); - // } else { - // botAI->TellMasterNoFacing("Has aggro: " + std::to_string(AI_VALUE2(bool, "has aggro", "current target")) - // + " No main tank detected"); - // } return !AI_VALUE2(bool, "has aggro", "current target"); } diff --git a/src/strategy/triggers/RangeTriggers.cpp b/src/strategy/triggers/RangeTriggers.cpp index fe992db6..8eb8e22c 100644 --- a/src/strategy/triggers/RangeTriggers.cpp +++ b/src/strategy/triggers/RangeTriggers.cpp @@ -135,15 +135,15 @@ EnemyOutOfSpellRangeTrigger::EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI) : O { } -bool EnemyOutOfSpellRangeTrigger::IsActive() -{ - Unit* target = AI_VALUE(Unit*, GetTargetName()); - if (!target) - return false; +// bool EnemyOutOfSpellRangeTrigger::IsActive() +// { +// Unit* target = AI_VALUE(Unit*, GetTargetName()); +// if (!target) +// return false; - float combatReach = bot->GetCombatReach() + target->GetCombatReach(); - return target && (sServerFacade->GetDistance2d(bot, target) > (distance + combatReach + sPlayerbotAIConfig->contactDistance) || !bot->IsWithinLOSInMap(target)); -} +// float combatReach = bot->GetCombatReach() + target->GetCombatReach(); +// return target && (sServerFacade->GetDistance2d(bot, target) > (distance + combatReach + sPlayerbotAIConfig->contactDistance) || !bot->IsWithinLOSInMap(target)); +// } // bool EnemyOutOfMeleeTrigger::IsActive() // { diff --git a/src/strategy/triggers/RangeTriggers.h b/src/strategy/triggers/RangeTriggers.h index f61f9b16..ce33b3be 100644 --- a/src/strategy/triggers/RangeTriggers.h +++ b/src/strategy/triggers/RangeTriggers.h @@ -74,8 +74,6 @@ class EnemyOutOfSpellRangeTrigger : public OutOfRangeTrigger { public: EnemyOutOfSpellRangeTrigger(PlayerbotAI* botAI); - - bool IsActive() override; }; class PartyMemberToHealOutOfSpellRangeTrigger : public OutOfRangeTrigger diff --git a/src/strategy/values/AttackerCountValues.cpp b/src/strategy/values/AttackerCountValues.cpp index 9c822d96..84e94f23 100644 --- a/src/strategy/values/AttackerCountValues.cpp +++ b/src/strategy/values/AttackerCountValues.cpp @@ -26,10 +26,10 @@ bool HasAggroValue::Calculate() return true; } - botAI->TellMaster("target: " + target->GetName() + " victim: " + victim->GetName()); - if (victim->ToPlayer() ) { - botAI->TellMaster("victim is mt: " + std::to_string(botAI->IsMainTank(victim->ToPlayer()))); - } + // botAI->TellMaster("target: " + target->GetName() + " victim: " + victim->GetName()); + // if (victim->ToPlayer() ) { + // botAI->TellMaster("victim is mt: " + std::to_string(botAI->IsMainTank(victim->ToPlayer()))); + // } return false; // HostileReference *ref = bot->getHostileRefMgr().getFirst(); // if (!ref) diff --git a/src/strategy/values/PartyMemberValue.h b/src/strategy/values/PartyMemberValue.h index d5ee2758..3dafe35c 100644 --- a/src/strategy/values/PartyMemberValue.h +++ b/src/strategy/values/PartyMemberValue.h @@ -25,7 +25,7 @@ class SpellEntryPredicate class PartyMemberValue : public UnitCalculatedValue { public: - PartyMemberValue(PlayerbotAI* botAI, std::string const name = "party member") : UnitCalculatedValue(botAI, name) { } + PartyMemberValue(PlayerbotAI* botAI, std::string const name = "party member", int checkInterval = 1) : UnitCalculatedValue(botAI, name, checkInterval) { } bool IsTargetOfSpellCast(Player* target, SpellEntryPredicate& predicate);