Forum Jump :

Author Message

Posts: 1

Level: Member

Country: au
In-game name:

#1 Posted at 2015-01-15 23:00        
Me and my friend are trying to make a Quarry script that assigns a player a target, and when that target is killed, it changes to a different target. This is as far as we've gotten:

_randomtarget = playableUnits; //Multiplayer variant of the script.
_randomtarget = ["q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8"]; //Singleplayer variant of the script.
_target = _randomtarget select (floor (random (count _randomtarget)));
if (side player == civilian) then {hint format["Your target is %1",_target];};
if (_randomtarget !alive) then {hint format["Your target is %1",_target];}; //This bit doesn't work, it's supposed to assign a new target to the player when his/her current target is killed but it doesn't.

Can anyone help?

If you can, thank you :)

Author Message

Posts: 1189

Level: Member

Country: tr
Occupation: Computer Science student
Age: 23
In-game name: Wak

#2 Posted at 2015-01-15 23:27        
Sorry for the giant columns of notes, hope you can understand from those :). If not you can just ask too, that'll probably work better. Also what is the civilian check for? Really wondered that. Thought of removing it at a point.

_targetList = []; //Define _targetList
if (isMultiplayer) then { //check for multi/single player, create _targetList based on that.
	{_targetList pushBack _x} forEach playableUnits;
} else {
	_targetList = ["q1", "q2", "q3", "q4", "q5", "q6", "q7", "q8"];
for "_a" from 1 to (count _targetList) do { //Loopty-loop
	//This is a for loop since we're dealing with arrays, it's usually more efficent. Also the loop will end as soon as the list is empty, a while loop wouldn't (Well it would but we'd need to put a check)
	_i = floor random count _targetList; //Pick a element from our array of units
	_trgt = _targetList deleteAt _i; //Delete that random element while the deleteAt command returns the element that it deleted
	if (side player == civilian) then {hint format["Your target is %1",_trgt]}; //Our target is out of the list, and is assigned as the target 
	waitUntil {!alive _trgt}; //Your if check wasn't working because it checked and went away the first frame the target was assigned, we need something that can wait
	//We waited until the target died and the loop starts over, assigning another target. Since the last one is out of the list, it's never the same target again and it's fully random!
//Also note not to use the "_target" variable. It's a reserved private variable and might cause issues. Read more here:

This post was edited by 654wak654 (2015-01-16 00:04, ago)

Sometimes I like to think as I started the whole "earplugs" thing.

W0lle: The only advice I can give you is: Do not try to understand BI. You will not succeed and it only makes your brain go boom. I would even go so far and say that not even they understand their own actions :-D.

#define getDamage getDammage