mirror of
https://github.com/liyunfan1223/mod-playerbots.git
synced 2026-06-20 15:39:25 +02:00
Bug fix. Edge case where bots would get stuck in cities. (#2269)
<!--
Thank you for contributing to mod-playerbots, please make sure that
you...
1. Submit your PR to the test-staging branch, not master.
2. Read the guidelines below before submitting.
3. Don't delete parts of this template.
DESIGN PHILOSOPHY: We prioritize STABILITY, PERFORMANCE, AND
PREDICTABILITY over behavioral realism.
Every action and decision executes PER BOT AND PER TRIGGER. Small
increases in logic complexity scale
poorly across thousands of bots and negatively affect all. We prioritize
a stable system over a smarter
one. Bots don't need to behave perfectly; believable behavior is the
goal, not human simulation.
Default behavior must be cheap in processing; expensive behavior must be
opt-in.
Before submitting, make sure your changes aligns with these principles.
-->
## Pull Request Description
<!-- Describe what this change does and why it is needed -->
When I refactored flight destinations, I wanted to make where bots go
more intentional. so I made it dependent on the
allianceHubsPerLevelCache and hodeHubsPerLevelCache. This system relied
on there being an innkeeper in each area that the bots would fly to.
However, not every zone has an innkeeper, and so there was an odd
situation where bots had nowhere to fly to. (Most notably at level 53.)
This solves that by hardcoding the flightmasters in those areas into the
cache.
I also put back in the city teleport probability check which was forcing
every bot to teleport to a city on level up.
## Feature Evaluation
<!--
If your PR is very minimal (comment typo, wrong ID reference, etc), and
it is very obvious it will not have
any impact on performance, you may skip these question. If necessary, a
maintainer may ask you for them later.
-->
<!-- Please answer the following: -->
- Describe the **minimum logic** required to achieve the intended
behavior.
- Describe the **processing cost** when this logic executes across many
bots.
## How to Test the Changes
<!--
- Step-by-step instructions to test the change.
- Any required setup (e.g. multiple players, number of bots, specific
configuration).
- Expected behavior and how to verify it.
-->
## Impact Assessment
<!-- As a generic test, before and after measure of pmon (playerbot pmon
tick) can help you here. -->
- Does this change increase per-bot/per-tick processing or risk scaling
poorly with thousands of bots?
- - [x] No, not at all
- - [ ] Minimal impact (**explain below**)
- - [ ] Moderate impact (**explain below**)
- Does this change modify default bot behavior?
- - [x] No
- - [ ] Yes (**explain why**)
- Does this change add new decision branches or increase maintenance
complexity?
- - [x] No
- - [ ] Yes (**explain below**)
## Messages to Translate
<!--
Bot messages have to be translatable, but you don't need to do the
translations here. You only need to make sure
the message is in a translatable format, and list in the table the
message_key and the default English message.
Search for GetBotTextOrDefault in the codebase for examples.
-->
- Does this change add bot messages to translate?
- - [x] No
- - [ ] Yes (**list messages in the table**)
| Message key | Default message |
| --------------- | ------------------ |
| | |
| | |
## AI Assistance
<!--
AI assistance is allowed, but all submitted code must be fully
understood, reviewed, and owned by the contributor.
We expect contributors to be honest about what they do and do not
understand.
-->
- Was AI assistance used while working on this change?
- - [ ] No
- - [x] Yes (**explain below**)
<!--
If yes, please specify:
- Purpose of usage (e.g. brainstorming, refactoring, documentation, code
generation).
- Which parts of the change were influenced or generated, and whether it
was thoroughly reviewed.
-->
Debugging and comments.
## Final Checklist
- - [x] Stability is not compromised.
- - [x] Performance impact is understood, tested, and acceptable.
- - [x] Added logic complexity is justified and explained.
- - [x] Documentation updated if needed (Conf comments, WiKi commands).
## Notes for Reviewers
<!-- Anything else that's helpful to review or test your pull request.
-->
This commit is contained in:
parent
f5363c9465
commit
ca54cff6f5
@ -1768,13 +1768,16 @@ void RandomPlayerbotMgr::RandomTeleportForLevel(Player* bot)
|
|||||||
if (bot->InBattleground())
|
if (bot->InBattleground())
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
if (bot->GetLevel() >= 10 && urand(0, 100) < sPlayerbotAIConfig.probTeleToBankers * 100)
|
||||||
|
{
|
||||||
std::vector<WorldLocation> locs = sTravelMgr.GetCityLocations(bot);
|
std::vector<WorldLocation> locs = sTravelMgr.GetCityLocations(bot);
|
||||||
if (!locs.empty())
|
if (!locs.empty())
|
||||||
{
|
{
|
||||||
RandomTeleport(bot, locs, true);
|
RandomTeleport(bot, locs, true);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
locs = sTravelMgr.GetTeleportLocations(bot);
|
}
|
||||||
|
std::vector<WorldLocation> locs = sTravelMgr.GetTeleportLocations(bot);
|
||||||
if (!locs.empty())
|
if (!locs.empty())
|
||||||
{
|
{
|
||||||
RandomTeleport(bot, locs, false);
|
RandomTeleport(bot, locs, false);
|
||||||
|
|||||||
@ -4419,6 +4419,7 @@ std::vector<std::vector<uint32>> TravelMgr::GetOptimalFlightDestinations(Player*
|
|||||||
bot->GetTeamId());
|
bot->GetTeamId());
|
||||||
if (!fromNode)
|
if (!fromNode)
|
||||||
return validDestinations;
|
return validDestinations;
|
||||||
|
|
||||||
std::vector<WorldLocation> candidateLocations;
|
std::vector<WorldLocation> candidateLocations;
|
||||||
if (bot->GetLevel() >= 10 && urand(0, 100) < sPlayerbotAIConfig.probTeleToBankers * 100)
|
if (bot->GetLevel() >= 10 && urand(0, 100) < sPlayerbotAIConfig.probTeleToBankers * 100)
|
||||||
candidateLocations = GetCityLocations(bot);
|
candidateLocations = GetCityLocations(bot);
|
||||||
@ -4673,6 +4674,31 @@ void TravelMgr::PrepareDestinationCache()
|
|||||||
if (forAlliance)
|
if (forAlliance)
|
||||||
allianceFlightMasterCache[guid] = pos;
|
allianceFlightMasterCache[guid] = pos;
|
||||||
flightMastersCount++;
|
flightMastersCount++;
|
||||||
|
|
||||||
|
// Zones that have flight masters but no innkeepers — use flight master as hub
|
||||||
|
static const std::set<uint32> zonesWithoutInnkeeper = {
|
||||||
|
4, // Blasted Lands (52-57)
|
||||||
|
16, // Azshara (45-52)
|
||||||
|
28, // Western Plaguelands (50-60)
|
||||||
|
46, // Burning Steppes (51-60)
|
||||||
|
51, // Searing Gorge (45-51)
|
||||||
|
361, // Felwood (47-57)
|
||||||
|
490, // Un'Goro Crater (49-56)
|
||||||
|
2817, // Crystalsong Forest (77-80)
|
||||||
|
4197 // Wintergrasp (79-80)
|
||||||
|
};
|
||||||
|
if (zonesWithoutInnkeeper.count(areaId))
|
||||||
|
{
|
||||||
|
LevelBracket bracket = zone2LevelBracket[areaId];
|
||||||
|
WorldPosition loc(mapId, x + cos(orient) * 5.0f, y + sin(orient) * 5.0f, z + 0.5f, orient + M_PI);
|
||||||
|
for (int i = bracket.low; i <= bracket.high; i++)
|
||||||
|
{
|
||||||
|
if (forHorde)
|
||||||
|
hordeHubsPerLevelCache[i].push_back(loc);
|
||||||
|
if (forAlliance)
|
||||||
|
allianceHubsPerLevelCache[i].push_back(loc);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else if (creatureTemplate->npcflag & UNIT_NPC_FLAG_INNKEEPER)
|
else if (creatureTemplate->npcflag & UNIT_NPC_FLAG_INNKEEPER)
|
||||||
{
|
{
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user