Announcement

Collapse
No announcement yet.

Arma 3 - Enemy Mortar Team Script

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

  • Arma 3 - Enemy Mortar Team Script

    This enemy mortar team script will pull all playable units from a side that you define and then check the following conditions every 10 seconds:
    • that the unit is still alive
    • that the forward observer knows about this unit


    Then the script will chose a target from this list at random and fire the mortars at the target up to 6 rounds from two different mortar guns.

    You need a mission with two enemy mortar guns placed named "mortar1" and "mortar2". You also need a forward observer named "mortarLeader".

    Code:
    //mortarAttack.sqf
    /* by |TG-189th| Unkl of TacticalGamer.com - ArmA Projects Team 
       written for ArmA 3 Beta mission co20_ClassDismissed_v1
    
    This script will choose all playable units for the side you define in _sideToAttack and
    target them with mortar strikes when they known to a forward observer.
    
    	- you need 2 static mortars named mortar1 and mortar2 in the editor
    	- you need 1 infantry man named mortarLeader who will be the forward observer(works 
    	  best when this unit has a team to report enemy positions to this leader)
    */
    private ["_sideToAttack","_run","_candidates","_targetKnown","_targets","_playable","_i","_aliveTargets","_knownTargets","_chosenTarget","_x"];
    
    //// enter the side you want attacked on the following line ///////////////////////////
    _sideToAttack = west; //blufor = WEST, opfor = EAST, independant = GUER, civilian = CIV
    ///////////////////////////////////////////////////////////////////////////////////////
    
    ////////////variable definitions
    _run = true;
    _candidates = [];
    _targetKnown = 0;
    _targets = [];
    _playable = [];
    _i = 0;
    _aliveTargets = [];
    _knownTargets = [];
    _chosenTarget = "";
    _x = "";
    
    //get a list of all playable units on the blufor side for targeting later
    {
    	_playable set [_i,_x];
    	_i = _i + 1;
    } forEach playableUnits;
    _i = 0;
    {
    	if (side _x == _sideToAttack) then
    	{
    		_targets set [_i, _x];
    		_i = _i + 1;
    	};
    } forEach _playable;
    
    ////////////////// loop to run while the mortar gunners are alive
    while {_run} do
    {
    	_chosenTarget = [];  ///reset chosen targets
    	_aliveTargets = [];  //reset all alive targets
    	_knownTargets = [];  //reset all known targets
    	_i = 0; 
    	
    	////////////////check for targets that are alive
    	{
    		if (alive _x) then
    		{
    			_aliveTargets set [_i, _x];
    			_i = _i + 1;
    		};
    	} forEach _targets;
    	_x = "";
    	_i = 0;  
    	
    	///////////////check for targets that are known to mortar leader
    	{
    		_targetKnown = mortarLeader knowsAbout _x;
    		if (_targetKnown > 1) then
    		{
    			_knownTargets set [_i, _x];
    			_i = _i + 1;
    		}; 
    	} forEach _aliveTargets;
    	
    	////////////// if there is known targets then chose one randomly and fire mortars at it
    	if (_i > 0) then
    	{
    		if (_i == 1) then
    		{
    			_chosenTarget = _knownTargets select 0;
    		} else {
    			_chosenTarget = _knownTargets select (floor random (_i - 1));
    		};
    		mortar1 commandArtilleryFire [getPos _chosenTarget, "8Rnd_82mm_Mo_shells", floor (random 6)]; //will fire up to 6 rounds at a time
    		sleep 15;
    		mortar2 commandArtilleryFire [getPos _chosenTarget, "8Rnd_82mm_Mo_shells", floor (random 6)];
    		sleep ((floor random 30) + 45); //will wait from 30 to 75 seconds after firing to reload
    	};
    	
    	////////////// if mortars are dead then stop this script
    	if (!alive mortar1 and !alive mortar2) then
    	{
    		_run = false;
    	};
    	sleep 10;  //wait an additional 10 seconds before checking for targets again
    };
    |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
    "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

  • #2
    Re: Arma 3 - Enemy Mortar Team Script

    do you have floor on
    Code:
    mortar1 commandArtilleryFire [getPos _chosenTarget, "8Rnd_82mm_Mo_shells", floor (random 6)];
    so there is a chance they wont fire at all? couldnt you just have done (round(random 5))+1 so they will always fire a round?
    Yink | Vanilla Pilot | Killer of Stirling | CS GOD | Projects Team

    Comment


    • #3
      Re: Arma 3 - Enemy Mortar Team Script

      Good catch
      |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
      "We quickly advance in the opposite direction and take cover in a house on the SW side of town." - BadStache

      Comment

      Connect

      Collapse

      TeamSpeak 3 Server

      Collapse

      Advertisement

      Collapse

      Twitter Feed

      Collapse

      Working...
      X