HeliJunkie/Sandbox – User
Lou Montana (talk | contribs) m (Text replacement - "://armaholic" to "://www.armaholic") |
Lou Montana (talk | contribs) m (Text replacement - "<code>" to "<code style="display: block">") |
||
(2 intermediate revisions by the same user not shown) | |||
Line 33: | Line 33: | ||
==== Scripted FSM ==== | ==== Scripted FSM ==== | ||
Scripted FSM is very good explained by rune's tutorial. So, I only list here a other sample: | Scripted FSM is very good explained by rune's tutorial. So, I only list here a other sample: | ||
<code><nowiki>class FSM | <code style="display: block"><nowiki>class FSM | ||
{ | { | ||
fsmName = "FSM_Document"; | fsmName = "FSM_Document"; | ||
Line 88: | Line 88: | ||
==== Native FSM ==== | ==== Native FSM ==== | ||
Native FSM have a slightly different format and they must be placed in the '''CfgFSMs''' class. | Native FSM have a slightly different format and they must be placed in the '''CfgFSMs''' class. | ||
<code><nowiki> | <code style="display: block"><nowiki> | ||
class CfgFSMs { | class CfgFSMs { | ||
class HJ_Debug | class HJ_Debug | ||
Line 268: | Line 268: | ||
For my tests I used following config entrys: | For my tests I used following config entrys: | ||
<code><nowiki>class CfgVehicles { | <code style="display: block"><nowiki>class CfgVehicles { | ||
//************************************************* | //************************************************* | ||
//*** West Soldiers | //*** West Soldiers | ||
Line 462: | Line 462: | ||
To watch the game config, it is not nessesary to extract and unrap all config.bin files.<br> | To watch the game config, it is not nessesary to extract and unrap all config.bin files.<br> | ||
Use my ConfigExplorer to watch the gameconfig easily.<br> | Use my ConfigExplorer to watch the gameconfig easily.<br> | ||
You can download it (for example) from [{{ | You can download it (for example) from [{{Link|link= http://www.armaholic.com/page.php?id=2208|text= here}}]. <br> | ||
It helps me really a lot, and not because i wrote it. | It helps me really a lot, and not because i wrote it. | ||
Line 470: | Line 470: | ||
=== We all need YOUR help === | === We all need YOUR help === | ||
Because the | Because the information about FSM is very spare, share all new information with us over this great Wiki! | ||
Latest revision as of 11:53, 11 January 2023
Hope that no Admin is deleting this. Is the only backup for a UserTalk page. I spend hours on it. --HeliJunkie 21:29, 6 December 2008 (CET)
Some (most verified) News about FSM
More than 2 Years are passed since CrashDome released the first information about FSM. The knowledge about FSM was and is low... but I'm happy to provide you with new infos I figured out.
A very good start about FSM is provided by rune from sinesofWar. I hardly recommend to read this Tutorial! You can get [FSM Introduction Tutorial here]. Not all is truth, but the most!
Let's start with the different types of FSM's (community given Names, no one knows, how they are called by BI):
- scripted FSM
- native FSM
Scripted FSM
scriptedFSM are devided in two styles by me:
- CommandFSM
- Files can be in mission directory, and are used by the doFSM script command.
The MissionFSM are NOT running alone (unlike the tutorial of rune explains). They are call parallel to the character FSM! (and that's verified by me!) ;-)
- (scripted)CharacterFSM
- Files must be placed in a Addon.
Then you must create new character classes and link the FSM Files. More about how to set them up later.
In Scripted FSMs you must use Script Commands.
Native FSM
Native FSM are stored in the GameConfig in the Class CfgFSMs. They use little other format than the scripted FSMs and you can't use script Commands. There are some different functions (a list of some(all?) later). The picture provided by SoldierIsNotHistory is the default formation FSM from BI. That IS the FSM used in Game! And its simple if you studie it for a while.
The Syntax of FSM
Scripted FSM
Scripted FSM is very good explained by rune's tutorial. So, I only list here a other sample:
class FSM
{
fsmName = "FSM_Document";
initState = "Init";
finalStates[] = {"End"};
class States
{
class Init
{
name = "Init";
init = "private[""_debug""];_debug = false; if (not isNil(""debug"")) then {_debug = true;}; if (_debug) then {debug globalChat format[""%1:Init Formation! # _this:%2 # _units:%3 # _queue%4"",time,_this,_units,_queue];};";
class Links
{
class default
{
to = "Start";
priority = "0,000000";
condition = "true";
action = "";
};
};
};
class Start
{
name = "Start";
init = "if (_debug) then {debug globalChat format[""%1:Start.."",time];};";
class Links
{
class default
{
to = "Start";
priority = "1,000000";
condition = "true";
action = "";
};
class goEnd
{
to = "End";
priority = "0,000000";
condition = "true";
action = "";
};
};
};
class End
{
name = "End";
init = "if (_debug) then {debug globalChat format[""%1:End.."",time];};";
};
};
};
To get the chat messages, you have to place a scriptLogic with the Name 'debug' on your map.
Native FSM
Native FSM have a slightly different format and they must be placed in the CfgFSMs class.
class CfgFSMs {
class HJ_Debug
{
initState = "Init";
finalStates[] = {"End"};
class States {
class Init {
name = "Init";
class Init {
function = "formationInit";
parameters[] = {};
thresholds[] = {};
};
class Links {
class Member {
to = "Member";
priority = "0,000000";
class condition {
function = "formationIsMember";
parameters[] = {};
threshold = 0;
};
class action {
function = "nothing";
parameters[] = {};
thresholds[] = {};
};
};
class Leader {
to = "Leader";
priority = "0,000000";
class condition {
function = "formationIsLeader";
parameters[] = {};
threshold = 0;
};
class action {
function = "";
parameters[] = {};
thresholds[] = {};
};
};
};
}; // End States/Init
class Member {
name = "Member";
class Init {
function = "setUnitPosToDown";
parameters[] = {};
thresholds[] = {};
};
class Links
{
class default
{
to = "Init";
priority = "1,000000";
class condition {
function = "true";
parameters[] = {};
threshold = 0;
};
class action {
function = "nothing";
parameters[] = {};
thresholds[] = {};
};
};
class goEnd
{
to = "End";
priority = "0,000000";
class condition {
function = "true";
parameters[] = {};
threshold = 0;
};
class action {
function = "nothing";
parameters[] = {};
thresholds[] = {};
};
};
};
};
class Leader {
name = "Leader";
class Init {
function = "nothing";
parameters[] = {};
thresholds[] = {};
};
class Links
{
class default
{
to = "Member";
priority = "1,000000";
class condition {
function = "randomDelay";
parameters[] = {100000};
threshold = 0;
};
class action {
function = "nothing";
parameters[] = {};
thresholds[] = {};
};
};
class goEnd
{
to = "End";
priority = "0,000000";
class condition {
function = "false";
parameters[] = {};
threshold = 0;
};
class action {
function = "nothing";
parameters[] = {};
thresholds[] = {};
};
};
};
};
class End
{
name = "End";
class Init {
function = "nothing";
parameters[] = {};
thresholds[] = {};
};
};
};
};
};
This is a working native FSM! (yeah.. i did it!!! ;-)).
Its very simple...
This native FSM does only make a difference between SquadLeader and SquadMember. SquadMembers go down to prone position directly after mission start. The SquadLeader with a little, random delay later. That's all... but it works!
Character with own FSM
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 engine will continue to execute fsmFormation if character is in danger.
For my tests I used following config entrys:
class CfgVehicles {
//*************************************************
//*** West Soldiers
//*************************************************
class SoldierWMedic; // External class reference
// A Character wirh a Scripted FSM
class FSM1SoldierWMedic : SoldierWMedic {
displayName = "FSMDebug Scripted";
fsmFormation = "HeliJunkie\DebugDirectEnd.fsm";
fsmDanger = "HeliJunkie\DebugDirectEndDanger.fsm";
};
// A Character with a native FSM
class FSM4SoldierWMedic : FSM1SoldierWMedic {
displayName = "FSMDebug CfgFSMs";
fsmFormation = "HJ_Debug";
fsmDanger = "HJ_DebugDanger";
};
};
Special variables for scripted FSM
There are some special variables (you know it, if you read the FSM Tutorial from rune). But you cant use all variables in all FSMs!
- _this
It's the only variable wich is provided in every FSM. It contains the Unit, wich is executing the FSM.
- _units, _destination and _target
This variables are the parameters provided to the doFSM script command. So you can use them only in FSM Files, wich are startet by that command. For more see doFSM.
- _queue
This variable is only available in scripts, wich are defined in fsmDanger. It contains an Array of Arrays. Each Arry contains:
- the danger cause
- the position of the threat
- the time, until this threat is valid
It can look like this:
[[1,[12.001,13.200,0.513],45.987]]
This array will only be extended! Even reasons, wich "until time" has elapsed stay in this array! So be shure that you leave the fsmDanger from time to time over the "End state". Otherwise this array will be very large!!!
The time can be compared with the time value. So you can see, if a threat is new or old.
The reason is a integer from 0 to 6. I don't know, wich reason causes wich number. But from the "formationCDanger.fsm" (you find it in "character.pbo/scripts") I extracted that BI gives them following prioritys:
cause 0 1 2 3 4 5 6 priority 3 3 4 5 2 1 1
nativeFSM Functions
I figured out some(all?) of the functions you can use in nativeFSM.
nativeFSM Functions/Commands | |||
---|---|---|---|
Name | Parameters | Remark | Verified |
formationDeadlock | ? | - | |
formationTooFarAreCovered | ? | - | |
randomDelay | ? | Returns true after a random delay. | X |
coverReached | ? | - | |
checkCover | ? | - | |
formationTooFar | ? | - | |
formationEnemy | ? | ( Saw a parameter {100 , 0}. But have no idea, what this means) | - |
reloadNeeded | ? | - | |
formationNotEnoughCover | ? | - | |
formationIsLeader | ? | Returns true if Unit is Leader of Group | X |
formationIsMember | ? | Returns true if Unit is a Member of Group | X |
vehicleAir | ? | - | |
behaviourCombat | ? | - | |
formationCleanUp | ? | - | |
setUnitPosToDown | ? | Unit goes to prone position. | X |
formationSetHideBehind | ? | - | |
formationNextTarget | ? | - | |
formationLeader | ? | - | |
formationProvideCover | ? | - | |
goToCover | ? | - | |
formationMember | ? | - | |
formationInit | ? | - | |
formationExcluded | ? | - | |
formationReturn | ? | - | |
formationNoCombat | ? | - | |
vehicle | ? | - | |
reload | ? | - |
Some Helpful Links
To watch the game config, it is not nessesary to extract and unrap all config.bin files.
Use my ConfigExplorer to watch the gameconfig easily.
You can download it (for example) from [here (dead link)].
It helps me really a lot, and not because i wrote it.
To edit FSM-Files you can use "FSM-Edit" by CrashDome.
You can download it from [here].
One Tip: Write all your code in one line! Otherwise you will get errors, if you use the FSM without the doFSM command!
We all need YOUR help
Because the information about FSM is very spare, share all new information with us over this great Wiki!
So I hope that are good news for all of you, wich are interested in FSM.
--HeliJunkie 21:29, 6 December 2008 (CET)