Jump to content
Sign in to follow this  
arigato

[SCRIPT] Arigato Defence Script

Recommended Posts

Arigato Defence Script (v1.4)

This is a script which simplifies the process of placing AI defenses in settlements. You do not have to manually set the soldiers in the city and ask them to conduct. Using this script you get entrenched in buildings, soldiers patrolled the city, civil, which can pick up weapons and join the battle and the women suicide bombers. Patrol bots are able to hold their own stationary tool. Unlike the manual placement of the defenders, the script will run each puts bots in different positions, as a result of the passage of each mission will have a certain element of surprise.

The script defines the six types of behavior of bots:

1. Patrols, walk to the city limits.

2. Entrenched in the homes of soldiers who can run out the attack.

3. Entrenched in the homes of the soldiers that rush out at the approach of the enemy.

4. Entrenched in the homes of soldiers who do not leave their position.

5. Civilians walking in the city can find a weapon with a corpse and attack the enemy.

6. Women go to the city limits. If a Muslim woman, she can blow himself up along with the enemy.

defence.sqf

/*
* ARIGATO DEFENCE SCRIPT (v1.4)
* (c) Arigato Software, 2012
*/

ARGT_DEFENCE_POSITION = {
 private ["_military", "_civilian", "_centre", "_radius", "_positions", "_patrol", "_units", "_group", "_unit", "_idx", "_pos", "_dir"];
 _military = if ( typename (_this select 0) == "ARRAY" ) then {_this select 0} else {[_this select 0]};
 _civilian = _this select 1;
 _centre   = _this select 2;
 _radius   = if ( count _this > 3 ) then {_this select 3} else {100};
 _units = [];
 {
   _group = if ( typename _x == "GROUP" ) then {_x} else {group _x};
   _group setcombatmode "YELLOW";
   _group setbehaviour "AWARE";
   _units = _units + units _group;
 } foreach _military;
 _positions = [_centre, _radius] call ARGT_DEFENCE_SCAN;
 /*hint format ["%1", count _positions];*/
 _patrol = (count _units) / 10;
 _patrol = _patrol + random _patrol;
 if ( _patrol < 1 ) then {_patrol = _patrol + random ((count _units) / 3)};
 [_centre, _radius, side (_units select 0), (count _units) / 4] spawn ARGT_DEFENCE_ESCAPE;
 while { count _units > 0 } do {
   _idx = floor random count _units;
   _unit = _units select _idx;
   _units set [_idx, "*"];
   _units = _units - ["*"];
   if ( _patrol >= 1 || count _positions == 0 ) then {
     if ( _patrol >= 0 ) then {
       [_unit, _centre, _radius] spawn ARGT_DEFENCE_PATROL;
       if ( _patrol >= 1 ) then {_patrol = _patrol - 1};
     };
   } else {
     _idx = floor random count _positions;
     _pos = _positions select _idx;
     _dir = (_pos select 1) - 15 + random 30;
     _unit setposatl (_pos select 0);
     _unit setdir _dir;
     if ( _unit != player && ! (_unit in switchableunits) ) then {
       _unit setvariable ["ARGT_DEFENCE_CENTRE", _centre, true];
       _unit setvariable ["ARGT_DEFENCE_RADIUS", _radius, true];
       [_unit] spawn ARGT_DEFENCE_CHICKEN;
     };
     _positions set [_idx, "*"];
     _positions = _positions - ["*"];
   };
 };
 [_civilian, _centre, _radius] call ARGT_DEFENCE_CIVILIAN;
};

ARGT_DEFENCE_DOORS = {
 private ["_centre", "_radius", "_phase", "_anims", "_animCfgList", "_configname"];
 _centre = _this select 0;
 _radius = _this select 1;
 _phase  = if ( count _this > 2 ) then {_this select 2} else {1};
 _anims = ["Lights_1", "Lights_2", "Lights_3", "Lights_4", "Lights_5"];
 {
   _animCfgList = configfile >> "CfgVehicles" >> typeof _x >> "AnimationSources";
   for "_i" from 0 to count _animCfgList - 1 do {
     _configname = configname (_animCfgList select _i);
     if ( ! (_configname in _anims) ) then {_x animate [_configname, _phase]};
   };
 } foreach (_centre nearobjects ["House", _radius]);
};

/* ------------------------------------------------------------------------- */

ARGT_DEFENCE_OCCUPIED = [];
ARGT_DEFENCE_VEHICLES = [];

ARGT_DEFENCE_CIVILIAN = {
 private ["_groups", "_centre", "_radius", "_group"];
 _groups = if ( typename (_this select 0) == "ARRAY" ) then {_this select 0} else {[_this select 0]};
 _centre = _this select 1;
 _radius = if ( count _this > 2 ) then {_this select 2} else {100};
 {
   _group = if ( typename _x == "GROUP" ) then {_x} else {group _x};
   _group setcombatmode "BLUE";
   {
     _x setcaptive true;
     _x setskill ["courage", 1];
     _x allowfleeing 0;
     if ( _x iskindof "Woman_EP1" ) then {[_x] spawn ARGT_DEFENCE_SHAHID};
     [_x, _centre, _radius] spawn ARGT_DEFENCE_PATROL;
     [_x] spawn ARGT_DEFENCE_BEHAVIOUR;
   } foreach units _group;
 } foreach _groups;
};

ARGT_DEFENCE_PATROL = {
 private ["_unit", "_centre", "_radius", "_limited", "_patrol", "_dir", "_length", "_position", "_targets", "_timeout", "_pos"];
 _unit = _this select 0;
 _centre = _this select 1;
 _radius = if ( count _this > 2 ) then {_this select 2} else {100};
 _limited = if ( count _this > 3 ) then {_this select 3} else {true};
 _patrol = _unit getvariable "ARGT_DEFENCE_PATROL";
 if ( isnil "_patrol" ) then {_patrol = false};
 if ( ! _patrol ) then {
   _unit setspeedmode "FULL";
   _unit setvariable ["ARGT_DEFENCE_PATROL", true, true];
   if ( ! (_unit iskindof "Woman") && ! (_unit iskindof "Woman_EP1") ) then {
     [_unit] spawn ARGT_DEFENCE_COLLECTION;
     if ( side _unit != civilian ) then {[_unit] spawn ARGT_DEFENCE_GUNNER};
   };
   while { alive _unit } do {
     if ( _unit getvariable "ARGT_DEFENCE_PATROL" ) then {
       _dir = random 360;
       _length = 10 + random _radius;
       _position = [(_centre select 0) + _length * sin _dir, (_centre select 1) + _length * cos _dir];
       _unit domove _position;
       _pos = "";
       waituntil {
         if ( _pos != str (getposatl _unit) ) then {
           _pos = str (getposatl _unit);
           _timeout = time + 30;
         };
         movetocompleted _unit || movetofailed _unit || unitready _unit || ! alive _unit || time > _timeout
       };
       if ( _limited ) then
       {
         _targets = _unit neartargets 69;
         if ( {_x select 3 > 10} count _targets > 0 ) then
         {
           _unit setbehaviour "AWARE";
           _unit setspeedmode "FULL";
         } else {_unit setspeedmode "LIMITED"};
       };
     } else {sleep 5};
   };
 };
};

ARGT_DEFENCE_CHICKEN = {
 private ["_unit", "_handle_damage", "_handle_firednear", "_position"];
 _unit = _this select 0;
 _handle_damage = _unit addeventhandler ["HandleDamage", {call ARGT_DEFENCE_DAMAGE}];
 _handle_firednear = _unit addeventhandler ["FiredNear", {call ARGT_DEFENCE_FIREDNEAR}];
 _unit setvariable ["ARGT_DEFENCE_CHICKEN", true, true];
 dostop _unit;
 if ( random 1 > 0.4 ) then {[_unit] spawn ARGT_DEFENCE_STOP};
 _unit setvariable ["ARGT_DEFENCE_CAREFUL", random 1 < 0.3, true];
 sleep 10;
 _position = getposatl _unit;
 while { alive _unit && _unit getvariable "ARGT_DEFENCE_CHICKEN" } do {
   _unit setunitpos "up";
   sleep (3 + random 10);
   if ( _unit distance _position > 0.5 ) then {_unit setvariable ["ARGT_DEFENCE_CHICKEN", false, true]};
   if ( alive _unit && _unit getvariable "ARGT_DEFENCE_CHICKEN" ) then {
     _unit setposatl _position;
     _unit setunitpos "middle";
     sleep (5 + random 20);
   };
 };
 _unit removeeventhandler ["HandleDamage", _handle_damage];
 _unit removeeventhandler ["FiredNear", _handle_firednear];
 _unit setunitpos "auto";
};

ARGT_DEFENCE_SCAN = {
 private ["_centre", "_radius", "_houses", "_house", "_result", "_bpos", "_position", "_dir"];
 _centre = _this select 0;
 _radius = if ( count _this > 1 ) then {_this select 1} else {100};
 _houses = _centre nearobjects ["House", _radius];
 _result = [];
 {
   _house = _x;
   _position = _house buildingpos 0;
   if ( _position select 0 != 0 ) then {
     _bpos = 1;
     while { _position select 0 != 0 } do {
       _dir = [getposatl _house, _position] call ARGT_DEFENCE_DIR;
       _position set [2, (_position select 2) + 0.1];
       _result set [count _result, [_position, floor _dir]];
       _bpos = _bpos + 1;
       _position = _house buildingpos _bpos;
     };
   };
 } foreach _houses;
 _result
};

ARGT_DEFENCE_SHAHID = {
 private ["_unit", "_side", "_targets", "_z", "_velocity", "_position", "_distance", "_min", "_timeout", "_pos"];
 _unit = _this select 0;
 _unit setcaptive false;
 _side = side _unit;
 _unit setcaptive true;
 _unit setvariable ["ARGT_DEFENCE_UP", false, true];
 while { alive _unit } do {
   sleep 5;
   _targets = _unit neartargets 12;
   _z = getposatl _unit select 2;
   if ( {_x select 3 > 10 && (_x select 4) iskindof "Man" && (_x select 4) distance _unit < 12 && abs (_z - (getposatl (_x select 4) select 2)) < 2} count _targets > 0 &&
        {alive _x && (side _x == _side || side _x == civilian) && ! (_x iskindof "Woman_EP1")} count (nearestobjects [_unit, ["Man"], 20]) == 0 ) exitwith {
     _unit setcaptive false;
     sleep 0.5;
     _unit say ["akbar", 10];
     sleep 1.5;
     if ( alive _unit ) then {
       _unit allowdamage false;
       {"Grenadebase" createvehicle getpos _unit} foreach [1,2,3,4];
       _velocity = velocity _unit;
       _unit setvelocity [_velocity select 0, _velocity select 1, (_velocity select 2) + 2];
       _unit spawn {sleep 1; _this setdamage 1};
     };
   };
   _targets = _unit neartargets 69;
   if ( {_x select 3 > 10 && (_x select 4) iskindof "Man" && abs (_z - (getposatl (_x select 4) select 2)) < 2} count _targets > 0 ) then {
     _position = [0,0,0];
     _min = 10000;
     {
       if ( _x select 3 > 10 && (_x select 4) iskindof "Man" && abs (_z - (getposatl (_x select 4) select 2)) < 2 ) then
       {
         _distance = _unit distance (_x select 4);
         if ( _distance < _min ) then {
           _min = _distance;
           _position = getpos (_x select 4);
         };
       };
     } foreach _targets;
     if ( _position select 0 != 0 ) then {
       _unit setvariable ["ARGT_DEFENCE_PATROL", false, true];
       _unit setunitpos "up";
       _unit domove _position;
       _unit setspeedmode "FULL";
       if ( ! (_unit getvariable "ARGT_DEFENCE_UP") ) then {
         _unit setvariable ["ARGT_DEFENCE_UP", true, true];
         [_unit] spawn {
           _pos = "";
           waituntil {
             _unit setunitpos "up";
             if ( _pos != str (getposatl _unit) ) then {
               _pos = str (getposatl _unit);
               _timeout = time + 30;
             };
             movetocompleted _unit || movetofailed _unit || unitready _unit || ! alive _unit || time > _timeout
           };
           _unit setvariable ["ARGT_DEFENCE_UP", false, true];
           _unit setvariable ["ARGT_DEFENCE_PATROL", true, true];
         };
       };
     };
   };
 };
};

ARGT_DEFENCE_GUNNER = {
 private ["_unit", "_vehicles", "_vehicle", "_timeout", "_pos", "_canfire"];
 _unit = _this select 0;
 while { alive _unit } do {
   waituntil { sleep (10 + random 5); _unit getvariable "ARGT_DEFENCE_PATROL" };
   _vehicles = nearestobjects [_unit, ["LandVehicle"], 69];
   {
     _vehicle = str _x;
     if ( ! (_vehicle in ARGT_DEFENCE_VEHICLES) && alive _x && _x emptypositions "Gunner" > 0 && count magazines _x > 0 ) exitwith {
       ARGT_DEFENCE_VEHICLES set [count ARGT_DEFENCE_VEHICLES, _vehicle];
       _unit setvariable ["ARGT_DEFENCE_PATROL", false, true];
       [_unit] allowgetin true;
       _unit assignasgunner _x;
       [_unit] ordergetin true;
       _unit setspeedmode "FULL";
       if ( requiredversion "1.60" ) then {_x call compile "_this allowcrewinimmobile true"}; /* ARMA II >= 1.60 */
       _pos = "";
       waituntil {
         if ( _pos != str (getposatl _unit) ) then {
           _pos = str (getposatl _unit);
           _timeout = time + 30;
         };
         movetocompleted _unit || movetofailed _unit || unitready _unit || ! alive _unit || _x emptypositions "Gunner" == 0 || time > _timeout
       };
       _canfire = true;
       if ( alive _unit && vehicle _unit == _x ) then {
         _unit setcombatmode "RED";
         _unit setbehaviour "AWARE";
         waituntil { sleep 1; _canfire = (alive _x && (canfire _x || ! alive _unit) && count magazines _x > 0); ! _canfire || ! alive _unit };
         [_unit] ordergetin false;
         unassignvehicle _unit;
         [_unit] allowgetin false;
         _unit leavevehicle _x;
         _unit action ["eject", _x];
         if ( requiredversion "1.60" ) then {_x call compile "_this allowcrewinimmobile false"}; /* ARMA II >= 1.60 */
       };
       if ( _canfire ) then {ARGT_DEFENCE_VEHICLES = ARGT_DEFENCE_VEHICLES - [_vehicle]};
       _unit setvariable ["ARGT_DEFENCE_PATROL", true, true];
     };
   } foreach _vehicles;
 };
};

ARGT_DEFENCE_COLLECTION = {
 private ["_unit", "_men", "_dead", "_occupied", "_timeout", "_pos"];
 _unit = _this select 0;
 while { alive _unit } do {
   waituntil { sleep (10 + random 5); (primaryweapon _unit == "" && secondaryweapon _unit == "" || count magazines _unit == 0) && _unit getvariable "ARGT_DEFENCE_PATROL" };
   _men = nearestobjects [_unit, ["Man"], 69];
   {
     if ( ! alive _x && getposatl _x select 2 < 2 ) then {
       _dead = _x;
       _occupied = str _dead;
       if ( ! (_occupied in ARGT_DEFENCE_OCCUPIED) && (primaryweapon _dead != "" || secondaryweapon _dead != "") && count magazines _dead > 0 ) exitwith {
         ARGT_DEFENCE_OCCUPIED set [count ARGT_DEFENCE_OCCUPIED, _occupied];
         _unit setvariable ["ARGT_DEFENCE_PATROL", false, true];
         _unit domove getpos _dead;
         _unit setspeedmode "FULL";
         _pos = "";
         waituntil {
           if ( _pos != str (getposatl _unit) ) then {
             _pos = str (getposatl _unit);
             _timeout = time + 30;
           };
           movetocompleted _unit || movetofailed _unit || unitready _unit || ! alive _unit || time > _timeout
         };
         if ( alive _unit && _unit distance _dead < 3 && (primaryweapon _dead != "" || secondaryweapon _dead != "") && count magazines _dead > 0 ) then {
           _unit dowatch _dead;
           _unit setunitpos "middle";
           _unit forcespeed 0;
           sleep 2;
           _unit disableai "move";
           if ( ! alive _unit ) exitwith {};
           _unit setcombatmode "RED";
           _unit setbehaviour "AWARE";
           {_dead addweapon _x} foreach weapons _unit;
           removeallweapons _unit;
           sleep 1;
           if ( ! alive _unit ) exitwith {};
           {
             _unit addmagazine _x;
             _dead removemagazine _x
           } foreach magazines _dead;
           sleep 1;
           if ( ! alive _unit ) exitwith {};
           {
             _unit addweapon _x;
              if ( primaryweapon _unit != "" ) then {
               _unit selectweapon primaryweapon _unit;
               _unit setcaptive false;
             };
             if ( secondaryweapon _unit != "" ) then {_unit setcaptive false};
           } foreach weapons _dead;
           removeallweapons _dead;
           if ( primaryweapon _unit == "" && secondaryweapon _unit != "" ) then {_unit selectweapon secondaryweapon _unit};
           sleep 1;
           if ( primaryweapon _unit != "" ) then {_unit selectweapon primaryweapon _unit};
           _unit dowatch objnull;
           _unit enableai "move";
           _unit forcespeed -1;
           _unit setunitpos "auto";
         };
         ARGT_DEFENCE_OCCUPIED = ARGT_DEFENCE_OCCUPIED - [_occupied];
         _unit setvariable ["ARGT_DEFENCE_PATROL", true, true];
       };
     };
   } foreach _men;
 };  
};

ARGT_DEFENCE_BEHAVIOUR = {
 private ["_unit"];
 _unit = _this select 0;
 while { alive _unit } do {
   _unit setbehaviour "SAFE";
   waituntil { sleep (10 + random 20); behaviour _unit == "COMBAT" };
   _unit setspeedmode "FULL";
   _unit setbehaviour "CARELESS";
   sleep (10 + random 20);
 };
};

ARGT_DEFENCE_ESCAPE = {
 private ["_centre", "_radius", "_side", "_count", "_escape"];
 _centre = _this select 0;
 _radius = _this select 1;
 _side = _this select 2;
 _count = _this select 3;
 _escape = false;
 while { ! _escape } do {
   sleep 10;
   if ( {side _x == _side && _x distance _centre < _radius} count allunits <= _count ) then {
     {
       if ( side _x == _side && _x distance _centre < _radius ) then {
         _x setvariable ["ARGT_DEFENCE_CHICKEN", false, true];
         _x setunitpos "middle";
         [_x, _centre, _radius, false] spawn ARGT_DEFENCE_PATROL;
         _escape = true;
       };
     } foreach allunits;
   };
 };
};

ARGT_DEFENCE_DIR = {
 private ["_pos1", "_pos2", "_distance", "_dir"];
 _pos1 = _this select 0;
 _pos2 = _this select 1;
 _distance = [_pos1 select 0, _pos1 select 1, 0] distance [_pos2 select 0, _pos2 select 1, 0];
 _dir = asin (((_pos2 select 0) - (_pos1 select 0)) / _distance);
 if ( _pos2 select 1 < _pos1 select 1 ) then {_dir = 180 - _dir};
 _dir
};

ARGT_DEFENCE_STOP = {
 private ["_unit"];
 _unit = _this select 0;
 waituntil {
   _unit forcespeed 0;
   ! alive _unit || ! (_unit getvariable "ARGT_DEFENCE_CHICKEN")
 };
 _unit forcespeed -1;
};

ARGT_DEFENCE_DAMAGE = {
 private ["_unit", "_damage"];
 _unit = _this select 0;
 _damage = _this select 2;
 _unit forcespeed -1;
 _unit setunitpos "middle";
 _damage
};

ARGT_DEFENCE_FIREDNEAR = {
 private ["_unit", "_firer"];
 _unit = _this select 0;
 _firer = _this select 1;
 if ( side _unit != side _firer ) then {
   _unit setunitpos "middle";
   if ( _unit getvariable "ARGT_DEFENCE_CAREFUL" ) then {
     [_unit, _firer] spawn {
       private ["_unit", "_firer", "_centre", "_radius"];
       _unit = _this select 0;
       _firer = _this select 1;
       _unit setvariable ["ARGT_DEFENCE_CHICKEN", false, true];
       sleep 1;
       _unit forcespeed -1;
       if ( _firer iskindof "Man" ) then {
         _unit domove position _firer;
         _unit dofire _firer;
       };
       _centre = _unit getvariable "ARGT_DEFENCE_CENTRE";
       _radius = _unit getvariable "ARGT_DEFENCE_RADIUS";
       if ( ! isnil "_centre" ) then {
         sleep 30;
         [_unit, _centre, _radius, false] spawn ARGT_DEFENCE_PATROL;
       };
     };
   };
 };
};

Use:

1. In init.sqf mission connect script: call compile preprocessfilelinenumbers "script\defence.sqf";

2. Put a marker in the center of the city, giving it a name, such as "argt_shukurkalay".

3. We place on the map of groups that will participate in the defense of the city, giving the names of their commanders, for example, argt_leader1, ...

4. We arrange group of civilians (men and women). Groups should have a defensive side, but not CIV. This can be either manually set the file mission mission.sqm, or put in a group commander of the fighter required by the rank of colonel, and with the probability of the presence of 0%.

5. Below init.sqf add a line placing defenders for the following positions:

[
 [argt_leader1, argt_leader2, argt_leader3, argt_leader4, argt_leader5, argt_leader6, argt_leader7],
 [argt_civ1, argt_civ2, argt_civ3, argt_civ4],
 getmarkerpos "argt_shukurkalay", 150
] call ARGT_DEFENCE_POSITION;

[argt_leader1, ..., argt_leader6] - a list of all team leaders.

[argt_civ1, ..., argt_civ4] - a list of units in groups of civilians.

getmarkerpos "argt_shukurkalay" - to patrol the city center.

150 - the radius of the city to patrol.

All you can run a mission, and storm the city.

The demo mission.

In the demo mission you have to storm the village there is a barricaded gunmen. The number of attackers and defenders: 80 to 50 people. In the village of 20 civilians (15 males and 5 females). 0-0-0 radio commands will show the remaining number of fighters. You can switch between the blue medic, red bone setters and a reporter.

Download: http://www.armaholic.com/page.php?id=17131

Demo mission 1: http://narod.ru/disk/56167938001.0200fbbec67983a8a57c64f990bc7f4f/DEFENCE_DEMO_1.Takistan.7z.html

Demo mission 2: http://narod.ru/disk/56167980001.4a518d154b65a78a9eb96717c357bdea/DEFENCE_DEMO_2.Takistan.7z.html

Discussion: http://www.flashpoint.ru/threads/%D0%A1%D0%BA%D1%80%D0%B8%D0%BF%D1%82-%D0%BE%D0%B1%D0%BE%D1%80%D0%BE%D0%BD%D1%8B-%D0%B3%D0%BE%D1%80%D0%BE%D0%B4%D0%B0.49786/

© Arigato Software, 2012

Edited by Arigato

Share this post


Link to post
Share on other sites

Just played the DEMO 1 mission.

Looks like a lot ot fun.

Now, i feel forced to ask: it looks a lot like what we can get with UPSMON (those civilians picking up weapons are a lot of fun though). How does it fare performance-wise? Particularly on a dedicated server?

Share this post


Link to post
Share on other sites

BlackMamb

The script in the multiplayer mode has not been tested.

Foxhound

Thank you.

Share this post


Link to post
Share on other sites

Interesting, this might be what I'm looking for to add to a specific mission type. Thank you for sharing.

Share this post


Link to post
Share on other sites

Do you have to put civilian group in a mission for the script to work? What if I don't want any civs in a mission?

Also, I have used the script in a mission on a dedicated server and what I can say it at least works. Can't say if there is any fps hit on sever or clients.

Share this post


Link to post
Share on other sites

Arigato Defence Script (v1.4)

The main innovation: bots learn to use the stationary gun. In addition many small improvements.

The demo mission with a new version of the swing in the first post topic.

Tested compatibility with other versions of the script the game:

1. Net Arma 2: The script works, but first, you may receive (1 time per game) that requires version 1.60 game, and secondly, in Chernarus much smaller buildings with a prescribed position than Takistane.

2. Iron Front - Liberation 1944: the use of the script is meaningless, although it sort of works, but, first, position in the new buildings are not spelled out at all IF, the bots will not take positions in houses and secondly, the bots will not use the stationary gun.

The demo mission is to clean Arma 2 attached below. This version of the demo mission for the script 1.4. In the future, it will not be maintained when a new version of the script.

Demo mission 3: http://narod.ru/disk/56168031001.79036a95652ffe09ac24e7559470002b/DEFENCE_DEMO_3.utes.7z.html

Share this post


Link to post
Share on other sites

I Have ONE Question.

Is it Possible that you Can Implement the Scripts Ability to Spawn and Despawn this Select of how ever many units when the Player/Players are a Specific or Certain distance to and Fro the Location/City?

Eg: "if {player distance argt_city1 <= 800} then {xxxxxxxxScriptHerexxxxx}" and What not. You should get the Idea.

Thanks for the Script.

Good Stuff :D :yay:

Edited by ShinShin

Share this post


Link to post
Share on other sites
Do you have to put civilian group in a mission for the script to work? What if I don't want any civs in a mission?

For example:

[[argt_leader1, argt_leader2, argt_leader3, argt_leader4, argt_leader5, argt_leader6, argt_leader7], [], getmarkerpos "argt_shukurkalay", 150] call ARGT_DEFENCE_POSITION;

Is it Possible that you Can Implement the Scripts Ability to Spawn and Despawn this Select of how ever many units when the Player/Players are a Specific or Certain distance to and Fro the Location/City?

Yes, this can be realized.

Share this post


Link to post
Share on other sites

and How about getting Multiple Cities/Locations in there?

Say I have 3 Locations that I want to be In Consideration for Spawning/Placing these Select Units.

How would this be Possible?

Share this post


Link to post
Share on other sites
and How about getting Multiple Cities/Locations in there?

For example:

[
 [argt_leader1_1, argt_leader1_2, argt_leader1_3],
 [argt_civ1_1, argt_civ1_2],
 getmarkerpos "argt_city1", 150
] call ARGT_DEFENCE_POSITION;

[
 [argt_leader2_1, argt_leader2_2, argt_leader2_3, argt_leader2_4, argt_leader2_5],
 [argt_civ2_1, argt_civ2_2, argt_civ2_3],
 getmarkerpos "argt_city2", 300
] call ARGT_DEFENCE_POSITION;

[
 [argt_leader3_1, argt_leader3_2],
 [],
 getmarkerpos "argt_city3", 100
] call ARGT_DEFENCE_POSITION;

Share this post


Link to post
Share on other sites

Thanks for the script that give us more difficulties.

Edited by panda123

Share this post


Link to post
Share on other sites
For example:

[
 [argt_leader1_1, argt_leader1_2, argt_leader1_3],
 [argt_civ1_1, argt_civ1_2],
 getmarkerpos "argt_city1", 150
] call ARGT_DEFENCE_POSITION;

[
 [argt_leader2_1, argt_leader2_2, argt_leader2_3, argt_leader2_4, argt_leader2_5],
 [argt_civ2_1, argt_civ2_2, argt_civ2_3],
 getmarkerpos "argt_city2", 300
] call ARGT_DEFENCE_POSITION;

[
 [argt_leader3_1, argt_leader3_2],
 [],
 getmarkerpos "argt_city3", 100
] call ARGT_DEFENCE_POSITION;

Hey guys. I could use a quick piece od advice on setting up multiple locations with this script. I've been staring at it for 2hrs now and I'm not seeing what I'm doing wrong, especially in accordance with what the example above of having more than one location.

The first part of the script works fine. I literally just copied and pasted it from the Demo Mission #1 example.

{
 if ( side _x == east && _x != player && ! (_x in switchableunits) ) then {
   _x setvariable ["ARGT_ALLAH_AKBAR", 0, true];
   _x addeventhandler ["Fired", {
     private ["_unit"];
     _unit = _this select 0;
     if ( time > _unit getvariable "ARGT_ALLAH_AKBAR" && vehicle _unit == _unit ) then {
       _unit say [format ["allah%1", 1 + (floor random 12)], 10];
       _unit setvariable ["ARGT_ALLAH_AKBAR", time + 4 + random 8, true];
     };
   }];
 };
} foreach allunits;

call compile preprocessfilelinenumbers "script\defence.sqf";

[
 [argt_leader1, argt_leader2, argt_leader3, argt_leader4, argt_leader5, argt_leader6, argt_leader7],
 [argt_civ1, argt_civ2, argt_civ3, argt_civ4],
 getmarkerpos "argt_huzrutimam", 300
] call ARGT_DEFENCE_POSITION; 

OK, so far, so good. Everything works fine, however I add the 2nd location and all of the groups just stand there. Nothing happens whatsoever. The only difference other than the unit & marker

names are that instead of Takistani Militia that are used in the first location, these are regular Takistani Army. Other than that I'm not seeing why these guys aren't moving.

[
 [argt_leader11, argt_leader12, argt_leader13, argt_leader14, argt_leader15, argt_leader16, argt_leader17],
 [argt_civ11, argt_civ12, argt_civ13, argt_civ14],
 getmarkerpos "argt_refinery", 300
] call ARGT_DEFENCE_POSITION;

Is it because its RA troops as opposed to militia that are causing the problem and if so, do I need to go into the script and change anything? The following is just the entire script in its entirety and not broken up. Again, other than the names, the layout looks the same as the example above but the 2nd option doesn't work at all.

{
 if ( side _x == east && _x != player && ! (_x in switchableunits) ) then {
   _x setvariable ["ARGT_ALLAH_AKBAR", 0, true];
   _x addeventhandler ["Fired", {
     private ["_unit"];
     _unit = _this select 0;
     if ( time > _unit getvariable "ARGT_ALLAH_AKBAR" && vehicle _unit == _unit ) then {
       _unit say [format ["allah%1", 1 + (floor random 12)], 10];
       _unit setvariable ["ARGT_ALLAH_AKBAR", time + 4 + random 8, true];
     };
   }];
 };
} foreach allunits;

call compile preprocessfilelinenumbers "script\defence.sqf";

[
 [argt_leader1, argt_leader2, argt_leader3, argt_leader4, argt_leader5, argt_leader6, argt_leader7],
 [argt_civ1, argt_civ2, argt_civ3, argt_civ4],
 getmarkerpos "argt_huzrutimam", 300
] call ARGT_DEFENCE_POSITION;

[
 [argt_leader11, argt_leader12, argt_leader13, argt_leader14, argt_leader15, argt_leader16, argt_leader17],
 [argt_civ11, argt_civ12, argt_civ13, argt_civ14],
 getmarkerpos "argt_refinery", 300
] call ARGT_DEFENCE_POSITION;


exit 



Share this post


Link to post
Share on other sites

Attach the archive to the mission as a whole, please.

Share this post


Link to post
Share on other sites
Attach the archive to the mission as a whole, please.

I'm sorry, I don't follow you. What do you mean by archive?

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×