OPCOM / TACOM FSMs

  1. 8 years ago

    From jmlane in the Discord channel:

    Is there a way to hook into the opcom.fsm loop to spawn a custom function after each analysis has finished? I've been building a mental model of how both opcom.fsm and tacom.fsm work and update opcoms hash state, but I'm not super familiar with FSMs and what I might be able to do at runtime with them.

  2. Thanks @SavageCDN.

    My intention is to fake a custom "operation" in the OPCOM loop. There is a custom operation option in opcom.fsm but it doesn't seem to work like the other standard opcom operations (it does not call out to tacom.fsm and await a completion status; I'm not sure that it does anything).

  3. Friznit

    15 Jan 2016 Administrator

    Will need to page Highhead to this thread - totally his baby :)

  4. highhead

    16 Jan 2016 Administrator

    Hi!

    yeah, custom operation was intended to be feeded with custom functions but i didnt get to finish it! basically you can monitor variables of the fsms with getFSMvariable and update them with setFSMvariable, those are the scripts running when the analysis is performed. Analysis happens if variable "_analyze" is not empty (!(isnil "_analyze")); Then i'd just wait for variable "_OPCOM_status" to be "reset"; Do you know how to get the OPCOM_FSM?

  5. Edited 8 years ago by SpyderBlack723

    Using the above, I believe this would work

    _fnc_getOpcomByFaction = {
    	private ["_opcom"];
    	_faction = _this;
    
    	{
    		if (_faction in ([_x,"factions"] call ALiVE_fnc_hashGet)) exitWith {
    			_opcom = _x;
    		};
    	} forEach OPCOM_instances;
    
    	_opcom
    };
    
    //-- Get opcom FSM
    _opcom = _faction call _fnc_getOpcomByFaction;
    _opcomFSM = [_opcom, "OPCOM_FSM"] call ALiVE_fnc_HashGet;
    _tacomFSM = [_opcom, "TACOM_FSM"] call ALiVE_fnc_HashGet;
    
    
    /////-- Loop this section --/////
    	//-- Wait until analysis started
    	waitUntil {sleep 2;!isNil(_opcomFSM getFSMVariable "_analyze")};
    
    	//-- During analysis
    
    	//-- Analysis complete
    	waitUntil {sleep 1;(_opcomFSM getFSMVariable "_OPCOM_status") == "reset"};
    
    	//-- Post analysis
    /////-- Loop this section --/////
  6. Edited 8 years ago by dixon13

    This will be faster...

    _fnc_getOpcomByFaction = {
    	private ["_opcom"];
    	_faction = _this;
    
    	{
    		if (_faction in ([_x,"factions"] call ALiVE_fnc_hashGet)) exitWith {
    			_opcom = _x;
    		};
                    false
    	} count OPCOM_instances;
    };
    
    //-- Get opcom FSM
    _opcom = _faction call _fnc_getOpcomByFaction;
    _opcomFSM = [_opcom, "OPCOM_FSM"] call ALiVE_fnc_HashGet;
    _tacomFSM = [_opcom, "TACOM_FSM"] call ALiVE_fnc_HashGet;
    
    
    /////-- Loop this section --/////
    	//-- Wait until analysis started
    	waitUntil {sleep 2;!isNil(_opcomFSM getFSMVariable "_analyze")};
    
    	//-- During analysis
    
    	//-- Analysis complete
    	waitUntil {sleep 1;(_opcomFSM getFSMVariable "_OPCOM_status") == "reset"};
    
    	//-- Post analysis
    /////-- Loop this section --/////
  7. If using the above, edit to correctly return the actual opcom

    _fnc_getOpcomByFaction = {
    	private ["_opcom"];
    	_faction = _this;
    
    	{
    		if (_faction in ([_x,"factions"] call ALiVE_fnc_hashGet)) exitWith {
    			_opcom = _x;
    		};
                    false
    	} count OPCOM_instances;
    
    	_opcom
    };
  8. ^good spot forgot that was in a function and I had to return a value

  9. Thanks folks. I was trying to avoid running my own loop outside the OPCOM/TACOMs but given what you've responded with, looks like that's what I have to do.

 

or Sign Up to reply!