-
Notifications
You must be signed in to change notification settings - Fork 148
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Update AI functions #333
Update AI functions #333
Conversation
Unfortunately clearing all waypoints from AI is not as simple as deleting them all with `deleteWaypoint`. You have to kill their pre-planned movement (based on old waypoints) by having them complete at least one waypoint. One solution is to move all of their old waypoints to their position before deleting them, however if waypoint statements are being used this could have adverse effects. So this function creates a fresh waypoint for the purpose of killing their movement. It is also self-deleting (through its completion statement) to avoid any possible issues with timing.
- Retain open building positions to make groups defending overlapping areas respect one another. - Use new A3 scripting commands to optimise and enhance the function. - Makes the function a lot more readable with comments and more spacing. - Capitalize commands and function names appropriately. - Any existing waypoints are cleared before defending begins.
- The `cycle` waypoint is placed back at the start of the loop instead of randomly within the radius. - Any existing waypoints are cleared before the patrol loop is created. - `_this` is now correctly private.
- Any existing waypoints are now cleared before the searching begins. - The recursive argument check is now more explicit.
- Now callable (by including the spawn within the function). - Accounts for units being killed while searching and dispatches all available units to search simultaneously. - Doesn't permanently change behaviour of the group if the function aborts due to building distance. - Optimized with new A3 commands and made more readable with comments and spacing.
waituntil {not (unitready (_this select 0))}; | ||
(_this select 0) enableai "move"; | ||
waituntil {unitReady _unit}; | ||
_unit disableAI "move"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a note that this function should definitely be updated to use the new feature added in today's dev branch changelog:
Ability to enableAI / disableAI "PATH", which stops the AI’s movement but not the target alignment
However I have no idea if the dev branch stuff will appear in the next verison of arma, or the one after
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Probably something for a future PR when we do know in which version it will be available?
I hadn't realize CBA is now supporting two versions of arma, well that sucks 😆 Will amend all of the above! |
Commented out the part that isn't easily regex replaced so that it can be uncommented in future.
In actuality this is something of a compromise. Having the leader enter the building was not an intentional change I made. However it makes sense to do things that way when the group is small and so for any group with 2 or less units (includes the leader) the leader will now search the building too.
Accounts for cases where the leader enters the building.
- The group leader (and any spare units) will now wait at his current position for the search to be complete before moving on. - Waiting between orders instead of between rounds of orders should prevent congestion and decrease time gaps in the search. - Embedding the post-search code into the waypoint condition and completion removes the need to `waitUntil` while also providing built in group unit list `thisList`.
If a waypoint was created at index 0 before the group complete the waypoint used to reset their path, then the wrong waypoint would be deleted upon its completion.
In creating some zeus AI modules for ACE I noticed that the CBA AI functions didn't behave exactly as expected and made this PR to change that.
The changes can be found in the commit descriptions, but to summarise:
fnc_clearWaypoints
was introduced to correctly clear all existing waypoints without issue).fnc_searchNearby
function can now be called and doesn't have to be spawned.fnc_taskPatrol
function now completes the patrol by placing the cycle waypoint back at the start instead of randomly.fnc_taskDefend
andfnc_searchNearby
were rewritten to be both more readable and optimized.fnc_taskDefend
now handles building positions slightly differently such that if multiple groups are tasked to defend overlapping areas the positions are shared between all of the units, not just the units within each group. Meaning that multiple units will not not occupy the same position unless all positions are occupied already.fnc_searchNearby
now handles cases where units are killed while searching the building better. The group will collectively try to search every position in the building, whereas previously some positions could be overlooked because they were assigned to a dead unit (since the units array wasn't updating correctly). Similarly the function will handle cases where the leader is killed better, returning units to their new leader after the search is complete.