-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/relaxed follow clean #79
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -23,7 +23,38 @@ bool FollowAction::Execute(Event event) | |||||||||||||||||||||||||||||||
| bool moved = false; | ||||||||||||||||||||||||||||||||
| if (!target.empty()) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| moved = Follow(AI_VALUE(Unit*, target)); | ||||||||||||||||||||||||||||||||
| // Relaxed follow: stay in radius, don't adjust angle/formation | ||||||||||||||||||||||||||||||||
| if (botAI->HasStrategy("relaxed follow", BOT_STATE_NON_COMBAT)) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| Unit* followTarget = AI_VALUE(Unit*, target); | ||||||||||||||||||||||||||||||||
| if (!followTarget) | ||||||||||||||||||||||||||||||||
| return false; | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| // Only move if bot is too far away from target | ||||||||||||||||||||||||||||||||
| float distance = sServerFacade->GetDistance2d(bot, followTarget); | ||||||||||||||||||||||||||||||||
| float maxDistance = formation->GetMaxDistance(); | ||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||
| if (distance > maxDistance) | ||||||||||||||||||||||||||||||||
| { | ||||||||||||||||||||||||||||||||
| // Calculate position at relaxedFollowDistance from master | ||||||||||||||||||||||||||||||||
| // Move towards master but stop at configured distance | ||||||||||||||||||||||||||||||||
| float keepDistance = sPlayerbotAIConfig->relaxedFollowDistance; | ||||||||||||||||||||||||||||||||
|
Comment on lines
+38
to
+41
|
||||||||||||||||||||||||||||||||
| { | |
| // Calculate position at relaxedFollowDistance from master | |
| // Move towards master but stop at configured distance | |
| float keepDistance = sPlayerbotAIConfig->relaxedFollowDistance; | |
| { | |
| // Validate formation max distance before using it | |
| if (maxDistance <= 0.0f) | |
| return false; | |
| // Calculate position at relaxedFollowDistance from master | |
| // Move towards master but stop at configured distance | |
| float keepDistance = sPlayerbotAIConfig->relaxedFollowDistance; | |
| // Ensure relaxed follow distance does not exceed formation max distance | |
| if (keepDistance >= maxDistance) | |
| keepDistance = maxDistance * 0.9f; |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| /* | ||
| * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it | ||
| * and/or modify it under version 3 of the License, or (at your option), any later version. | ||
| */ | ||
|
|
||
| #include "RelaxedFollowStrategy.h" | ||
|
|
||
| #include "Playerbots.h" |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,21 @@ | ||
| /* | ||
| * Copyright (C) 2016+ AzerothCore <www.azerothcore.org>, released under GNU AGPL v3 license, you may redistribute it | ||
| * and/or modify it under version 3 of the License, or (at your option), any later version. | ||
| */ | ||
|
|
||
| #ifndef _PLAYERBOT_RELAXEDFOLLOWSTRATEGY_H | ||
| #define _PLAYERBOT_RELAXEDFOLLOWSTRATEGY_H | ||
|
|
||
| #include "Strategy.h" | ||
|
|
||
| class PlayerbotAI; | ||
|
|
||
| class RelaxedFollowStrategy : public Strategy | ||
| { | ||
| public: | ||
| RelaxedFollowStrategy(PlayerbotAI* botAI) : Strategy(botAI) {} | ||
|
|
||
| std::string const getName() override { return "relaxed follow"; } | ||
| }; | ||
|
|
||
| #endif |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The configuration comment could be more descriptive to help users understand the relationship between RelaxedFollowDistance and FollowDistance. Consider clarifying that RelaxedFollowDistance should be less than FollowDistance, and explaining that this is the target distance bots will move to when they exceed the maximum formation distance. For example: "Distance to maintain when using 'relaxed follow' strategy. Bots move to this distance from master when they exceed the formation's max distance. Should be less than AiPlayerbot.FollowDistance to avoid constant re-positioning."