Jump to content
Sign in to follow this  
dissaifer

Unexpected Danger FSM triggering

Recommended Posts

So, I've been playing with the FSMs and found the formation and danger FSMs can be over written.

As a test, the formation FSM was overridden just loop every second and write out to global. The same was done with the danger FSM.

When you start you see the FSM for formation start, and a second goes by, and it is fine. I fire a gun, the danger FSM is triggered. And it keeps re-triggering, as in it continues to say "DANGER FSM STARTED" then an occasional second will tick by and the "Danger FSM time 2" will fire off, then the DANGER FSM STARTED again...

Is this how this is supposed to work? :confused:

Share this post


Link to post
Share on other sites

Maybe it has to be disabled again?

Share this post


Link to post
Share on other sites

From my knowledge of the danger FSM, it triggers everytime there is an update to the _dangerCause there are 8 possible causes varying from different levels of "awareness", the FSM loops itself until there is no cause of danger (ie area clear or enemy presence knowsAbout times out).

I believe yes... what you described is normal. Since the input to that fsm is commanded by the engine. The multiple states are going to update. Your control is more about the "micro" behaviour of the AI on the different hardcoded states.

Share this post


Link to post
Share on other sites

any way to modify danger.fsm, where is it located?

for example:

if (allow_danger_fsm) then {
  <danger.fsm code>;
} else {
  <do nothing>;
};

Share this post


Link to post
Share on other sites

@Demonized - I don't think you can do that per se... I over rode the fsm via the config and placed my own "mydanger.fsm" there.

@gammadust - ok that makes a lot of sense, but leads to more questions. It looks like formationC - is the stand in formation (no danger) situation.

But formationCDanger and formationEntity seem to do the more interesting stuff (mind you I am looking at these from the Arma 2 character/scripts, if that matter).

Does anyone know how these (all formations and danger) interact?

Share this post


Link to post
Share on other sites

@Demonized (from a unreleased mod)

class CfgVehicles
{
class Man;
class CAManBase: Man
{
	fsmDanger = "GAM\GAM_ClockfacingReport\scripts\danger.fsm";
};
class Civilian: CAManBase{};
};

This turns all CAManBase classes to use my new danger.fsm

And based on original danger.fsm I implement new actions I want AI to do. This was pretty much inspired in SLX_AI method (by Solus).

@Dissaifer Good point!

I never thought about that since I wasn't required to by the mod I was working on.

But indeed there must be some kind of overlap (not sure if this is actually possible) between both FSMs, fsmFormation always ON (or OFF, do group units keep formation under danger- not tested) and when in danger fsmDanger has priority over whatever behaviour is underneath.

Mind you this is just guessing.

---

I am clearly thinking on the way... lol

AFAIK this does imply config editing and is not simply controllable in mission editing.

---------- Post added at 08:07 PM ---------- Previous post was at 07:50 PM ----------

Check this if you haven't.

some usefull, despite old info there.

forgot to mention before that the original danger.fsm is packed in

characters.pbo under folder "scripts". The others FSMs are there also.

---------- Post added at 08:15 PM ---------- Previous post was at 08:07 PM ----------

(from the above link)

Each CharacterType can have up to 2 FSMs.

fsmFormation

fsmDanger

The fsmFormation is the default FSM, wich is automatically run at mission start. You can leave it blank, but then the game engine falls back to the native "Formation" FSM, wich is declared in "CfgFSM/Formation". The value should be the name of a nativeFSM or the name of a FSM file(see example below).

The fsmDanger is the second FSM you can define. This FSM is optional. It's automatically run by the game engine, if your character 'thinks' he is in danger (for example i could start it by firing some bullets into the ground close to the character). The fsmFormation is then immediatly aborted (it will not run an "End State"). If the fsmDanger comes to a "End State", the engine will restart the fsmDanger again (if the fsmFormation was running while firing the fsmDanger). If you don't use it, set the value to "" and the game e.ngine will continue to execute fsmFormation if character is in danger.

This answers some questions

Edited by gammadust

Share this post


Link to post
Share on other sites

If this is the topic: how can you get what the danger.fsm is currently doing?

That is:

  • the danger cause
  • the position of the threat
  • the time, until this threat is valid

Do you guys know it?

It would be a lot of help for me if you could continue talking about danger.fsm. I can only find info parts about this, I can even take a look into the code, but haven't yet found a way to see it in action. Only the resulting behaviour.

Share this post


Link to post
Share on other sites
If this is the topic: how can you get what the danger.fsm is currently doing?

(...)

Have you taken a look at the original danger.fsm? It is commented which also helps. My testing did not depend too much on exacly which cause was on at the moment I needed custom triggering.

These are the 9 states of this FSM, arma engine decides where you are:

/*

comment "0 DCEnemyDetected";

comment "1 DCFire";

comment "2 DCHit";

comment "3 DCEnemyNear";

comment "4 DCExplosion";

comment "5 DCDeadBodyGroup";

comment "6 DCDeadBody";

comment "7 DCScream";

comment "8 DCCanFire";

*/

// Retrieve the highest priority event from the _queue

private ["_priors","_priorCur"];

_priors = [3, 4, 5, 1, 4, 1, 1, 2, 2];

if (_dangerCause>0) then {_priorCur = _priors select _dangerCause}

else {_priorCur=-1};

{

private ["_cause"];

_cause = _x select 0;

if ((_priors select _cause)>_priorCur) then

{

_dangerCause = _cause;

_dangerPos = _x select 1;

_dangerUntil = _x select 2;

_dangerCausedBy = _x select 3;

}

} forEach _queue;

_queue = [];

That means each element in _queue has a subarray where you can extract precisely the information you need. The _queue is prioritized according to the table (_priors). So "DCHit" has the highest priority.

Still it is a little blurry how that the engine ultimately leaves the state in. My testing was sometimes contradictory. But I didn't went through all the possibilities.

Edited by gammadust

Share this post


Link to post
Share on other sites

@Zapat to see the code you need to unpbo the characters.pbo under your Arma 2 directory. In that folder there is a folder called scripts and in that the danger.fsm.

I used the BIS tool FSMEditor from the wiki to view the file. It's a little to hard read the code like this at first, but you get used to it.

@gammadust - FormationEntity is a native FSM with no End condition and doesn't appear to have any combat built in. Maybe this is the civ or default FSM? Thanks for the link, seen it before, it appears other people are as lost as well.

Share this post


Link to post
Share on other sites

@gammadust - FormationEntity is a native FSM with no End condition and doesn't appear to have any combat built in. Maybe this is the civ or default FSM? Thanks for the link, seen it before, it appears other people are as lost as well.

Prolly one of the reasons I did not find any custom formations made by the community yet. In my early times with Arma2 I did explore the possibility but never arrived to a conclusion. I wanted to vary how tight the formation would be while keeping the top view configuration.. maybe even control where a unit would keep their eyes on. With the appearance of FSMs I thought again it could be done... but my interest has faded away for other projects.

Those native FSMs sure could be more documented by BIS.

Share this post


Link to post
Share on other sites

Custom formations are to be defined in class cfgFormations and are only possible since OA.

The formation FSM is about something different I think.

Share this post


Link to post
Share on other sites
Custom formations are to be defined in class cfgFormations and are only possible since OA.

The formation FSM is about something different I think.

Tnx for the hint... I might revive the idea, have to take a look at that cfg.

Share this post


Link to post
Share on other sites

And here is the formation FSM from the config space converted to .FSM: formationConfig.7z

The links are yet missing though. It includes the config definition, the source FSM from

my conversion attempt and a version once saved with the FSM editor thereafter.

Share this post


Link to post
Share on other sites

@ gammadust (or anyone else with insights)

Is there a way to make AI units leaving the danger mode faster?

Or in the worst case to have them no enter it at all?

Share this post


Link to post
Share on other sites

only thing that occurs to me is this, but somehow I suspect you've been there already. And this would be "in your worst case".

SLX_AI (by Solus) might give you some direction, it is evident he tested a lot with his AI pack, might worth take a look.

I noticed he altered the priority of states, perhaps that gave him more room (forcing a AI state that you can manipulate easyer later on). I simply haven't tested to have any idea. His code is well commented though.

PS:Tnx again for your input, I am bunching together all that stuff in folder with your name on it if I happen to have use for it.

Edited by gammadust

Share this post


Link to post
Share on other sites

If you override the config with "" in the dangerFSM, they don't go into it.

Share this post


Link to post
Share on other sites
The _queue is prioritized according to the table (_priors).

Maybe I am missing something here: Isn't _queue a variable local to danger.fsm? :j:

So is there a variable that can be read from a different script? Eg. through a mission I could check what frightens my men around. :)

I found something like "BIS_dangerHandler", but I couldn't yet read it...

Anyways thanks for showing me this info, this is a good starting point in finding what makes my planes go detour all the time...

Edited by zapat

Share this post


Link to post
Share on other sites

_queue is local to the unit that is running the danger.fsm

you could change the fsm to pass the variable to a script via the fsm. Or just change the fsm to have the guys act the way you wanted to.

Share this post


Link to post
Share on other sites
Maybe I am missing something here: Isn't _queue a variable local to danger.fsm? :j:

So is there a variable that can be read from a different script? Eg. through a mission I could check what frightens my men around. :)

I found something like "BIS_dangerHandler", but I couldn't yet read it...

Anyways thanks for showing me this info, this is a good starting point in finding what makes my planes go detour all the time...

Yes it is. To circunvent that and since my script is triggered from the danger.fsm:

if(isnil "GAM_notify")then{GAM_notify=(compile preProcessFileLineNumbers 'GAM\GAM_ClockfacingReport_CO\scripts\GAM_notify.sqf');};

[_this,_dangerCausedBy] call GAM_notify;

and in my GAM_notify.sqf, somewhere I do this to have the variable handy:

...
_unit setVariable ["dangerCB",_this select 1, true]; // keep this with the unit so we can use it out of this scope

be mindeful that "_this" in the upper context is the function, and I am accessing its parameter set from danger.fsm.

in another script I access it with:

_unitTarget = _selectedUnit getVariable "dangerCB";

this is in practice what Dissaifer suggested.

-------

In regards to the method I am not perfectly sure this is the best way, since I don't know for sure how many times the function is being triggered by danger.fsm for each enemy encounter. I do have some conditioning afterwards to lighhten the load. But this approach might have room for polishing.

Edited by gammadust

Share this post


Link to post
Share on other sites

Ok, I see it now.

It means that it is only possible through an Addon, and not in a mission then, isn't it?

Thanks for the answers!

Share this post


Link to post
Share on other sites

Found out that the formationEntity.fsm (inside ca\characters\scripts) is equal to 'class

Formation' of 'class CfgFSMs' in the config space.

The FSM file also has two code comments.

It means one can look at the structure/FSM easily with the FSMEditor.

And modify it this way. To the conversion to the config representation is very simple.

It seems it uses a special configuration for the FSMEditor called entityFSM.cfg.

The FSM uses special / low level commands contrary to SQF used in others.

So the ability to modify it might be limited.

Will start a (series) of BIKI pages about the AI FSM in a bit to make it easier to gather insights.

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  

×