Skip to content

Commit 9af8ed5

Browse files
committed
Hearstone: Groupmembers of a botgroup now try to set their hearthstone to the same location as the group leader.
1 parent 985ca6e commit 9af8ed5

File tree

3 files changed

+40
-18
lines changed

3 files changed

+40
-18
lines changed

playerbot/strategy/triggers/RpgTriggers.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -421,10 +421,31 @@ bool RpgHomeBindTrigger::IsActive()
421421
if (guidP.IsHostileTo(bot))
422422
return false;
423423

424-
if (AI_VALUE(WorldPosition, "home bind").distance(bot) < 500.0f)
424+
//Do not update for realplayers/always online when at max level.
425+
if ((ai->IsRealPlayer() || sPlayerbotAIConfig.IsFreeAltBot(bot)) && bot->GetLevel() == DEFAULT_MAX_LEVEL)
425426
return false;
426427

427-
if ((ai->IsRealPlayer() || sPlayerbotAIConfig.IsFreeAltBot(bot)) && bot->GetLevel() == DEFAULT_MAX_LEVEL)
428+
WorldPosition currentBind = AI_VALUE(WorldPosition, "home bind");
429+
WorldPosition newBind = (guidP.sqDistance2d(bot) > INTERACTION_DISTANCE * INTERACTION_DISTANCE) ? guidP : bot;
430+
431+
//Do not update if there's almost not change.
432+
if (newBind.fDist(currentBind) < INTERACTION_DISTANCE * 2)
433+
return false;
434+
435+
//Update if the new bind is closer to the group leaders bind than the old one.
436+
if (bot->GetGroup() && !ai->IsGroupLeader() && ai->GetGroupMaster()->GetPlayerbotAI())
437+
{
438+
Player* player = ai->GetGroupMaster();
439+
WorldPosition leaderBind = PAI_VALUE(WorldPosition, "home bind");
440+
441+
float newBindDistanceToMasterBind = newBind.fDist(leaderBind);
442+
float oldBindDistanceToMasterBind = currentBind.fDist(leaderBind);
443+
444+
return newBindDistanceToMasterBind < oldBindDistanceToMasterBind;
445+
}
446+
447+
//Do not update if the new bind is pretty close already.
448+
if (currentBind.fDist(bot) < 500.0f)
428449
return false;
429450

430451
return true;

playerbot/strategy/values/LastMovementValue.h

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -115,4 +115,21 @@ namespace ai
115115
public:
116116
StayTimeValue(PlayerbotAI* ai) : ManualSetValue<time_t>(ai, 0) {}
117117
};
118+
119+
class LastLongMoveValue : public CalculatedValue<WorldPosition>
120+
{
121+
public:
122+
LastLongMoveValue(PlayerbotAI* ai) : CalculatedValue<WorldPosition>(ai, "last long move", 30) {}
123+
124+
WorldPosition Calculate();
125+
};
126+
127+
128+
class HomeBindValue : public CalculatedValue<WorldPosition>
129+
{
130+
public:
131+
HomeBindValue(PlayerbotAI* ai) : CalculatedValue<WorldPosition>(ai, "home bind", 30) {}
132+
133+
WorldPosition Calculate();
134+
};
118135
}

playerbot/strategy/values/TargetValue.h

Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -78,22 +78,6 @@ namespace ai
7878
virtual ~TravelTargetValue() { delete value; }
7979
};
8080

81-
class LastLongMoveValue : public CalculatedValue<WorldPosition>
82-
{
83-
public:
84-
LastLongMoveValue(PlayerbotAI* ai) : CalculatedValue<WorldPosition>(ai, "last long move", 30) {}
85-
86-
WorldPosition Calculate();
87-
};
88-
89-
class HomeBindValue : public CalculatedValue<WorldPosition>
90-
{
91-
public:
92-
HomeBindValue(PlayerbotAI* ai) : CalculatedValue<WorldPosition>(ai, "home bind", 30) {}
93-
94-
WorldPosition Calculate();
95-
};
96-
9781
class IgnoreRpgTargetValue : public ManualSetValue<std::set<ObjectGuid>& >
9882
{
9983
public:

0 commit comments

Comments
 (0)