Update AI functions#333
Merged
Killswitch00 merged 10 commits intoCBATeam:masterfrom May 21, 2016
kymckay:master
Merged
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.
7 tasks
- 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"; |
Contributor
Author
There was a problem hiding this comment.
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
Contributor
There was a problem hiding this comment.
Probably something for a future PR when we do know in which version it will be available?
Contributor
Author
|
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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_clearWaypointswas introduced to correctly clear all existing waypoints without issue).fnc_searchNearbyfunction can now be called and doesn't have to be spawned.fnc_taskPatrolfunction now completes the patrol by placing the cycle waypoint back at the start instead of randomly.fnc_taskDefendandfnc_searchNearbywere rewritten to be both more readable and optimized.fnc_taskDefendnow 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_searchNearbynow 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.