Announcement

Collapse
No announcement yet.

Script Request: Defending A Sector

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

  • Script Request: Defending A Sector

    I am trying to finish my defense mission, however, I want the players to defend an area. The area is in Pyrgos with the three multistory buildings. The players should have to defend the area for about 45 minutes against waves of enemies that increase in intensity depending on player count. I have everything I need for the mission. However, I wanted to change how the sector is represented in the mission.
    Currently, I have two triggers and an area marker to create a sector:
    -The first trigger is the actual sector, it detects the AI in the zone and counts up to 5 minutes before activating the fail condition for the mission.
    -The second trigger is a warning for the players giving them an on-screen hint that enemies are close to the sector.
    -The area marker gives the players a visual representation on the map of the sector they need to defend.

    How do I create a more interactive sector to defend?
    For instance; A sector that is green if friendlies are in control, orange if it is contested and red if in enemy control, somewhat like how the sectors behave in Insurgency.
    The sector should change based on how many of one side is in the zone. Example: 10 AAF vs 11 CSAT = CSAT controlled zone
    The sector should also give players a few minutes to take back the sector before they lose.

    Thanks for any help!
    I wasn't originally going to get a brain transplant, but then I changed my mind.

  • #2
    https://community.bistudio.com/wiki/setMarkerColor
    https://community.bistudio.com/wiki/...rColors_Arma_3

    If you want a circular sector you don't need a trigger at all because you can script the distance that each unit is from the center of your sector and check for distance in your script. If you want a rectangular sector then it is still easy to create a trigger that is set for "Anybody" "Present" and is repeatable, and name your trigger something like "trigSectorA".

    Create your marker in the editor that covers the sector and name it "mrkSectorA".

    Now in your script you can do a check to grab who is in you trigger and do your math.

    Code:
    if !(isServer) exitWith {};
    _unitsInSector = [];
    _eastUnitsInSector = [];
    _indUnitsInSector = [];
    _controlledBy = "";
    _sectorChangedHands = "neutral";
    _sectorTimerStart = 0;
    _winner = "";
    
    _run = true;
    
    while {_run} do
    {
      _unitsInSector = list trigSectorA;
      _eastUnitsInSector = [];
      _indUnitsInSector = [];
      {
        if (side _x = east) then {_eastUnitsInSector pushBack _x;};
        if (side _x = independent) then {_indUnitsInSector pushBack _x;};
      } forEach _unitsInSector;
    
      //players are independent
      if (count _eastUnitsInSector > count _indUnitsInSector) then
      {
        _controlledBy = "east";
        if !(_sectorChangedHands == _controlledBy) then
        {
          "mrkSectorA" setMarkerColor "ColorOpfor";
          _sectorChangedHands = "east";
          _sectorTimerStart = time;
          "CSAT now controls Sector A" remoteExec ["hint",0,false];
        };
        if (time - _sectorTimerStart > 300) then {_winner = "CSAT";};
      };
    
      if (count _eastUnitsInSector == count _indUnitsInSector) then
      {
        _controlledBy = "neutral";
        if !(_sectorChangedHands == _controlledBy) then
        {
          "mrkSectorA" setMarkerColor "ColorUnknown";
          _sectorChangedHands = "neutral";
          _sectorTimerStart = time;
          "Sector A is neutral." remoteExec ["hint",0,false];
          _winner = "";
        };
      };
    
      if (count _eastUnitsInSector < count _indUnitsInSector) then
      {
        _controlledBy = "ind";
        if !(_sectorChangedHands == _controlledBy) then
        {
          "mrkSectorA" setMarkerColor "ColorIndependent";
          _sectorChangedHands = "indy";
          _sectorTimerStart = time;
          "AAF now controls Sector A" remoteExec ["hint",0,false];
        };
        if (time - _sectorTimerStart > 300) then {_winner = "AAF";};
      };
    
      //check for 5 minute winner
      if (_winner == "CSAT") then
      {
        _run = false;
        ["end1",false,true,true] call bis_fnc_endMission;
      };
      if (_winner == "AAF") then
      {
        _run = false;
        ["end2",true,true,true] call bis_fnc_endMission;
      };
    };
    Last edited by Unkl; 02-12-2017, 07:44 PM.
    |TG-189th| Unkl
    ArmA 3 Game Officer
    Dean of Tactical Gamer University
    189th Infantry Brigade Member

    SUBMIT A RIBBON NOMINATION OR CONTACT AN ARMA ADMIN

    Comment

    Connect

    Collapse

    TeamSpeak 3 Server

    Collapse

    Advertisement

    Collapse

    Twitter Feed

    Collapse

    Working...
    X