The branch that has the absolute highest priority is the Near Grenade branch:
No matter what else the agent is doing, if a grenade comes near the agent then the agent should evade that grenade. This dynamic response is triggered with Conditional Aborts. As a quick recap, conditional aborts allow higher priority conditional tasks to stop the execution of lower priority tasks. The Near Grenade branch uses a Both conditional abort. This means that the Is Near Grenade task can stop the execution of any task that is to the right of it. As an example, if the agent is currently attacking within the Attack branch and a grenade comes near the agent, the Is Near Grenade task will reevaluate from Failure to Success because there is now a grenade near the agent. This will then stop the Attack branch and start the Near Grenade branch.
If Is Near Grenade returns Success the next task that is run is the Reset task. Similar to the Reset task from the previous page, this Reset task will reset the variables so they start fresh. The reason this is needed is because a conditional abort may have interrupted a lower priority branch so that lower priority branch didn’t get a chance to clean up after itself.
After the Reset task is called there is another branch which looks similar to the power weapon search branch from before. The Compare Shared GameObject task will compare the Target variable to null. If the Target variable is not null and the target is alive then the agent should go back to searching for the target after they have evaded the grenade. The Get Last Position task will store the target’s position into a Vector3 and Set Bool will then set the Wander variable to true. The Reset task is then called again so the Target variable can be reset.
Once these tasks have run the next task that runs is the Evade Grenade task which moves the character to evade the grenade. This task will return Success as soon as the agent is far enough away from the grenade. Notice that the top Sequence task is using a Both conditional abort. This means that the Is Near Grenade task is still reevaluated when any task within this branch is run. This allows for Is Near Grenade to return Failure if for example the grenade explodes and the agent is still alive.
The agents can determine if they are near a grenade by a trigger placed on the grenade. This trigger is in addition to the normal grenade collider and allows the Is Near Grenade task to return Success or Failure depending on if the agent is inside or outside of the trigger.