NPC Grid Pause Bug
There is a bug in 4.4 that will cause roaming NPCs, moving along a grid to stop at a waypoint. Here is the fix we have put in at the Scorpious2k server.
The problem is in MovAI.CPP. In Mob::AI_Process() you find the following performed almost immediately on entry: Code:
if (AIwalking_timer->Check()) The problem is that, because of other considerations, it may not get to the part of the function that gets the new waypoint, resets the timer to the new pause time and starts moving it. The next time (and subsequent times) it will find the timer disabled and the local variable reset... so the mob will no longer move. I considered several possible solutions to this problem. The timer does have to be disabled so that can't be removed. Finally I came up with this: Find the line Code:
else if (roamer) AIwalking_timer->Enable(); so it looks like this Code:
else if (roamer) I hope this helps.[/i][/b] |
With the timer still being in the MobAI.cpp tho , do you still have the first in - first out npc movement?
Or do the mobs all move about freely? The only way I was able to get ALL mobs moving without first in - first out , was to move timer into Mob.h , but it didn't fix the whole problem. |
I didn't look, but I'm sure its still FIFO. Since I use random or random-half pauses unless I absolutely have to stay at a waypoint for a fixed time, it would be hard to tell by watching them.
It might interest you too, that this seems to have reduced the lag from zones with moving mobs. I was actually forced to find and fix this problem because it got in the way of making the boats work. We have come up with a way to do that and are in the process of implementing it. I will post the how-to when we have enough done to make it worthwhile for the other server ops. Its complex, but not especially difficult. The explination will be long. |
Excellent work Scorp. I was working on this as well and you beat me to it. From your description sounds like I was on the right track anyways...
As an added bonus, your contribution will allow tcsmyworld to sleep at night now. Regards, krich |
Thanks a ton scorpious2k :)
I threw in a small twist and wound up with exactly what i was looking for, move the timer into Mob.h and it lets each npc run on it's own timer , no first in - first out :) Krich get ahold of me , on irc channel or PM me :idea: |
TCS,
I got your message, but am having problems with replying to the PM...not sure why. Anyway, the short answer is yes. I'll contact you later on. Regards, krich |
ok, the celebration was a bit premature. yes it worked, but it was more of a band-aid than a cure. I wasn't happy with it, and felt it wasn't right. Timing pauses on npcs proved it. So I dug back in and ended up redoing a lot of the logic. It now works *perfectly*. But this is a major overhaul, not just a simple fix...
There were several problems. When spawned, the npc never paused at the first wp. The program logic actually assigned the pause time and started the timer at the time of the wp change. So the timer started at the time the npc started moving towards the next wp not when it got there. There were a few others, but who cares, right? All you want is the fix. :-) this is for 4.4 (of course) here it is.... in mob.h add the declaration Code:
void SetWaypointPause(); Code:
int16 gridno; move the following from its position near the top Code:
if (AIwalking_timer->Check()) Code:
else if (roamer) anway, replace the rest of Mob::AI_Process from this point down with the following so that starting at the else if (roamer) it looks like this Code:
else if (roamer) Code:
Code:
void Mob::SetWaypointPause() Finally in Mob::AssignWaypoints after the following Code:
else { //Retrieve a waypoint Code:
UpdateWaypoint(0); <whew> hope I didn't forget anything... I posted this in a hurry so I could get the info out. might even be useful in 5.0. [/b] |
Holy crap that's a lot of work! Good job.
I don't believe the AI engine has changed at all in 0.5.0, so it may port directly. Unfortunately, I've got my hands tied up in too many other pieces of code at the moment. I'm going to make this a sticky to remind us to integrate it when the time comes. |
Quote:
Quote:
If you want to do this, there is one thing I'd like to do first. I have it set now so all grids numbered 1-49 are a "1 way 1 time" type. They simply follow the waypoints from 1 to the end and then depop. I'm using it for boats, but there could be other uses. So what I'd like to do is change it to a new wander type rather than have it based on the grid id. Let me know about getting the code to you and about the new wander type. Always glad to help out on the project. |
merged in, by trump, love him
|
omg ban kathgar for bumping!!!!
|
All times are GMT -4. The time now is 04:58 AM. |
Powered by vBulletin®, Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.