Jump to content
Sign in to follow this  
abdecken

Cover script (simple error?)

Recommended Posts

My script is supposed to make the AI go prone for a random ammount of time, stand breifely and repeat. I think the random command has a problem becuase it dosnt seem to work (although the AI changes seunitpos):

if (!isServer) exitWith {};
_unit = _this select 0; 
sleep (random 20);
//This is a while loop which will run until _unit dies 
while {alive _unit} do {        
			_unit setunitpos "DOWN";
			sleep 35 + (random 120);
			_unit setunitpos "UP";
			sleep 5 + (random 10);
}; 

script is called with this in unit ini line:

MyProcedureHandler = [this] execVM "cover.sqf";

Edited by abdecken

Share this post


Link to post
Share on other sites

I am not sure if I need the !isServer logic but I dont think it could cause a problem.

Although the outcome of random will be different on client computers the _unit is local to the server and will not be affected.

Share this post


Link to post
Share on other sites

Try writing your sleep commands like

sleep (5 + (random 10));

This will ensure the value component is evaluated fully first before applying that value to the sleep command. At the moment arma is evaluating sleep 5 before evaluating the random component.

You can confirm this by placing the below in the player init field.

SR1 = [] spawn
{

while {true} do
{
	hintsilent format ["%1",time];
	sleep (5 + (random 10));
};


};

Then try it with

SR1 = [] spawn
{

while {true} do
{
	hintsilent format ["%1",time];
	sleep 5 + (random 10);
};


};

Share this post


Link to post
Share on other sites

Unfortunately you're unlikely to have much success with manually getting the AI to go prone/stand-up on request since their FSMs will cause them to change position independently.

Share this post


Link to post
Share on other sites

thankyou blakeace for solving this and explaining. much appriciated!

sbsmac, yes the FSMs will take priority but if setunitpos commands are given reguarly it shouldnt make much difference.

I understand setunitposweak will not work in multi player and so i cant use it. I could make some if setunitpos="down" then setunitpos "up" logic but I dont think its really needed.

Share this post


Link to post
Share on other sites
sbsmac, yes the FSMs will take priority but if setunitpos commands are given reguarly it shouldnt make much difference.

A while back I tried using the same technique as you to create civilians who didn't lie down at the first sounds of gunfire. Unfortunately the results were very poor since animations were not interruptable they spent all their time lying down then getting up again. Maybe you'll have better luck but I ended up having to remove the units fsms to get the effect I wanted.

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  

×