Sector control

  1. 7 years ago

    Hello, quick question here.

    Does Alive work with the sector control modules? As in, even when the units are virtual.

    Thanks!

  2. No, it would require manual scripting and triggers to bridge the two functionalities.

  3. Alright, thanks for the reply! Im decent with scripting so I will investigate and see if I manage to get it to work.

  4. Edited 7 years ago by Imbazil

    Apparently it was harder than I first thought =P Alive have some nice snippets on the wiki for detecting the virtual AI but I cant find a way to alter the Sectors by script.

    So Instead I thought that I could use a regular marker and simply change it's color, is it possible to get the position, "owner" and possibly size (as in medium, small, tiny, etc) of all the MilObj and CivObj created? or is this info that is unavailable for scripts?

    Didn't find anything regarding this among the snippets, is there another place to look?

  5. ALiVE_fnc_getDominantFaction (or something similar to that)

  6. cheers! Managed to find the function and it seems like it will fit perfectly.

    Is there any documentation of all the ALiVE_fnc_X methods anywhere? apart from the in game function viewer?

  7. Not really

  8. Edited 7 years ago by Imbazil

    My mission is now pretty much done, however I have noticed a minor issue with the capturing of sectors.

    I use the following code in a trigger condition field:

    [getpos tsk2trigger, 100] call ALiVE_fnc_getDominantFaction == "rhs_faction_usarmy_d"

    to detect when the players faction has control over the area.

    and this in the activate field (with a 30 sec timeout):

    "tsk2marker" setMarkerColor "colorBLUFOR";
    ["t2", "SUCCEEDED"] call BIS_fnc_taskSetState;

    Seems to work fine, but only when there are actual AI units in the area, it wont trigger if the player group enters an area by themselves and clears it out. It seems like ALiVE_fnc_getDominantFaction don't care for players so is there a way to also take eventual players in the area into account?

  9. Try looking into the function definition in the function viewer, I think it was an optional bool for counting real units as well.

  10. Edited 7 years ago by Imbazil

    I actually had a look since it seemed logical that there would be, but that did not seem to be the case unfortunately. Or am I missing something?

    #include <\x\alive\addons\x_lib\script_component.hpp>
    SCRIPT(getDominantFaction);
    
    /* ----------------------------------------------------------------------------
    Function: ALiVE_fnc_getDominantFaction
    
    Description:
    Returns the dominant faction within given radius, Takes into account profiles
    
    Parameters:
    Array - Position measuring from
    Number - Distance being measured (optional)
    
    Returns:
    Number - Faction ConfigName ("BLU_F","OPF_F",etc.)
    
    Examples:
    (begin example)
    [getposATL player, 500] call ALiVE_fnc_getDominantFaction
    (end)
    
    Author:
    Highhead
    ---------------------------------------------------------------------------- */
    private ["_pos","_radius","_fac","_facs","_profiles","_result","_noCiv"];
    
    PARAMS_1(_pos);
    DEFAULT_PARAM(1,_radius,500);
    DEFAULT_PARAM(2,_noCiv,false);
    
    //Virtual Profiles activated?
    if !(isnil "ALIVE_profileHandler") then {
        _profiles = [ALIVE_profileHandler, "profiles"] call ALIVE_fnc_hashGet;
    } else {
        _profiles = [[],[],[]];
    };
    
    _facs = [];
    {
        if (((_x select 2 select 5) == "entity") && {!(_x select 2 select 1)} && {!(_x select 2 select 30)} && {(_x select 2 select 2) distance _pos < _radius}) then {
            _facs pushback (_x select 2 select 29);
        };
    } foreach (_profiles select 2);
    
    {
        if ((_pos distance (getposATL (leader _x)) < _radius) && {{isPlayer _x} count (units _x) < 1}) then {
            _facs pushback (faction(leader _x));
        };
    } foreach allgroups;
    
    _result = [];
    {
        private ["_fac","_cnt"];
        if (count _facs == 0) exitwith {};
    
        _fac = _x;
        _cnt = {_fac == _x} count _facs;
    
        if (_cnt > 0) then {
            _result pushback [_fac,_cnt];
            _facs = _facs - [_fac];
        };
    } foreach _facs;
    
    _result = [_result,[],{_x select 1},"DESCEND",{if (_noCiv) then {!(((_x select 0) call ALiVE_fnc_factionSide) == CIVILIAN)} else {true}}] call ALiVE_fnc_SortBy;
    
    if ((count _result > 0) && {(_result select 0 select 1) > 0}) then {
        (_result select 0) select 0;
    } else {nil};
  11. @Imbazil could you elaborate on your trigger marker system? I've been trying to emulate your results and failing! I'm having a hard time with getting [getpos Trig_1, 100] call ALiVE_fnc_getDominantFaction == "OPF_F" in a trigger condition to activate it.

    Thanks!

  12. I don't see any issue with the actual condition, maybe it's what you have in the activation box that isn't working?

    Try to just add a hint in the on activation field and place a trigger far off with only a opfor unit in it. does it fire then? It also seem like it has to be an actual AI unit so you can't try with the player character.

  13. That was weird out of pure frustration i deleted the trigger and made a copy from scratch ... NOW its working...lol typical thanks for the response though!

  14. glad to hear you solved it! =)

 

or Sign Up to reply!