Using objective capture status for triggering events

  1. 10 months ago

    Hello there!

    Can the objective capture status (captured & occupied) be somehow parsed and then be used for triggering events?

    So for example when the ALiVE virtualized (or spawned) units "occupy" an objective I'd like to use that moment when the "Occupied" text appears over the objective to trigger an event of my choice.

    I've put ALIVE_fnc_getNearProfiles to good use for the purpose of triggering events but "capturing" and "occupying" an objective takes n-amount of time and it's slightly difficult to set the trigger timer to match the actual time when an objective will turn to "Occupied" state.

  2. This file is a good one to learn from:
    https://github.com/ALiVEOS/ALiVE.OS/blob/master/addons/fnc_analysis/fnc_militaryIntel.sqf

    Notably, the "listen" operation

  3. Hey spyder and thanks for shoving me in the right direction.

    I guess you meant this when you mentioned the "listen" operation?

    case "listen": {
    private["_listenerID"];
    
    _listenerID = [ALIVE_eventLog, "addListener",[_logic, ["LOGISTICS_INSERTION","LOGISTICS_DESTINATION","PROFILE_KILLED","AGENT_KILLED","OPCOM_RECON","OPCOM_CAPTURE","OPCOM_DEFEND","OPCOM_RESERVE","OPCOM_TERRORIZE"]]] call ALIVE_fnc_eventLog;
    [_logic,"listenerID",_listenerID] call ALIVE_fnc_hashSet;
    };

    Now that is just the stuff I never seem to be able to wrap my head around.

    Ok, so how much wrong I get this when I say that the OPCOM markers are the one's that switch state between neutral/captured/occupied and those are the ones that I should monitor (or in this case "listen")? Or is it actually the military placement modules that I should be "listening" and the markers are just there to relay the changing status information?

    Is everything that is inside the fnc_militaryIntel.sqf file actual code or.. if I want to use that case "listen" somehow do I need to change _listenerID, _logic and "listener" to something actual (like variable names) I have placed in the editor?

    I guess I should start with a plain SQF-file, give it a name such as "listen.sqf" and paste that code block in it and then call the SQF-file with []exec listen.sqf from somewhere or?

  4. 9 months ago

    So how could I go on to create triggers that activate endMission or BIS_fnc_endMission state with the help of this "listener"?

  5. Somewhere...

    _listener = [nil,"create"] call ALiVE_fnc_baseClass;
    _listener setVariable ["class","somefunction"];
    
    _listenerID = [ALiVE_eventLog,"addListener",[_listener, ["OPCOM_CAPTURE"]]] call ALIVE_fnc_eventLog;

    // [_listener,"handleEvent",_event] call _class; // how the event is dispatched within ALiVE internals

    inside someFunction
    handle event

    params ["_logic","_operation","_args"];
    
    switch (_operation) do {
        case "handleEvent": {
            _event = _args;
            _id = [_event, "id"] call ALIVE_fnc_hashGet;
            _data = [_event, "data"] call ALIVE_fnc_hashGet;
    
            _data params ["_side","_objective"]; // not sure if _objective is an ID or actual objective hash/array
    
            if (_side == "WEST") then { // or whatever side as a string
                private _objectiveID = [_objective,"id"] call ALiVE_fnc_hashGet;
                private _objectivePos = [_objective,"center"] call ALiVE_fnc_hashGet;
    
                // do magic here
            };
        };
    };
  6. 8 months ago
    Edited 8 months ago by Asmodeus

    Hopeless for me. Is there anyone that could decipher what to put and where and if something needs to be changed? for greater good and so not to cause an untimely death to SpyderBlack because putting all the strain on him

  7. 8 weeks ago

    highhead

    Aug 21 Administrator
    Edited 8 weeks ago by highhead

    Hi!

    I have provided a sample init.sqf for you, with included documentation - In this example a side chat info is given, when an objective is reserved by side west! Open for better readability, but below i pasted whats inside.

    http://s000.tinyupload.com/index.php?file_id=22219349752712892355

    ///////////////////////////////////////////////////////////////////////////////////////////////////
    //Put in init.sqf
    //only use on an ALiVE mission with virtual AI module placed
    waituntil {!isnil "ALiVE_eventLog"};
    
    //Leave alone
    _fnc_custom = {
    
        //Do not touch that
        params ["_logic","_operation","_args"];
    
        //Also do not touch that
        switch (_operation) do {
            case "handleEvent": {
                _event = _args;
                
                _event params ["_id","_data"];
                _id = [_event, "id"] call ALIVE_fnc_hashGet;
                _data = [_event, "data"] call ALIVE_fnc_hashGet;
                
                _data params ["_side","_objective"];
    
    
                ///////////////////////////////////////////////////////////////////////////
                /////
                /////
                /////
                //// This is the part you can put your code in
                /////
                //
                //
                /* Example objective data from _objective call ALiVE_fnc_InspectHash;
                ---------------- Inspecting Hash --------------------
                k [0]: objectiveID v: OPCOM_2390318919_objective_0
                k [1]: center v: [23334.9,19291.6,0]
                k [2]: size v: 50
                k [3]: objectiveType v: MIL
                k [4]: priority v: 50
                k [5]: opcom_state v: idle
                k [6]: clusterID v: CUSTOM_42626
                k [7]: opcomID v: 2390318919
                k [8]: _rev v:
                k [9]: opcom_orders v: none
                k [10]: danger v: -1
                k [11]: sectionAssist v: ["BLU_F-entity_12"]
                k [12]: section v: ["BLU_F-entity_12"]
                k [13]: tacom_state v: reserve
                ---------------- Inspection Complete --------------------
                */
    
                //Get objective id and position
                private _objectiveID = [_objective,"objectiveID","empty"] call ALiVE_fnc_hashGet;
                private _objectivePos = [_objective,"center",[]] call ALiVE_fnc_hashGet;
    
                //If objective is of side east ("GUER" for resistance)
                if (_side == "EAST") then {
                    ["ALiVE - objective %1 reserved at position %2 side %3 - id %4!",_objectiveID,_objectivePos,_side,_id] call ALiVE_fnc_DumpR;
                };
    
                ////
                ///////////////////////////////////////////////////////////////////////////
            };
        };
    };
    
    //Register function
    _listener = [nil,"create"] call ALiVE_fnc_baseClass;
    _listener setVariable ["class",_fnc_custom];
    
    //Will always fire the function above if one of the events below is fired
    //Possible values are: "OPCOM_RESERVE","OPCOM_RECON","OPCOM_CAPTURE","OPCOM_DEFEND","OPCOM_TERRORIZE"
    _listenerID =   [ALiVE_eventLog,"addListener",[_listener, ["OPCOM_RESERVE"]]] call ALIVE_fnc_eventLog;
    
    //
    ///////////////////////////////////////////////////////////////////////////////////////////////////

    enjoy

  8. 6 weeks ago
    Edited 6 weeks ago by Reddog

    Thanks @highhead . So if I wanted to trigger a message when west capture an objective from east, I'd change this to be something along the lines of

    	
    //Reddog ALIVE CODE	
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    //Put in init.sqf
    //only use on an ALiVE mission with virtual AI module placed
    waituntil {!isnil "ALiVE_eventLog"};
    
    //Leave alone
    _fnc_custom = {
    
        //Do not touch that
        params ["_logic","_operation","_args"];
    
        //Also do not touch that
        switch (_operation) do {
            case "handleEvent": {
                _event = _args;
                
                _event params ["_id","_data"];
                _id = [_event, "id"] call ALIVE_fnc_hashGet;
                _data = [_event, "data"] call ALIVE_fnc_hashGet;
                
                _data params ["_side","_objective"];
    
    
                ///////////////////////////////////////////////////////////////////////////
                /////
                /////
                /////
                //// This is the part you can put your code in
                /////
                //
                //
                /* Example objective data from _objective call ALiVE_fnc_InspectHash;
                ---------------- Inspecting Hash --------------------
                k [0]: objectiveID v: OPCOM_2390318919_objective_0
                k [1]: center v: [23334.9,19291.6,0]
                k [2]: size v: 50
                k [3]: objectiveType v: MIL
                k [4]: priority v: 50
                k [5]: opcom_state v: idle
                k [6]: clusterID v: CUSTOM_42626
                k [7]: opcomID v: 2390318919
                k [8]: _rev v:
                k [9]: opcom_orders v: none
                k [10]: danger v: -1
                k [11]: sectionAssist v: ["BLU_F-entity_12"]
                k [12]: section v: ["BLU_F-entity_12"]
                k [13]: tacom_state v: reserve
                ---------------- Inspection Complete --------------------
                */
    
                //Get objective id and position
                private _objectiveID = [_objective,"objectiveID","empty"] call ALiVE_fnc_hashGet;
                private _objectivePos = [_objective,"center",[]] call ALiVE_fnc_hashGet;
    
                //If objective is of side east ("GUER" for resistance)
                if (_side == "WEST") then {
    systemchat format ["WEST JUST CAPTURED OBJ- %1 at position %2", _objectiveID, _objectivePos];                
                };
    
                ////
                ///////////////////////////////////////////////////////////////////////////
            };
        };
    };
    
    //Register function
    _listener = [nil,"create"] call ALiVE_fnc_baseClass;
    _listener setVariable ["class",_fnc_custom];
    
    //Will always fire the function above if one of the events below is fired
    //Possible values are: "OPCOM_RESERVE","OPCOM_RECON","OPCOM_CAPTURE","OPCOM_DEFEND","OPCOM_TERRORIZE"
    _listenerID =   [ALiVE_eventLog,"addListener",[_listener, ["OPCOM_CAPTURE"]]] call ALIVE_fnc_eventLog;
    
    //
    ///////////////////////////////////////////////////////////////////////////////////////////////////
    
    

    I'm assuming (BIG ASSUMPTION) that I can use the position to generate a town name/map label for the major towns at least, and that OPCOM_CAPTURE is the right event to listen for??

  9. highhead

    Sep 4 Administrator

    Correct! :)

  10. highhead

    Sep 4 Administrator
    Edited 6 weeks ago by highhead

    PS:

    Please mind:
    Once an objective has been secured it is "OPCOM_RESERVE". Basically if "OPCOM_CAPTURE" is triggered, then the groups have been finished grouping at the attack staging position and will go blazing it up, and once it is secured its reserved! Basically the flow is --> RECON -> CAPTURE -> RESERVE

  11. 5 weeks ago

    Thanks Highhead. That makes sense.

    Is there any documentation about the various functions in alive except whats in the script snippets on the wiki and the source code itself?

  12. 3 weeks ago

    I also would like to thank You @highhead for sharing the script here!

    When testing with your initial version I couldn't see any info on the side chat for some reason. Probably because of me :)
    Thus I did test with @Reddog 's version and that was printing objective info on the systemchat so now I could somewhat understand what's going on there.

    When I started this discussion I was looking a way to end (ALiVE) missions when a side has Occupied objectives that are needed to successfully complete one.

    Apparently I got this far on my own: when I place the following code

    if (_objectiveID == "OPCOM_7388496_objective_0") then {"end1" call BIS_fnc_endMissionServer;};

    in highhead's script the mission successfully ends. But after that I haven't been able to come up with anything level-headed that would solve the following problems:

    • What if one wanted a mission to end when multiple objectives are occupied? Would I need to create an array of objectives and if yes then how? (to this day I haven't digested how to "array" in Arma..)
    • Naturally a mission should end when certain objectives have been occupied by a certain Side and not just any, so the code for this should include a side check. How should one approach this?

    Additionally: I used the Reddog's version to display a single objective's objectiveID but how can one find objectiveID's of multiple objectives in a single mission? Is there a convenient way to dump them to clipboard or something the like with a code snippet?

  13. 2 weeks ago

    If youve got logging switched on, it all gets dumped into the log file?

 

or Sign Up to reply!