Jump to content
Sign in to follow this  
MadMonk

FSM moveTo and DoMove

Recommended Posts

Ive been trying to convert some sqf script for a dog AI system into an FSM now I understand how they work, but I'm really struggling with moving the dog unit around from within the FSM its self.

As I understand it, if the FSM is called using the execFSM, any agent moves must be done using doMove. If the FSM is called using doFSM, then moveTo should be used. Having looked at some

existing FSM code in arma2, I have seen examples that disprove this observation and I'm thinking that something could have changed with a patch. I've tried both calling methods in my code and

the unit doesnt move at all. Ive put some over the top logging on all scripts and stages in the FSM and everything seems to be ok but no movement and no errors are logged in the rpt file.

Up to now, the only Arma 3 FSM's Ive seen do not contain any functionality to move units and any information about moving units relates to Arma 2 and before.

In case anyone else is looking at FSM's and finds this post in the future, Im posting a link to another thread I found which contains some good info but it doesnt seem to apply to Arma3.

http://forums.bistudio.com/showthread.php?118451-doFSM-or-execFSM-is-there-an-advantage-for-one-over-the-other

Edited by MadMonk

Share this post


Link to post
Share on other sites

when it comes to agents my experience is that you can only use moveto since domove seems to be reserved for "human-like" units, meaning based on CAManBAse rather than its parent Man. unfortunately moveTo commands don't overwrite each other. that means if you have a script that has the unit moving to a location and the location is constantly changing, like when you want it to follow another unit, your unit will always complete the old moveto command before doing the new one. that's the main reason why the dayZ mod zombies, for example, are so ineffective. they always run to your old position not your current one.

not sure if this will be of any help but i thought why not share this annoying little detail. you can test this by simply using a radio trigger to issue a moveTo or domove command using your own position as a destination using "getpos player" since this updates your postion. you will see the difference right away when you keep triggering the trigger several times shortly after another.

EDIT: i just tested myself and it seems moveTo doesn't do anything to the unit in arma 3. i'm pretty sure it worked like described in arma 2. my memory could be clouded though.

Edited by Bad Benson

Share this post


Link to post
Share on other sites

Are there dogs in A3? :)

I don't remember my exact reasons, but I eventually ended up using execFSM only in A2 too. I had some issues with doFSM, and the greater control of execFSM was welcomed as far as I remember.

doMove and doStop surely works in A3 as well. I haven't tested it extensively yet though (eg.: in A2 I had issues of the destination position not filling up correctly, so I had to reissue doMoves)

So I'd advise you to go with execFSM and doMoves, but it is a no way well-founded advice for A3, only my past experiences are making me say this. :)

BTW: doMove in doFSM mustn't work in A2 either, since they both are DOs and you can DO one thing at a time. And moveTo was not working outside of DOs either in A2.

I can send you my dog-controlling FSMs from A2 if interested.

Edited by zapat

Share this post


Link to post
Share on other sites

Thanks for the replies. Ive tried reproducing the FSM in arma 2 and it still doesnt work so it looks like its a problem with my understanding of FSM's. At the moment, I'm experimenting with an example I found at this link : http://resources.bisimulations.com/wiki/File:FSM_Demo.zip

I've got the example working, with a little tweaking as it was written for the BIS simulator system. Once I'm happy I understand what I did wrong, I'll convert it to Arma 3 and post my findings.

Btw Zapat, I took the dogs from arma 2 by adding the animals2 pbo file. They work pretty well when controlling the dogs by script but I know FSM is the way forward now Ive been reading up on them. The animals 2 pbo dog (Pastor) does have some references missing to certain animations (like attack) which is a shame, Im hoping to be able to fix this by extending the config and adding the references to the rtm files. I have tried this once but didnt have any joy, but Im definitely giving it another go once I crack this FSM.

Share this post


Link to post
Share on other sites

You've managed to find yourself a pretty complicated example, which is too simple. :D

I mean it does nothing that an FSM is best at (that's why it is simple)

but uses the same FSM file for a doFSM call and for a execFSM call (that's why it is complicated).

Here is my simplistic dog attack FSM:

https://docs.google.com/file/d/0BxjqGzmtx1GBZVNhMmtHVjltODA/edit?usp=sharing

This must be run for each dog of a pack by

{[_x, player] execFSM "ai_dog.fsm";}foreach _dogs;

And they all will attack everyone around player. :) Pretty fun actually. Can't wait for A3 dogs. :)

So in fact this should be done by doFSM (since this describes a DO for a dog unit: attack), but as I said I'd had problems with that, and this execFSM is working great. This FSM is btw called by another FSM, which is looking for units getting close to the dogs, and which is controlling the idle dogs.

Always keep an eye on priorities in the FSM. If you do that, you'll spot the error I left for you in the FSM. Hahaha. Actually I didn't leave it for you, but its there. He who finds it first gets a lollipop.

(okay, I don't want you to run unfinishable FSMs: change the "dead" priority to 1)

Edited by zapat

Share this post


Link to post
Share on other sites
when it comes to agents my experience is that you can only use moveto since domove seems to be reserved for "human-like" units, meaning based on CAManBAse rather than its parent Man. unfortunately moveTo commands don't overwrite each other. that means if you have a script that has the unit moving to a location and the location is constantly changing, like when you want it to follow another unit, your unit will always complete the old moveto command before doing the new one. that's the main reason why the dayZ mod zombies, for example, are so ineffective. they always run to your old position not your current one.

not sure if this will be of any help but i thought why not share this annoying little detail. you can test this by simply using a radio trigger to issue a moveTo or domove command using your own position as a destination using "getpos player" since this updates your postion. you will see the difference right away when you keep triggering the trigger several times shortly after another.

EDIT: i just tested myself and it seems moveTo doesn't do anything to the unit in arma 3. i'm pretty sure it worked like described in arma 2. my memory could be clouded though.

Thanks for this, Im going to have to look into it further. Actually, when I say dog, I'm actually using a man for the time being since creating a dog from the animals2 pbo using the createAgent method throws a repeated error log in the rpt file that just continues indefinitely.

This is the error in case it means anything to anyone. I am thinking that its a conflict somewhere with an underlying fsm for the dog.

The following three messages are logged repeatedly -:

Error in expression <places [position _agent,_runDistanceMax,_expDanger,10,_tries];

_closeEnemy = _>

Error position: <_expDanger,10,_tries];

_closeEnemy = _>

Error Undefined variable in expression: _expdanger

Error in expression <places [position _agent,_runDistanceMax,_expDanger,10,_tries];

It seems that the createAgent command is causing problems with Arma 3. With further testing, I proved that doMove does work in the fsm if I add a unit in the editor and call the script in the units init to run the fsm file, whereas using createAgent and doMove, the unit remains static. To note, with createAgent and setpos, this does work. I seem to remember reading something a while back about createAgent not having any underlying AI functionality and that a doMove doesnt work because the base AI isnt there, I could be wrong though.

Next step is to test createAgent and doMove with Arma2.

The reason I'm caught up on using the createAgent method is that I've seen it being used in the Dayz code and thought the technique could be applied to dogs. Maybe not, or maybe its an arma 3 quirk. Basically I want lots of dogs that can run in packs and Im hoping to implement a fairly in-depth AI system.

---------- Post added at 20:51 ---------- Previous post was at 20:37 ----------

You've managed to find yourself a pretty complicated example, which is too simple. :D

I mean it does nothing that an FSM is best at (that's why it is simple)

but uses the same FSM file for a doFSM call and for a execFSM call (that's why it is complicated).

Here is my simplistic dog attack FSM:

https://docs.google.com/file/d/0BxjqGzmtx1GBZVNhMmtHVjltODA/edit?usp=sharing

This must be run for each dog of a pack by

{[_x, player] execFSM "ai_dog.fsm";}foreach _dogs;

And they all will attack everyone around player. :) Pretty fun actually. Can't wait for A3 dogs. :)

So in fact this should be done by doFSM (since this describes a DO for a dog unit: attack), but as I said I'd had problems with that, and this execFSM is working great. This FSM is btw called by another FSM, which is looking for units getting close to the dogs, and which is controlling the idle dogs.

Always keep an eye on priorities in the FSM. If you do that, you'll spot the error I left for you in the FSM. Hahaha. Actually I didn't leave it for you, but its there. He who finds it first gets a lollipop.

(okay, I don't want you to run unfinishable FSMs: change the "dead" priority to 1)

Many thanks for this, I'll give it a try and let you know how it goes. Yes, I'm hoping for some badass dogs with arma 3, the arma 2 dogs are pretty tame looking but I found that sampling some decent barking sounds off youtube clips does give them an edge. Its a shame the attack animation isnt configured though, I spent a good while looking at it, learned a fair bit but didnt crack it in the end.

Share this post


Link to post
Share on other sites
You've managed to find yourself a pretty complicated example, which is too simple. :D

I mean it does nothing that an FSM is best at (that's why it is simple)

but uses the same FSM file for a doFSM call and for a execFSM call (that's why it is complicated).

Here is my simplistic dog attack FSM:

https://docs.google.com/file/d/0BxjqGzmtx1GBZVNhMmtHVjltODA/edit?usp=sharing

This must be run for each dog of a pack by

{[_x, player] execFSM "ai_dog.fsm";}foreach _dogs;

And they all will attack everyone around player. :) Pretty fun actually. Can't wait for A3 dogs. :)

So in fact this should be done by doFSM (since this describes a DO for a dog unit: attack), but as I said I'd had problems with that, and this execFSM is working great. This FSM is btw called by another FSM, which is looking for units getting close to the dogs, and which is controlling the idle dogs.

Always keep an eye on priorities in the FSM. If you do that, you'll spot the error I left for you in the FSM. Hahaha. Actually I didn't leave it for you, but its there. He who finds it first gets a lollipop.

(okay, I don't want you to run unfinishable FSMs: change the "dead" priority to 1)

Thanks for the dog script it works great! Its cleared up a couple of misunderstandings I had about FSM's. It looks like the create agent method is broken when using doMove, Ive verified this a number of times now and have converted to using createUnit instead. It would be interesting to know the difference as I get the imrpression that createAgent has less overhead.

Share this post


Link to post
Share on other sites

Good question. Haven't really found an answer yet. Nor have I really cared actually. You could ask that in A2, the bigger minds are still over there I guess.

Share this post


Link to post
Share on other sites
It looks like the create agent method is broken when using doMove,

Try adding this to your FSM.

_dog disableAI "FSM";

_dog setBehaviour "CARELESS";

_dog setCombatMode "RED";

_dog setSkill 0;

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×