Jump to content
gutiarhero814

Random Target Script Issue

Recommended Posts

So I have created this script and have lanes of twelve targets down. I have the script to pop up 20 random targets but only will pop as many targets as I have laid down on the map.

 

Perhaps can look at this and give me some insight why.

 

Thanks

 

// Prepping the arrays to hold the sorted targets
TargetsLane1 = [];
TargetsLane2 = [];
TargetsLane3 = [];
TargetsLane4 = [];
TargetsLane5 = [];
TargetsLane6 = [];



// This function checks all the targets and sorts them based on catagories and stores them in arrays.
{
	_x addEventHandler ["Hit", {_this call third_Func_Target_Hit}];
	_x animate ['terc', 1];

	_Ln1 = [lane1trigger,getPosAtl _x] call BIS_fnc_inTrigger;
	_Ln2 = [lane2trigger,getPosAtl _x] call BIS_fnc_inTrigger;
	_Ln3 = [lane3trigger,getPosAtl _x] call BIS_fnc_inTrigger;
	_Ln4 = [lane4trigger,getPosAtl _x] call BIS_fnc_inTrigger;
	_Ln5 = [lane5trigger,getPosAtl _x] call BIS_fnc_inTrigger;
	_Ln6 = [lane6trigger,getPosAtl _x] call BIS_fnc_inTrigger;




	if (_Ln1) then {TargetsLane1 set [count TargetsLane1, _x];_x addEventHandler ["Hit", {_this spawn third_Func_No_Pop;}];};
	if (_Ln2) then {TargetsLane2 set [count TargetsLane2, _x];_x addEventHandler ["Hit", {_this spawn third_Func_No_Pop;}];};
	if (_Ln3) then {TargetsLane3 set [count TargetsLane3, _x];_x addEventHandler ["Hit", {_this spawn third_Func_No_Pop;}];};
	if (_Ln4) then {TargetsLane4 set [count TargetsLane4, _x];_x addEventHandler ["Hit", {_this spawn third_Func_No_Pop;}];};
	if (_Ln5) then {TargetsLane5 set [count TargetsLane5, _x];_x addEventHandler ["Hit", {_this spawn third_Func_No_Pop;}];};
	if (_Ln6) then {TargetsLane6 set [count TargetsLane6, _x];_x addEventHandler ["Hit", {_this spawn third_Func_No_Pop;}];};



} forEach _targetList;




// Unknow distance functions

thirdUnkDistMasterArray = [TargetsLane1,TargetsLane2,TargetsLane3,TargetsLane4,TargetsLane5,TargetsLane6];

Third_Func_PronSup = {

	// 20 targets but must start with 0.
	// this will keep track of whats been poped.
	_ProneSupMasterCount = [0,1,2,3,4,5,6,7,8,9,10,12,13];

	_meu_Func_get_rand_targets = {

		//Pick 1 random targets
		_target1 = _ProneSupMasterCount call BIS_fnc_selectRandom;

		//remove them so we dont select them again
		//_uknTargetMasterCount = _uknTargetMasterCount - [_target1];

		_list = [_target1];
		_list
	};

// First Target
hint "Target 1!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Second Target
hint "Target 2!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Third Target
hint "Target 3!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Fourth Target
hint "Target 4!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Fifth Target
hint "Target 5!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Sixth Target
hint "Target 6!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Seventh Target
hint "Target 7!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Eigth Target
hint "Target 8!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Ninth Target
hint "Target 9!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Tenth Target
hint "Target 10!";
	_targetsList = [] call _third_Func_get_rand_targets;
	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 0];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;

	sleep 6;

	{
		_laneNum = _x;

		{
			(_laneNum select _x) animate ['terc', 1];
		} forEach _targetsList;


	} forEach thirdUnkDistMasterArray;
// Tenth Target

_showNote =[["ThirdKneelingProne",[]],"BIS_fnc_showNotification",true,false] spawn BIS_fnc_MP;
};

I've only included 10 targets in the script but if I have 20 or 15 or any more than a number of targets in the triggers (which is 12) it will only pop up that amount. Any help on this would be helpful.

 

Thanks

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

×