SNKMAN – User talk

From Bohemia Interactive Community
Jump to navigation Jump to search
No edit summary
No edit summary
 
(One intermediate revision by the same user not shown)
Line 1: Line 1:
'''FSM: ( Fine State Machine )'''


In ArmA 2 we have 2 different .fsm which are used to set how A.I. should behave in combat.
1. NativeFSM ( CACharacters\CfgFSMs.hpp )<br/>
2. ScriptedFSM ( CACharacters\Scripts\Danger.fsm )
Bouth FSMs are initialized in the "CACharacter" >> "CfgVehicles" >> "CAManBase".
The '''NativeFSM''' is used to control the general behaviour of A.I. units in combat.<br/>
It will choose if A.I. should go to cover or attack a known enemy.<br/>
If A.I. should reload while in cover or if A.I. should look for any other ( may better ) cover.<br/>
It also let you choose if A.I. should provide cover or if they should try fighting on their own.<br/>
The '''ScriptedFSM''' is used to control the general behaviour of A.I. in situations which are dangerous.<br/>
This is something like a Event Handler which is triggering after a specific event happend.<br/>
The ScriptedFSM Conditions:<br/>
*'''Detect Enemys:''' This will trigger every time A.I. has detected a enemy unit.
*'''Detect Weapon fire:''' This will trigger every time a unit has fired a weapon.<br/>
''Note:'' The A.I. which should detect weapon fire must have the chance to know more then 0 about the unit which has fired the weapon.
*'''Detect Enemys Near:''' This will trigger every time A.I. has detected a enemy unit which is very close.
*'''Detect Explosions:''' This will trigger every time after something is exploded? ( Havent seen this so far... )
*'''Detect Dead Bodys:''' This will trigger every time A.I. has detected a dead body. Note: Exploded vehicles are triggered here too.
*'''Detect Stop Fire:''' This will trigger randomly and make A.I. to stop moving for 4 - 8 sec.<br/>
If multiple conditions match then they will be triggered given to the priority set in the event.
----
====Global Array System====
Each "[[Variables|Global Variable]]" will be stored in the memory.
This means many "[[Variables|Global Variable]]" will need much memory space.
You can reduce the resources used from "[[Variables|Global Variable]]" by using a "Gloabal Array" which stores all needed values instead of creating a new "[[Variables|Global Variable]]" for each value.
'''Default:''' ( Bad )
<code><nowiki>
Global_Bool = True;
Global_Number = 30;
Global_Distance = 500;
Global_Array = [];
</nowiki></code>
Now we have created 4 different "[[Variables|Global Variable]]" which will need 3x more memory like the optimized way.
Examples:
<code><nowiki>
if (Global_Bool) then
{
      Global_Bool = False;
      .......
};
</nowiki></code>
<code><nowiki>
if (count _array < Global_Number) then
{
      .......
};
</nowiki></code>
<code><nowiki>
if (player distance _object < Global_Distance) then
{
      .......
};
</nowiki></code>
<code><nowiki>
if !(_object in Global_Array) then
{
      Global_Array = Global_Array + [_object];
      .......
}
else
{
      Global_Array = Global_Array - [_object];
      .......
};
</nowiki></code>
'''Optimized:''' ( Good )
<code><nowiki>
Global_System = [True, 30, 500, [] ];
</nowiki></code>
Now we have stored all values in only '''1''' "Global Variable" called "Global_System".
You can check / select the needed value by using (Global_System select Index).
Index is the position ( number ) in which the given value was stored.
Select the Bool: True
<code><nowiki>
(Global_System select 0)
</nowiki></code>
Select the Number: 30
<code><nowiki>
(Global_System select 1)
</nowiki></code>
Select the Array: []
<code><nowiki>
(Global_System select 3)
</nowiki></code>
Examples:
<code><nowiki>
if (Global_System select 0) then
{
      Global_System set [0, False];
      .......
};
</nowiki></code>
<code><nowiki>
if (count _array < (Global_System select 1) ) then
{
      .......
};
</nowiki></code>
<code><nowiki>
if (player distance _object < (Global_System select 2) ) then
{
      .......
};
</nowiki></code>
<code><nowiki>
if !(_object in (Global_System select 3) ) then
{
      Global_System set [3, (Global_System select 3) + [_object] ];
      .......
}
else
{
      Global_System set [3, (Global_System select 3) - [_object] ];
      .......
};
</nowiki></code>

Latest revision as of 08:23, 12 August 2010