Jump to content
izen

Is there a relative command for a groups leader instead of its name?

Recommended Posts

So I want to make AI groups with Probability of presence.

I currently set a probability for the leader, and for the group members a condition (Alive leadername);

 

This works perfect, but on copypaste I need to adjust all the values for the leaders name.

 

It would seem to me that there must be a relative variable for this to call up a units leader so the condition (Alive ThisUnitsLeader); always works?

 

 

Share this post


Link to post
Share on other sites

Sorry, I don't know any syntax :(

 

I tried everything but how to use the leader command in this example?

Share this post


Link to post
Share on other sites

grp_leader = leader (group this); alive grp_leader

or

 

null = this spawn {

    params ["_thisUnit", "_grp_leader"];
    _grp_leader = leader (group _grp_leader);
    _thisUnit setVariable ["myLeader", _grp_leader,false];

};

alive (this getVariable "myLeader")

Share this post


Link to post
Share on other sites

Place the leader on the map and set his probability to 100%.

Place 6 subordinates on map and group them to the leader.

Set the probability of each of the 6 to 50%.

Now when the mission starts, the number of enemy on the map will be any number from 1 - 7. You will never know how many enemy are on the map.

Now copy and paste the group to around the map.

Share this post


Link to post
Share on other sites

@joe:

Thanks, but that doesn't solve my problem. I either want the entire group to spawn, or nobody.

 

@david:

 

 

grp_leader = leader (group this);
alive grp_leader

 

I tried this out in a ton of variation, as it would exactly solve my problem, but it either doesn't work or the code isn't accepted.

 

Something still isn't right...There must be a way to solve this.

 

I know I could manually change variable names but I WANT it to work on its own, just because I want perfection in the code.

Share this post


Link to post
Share on other sites

That doesn't work because there's always a group leader, even a single unit is its own group leader.

Share this post


Link to post
Share on other sites

That wont work because its setting and then resetting the variable over and over again for each leader.And as profTounesol said it also wont work because a group always has a leader, regardless if the one you set is alive or not. If he doesnt exist, number 2 becomes the leader.

Unfortunately, you need a specific global name for each leader as far as I can think without some pretty heavy scripting because you cant look for a group leader, you need to look for a specific unit. I would completely avoid using the unit and set a random chance of the group being deleted in code,

randomgroups.sqf

{

   //Select probability of existing
   _probability = random 99;

   //Define group
   _selectedGroup = _x;

   //Check side and whether it should exists, then delete if needed
   if ( (side _selectedGroup == "EAST") && (_probability > 50) ) then { {deletevehicle _x} foreach units _selectedGroup};

} foreach allgroups;

Not tested.

 

  • Like 1

Share this post


Link to post
Share on other sites

MKD3, thanks for your answer - very good explanation!

Share this post


Link to post
Share on other sites

Set the probability of the leader back to 100%, then put this in the init field of any unit (Preferably the leader to make it easier to find again).

0.5 call { _group = group this; if (_this <= random 1) then { { deleteVehicle _x; } forEach units _group; }; };
Change the 0.5 to the probability you want (0.0 through 1.0).
  • Like 1

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

×