Skip to content

Commit d4b5af2

Browse files
committed
Sync NPCBot Changes 2-14-26
1 parent e9241db commit d4b5af2

File tree

2 files changed

+21
-6
lines changed

2 files changed

+21
-6
lines changed

src/server/game/AI/NpcBots/bot_ai.cpp

Lines changed: 19 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -11401,6 +11401,20 @@ bool bot_ai::OnGossipSelect(Player* player, Creature* creature/* == me*/, uint32
1140111401
}
1140211402
break;
1140311403
}
11404+
case 7: // Show Waypoint Data
11405+
{
11406+
ChatHandler ch(player->GetSession());
11407+
if (_travel_node_last && _travel_node_cur)
11408+
{
11409+
ch.PSendSysMessage("Waypoint node data:");
11410+
ch.PSendSysMessage("Current: name:{}, id:{}, x:{}, y:{}, z:{}, proximity:{}", _travel_node_last->GetName(), _travel_node_last->GetWPId(), _travel_node_last->GetPositionX(), _travel_node_last->GetPositionY(), _travel_node_last->GetPositionZ(), _travel_node_last->GetProximity());
11411+
ch.PSendSysMessage("Next: name:{}, id:{}, x:{}, y:{}, z:{}, proximity:{}", _travel_node_cur->GetName(), _travel_node_cur->GetWPId(), _travel_node_cur->GetPositionX(), _travel_node_cur->GetPositionY(), _travel_node_cur->GetPositionZ(), _travel_node_cur->GetProximity());
11412+
ch.PSendSysMessage("Actual: x:{}, y:{}, z:{}, distance:{}", me->GetPositionX(), me->GetPositionY(), me->GetPositionZ(), me->GetDistance(_travel_node_last->GetPosition()));
11413+
}
11414+
else
11415+
ch.PSendSysMessage("Waypoint data hasn't been created yet");
11416+
break;
11417+
}
1140411418
case 9: //reload config
1140511419
{
1140611420
close = false;
@@ -11419,7 +11433,6 @@ bool bot_ai::OnGossipSelect(Player* player, Creature* creature/* == me*/, uint32
1141911433
close = false;
1142011434
break;
1142111435
}
11422-
1142311436
if (close)
1142411437
break;
1142511438
}
@@ -11450,6 +11463,7 @@ bool bot_ai::OnGossipSelect(Player* player, Creature* creature/* == me*/, uint32
1145011463
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "<List Roles>", GOSSIP_SENDER_DEBUG_ACTION, GOSSIP_ACTION_INFO_DEF + 4);
1145111464
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "<List Spells>", GOSSIP_SENDER_DEBUG_ACTION, GOSSIP_ACTION_INFO_DEF + 5);
1145211465
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "<List Owners>", GOSSIP_SENDER_DEBUG_ACTION, GOSSIP_ACTION_INFO_DEF + 6);
11466+
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "<Waypoint Data>", GOSSIP_SENDER_DEBUG_ACTION, GOSSIP_ACTION_INFO_DEF + 7);
1145311467
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "<List Items>", GOSSIP_SENDER_EQUIPMENT_LIST, GOSSIP_ACTION_INFO_DEF + 1);
1145411468
AddGossipItemFor(player, GOSSIP_ICON_CHAT, "<Reload Config>", GOSSIP_SENDER_DEBUG_ACTION, GOSSIP_ACTION_INFO_DEF + 9);
1145511469

@@ -19091,7 +19105,7 @@ void bot_ai::Evade()
1909119105
if (nextNode->GetProximity() > 0.5f)
1909219106
{
1909319107
float angle = frand(0.f, float(M_PI) * 2.f);
19094-
float pdist = frand(0.f, nextNode->GetProximity() * 2.f);
19108+
float pdist = frand(0.f, nextNode->GetProximity());
1909519109
x = x + pdist * std::cos(angle);
1909619110
y = y + pdist * std::sin(angle);
1909719111
float ground = z;
@@ -19485,7 +19499,7 @@ WanderNode const* bot_ai::GetNextWanderNode(Position const* fromPos, uint8 lvl,
1948519499
if (me->IsInWorld() && !me->GetMap()->IsBattlegroundOrArena())
1948619500
{
1948719501
WanderNode::DoForAllMapWPs(_travel_node_cur->GetMapId(), [&nlinks, lvl = lvl, fac = faction, pos = fromPos](WanderNode const* wp) {
19488-
if (pos->GetExactDist2d(wp) < MAX_WANDER_NODE_DISTANCE && IsWanderNodeAvailableForBotFaction(wp, fac, true) && node_viable(wp, lvl))
19502+
if (pos->GetExactDist2d(wp) < MAX_WANDER_NODE_DISTANCE && IsWanderNodeAvailableForBotFaction(wp, fac, true) && node_viable(wp, lvl) && !wp->HasFlag(BotWPFlags::BOTWP_FLAG_NOT_A_START_POINT))
1948919503
nlinks.push_back(wp);
1949019504
});
1949119505
if (!nlinks.empty())
@@ -19497,7 +19511,7 @@ WanderNode const* bot_ai::GetNextWanderNode(Position const* fromPos, uint8 lvl,
1949719511
float mindist = 50000.0f; // Anywhere
1949819512
WanderNode::DoForAllMapWPs(_travel_node_cur->GetMapId(), [&node_new, &mindist, lvl = lvl, fac = faction, pos = fromPos](WanderNode const* wp) {
1949919513
float dist = pos->GetExactDist2d(wp);
19500-
if (dist < mindist && IsWanderNodeAvailableForBotFaction(wp, fac, false) && node_viable(wp, lvl))
19514+
if (dist < mindist && IsWanderNodeAvailableForBotFaction(wp, fac, false) && node_viable(wp, lvl) && !wp->HasFlag(BotWPFlags::BOTWP_FLAG_NOT_A_START_POINT))
1950119515
{
1950219516
mindist = dist;
1950319517
node_new = wp;
@@ -19522,7 +19536,7 @@ WanderNode const* bot_ai::GetNextWanderNode(Position const* fromPos, uint8 lvl,
1952219536

1952319537
//Overleveled or died: no viable nodes in reach, find one for teleport
1952419538
WanderNode::DoForAllWPs([&nlinks, lvl = lvl, fac = faction](WanderNode const* wp) {
19525-
if (IsWanderNodeAvailableForBotFaction(wp, fac, true) && wp->HasFlag(BotWPFlags::BOTWP_FLAG_SPAWN) && node_viable(wp, lvl))
19539+
if (IsWanderNodeAvailableForBotFaction(wp, fac, true) && wp->HasFlag(BotWPFlags::BOTWP_FLAG_SPAWN) && node_viable(wp, lvl) && !wp->HasFlag(BotWPFlags::BOTWP_FLAG_NOT_A_START_POINT))
1952619540
nlinks.push_back(wp);
1952719541
});
1952819542

src/server/game/AI/NpcBots/botwanderful.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@ enum class BotWPFlags : uint32
3838
BOTWP_FLAG_MOVEMENT_FORCE_JUMP_BEGIN = 0x00010000, // movement between 2 WPs having begin and end flags is forced to be a jump (prevent casting when falling from a cliff)
3939
BOTWP_FLAG_MOVEMENT_FORCE_JUMP_END = 0x00020000, // movement between 2 WPs having begin and end flags is forced to be a jump (prevent casting when falling from a cliff)
4040
BOTWP_FLAG_INTERACTION_MILL_RADIUS = 0x00040000, // if chosen as a mill point, radius is reduced to INTERACTION_DISTANCE
41-
BOTWP_FLAG_END = 0x00080000,
41+
BOTWP_FLAG_NOT_A_START_POINT = 0x00080000, // a bot can not teleport to this node, its a waypoint for moving only.
42+
BOTWP_FLAG_END = 0x00100000,
4243

4344
BOTWP_FLAG_ALLIANCE_OR_HORDE_ONLY = BOTWP_FLAG_ALLIANCE_ONLY | BOTWP_FLAG_HORDE_ONLY,
4445
BOTWP_FLAG_ALLIANCE_SPAWN_POINT = BOTWP_FLAG_SPAWN | BOTWP_FLAG_ALLIANCE_ONLY,

0 commit comments

Comments
 (0)