[CPP] Update useMobAbility to check distance #5815
Merged
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.
I affirm:
What does this pull request do?
This resolves an edge-case where if a mob is issued the command
mob:useMobAbility(####)
, no distance check is performed on the ability being used. This can cause the mob to ready a skill while the player is already out of range and results in the mob pseudo-stunning itself. In cases where a mob may be issued multiple calls touseMobAbility(####)
in quick succession, the mob becomes locked in place preventing it from moving or performing any other actions.The function itself, in its current iteration, provides no guarantee that the mob will successfully use the ability specified as an argument unless distance checks are performed within that same mob script. This update does not change this consideration, but rather instead of the mob stunning itself for 3s, it will fail the distance check and just continue without performing the skill.
Steps to test these changes
** Before Rebuilding **
1 - Move a character to any zone with mobs
2 - Find a mob and engage combat with it.
3 - Use
!exec target:useMobAbility(470)
(or any mob skill)4 - Update your movement speed
!speed 200
5 - Run away from the mob and issue
!exec target:useMobAbility(470)
while you are out of range (15y+)6 - Note that the mob will still "Ready" the skill.
7 - Repeatedly issue the
useMobAbility
command and note that the mob becomes stunlocked.** After Rebuilding **
Special Thanks to @TracentEden for helping me develop/update this.