Jump to content
Sign in to follow this  
Dielos

AI stop while on way to waypoint

Recommended Posts

Hi, I've searched through the forums and haven't found an answer.

The AI is supposed to check a location's side and if not from it's own side go and take it. The following script gives them a waypoint to that location and monitors if locations side changes. There are 6 groups per side all running this script. It works well for most groups, but some do several locations and then just stop.

<table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">

_unit = _this select 0

_unittype = _this select 1

_testing = _this select 2

_unitside = side _unit

_group = group _unit

#start

~2

;[_unit] exec "testloop.sqs"

?{alive _x} count units _group <= 0:goto "alldead"

_group addWaypoint [getpos _unit, 50]

goto "setwpp"

;=============MAIN LOOP START============

#mainloop

~2

;_testtext = text _nearloc

;?(_testing == 1):hint format["%1",_testtext]

?{alive _x} count units _group <= 0:goto "alldead"

?(getPos leader _group in _nearloc):goto "inposition"

?(side _altloc != _unitside)&&(leader _group distance locationposition _altloc <= leader _group distance locationposition _nearloc):goto "setwpp"

goto "mainloop"

;==============MAIN LOOP END=============

#setwpp

~1

?{alive _x} count units _group <= 0:goto "alldead"

_locarray = nearestLocations [getPos leader _group, ["NameLocal"], 5000]

~1

_loccount = count _locarray

~1

_i=0

~1

#locfind

~0.1

?(_i >= (_loccount -1)):goto "setwpp"

_locside = side (_locarray select _i)

?(_locside == _unitside):_i=_i+1;goto "locfind"

_nearloc = (_locarray select _i)

[_group, 0] setWPPos getpos _unit

[_group, 1] setWPPos locationposition _nearloc

[_group, 1] setWaypointType "SAD"

[_group, 1] setWaypointBehaviour "AWARE"

_group setCurrentWaypoint [_group, 1]

_testtext = name _nearloc

?(_testing == 1):hint format["%1",_locarray]

goto "mainloop"

#inposition

~15

?{alive _x} count units _group <= 0:goto "alldead"

?(side _nearloc == _unitside):goto "checkgroups"

?(side _nearloc == resistance):goto "inconflict"

goto "inposition"

#inconflict

~15

?{alive _x} count units _group <= 0:goto "alldead"

[_group, 1] setWPPos [((locationposition _nearloc) select 0) + ((random 100) - (random 100)), ((locationposition _nearloc) select 1) + ((random 100) - (random 100))]

?(side _nearloc == _unitside):goto "checkgroups"

goto "inposition"

#checkgroups

~10

?(side _nearloc == _unitside):_altloc = _nearloc;goto "setwpp"

?(side _nearloc == resistance):goto "inconflict"

goto "checkgroups"

#alldead

[_unitside,_unittype] exec "spawnai.sqs"

exit

If I get into the group as non leader I can see the waypoint in the map normally and they move towards that direction, but then the waypoint changes at a certain time into a cross and the group just stops. It's a urban environment (Sakakah Al Jawf (Open Beta)).

Can it be because they get lost between all the buildings? Sometimes they even stop in building free areas! If it's because they get lost, is there anyway to solve this?

Thanks!

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  

×