mirror of
https://github.com/EQEmu/Server.git
synced 2026-02-21 13:42:24 +00:00
commit
5238d30236
@ -1723,7 +1723,9 @@ void NPC::AI_DoMovement() {
|
||||
// reached our randomly selected destination; force a pause
|
||||
if (cur_wp_pause == 0)
|
||||
{
|
||||
if (Waypoints.size() > 0 && Waypoints[0].pause)
|
||||
if (Waypoints.size() >= cur_wp && Waypoints[cur_wp].pause)
|
||||
cur_wp_pause = Waypoints[cur_wp].pause;
|
||||
else if (Waypoints.size() > 0 && Waypoints[0].pause)
|
||||
cur_wp_pause = Waypoints[0].pause;
|
||||
else
|
||||
cur_wp_pause = 38;
|
||||
|
||||
@ -308,13 +308,12 @@ void NPC::CalculateNewWaypoint()
|
||||
{
|
||||
bool on_center = Waypoints[cur_wp].centerpoint;
|
||||
std::vector<wplist> random_waypoints;
|
||||
for (auto &w : Waypoints)
|
||||
for (auto &wpl : Waypoints)
|
||||
{
|
||||
wplist wpl = w;
|
||||
if (wpl.index != cur_wp &&
|
||||
((on_center && !wpl.centerpoint) || (!on_center && wpl.centerpoint)))
|
||||
{
|
||||
random_waypoints.push_back(w);
|
||||
random_waypoints.push_back(wpl);
|
||||
}
|
||||
}
|
||||
|
||||
@ -385,8 +384,47 @@ void NPC::CalculateNewWaypoint()
|
||||
{
|
||||
if (cur_wp == patrol) // reutilizing patrol member instead of making new member for this wander type; here we use it to save a random waypoint
|
||||
{
|
||||
if (!Waypoints[cur_wp].centerpoint)
|
||||
{
|
||||
// if we have arrived at a waypoint that is NOT a centerpoint, then check for the existence of any centerpoint waypoint
|
||||
// if any exists then randomly go to it otherwise go to one that exist.
|
||||
std::vector<wplist> random_centerpoints;
|
||||
for (auto& wpl : Waypoints)
|
||||
{
|
||||
if (wpl.index != cur_wp && wpl.centerpoint)
|
||||
{
|
||||
random_centerpoints.push_back(wpl);
|
||||
}
|
||||
}
|
||||
|
||||
if (random_centerpoints.size() == 1)
|
||||
{
|
||||
patrol = random_centerpoints[0].index;
|
||||
break;
|
||||
}
|
||||
else if (random_centerpoints.size() > 1)
|
||||
{
|
||||
int windex = zone->random.Roll0(random_centerpoints.size());
|
||||
patrol = random_centerpoints[windex].index;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
while (patrol == cur_wp)
|
||||
patrol = zone->random.Int(0, Waypoints.size() - 1);
|
||||
{
|
||||
// Setting a negative number in pause of the select waypoints will NOT be included in the group of waypoints to be random.
|
||||
// This will cause the NPC to not stop and pause in any of the waypoints that is not part of random waypoints.
|
||||
std::vector<wplist> random_waypoints;
|
||||
for (auto& wpl : Waypoints)
|
||||
{
|
||||
if (wpl.index != cur_wp && wpl.pause >= 0 && !wpl.centerpoint)
|
||||
{
|
||||
random_waypoints.push_back(wpl);
|
||||
}
|
||||
}
|
||||
int windex = zone->random.Roll0(random_waypoints.size());
|
||||
patrol = random_waypoints[windex].index;
|
||||
}
|
||||
}
|
||||
if (patrol > cur_wp)
|
||||
cur_wp = cur_wp + 1;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user