Announcement

Collapse
No announcement yet.

Creating a capturable sector with scripts

Collapse
X
  • Filter
  • Time
  • Show
Clear All
new posts

  • [GUIDE] Creating a capturable sector with scripts

    The following code gives a bit of sector creating via scripting. I have tested it a bit but have not done so in dedicated. I ran into this source just by browsing by chance. I wanted to get this working for a long time to use dynamic sector creating and deleting. I wanted to share this so that other mission makers to modify and use, as I am to be absent for an some amount of time.

    pasteBin

    Code:
    /*Usage: ["makername", west, east] spawn TG_fnc_mySector;
    
    Parameters:
    "markername" - a rectangle marker on the map in editor
    ""
    */
    
    if !(isServer) exitWith {}; //Do not run on the server
    
    private ["_mrkName", "_mrkSize", "_mrkDir", "_mrkPos", "_areaTrig", "_logic",
            "_areaLogic", "_side1", "_side2"];
    
    //Retrieve marker information
    _mrkName = _this select 0;
    _side1 = _this select 1;
    _side2 = _this select 2;
    _mrkSize = getMarkerSize _mrkName;
    _mrkDir = markerDir _mrkName;
    _mrkPos = markerPos _mrkName;
    
    //Create a trigger
    _areaTrig = createTrigger ["EmptyDetector", _mrkPos];
    _areaTrig setTriggerArea [_mrkSize select 0, _mrkSize select 1, _mrkDir, true, 20];
    
    //Create the sector logic
    _logic = (createGroup sideLogic) createUnit ["ModuleSector_F", _mrkPos, [], 0, "NONE"];
    
    //Creates area & side logics and trigger
    _areaLogic = (createGroup sideLogic)createUnit["LocationArea_F", _mrkPos, [], 0, "NONE"];
    
    // Synchronizes the area
    _logic synchronizeObjectsAdd [_areaLogic];
    
    //Synchronze the area to the trigger
    _areaLogic synchronizeObjectsAdd [_areaTrig];
    
    //Sector settings
    _logic setVariable ["Name"," "];
    _logic setVariable ["Designation",""];
    _logic setVariable ["ScoreReward","0"];
    _logic setVariable ["OnOwnerChange","hint 'sup sup'"];
    _logic setVariable ["OwnerLimit","0.8"];
    _logic setVariable ["DefaultOwner","-1"];
    _logic setVariable ["TaskOwner","0"];//nobody 0
    _logic setVariable ["TaskTitle",""];
    _logic setVariable ["TaskDescription",""];
    _logic setVariable ["CostInfantry","1"];
    _logic setVariable ["CostWheeled","2"];
    _logic setVariable ["CostTracked","4"];
    _logic setVariable ["CostWater","0"];
    _logic setVariable ["CostAir","2"];
    _logic setVariable ["CostPlayers","1"];
    
    //Set sides competing for the sector
    _logic setVariable ["sides", [_side1, _side2]];
    
    //initialize the module code
    [_logic] call BIS_fnc_moduleSector;
    
    //Wait until sector is initialised
    waitUntil
    {
        !isNil { _logic getVariable [ "finalized", nil ] } &&
        { !( _logic getVariable [ "finalized", true ] ) }
    };
    
    //Hide the markers
    _areas = _logic getVariable "areas";
    _trigger = _areas select 0;
    _trigMarker = (_trigger getVariable "markers") select 0;
    _iconMarker = (_trigger getVariable "markers") select 1;
    _trigMarker setMarkerAlpha 0;
    _iconMarker setMarkerAlpha 0;

Connect

Collapse

TeamSpeak 3 Server

Collapse

Twitter Feed

Collapse

Working...
X