EDIT: See my second thread.. Maybe an admin can delete this thread as I don't think its of any help to anyone!
Does anyone know why this script would be adding 2 units to my map, when I'm only putting 1 in the number of units field. Even when I do this manually, putting the number into the createunit line , i still get 2 units spawning in the same spot :(
//Original Credits: Created by axeman Edited by TheSzerdi
//Edited for his custom missions by Hayward
private ["_chooseSkin","_aiunit","_xpos","_ypos","_unitpos","_aiGroup","_wppos","_wpradius","_wpnum","_levelnum","_numunits","_rndLOut","_ailoadout","_wp","_aispawnpos","_aiwep1","_aiammo1","_aiwep2","_aiammo2","_buildpos"];
_aiunit = objNull;
_aiGroup = createGroup resistance;
_aispawnpos =_this select 0;
_wpradius = _this select 1;
_wpnum = _this select 2;
_numunits = _this select 3;
_levelnum = _this select 4;
_buildpos = _this select 5;
_xpos = _aispawnpos select 0;
_ypos = _aispawnpos select 1;
MYSKIN_fnc_selectRandom = {_this select (floor random (count _this)) };
// diag_log format ["AIUNIT: Spawn initiated: Centre:%1 | Radius in m:%2 | Waypoint number:%3 | WeaponLevel:%4",_aispawnpos,_wpradius,_wpnum,_levelnum];
for [{ x=1 },{ x < _numunits+1 },{ x = x + 1; }] do
{
_unitpos = [_xpos+x,_ypos+x,0];
_chooseSkin = ["BanditW2_DZ","GUE_Soldier_MG_DZ","GUE_Soldier_Sniper_DZ","Ins_Soldier_GL_DZ","GUE_Soldier_CO_DZ","BanditW1_DZ"] call MYSKIN_fnc_selectRandom;
if (_levelnum==0) then // in_sityes troops
{
if ((x == 1) || (x == 3) || (x == 5)) then //troop soldiers
{
_chooseSkin createUnit [_unitpos, _aiGroup, "_aiunit=this;",1,"PRIVATE"];
_rndLOut=floor(random 4);
_ailoadout=
switch (_rndLOut) do
{
case 0: {["M1014","8Rnd_B_Beneli_74Slug","revolver_EP1","6Rnd_45ACP"]};
case 1: {["M1014","8Rnd_B_Beneli_Pellets","revolver_EP1","6Rnd_45ACP"]};
case 2: {["Remington870_lamp","8Rnd_B_Beneli_74Slug","Colt1911","7Rnd_45ACP_1911"]};
case 3: {["Remington870_lamp","8Rnd_B_Beneli_Pellets","Colt1911","7Rnd_45ACP_1911"]};
};
};
if ((x == 2) || (x == 4) || (x >= 6)) then //troops snipers
{
_chooseSkin createUnit [_unitpos, _aiGroup, "_aiunit=this;",1,"PRIVATE"];
_rndLOut=floor(random 3);
_ailoadout=
switch (_rndLOut) do
{
case 0: {["LeeEnfield","10x_303","Makarov","8Rnd_9x18_Makarov"]};
case 1: {["Huntingrifle","5x_22_LR_17_HMR","Makarov","8Rnd_9x18_Makarov"]};
case 2: {["M14_EP1","20Rnd_762x51_DMR","Makarov","8Rnd_9x18_Makarov"]};
};
};
};
diag_log format ["AIUNIT: Creating BAF_Soldier_L_DDPM by %1 at %2. Result:%3 | Loadout:%4 / Num:%5",player,_unitpos,_aiunit,_ailoadout,_rndLOut];
_aiunit enableAI "TARGET";
_aiunit enableAI "AUTOTARGET";
_aiunit enableAI "MOVE";
_aiunit enableAI "ANIM";
_aiunit enableAI "FSM";
_aiunit allowDammage true;
_aiunit addEventHandler ['killed',{_this execVM "missions\bodyclean.sqf"}]; //Body disappear time
_aiunit setCombatMode "RED";
_aiunit setBehaviour "AWARE";
//clear default weapons / ammo
removeAllWeapons _aiunit;
//add random selection
_aiwep1 = _ailoadout select 0;
_aiammo1 = _ailoadout select 1;
_aiwep2 = _ailoadout select 2;
_aiammo2 = _ailoadout select 3;
_aiunit addweapon _aiwep1;
_aiunit addMagazine _aiammo1;
_aiunit addMagazine _aiammo1;
_aiunit addMagazine _aiammo1;
_aiunit addweapon _aiwep2;
_aiunit addMagazine _aiammo2;
_aiunit addMagazine _aiammo2;
_aiunit removeWeapon "ItemRadio";
// Set Skill
_aiunit setSkill ["aimingAccuracy",0.15];
_aiunit setSkill ["aimingShake",0.16];
_aiunit setSkill ["aimingSpeed",0.15];
_aiunit setSkill ["endurance",0.10];
_aiunit setSkill ["spotDistance",0.10];
_aiunit setSkill ["spotTime",0.10];
_aiunit setSkill ["courage",0.80];
_aiunit setSkill ["reloadSpeed",0.18];
_aiunit setSkill ["commanding",0.15];
_aiunit setSkill ["general",0.65];
sleep 0.5;
// _aiunit setPos ((nearestBuilding _aiunit) buildingPos 1);
};
Question
MatthewK
EDIT: See my second thread.. Maybe an admin can delete this thread as I don't think its of any help to anyone!
Does anyone know why this script would be adding 2 units to my map, when I'm only putting 1 in the number of units field. Even when I do this manually, putting the number into the createunit line , i still get 2 units spawning in the same spot :(
Link to comment
Share on other sites
15 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now