From 9af8ed5847cc9e853406dbc87d250d7b7426eb0e Mon Sep 17 00:00:00 2001 From: mostlikely4r Date: Thu, 6 Mar 2025 15:39:16 +0100 Subject: [PATCH] Hearstone: Groupmembers of a botgroup now try to set their hearthstone to the same location as the group leader. --- playerbot/strategy/triggers/RpgTriggers.cpp | 25 +++++++++++++++++-- playerbot/strategy/values/LastMovementValue.h | 17 +++++++++++++ playerbot/strategy/values/TargetValue.h | 16 ------------ 3 files changed, 40 insertions(+), 18 deletions(-) diff --git a/playerbot/strategy/triggers/RpgTriggers.cpp b/playerbot/strategy/triggers/RpgTriggers.cpp index 5ae16999f..6c86332dc 100644 --- a/playerbot/strategy/triggers/RpgTriggers.cpp +++ b/playerbot/strategy/triggers/RpgTriggers.cpp @@ -421,10 +421,31 @@ bool RpgHomeBindTrigger::IsActive() if (guidP.IsHostileTo(bot)) return false; - if (AI_VALUE(WorldPosition, "home bind").distance(bot) < 500.0f) + //Do not update for realplayers/always online when at max level. + if ((ai->IsRealPlayer() || sPlayerbotAIConfig.IsFreeAltBot(bot)) && bot->GetLevel() == DEFAULT_MAX_LEVEL) return false; - if ((ai->IsRealPlayer() || sPlayerbotAIConfig.IsFreeAltBot(bot)) && bot->GetLevel() == DEFAULT_MAX_LEVEL) + WorldPosition currentBind = AI_VALUE(WorldPosition, "home bind"); + WorldPosition newBind = (guidP.sqDistance2d(bot) > INTERACTION_DISTANCE * INTERACTION_DISTANCE) ? guidP : bot; + + //Do not update if there's almost not change. + if (newBind.fDist(currentBind) < INTERACTION_DISTANCE * 2) + return false; + + //Update if the new bind is closer to the group leaders bind than the old one. + if (bot->GetGroup() && !ai->IsGroupLeader() && ai->GetGroupMaster()->GetPlayerbotAI()) + { + Player* player = ai->GetGroupMaster(); + WorldPosition leaderBind = PAI_VALUE(WorldPosition, "home bind"); + + float newBindDistanceToMasterBind = newBind.fDist(leaderBind); + float oldBindDistanceToMasterBind = currentBind.fDist(leaderBind); + + return newBindDistanceToMasterBind < oldBindDistanceToMasterBind; + } + + //Do not update if the new bind is pretty close already. + if (currentBind.fDist(bot) < 500.0f) return false; return true; diff --git a/playerbot/strategy/values/LastMovementValue.h b/playerbot/strategy/values/LastMovementValue.h index 75527d81d..cab47a0db 100644 --- a/playerbot/strategy/values/LastMovementValue.h +++ b/playerbot/strategy/values/LastMovementValue.h @@ -115,4 +115,21 @@ namespace ai public: StayTimeValue(PlayerbotAI* ai) : ManualSetValue(ai, 0) {} }; + + class LastLongMoveValue : public CalculatedValue + { + public: + LastLongMoveValue(PlayerbotAI* ai) : CalculatedValue(ai, "last long move", 30) {} + + WorldPosition Calculate(); + }; + + + class HomeBindValue : public CalculatedValue + { + public: + HomeBindValue(PlayerbotAI* ai) : CalculatedValue(ai, "home bind", 30) {} + + WorldPosition Calculate(); + }; } diff --git a/playerbot/strategy/values/TargetValue.h b/playerbot/strategy/values/TargetValue.h index a73d65b94..4776c2b09 100644 --- a/playerbot/strategy/values/TargetValue.h +++ b/playerbot/strategy/values/TargetValue.h @@ -78,22 +78,6 @@ namespace ai virtual ~TravelTargetValue() { delete value; } }; - class LastLongMoveValue : public CalculatedValue - { - public: - LastLongMoveValue(PlayerbotAI* ai) : CalculatedValue(ai, "last long move", 30) {} - - WorldPosition Calculate(); - }; - - class HomeBindValue : public CalculatedValue - { - public: - HomeBindValue(PlayerbotAI* ai) : CalculatedValue(ai, "home bind", 30) {} - - WorldPosition Calculate(); - }; - class IgnoreRpgTargetValue : public ManualSetValue& > { public: