Jump to content
Sign in to follow this  
redarmy

AI hunt player lag moments

Recommended Posts

Hi all,

so i have a script:

while {{alive _x} count units theGroup > 0} do {

{

_x doMove getPosATL player;

} forEach units theGroup;

if ((leader theGroup) distance player < 100) then {

theGroup setBehaviour "STEALTH";

theGroup setCombatMode "RED";

theGroup setSpeedMode "LIMITED";

} else {

theGroup setBehaviour "AWARE";

theGroup setCombatMode "GREEN";

theGroup setSpeedMode "FULL";

};

sleep 30;

};

placed into init.sqf that forces "thegroup" to hunt player,checking players position every 30seconds.

The issue im having is that each time it checks players position,the game will lag for a few seconds.Its a dead give away that im being tracked down,and contridicts the point of the script.

If i put this code into trigger(without sleep)it wont lag,but it will not get player position after so many seconds obviously.So i cant use trigger as i the player will be on the move throughout the scenario.

Is there a way to make the "sleep" not lag and give away the suprise butt sex?

Cheers

Share this post


Link to post
Share on other sites

I don't think the sleep is the issue as that just makes the script wait which should increase performance as less script is running.

Try disabling each part of the script to see if you can track down the issue.

add the /* */ to disable / enable a section

/*

{

_x doMove getPosATL player;

} forEach units theGroup;

*/

and if that still lags try

/*

if ((leader theGroup) distance player < 100) then {

theGroup setBehaviour "STEALTH";

theGroup setCombatMode "RED";

theGroup setSpeedMode "LIMITED";

} else {

theGroup setBehaviour "AWARE";

theGroup setCombatMode "GREEN";

theGroup setSpeedMode "FULL";

};

*/

Where is the script being launched, make sure it's only being run once.

Share this post


Link to post
Share on other sites

You can try the following :

while {{alive _x} count units theGroup > 0} do {

(leader theGroup) doMove getPosASL player;

if ((leader theGroup) distance player < 100) then {
	theGroup setBehaviour "STEALTH";
	theGroup setCombatMode "RED";
	theGroup setSpeedMode "LIMITED";
} else {
	theGroup setBehaviour "AWARE";
	theGroup setCombatMode "GREEN";
	theGroup setSpeedMode "FULL";
};

sleep 30;
};

You don't need to get the player's position for all the group : just get the leader to hunt the player and his group will follow.

Also, getPosASL is the fastest way to obtain a position.

Share this post


Link to post
Share on other sites

Thanks for responses.

@pepe the code you gave me causes only the group leader to hunt player.But i just thought about something,i named the group leader the group.Maybe if i make callsign for the group it will work.

@F2K sel,i am taking a look at disabling parts now to find the issue if there is one.

---------- Post added at 13:44 ---------- Previous post was at 12:59 ----------

Simplifying it down to this worked:

while { {alive _x} count (units thegroup) >= 1 } do {

thegroup move (position player);

sleep 30;

};

Only problem is the group see to take a very long time to get to the player....1km on foot took them nearly ten minutes real time.

---------- Post added at 14:02 ---------- Previous post was at 13:44 ----------

so it turns out that it was the 0 that caused issue.Changing to 1 its ok now

while {{alive _x} count units theGroup > 1} do {

{

_x doMove getPosATL player;

} forEach units theGroup;

if ((leader theGroup) distance player < 100) then {

theGroup setBehaviour "STEALTH";

theGroup setCombatMode "RED";

theGroup setSpeedMode "LIMITED";

} else {

theGroup setBehaviour "AWARE";

theGroup setCombatMode "GREEN";

theGroup setSpeedMode "FULL";

};

sleep 30;

};

EXCEPT,the group hunting player seems to ignore the FULL speed order.Possibly fatigued?His weapons are also high,which dosent help.either way,better than nothing il try find command to disable fatigue for them.

Thanks for help

Share this post


Link to post
Share on other sites

Thanks, I was looking for something like this, to simulate a car chase in a mission I'm in the planning phase of making. I'm assuming it'd have the same ultimate effect? I'm just wondering how intense the chase would be though - every 30 seconds, wouldn't the AI stop their car, to get the new position? Not really sure how that'd work when pertaining to a vehicle chase. It's a SP mission. Preferably would like to have the cops chasing you, pretty close to you all the time to simulate a proper chase.

Preferably also at top speed. I have the right music for the chase, at least! (Black Betty by Ram Jam)

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  

×