Prevent point blank spellcasting into low obstacles #1861
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.
When enemy casters can see their target but are right behind some obstacle (say low obstacles like tables, fountains,...), the SphereCast used to check whether they're free to cast can miss the obstacle and allow them to cast, potentially damaging themselves (in classic lich style). An easily reproducible example of such behavior can be triggered in Orsinium entrance hall, if you agro the orc shaman but keep tables in his way.
Starting SphereCast from some position behind the caster could be a workaround, but since its radius is usually larger than caster's capsule radius, it's not very satisfactory (you don't start the SphereCast from inside a "known empty space"; The right offset would also depend on enemy capsule radius).
So instead I prepend the SphereCast test with a SphereCheck at its origin, temporarily excluding caster's collider.
I do not check whether that SphereCheck hits the target (point blank shooting), so HasClearPathToShootProjectile() will return false in this case, favoring other attack types (melee, touch spells,...)