while {alive _unit && (_unit distance _target > 10)} do {
_unit doMove getPos _target;
sleep 3;
};
//generate waypoints
for [{ x=1 },{ x < _wpnum },{ x = x + 1; }] do {
_wppos = [_xpos+(x*20),_ypos+(x*20),_wpradius];
_wp = _aiGroup addWaypoint [_wppos, _wpradius];
_wp setWaypointType "MOVE";
};
_wp = _aiGroup addWaypoint [[_xpos,_ypos,0], _wpradius];
_wp setWaypointType "CYCLE";
Now this obviously is not the whole script, it is just the parts that are important. I changed the name of the entity that he seeks for testing purposes, if I wear that skin he will then come after me.
Now here is the problem I am having, If I am in line of sight and within the parameters of _wpradius when the server restarts, then as soon as he spawns he will come right at me, however if I let him spawn and I'm outside of the _wpradius he will just proceed to the waypoints and that's it. If I get near him he will not come after me. Now I know this is happening because the script is only designed to run once, so basically he spawns, runs the code once, finds nothing and goes about his business and for the LIFE of me I cannot get a loop script to work.
So does anyone have a an old script laying around that makes AI search for a target and makes the AI run right up to the target once it is found?
I want this guy to be running to his way point, discover a target along the way, run up to the target, do his thing, and then proceed back on course to his way point while still actively checking for valid targets. Now keep in mind that when he does his thing, the target (which is the player) will have been moved outside of the parameters of _wpradius, so he could simply sleep 1; clear the target array, and then loop the script.
Anyone out there have anything like that or something close to that? Thanks!
Question
Nemaconz
So I have a script that works, just not the way I want it to. Here it is, it will probably look familiar to some people have been around a while.
_theHunt = (position _aiunit) nearEntities ["Bandit2_DZ", _wpradius];
_target = _theHunt call BIS_fnc_selectRandom;
while {alive _unit && (_unit distance _target > 10)} do {
_unit doMove getPos _target;
sleep 3;
};
//generate waypoints
for [{ x=1 },{ x < _wpnum },{ x = x + 1; }] do {
_wppos = [_xpos+(x*20),_ypos+(x*20),_wpradius];
_wp = _aiGroup addWaypoint [_wppos, _wpradius];
_wp setWaypointType "MOVE";
};
_wp = _aiGroup addWaypoint [[_xpos,_ypos,0], _wpradius];
_wp setWaypointType "CYCLE";
Now this obviously is not the whole script, it is just the parts that are important. I changed the name of the entity that he seeks for testing purposes, if I wear that skin he will then come after me.
Now here is the problem I am having, If I am in line of sight and within the parameters of _wpradius when the server restarts, then as soon as he spawns he will come right at me, however if I let him spawn and I'm outside of the _wpradius he will just proceed to the waypoints and that's it. If I get near him he will not come after me. Now I know this is happening because the script is only designed to run once, so basically he spawns, runs the code once, finds nothing and goes about his business and for the LIFE of me I cannot get a loop script to work.
So does anyone have a an old script laying around that makes AI search for a target and makes the AI run right up to the target once it is found?
I want this guy to be running to his way point, discover a target along the way, run up to the target, do his thing, and then proceed back on course to his way point while still actively checking for valid targets. Now keep in mind that when he does his thing, the target (which is the player) will have been moved outside of the parameters of _wpradius, so he could simply sleep 1; clear the target array, and then loop the script.
Anyone out there have anything like that or something close to that? Thanks!
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now