Jump to content
Sign in to follow this  
Fisunaama

Check health of all group members

Recommended Posts

Hey,

 

I'm making a scenario where if a member of a group's health drops below 50 the unit will unassign itself from the group and independently retreat. How would I script this sort of a .sqf?

 

- Fisunaama

Share this post


Link to post
Share on other sites

To check if at least one member is injured above 50%:

_groupHasInjured = {damage _x >= 0.5} count units group player >= 1;//returns true if at least one soldier is hurt above 50%

Cheers

  • Like 1

Share this post


Link to post
Share on other sites

this should make it so if one of the units health is below 50, he is removed from the group and runs towards a waypoint called retreatMarker

{
	if (_x getDammage < 0.5) then
	{
		_x joinSilent grpNull;
		_wp = (group _x) addWaypoint [getMarkerPos "retreatMarker", 0];
		_wp setWaypointType "MOVE";
	};
} forEach (group player);

 

  • Like 1

Share this post


Link to post
Share on other sites

Thank you,

 

Much appreciated! I fixed some lines and put it in the init.sqf to run.

 

_groupHasInjured = {damage _x >= 0.5} count units group player >= 1;

{
	if ((damage _x == 0.5) && (_grouphasinjured)) then
	{
		[_x] joinSilent grpNull;
		_wp = (group _x) addWaypoint [getMarkerPos "retreatMarker", 0];
		_wp setWaypointType "MOVE";
	};
} forEach units group player;

sleep 0.1;

 

- Fisunaama

  • 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
Sign in to follow this  

×