Jump to content
Sign in to follow this  
creartan

LOOP check health/damage script

Recommended Posts

i want to make a LOOP for health check script triggered by EH hit

have two choice, but actually they both dont work, :p hehe

can someone help me please..

wich one better and the right way to do it?

First choise of loop

for [{_i=0}, {_i<30}, {_i=_i+1}] do
{
if ((damage _this < 0.9)) than 
{
	_this setdamage 0;
	_this SetUnitPos "up";	
	_this switchMove "";  
	_this enableAI "ANIM"; 
	_this setCaptive false;
	_this allowDamage true;
	if((damage _this < 0.9)) exitWith{};
};
};

Second Choice of loop

scopename "healthcheck";
while ((damage _this >= 0.9)) do 
{
if ((damage _this < 0.9)) than 
	{
	_this setdamage 0;
	_this SetUnitPos "up";
	_this SetUnitPos "";	
	_this switchMove "";  
	_this enableAI "ANIM"; 
	_this setCaptive false;
	_this allowDamage true;
	if((damage _this < 0.9)) exitWith{};
	};
if ((damage _this >= 0.9)) then 
	{
	breakto "healthcheck";
	};
};

Share this post


Link to post
Share on other sites

Why use a loop after an event handler? Just do the "Hit" EH or "HandleDamage" EH and have it check the damage level of the player, if it's below 0.9 then do all the stuff you have here, I don't see the need for a loop?

And it could be especially heavy on the server/client because everytime they are hit it starts another loop.

Edited by JShock

Share this post


Link to post
Share on other sites

because at the other side ive already make a hit trigger wounded script, now i want to do the healed event, so the unit will switch back to normal anim,

i did use aishealed.. to trigger the switchback but it seem the EH ais healed is not working,

or maybe can u show me the right way to use aishealed? or maybe handleheal eh?

Share this post


Link to post
Share on other sites

Either loop is fine to use when the task requires a loop. Disregarding code, what exactly are you trying to achieve in the game? Lay it out for us. So far it reads like this:

- Unit gets hit

- EH Fires

- Initiate a for loop for 30 iterations (??)

- Check the unit's health each iteration

- If the damage value is smaller than 0.9 then set units damage to 0

- Check the units damage even though we already know it's 0 and exit the loop (??)

Edited by Iceman77

Share this post


Link to post
Share on other sites

i dont really know how to use loop,:p

but i want to achieve, if unit damage 0.9 it will check the unit health for 30sec, but if in the moment before reaching 30sec unit damage become less< than 0.9 it will set unit back to default anim and stop the loop

i did use the handleheal eh but it seems never fire..

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  

×