Jump to content
Sign in to follow this  
TobiasRp

Random selection of units

Recommended Posts

Do you know how to please someone randomly choose one soldier from the group (grp1)?

Note: The selection not to be a vehicle.

Thank you in advance.

Share this post


Link to post
Share on other sites
_randomSoldier = objNull;
_units = units grp1;
while {isNull _randomSoldier || (vehicle _randomSoldier) != _randomSoldier} do
{
   _randomSoldier = _units call BIS_fnc_selectRandom;
};

Share this post


Link to post
Share on other sites

She would please the script to add the condition that the player has not been selected (if a group member) but the other unit?

Share this post


Link to post
Share on other sites

Uhhhh, hmmm, sorry but I really have problems understanding your question right know :D

Share this post


Link to post
Share on other sites

That sounds like it's been translated from German (Konnen Sie etc, which may have appeared as Konnen sie and sie = she in English).

I think what Tobias is saying is "Can you add the condition to the script where it checks if the player has not been selected, instead a different unit has, as long as that other unit is in the same group?" <-- Something to do with trigger conditions I believe - maybe on how to get that to fire when a condition is true?

All this is just my best workings out, no hate please :P

Share this post


Link to post
Share on other sites

Sorry for the bad translation...

Yes, I need to modify this script to _randomSoldier not a player, but always AI.

It is possible that the condition (I do not know where to add it in the script):

if (isPlayer _randomSoldier) Then ...

Edited by TobiasRp

Share this post


Link to post
Share on other sites

Ok Tobias, I think I understand you now.

You can always reverse a condition by inserting an exclamation mark (!) into the condition like so:

[color=#3E3E3E]if (!isPlayer _randomSoldier) then {} else {};[/color]

Your code inbetween then {} is what will execute if _randomSoldier is not a player. Your code inbetween else {} is what will execute if _randomSoldier *IS* a player. else {} isn't required, though.

Where you want to put it in the script depends on what you want to happen if the player isn't _randomsoldier.

Share this post


Link to post
Share on other sites

Is this correct?

Thanks.

_randomSoldier = objNull;

_units = units grp1;

while {isNull _randomSoldier || (vehicle _randomSoldier) != _randomSoldier} do

{

while {(isPlayer _randomSoldier)} do {

_randomSoldier = _units call BIS_fnc_selectRandom;

};

_randomSoldier say "USMove_01"

};

Edited by TobiasRp

Share this post


Link to post
Share on other sites

_randomSoldier = objNull;
_units = units grp1;
while {isNull _randomSoldier || (vehicle _randomSoldier) != _randomSoldier || isPlayer _randomSoldier} do
{
   _randomSoldier = _units call BIS_fnc_selectRandom;
};  

Be advised that using this script will most likely create an infinite loop if you have no AI soldiers in your group.

Make sure to have at least one AI in your group which isn't in a vehicle before executing this script.

Share this post


Link to post
Share on other sites

Perhaps resolved:

_randomSoldier = objNull;

_units = units grp1;

_alivecount = ({alive _x} count units grp1);

while {isNull _randomSoldier || (_alivecount > 1) || (vehicle _randomSoldier) != _randomSoldier || isPlayer _randomSoldier} do

{

_randomSoldier = _units call BIS_fnc_selectRandom;

};

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  

×