Jump to content

Photo
- - - - -

FSM editing


  • Please log in to reply
49 replies to this topic

#1 fabrizio_T

fabrizio_T

    Master Gunnery Sergeant

  • Members
  • 1380 posts

Posted 18 February 2007 - 05:38 PM

Hello,

i've tried to do some FSM editing through Flea's nice editor.

I was able to correctly load my FSM (a modified version of formation.fsm) through DoFSM / CommandFSM, but i noticed that the unit i've bound was ignoring the FSM logic.

After some investigation i discovered the variable "_this" - the one i think should identify the unit object appears to be undefined in the FSM (tried to dump it by Hint / sidechat).

Also it seems that a "default" FSM is still overriding my own ...

Any clue ?




bCombat ArmA 3 infantry AI Mod :
Download: bCombat [SP]
Official thread: [OPEN BETA] [SP] bCombat infantry AI Mod
Project page: https://github.com/fabrizioT/bCombat

Youtube Channel:
http://www.youtube.c...ser/MrFabrizioT

#2 sbsmac

sbsmac

    Master Gunnery Sergeant

  • Members
  • 1297 posts

Posted 18 February 2007 - 07:03 PM

See my post here:-

http://www.flashpoin...-bin....0;st=15

You want to use the _units variable for your case.

When you use fms's in addons, the _this variable _is_ defined but that's a lot more awkward than just calling doFSM.
Author of PVPmissionWizard ArmA2FPSAnalyser AddonChecker and ... squint

Tools homepage

Crosseyed and Painless - a blog about my ArmA2 developments



#3 fabrizio_T

fabrizio_T

    Master Gunnery Sergeant

  • Members
  • 1380 posts

Posted 19 February 2007 - 07:54 AM

Thank you very much.
bCombat ArmA 3 infantry AI Mod :
Download: bCombat [SP]
Official thread: [OPEN BETA] [SP] bCombat infantry AI Mod
Project page: https://github.com/fabrizioT/bCombat

Youtube Channel:
http://www.youtube.c...ser/MrFabrizioT

#4 5133p39

5133p39

    Sergeant Major

  • Members
  • 1423 posts

Posted 16 June 2007 - 03:39 PM

sorry for "stealing" this topic, but i think it would be counterproductive to create another topic about FSM.

I want to ask for anybodys opinion on using and running one big FSM file, or splitting it into more files which will switch between themselves.
What do you think works better (performance-wise)?

EDIT: ...it probably depends on how often are the FSM switched, so let's assume that it will be switching between 3-4 different FSM files, while each FSM file should be running for at least about 5 seconds (which is the shortest possible time, in reality it should last few minutes),
with 50-70 units each running its own FSM.




Core i7-4820K @ 4.8GHz | 64GB DDR3 | ASUS GTX TITAN Black | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
Windows 7 64bit Professional | OFP, Arma, Arma 2, Arma 3

Free hug for everybody who reads first, and asks later! :286:

#5 CrashDome

CrashDome

    Master Gunnery Sergeant

  • Members
  • 1260 posts

Posted 17 June 2007 - 03:37 AM

Have you read the tutorial?

Tutorial

You may find some of your answers there.

#6 RN Malboeuf

RN Malboeuf

    Chief Warrant Officer

  • Members
  • 3458 posts

Posted 17 June 2007 - 07:07 AM

CrashDome
great job on the tute Posted Image

Needed tools can be found here
http://community.bis...Community_Tools
Finite State Machine Editor 1.04 (by Flea) seems to be the best imho.
[im]http://www.roughnecks.org/malboeuf/pissonTKC.gif[/img] >100kb
Roughneck Whore House - rn1.roughnecks.org
AMD 64x2 4400 2200@2450 Mhz- 2 gig dual DDR PC4000 - SATA HDs

#7 5133p39

5133p39

    Sergeant Major

  • Members
  • 1423 posts

Posted 17 June 2007 - 07:15 AM

Have you read the tutorial?

Tutorial

You may find some of your answers there.

yes, i read it, but that didn't answered my question.
Maybe i missed it, but i really haven't found anything concerning the overhead of switching FSMs.

btw. it would be nice to have some HTML version of the tutorial (i prefer html or plaintext, except when you really need to preserve correct layout of the document)
Core i7-4820K @ 4.8GHz | 64GB DDR3 | ASUS GTX TITAN Black | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
Windows 7 64bit Professional | OFP, Arma, Arma 2, Arma 3

Free hug for everybody who reads first, and asks later! :286:

#8 5133p39

5133p39

    Sergeant Major

  • Members
  • 1423 posts

Posted 17 June 2007 - 08:16 AM

I decided to use the switching of different FSM files - primarily because it makes the sources more lucid, and truth is that i can simly join them back into one FSM whenever i want.

I'll try the difference later, but if there is anybody who's got some insight, it would be nice to share :)
Core i7-4820K @ 4.8GHz | 64GB DDR3 | ASUS GTX TITAN Black | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
Windows 7 64bit Professional | OFP, Arma, Arma 2, Arma 3

Free hug for everybody who reads first, and asks later! :286:

#9 ManDay

ManDay

    Master Sergeant

  • Members
  • 690 posts

Posted 17 June 2007 - 09:24 AM

Did I miss it? The originally question hasn't really been answered here, has it?!

Someone sometime said that only one FSM can run at time and former FSM will terminate as soon as a doFSM is executed.
But from what latinman says it doesnt apply here.

#10 5133p39

5133p39

    Sergeant Major

  • Members
  • 1423 posts

Posted 17 June 2007 - 09:53 AM

[quote name='(ManDay @ June 17 2007,11:24)']Did I miss it? The originally question hasn't really been answered here, has it?!

Someone sometime said that only one FSM can run at time and former FSM will terminate as soon as a doFSM is executed.
But from what latinman says it doesnt apply here.[/QUOTE]
No, you cannot run more than one scripted FSM.

You can test it yourself - create this FSM file:
<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">class FSM {
fsmName="Test";
initState="Init";
finalStates[]={};
class States {
class Init {
name="Init";
init="_tout=0; _unit=_units select 0; _n=_destination select 0";
class Links {
class RunTest {
priority=1.000000;
to="Testing";
condition="true";
action="";
};
};
};
class Testing {
name="Testing";
init="";
class Links {
class Repeat {
priority=0.500000;
to="Testing";
condition="true";
action="if(_tout<time)then{_tout = time + 1.5; _unit globalChat format[""test%1"",_n]}";
};
};
};
};
};[/QUOTE]
Then you can try to run multiple FSM files like this:<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">unit doFSM ["test.fsm", [1,0,0], nil];
Sleep 5;
unit doFSM ["test.fsm", [2,0,0], nil];
Sleep 5;
unit doFSM ["test.fsm", [3,0,0], nil];[/QUOTE]
You will see that "test1" is printed continualy, then after 5 seconds the "test2" is printed continualy,etc. - no mixed output of "test1" and "test2" and "test3".
There is only "test1" in the output, then the fsm is ended by the other run fsm and then only "test2" will be print to the output, and then only "test3".
Or you can remove the Sleep commands, and then you will see ONLY "test3" - all previous FSMs were stopped by the next doFSM.
Core i7-4820K @ 4.8GHz | 64GB DDR3 | ASUS GTX TITAN Black | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
Windows 7 64bit Professional | OFP, Arma, Arma 2, Arma 3

Free hug for everybody who reads first, and asks later! :286:

#11 CrashDome

CrashDome

    Master Gunnery Sergeant

  • Members
  • 1260 posts

Posted 18 June 2007 - 02:01 PM

It is always an assumption that one versus many is going to be better when you cannot compile before hand. This is assuming it needs to compile or read the file each call. What type of difference this makes is not known.

Quote[/b] ]CrashDome
great job on the tute


Don't thank me! I didn't write it Posted Image

#12 5133p39

5133p39

    Sergeant Major

  • Members
  • 1423 posts

Posted 18 June 2007 - 10:51 PM

i just realized, that my logic regarding proof, that you can't run multiple FSM files, is seriously flawed :-)
In the example i gave, the termination of previous FSMs can be happening because we are trying to run agan same FSM file for same unit.

...however, i think that its impossible to run multiplne FSM files - why would you do that anyway?
Running multiple FSMs for the same object is ...contraproductive? contradictory to the purpose of FSM, in one word - a nonsense.
Or maybe i am too blind to see why would anyone wanted to do such thing.


Question: Is there any way of passing more parameters/variables to the FSM?
Anything other than what is available through _units, _unit, _destination, and _target?

So far i was able to devise only one primitive workaround, by creating a global array named 'somearray#'. Then i fill this array with desired values of desired types, and then i run the FSM while substituting one of the _destination array elements with the number #.
The FSM can then run some function which will take this # from the _destination array, and through "call compile" accesses the array 'somearray#'.

Any other ideas?
Core i7-4820K @ 4.8GHz | 64GB DDR3 | ASUS GTX TITAN Black | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
Windows 7 64bit Professional | OFP, Arma, Arma 2, Arma 3

Free hug for everybody who reads first, and asks later! :286:

#13 whisper

whisper

    Chief Warrant Officer

  • Members
  • 3476 posts

Posted 19 June 2007 - 07:21 AM

[quote name='(5133p39 @ June 19 2007,00:51)']i just realized, that my logic regarding proof, that you can't run multiple FSM files, is seriously flawed :-)
In the example i gave, the termination of previous FSMs can be happening because we are trying to run agan same FSM file for same unit.

...however, i think that its impossible to run multiplne FSM files - why would you do that anyway?
Running multiple FSMs for the same object is ...contraproductive? contradictory to the purpose of FSM, in one word - a nonsense.
Or maybe i am too blind to see why would anyone wanted to do such thing.


Question: Is there any way of passing more parameters/variables to the FSM?
Anything other than what is available through _units, _unit, _destination, and _target?

So far i was able to devise only one primitive workaround, by creating a global array named 'somearray#'. Then i fill this array with desired values of desired types, and then i run the FSM while substituting one of the _destination array elements with the number #.
The FSM can then run some function which will take this # from the _destination array, and through "call compile" accesses the array 'somearray#'.

Any other ideas?[/QUOTE]
I use created HeliHEmpty invisible helipads and setVariable on them, and I put these HeliHEmpty as "_target" of FSM. This for SP missions, for MP it could be tricky as variables attached to objects through setVariable are local only. OTOH FSM are not supposed to run on clients's PC Posted Image You don't want to replace human logic by FSM ones, as stupid a player can be Posted Image Posted Image

My issue at the moment is that using <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">group move position [/QUOTE] on FSM _units's group doesn't work. I hear the leader ordering the "move to XXX", but no one moves




Whisper / Kalbuth / MrK
ex-OFrP member.
ArmA3 / Planetside 2, member of MercenaryS
Planetside / ET:QW / Tribes Ascend, member of Formido Clan

#14 CrashDome

CrashDome

    Master Gunnery Sergeant

  • Members
  • 1260 posts

Posted 19 June 2007 - 02:36 PM

@5133p39

You are absolutely correct. You wouldn't want the headache with trying to run multiple FSMs. Also, there is some behavior changes in regards to coding with FSMs and these are not scripts which can be run in parallel and loop consistantly. It is not the purpose.

@whisper

FSMs can be run on client PCs. Remember that your group of AI units are local to you.

Do NOT use doMove or move in an FSM. The reason they are not moving is because Move creates a waypoint and all waypoint following is suspended in an FSM while doMove will instantly terminate your FSM. Use moveTo or setDestination.

#15 whisper

whisper

    Chief Warrant Officer

  • Members
  • 3476 posts

Posted 19 June 2007 - 02:47 PM

Right, gonna dig into this setDestination, but its parameters are really strange. Any better description than Biki's one?
I ask cause once I'm @home able to edit a bit, I don't have access to Internet and I'm completely blind, no comref, no Biki, searching in the mist, so any bit of advice is welcome beforehand Posted Image
Whisper / Kalbuth / MrK
ex-OFrP member.
ArmA3 / Planetside 2, member of MercenaryS
Planetside / ET:QW / Tribes Ascend, member of Formido Clan

#16 CrashDome

CrashDome

    Master Gunnery Sergeant

  • Members
  • 1260 posts

Posted 19 June 2007 - 03:08 PM

[quote name='(whisper @ June 19 2007,09:47)']Right, gonna dig into this setDestination, but its parameters are really strange. Any better description than Biki's one?
I ask cause once I'm @home able to edit a bit, I don't have access to Internet and I'm completely blind, no comref, no Biki, searching in the mist, so any bit of advice is welcome beforehand Posted Image[/QUOTE]
I answered your ? at OFPEC which might give you headway, but I'll reiterate here in a diff way:

Try using your FSM to create a waypoint structure rather than controlling all movement at all times. I found you can create a whole series of waypoints that the AI will promptly follow once you kill you FSM. Now, I believe that some waypoints you can even attach another FSM using setWaypointStatements command.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[grp,2] setWaypointStatements ["true", "grp doFSM ""MyFSM.fsm"";"][/QUOTE]

i.e. when the above waypoint is reached (and set 'true' by waypoint condition) the FSM will engage. I have not tested this myself, but might provide you insight.

My whole point is to - instead of disregarding waypoints and trying to control everything yourself - use the FSMs as a tool to make the AI behave and create/use the waypoints properly.

Also, setDestination I think is more for formation behavior and things like flanking/combat maneuvars because you need to set it for each individual unit.





#17 whisper

whisper

    Chief Warrant Officer

  • Members
  • 3476 posts

Posted 19 June 2007 - 04:03 PM

Thanks a bunch, I gonna try that tonight.
Whisper / Kalbuth / MrK
ex-OFrP member.
ArmA3 / Planetside 2, member of MercenaryS
Planetside / ET:QW / Tribes Ascend, member of Formido Clan

#18 whisper

whisper

    Chief Warrant Officer

  • Members
  • 3476 posts

Posted 20 June 2007 - 07:38 AM

Posted Image It works flawlessly now (well, 1% of the work is now done, I now can go on completing the other 99 Posted Image )

Thank you CrashDome




Whisper / Kalbuth / MrK
ex-OFrP member.
ArmA3 / Planetside 2, member of MercenaryS
Planetside / ET:QW / Tribes Ascend, member of Formido Clan

#19 5133p39

5133p39

    Sergeant Major

  • Members
  • 1423 posts

Posted 29 June 2007 - 06:46 AM

It seems the orderGetIn command interrupts my scripted FSM.

I need the unit to get in a vehicle, while the FSM is running.
I hate the idea of spawning a script only to wait until the unit is inside the vehicle to run the FSM again.
Any usable workaround?

EDIT: now that i am thinking about this problem, it seems logical - the FSM was initialy run for a MAN, but when this man gets into a vehicle, he becomes "something else" - he becomes a VEHICLE, so it seems logical that the old FSM will end because vehicles often need to be treated differently.
Therefore i think it's not possible to prevent stopping of the previously run FSM - it seems to be on purpose. I need only some reliable way to start new/same FSM after the original one is stopped.

Maybe some special named state exists, which, when present in the FSM file, is being used when the FSM execution is interrupted?




Core i7-4820K @ 4.8GHz | 64GB DDR3 | ASUS GTX TITAN Black | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
Windows 7 64bit Professional | OFP, Arma, Arma 2, Arma 3

Free hug for everybody who reads first, and asks later! :286:

#20 5133p39

5133p39

    Sergeant Major

  • Members
  • 1423 posts

Posted 30 June 2007 - 03:03 AM

It seems the orderGetIn command interrupts my scripted FSM.

I need the unit to get in a vehicle, while the FSM is running.
I hate the idea of spawning a script only to wait until the unit is inside the vehicle to run the FSM again.
Any usable workaround?

I need help with this.

I made a workaround - i am stopping the FSM myself when a unit is about to get in or out of a vehicle, and before stopping the FSM i spawn a script which waits until the unit gets in or out of a vehicle, or until a 10 seconds timeout runs out (could be less, maybe, but i better be safe than sorry), and then it will start the FSM again.

The problem is, everytime this happens, the unit is just standing/sitting and doing nothing for 10 seconds, which is little awkward.
I tried the unitReady command, but it doesn't help - either it's functionality is disrupted because of the doFSM or other commands i used, or it won't help simply because the unit is in middle of something (a MoveTo which it hasn't completed yet).

I need some reliable way to determine when it is safe to run the FSM again - if i run it too early after the unit's get in/out action, it will be still stopped by something unknown (by native FSM?).
The 10 seconds delay works, but i don't want any unnecessary delay.

Please, give it some thoughts, i really really need help with this.
(It would be VERY nice if we could get at least a little comment from the developers, regarding this issue)
Core i7-4820K @ 4.8GHz | 64GB DDR3 | ASUS GTX TITAN Black | OCZ Revo 120GB PCIe SSD | 2x OCZ Vertex 4 120GB |
Windows 7 64bit Professional | OFP, Arma, Arma 2, Arma 3

Free hug for everybody who reads first, and asks later! :286:


1 user(s) are reading this topic

0 members, 1 guests, 0 anonymous users