AIWander

Everything about development and the OpenMW source code.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: AIWander

Post by Zini »

Looks like we need a fix both in MWMechanics::AiWander and MWScript::OpAiWander. The repeat parameter needs to be split off from the idleList. And then this repeat parameter must default to a different value, depending on the number of additional parameters beyond the mandatory 3 (the arg0 value). Should be easy to fix. Let me know if you have any problems with that.
User avatar
TorbenC
Posts: 146
Joined: 26 Aug 2012, 23:13

Re: AIWander

Post by TorbenC »

Zini wrote:Looks like we need a fix both in MWMechanics::AiWander and MWScript::OpAiWander. The repeat parameter needs to be split off from the idleList. And then this repeat parameter must default to a different value, depending on the number of additional parameters beyond the mandatory 3 (the arg0 value). Should be easy to fix. Let me know if you have any problems with that.
Yes, it will indeed be an easy fix. The only reason I haven't assigned the task to myself is because I'm having trouble with openmw not building (cannot find ogre). Once i get this fixed I'll be on it if it is still readily available, hoping to get openmw working tonight.

Edit: And now thanks to werdanith ogre is fixed! :D Assigned.
User avatar
riothamus
Posts: 8
Joined: 10 Apr 2013, 21:19

Re: AIWander

Post by riothamus »

Torben,

We discussed on IRC today the minimum and maximum amount of time between an NPC's movements. I followed Fargoth around for about 45 minutes today and cam up with these:

Minimum - 0 seconds. I noticed quite a few instances where Fargoth would go to a place that he normally stopped at just to turn around and go back the way he came.

Maximum - 86 seconds. This was the longest time I noticed Fargoth staying in one spot. Perhaps round this up to 90 seconds?

From this, the AIWander pause time can be randomly picked from between 0 to 90 seconds.

More testing could be done, but after watching this guy walk around for 45 minutes, I'd say that this is what should be used.
User avatar
raevol
Posts: 3093
Joined: 07 Aug 2011, 01:12
Location: Caldera

Re: AIWander

Post by raevol »

riothamus wrote:... after watching this guy walk around for 45 minutes...
You deserve a medal.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: AIWander

Post by scrawl »

I would think it simply waits until the idle animation is finished. Then after that, it could either pick a new waypoint or play another full idle animation, based on the idle chance.
User avatar
riothamus
Posts: 8
Joined: 10 Apr 2013, 21:19

Re: AIWander

Post by riothamus »

That may actually be the case:

http://www.fliggerty.com/phpBB3/viewtop ... =30&t=5833

Especially this part:
There is no timer, just a randomized destination point which the AI arrives at, then makes a new decision. You can test your thesis by blocking a wandering NPC's path, it does not appear to make a new decision after any length of time. You can also test by using a very long range distance, the AI should not idle until it reaches its very distant destination.
Well, following that damned Fargoth around was a good use of time. :roll: Glad I read the fliggerty post AFTER I did that.
User avatar
TorbenC
Posts: 146
Joined: 26 Aug 2012, 23:13

Re: AIWander

Post by TorbenC »

Thank you very much riothamus I know the pain of watching the NPCs do the same thing over and over again for so long, putting yourself through it was very nice of you. :)

Indeed, it looks like what you did proved Hrnchamd right further, no timer is used in any way by the looks of it. This is great info, after this step I think AIWander will be complete.

Edit:

Aaaaand, now AIWander is mostly implemented. Only two things left to do, figure out how high or low vanilla NPCs are able to choose nodes from in range then implement that, and I need a function that allows me to get if the idle animations I'm passing have completed yet (I wanted to avoid this seeing as I have no clue how to implement it but it is indeed necessary).

Then one tweak to pathfinding (will be a later merge) will do it.

Edit 2:

Alright, AIWander is now for the most part complete. Highest and lowest z axis checks were unnecessary (already done and there are no special limits), I created the function to check if the idle is done with great help from Chris. All that is left now is kind of important...

See, NPCs will actually add to the list of nodes they can move to, all the locations that NPCs were placed at in the current cell via editor. This looks like a change better suited for pathfinding itself. Then it is simply checking if I am within distance of a node instead of checking if I am dead on the node so it prevents clogging the pathgrid when two npcs collide, and AIWander will be ready to merge.

Edit 3:

AIWander has been merged (and 2 day 1 patches on it... -_-; ). Everything works great except for one major problem, something that *should* have come up when I was testing it, if there is no pathgrid then it segfaults upon initiating the command with a range. This will prolly be an easy fix but I can't do it right this second.
User avatar
cc9cii
Posts: 523
Joined: 28 Mar 2013, 04:01

Re: AIWander

Post by cc9cii »

Reviving an old thread, I was directed here by TorbenC.

Quoting from GHF:
TorbenC wrote:
Hrnchamd wrote: As far as I can tell an NPC strongly prefers travelling to the starting location of any NPC (including their own), which is why they always travel back to their starting location when given short wander distances. That was a good observation. This keeps NPCs walking around in populated areas instead of spreading out. I don't think path nodes are used as targets, they are only used by the route planner; wandering clearly works in areas without a path grid. Anyway, stopping directly on a path node to idle would cause blockages, you should pick a point near but not on top of the destination.
Going to work on the "selecting around a node" thing now, though this might be something in pathfinding and not actually in AIWander itself. First I'll need to see how Morrowind does it though, also AIWander doesn't work at all properly (in fact NPCs stop after taking a few steps) if there is no pathgrid. The way it works? It goes to the nearest actual pathnode available (not where an NPC was placed) and then it will completely stop some times, other times it will walk back then do some random stuff, then stop.
If one turns on pathgrid display and observe wandering NPC's on vanilla (tpg using the console), they don't stop right on the pathgrid point. Some stop a bit further away, some stop before.

Issuing Actors Reset command (ra using the console in vanilla), one can also see that the NPC's don't always start at the nearest pathgrid point. The back path (where there are no houses) in Sadrith Mora there is a guard. Issue "tpg" and "ra" while watching him. He will start walking towards the council building, but on a direct path, ignoring a pathgrid point nearby.

Our implementation of PathFinder may need some changes if we want to mimic vanilla faithfully. But do we want/need to? I would prefer to make improvements as long as existing scripts or mods don't break. I'm also investigating support for recast navmesh and that definitely isn't in vanilla.
User avatar
TorbenC
Posts: 146
Joined: 26 Aug 2012, 23:13

Re: AIWander

Post by TorbenC »

cc9cii wrote:If one turns on pathgrid display and observe wandering NPC's on vanilla (tpg using the console), they don't stop right on the pathgrid point. Some stop a bit further away, some stop before.
Yes, this is a work around, I am unsure if vanilla has this behavior as well. The problem is that if an NPC chooses a node that another NPC is already standing on (playing an animation for instance), it can't get close enough to trigger it as a complete travel and move on to decision making.

In vanilla i have seen two NPCs standing on (or... near) one path node and playing animations so there must be something they are doing, I did not research this thoroughly though so for now I am simply entitling it a "work around."
cc9cii wrote:Issuing Actors Reset command (ra using the console in vanilla), one can also see that the NPC's don't always start at the nearest pathgrid point. The back path (where there are no houses) in Sadrith Mora there is a guard. Issue "tpg" and "ra" while watching him. He will start walking towards the council building, but on a direct path, ignoring a pathgrid point nearby.
Yes, this is because there is a flaw with how pathgrids are read in, it turns out that the original location of an NPC in a cell is, while not considered a node for traveling *to*, a path grid node for, as said on GHF, "a place of interest." Normally only the NPC placed there will actually use it, but you can test this theory out in Seyda Neen in vanilla by going to the shacks in town, the Dark Elf (male) standing next to the shore will show you this if you turn on pathgrids and tell him to AIWander in about a 500 radius, he will also walk back to his original location.

This is actually what I was going to work on next before real life started turning hectic, then we lost internet for 6 months and I wasn't able to program. Now I am doing other things and I simply don't have time for programming OpenMW AI (otherwise I would be). I plan on returning eventually though.
cc9cii wrote:Our implementation of PathFinder may need some changes if we want to mimic vanilla faithfully. But do we want/need to? I would prefer to make improvements as long as existing scripts or mods don't break. I'm also investigating support for recast navmesh and that definitely isn't in vanilla.
I personally prefer exact mimicing, but honestly it isn't my project and there is a whole team at play which should be asked this. Personally I would await Zini's responce to this question, though I believe it will be something along the lines of agreeing with you in regards to "as long as existing scripts or mods don't break."

Thank you for taking the time to read this and the other threads, I'm hoping the AIWander package makes a bit more sense and answers some of those TODOs you were placing.
User avatar
Zini
Posts: 5538
Joined: 06 Aug 2011, 15:16

Re: AIWander

Post by Zini »

I suggest to not spend a lot of time on improving the waypoint system beyond MW. Chances are we will throw it out after 1.0 anyway in favour of navmeshes. We may keep the waypoint system as a compatibility fallback for old content that otherwise gets into trouble, but I don't see much of a future for it.
Post Reply