|
6 | 6 | using Intersect.Collections.Slotting; |
7 | 7 | using Intersect.Core; |
8 | 8 | using Intersect.Enums; |
| 9 | +using Intersect.Framework; |
9 | 10 | using Intersect.Framework.Core; |
10 | 11 | using Intersect.Framework.Core.GameObjects.Variables; |
11 | 12 | using Intersect.GameObjects; |
@@ -5686,8 +5687,36 @@ public void UseSpell(int spellSlot, Entity target, bool softRetargetOnSelfCast) |
5686 | 5687 | return; |
5687 | 5688 | } |
5688 | 5689 |
|
5689 | | - if (!CanCastSpell(spellDescriptor, target, true, softRetargetOnSelfCast, out _)) |
| 5690 | + if (!CanCastSpell(spellDescriptor, target, true, softRetargetOnSelfCast, out var spellCastFailureReason)) |
5690 | 5691 | { |
| 5692 | + switch (spellCastFailureReason) |
| 5693 | + { |
| 5694 | + case SpellCastFailureReason.InvalidSpell: |
| 5695 | + case SpellCastFailureReason.InsufficientHP: |
| 5696 | + case SpellCastFailureReason.InsufficientMP: |
| 5697 | + case SpellCastFailureReason.InvalidTarget: |
| 5698 | + case SpellCastFailureReason.InvalidProjectile: |
| 5699 | + case SpellCastFailureReason.InsufficientItems: |
| 5700 | + case SpellCastFailureReason.OutOfRange: |
| 5701 | + case SpellCastFailureReason.ConditionsNotMet: |
| 5702 | + case SpellCastFailureReason.OnCooldown: |
| 5703 | + // There's no logical reason for the answer to change in any of these cases, just abort |
| 5704 | + return; |
| 5705 | + |
| 5706 | + case SpellCastFailureReason.Silenced: |
| 5707 | + case SpellCastFailureReason.Stunned: |
| 5708 | + case SpellCastFailureReason.Asleep: |
| 5709 | + // Leaving these three in a group for now because they _might not_ be reasons to abort all spells |
| 5710 | + break; |
| 5711 | + |
| 5712 | + case SpellCastFailureReason.Snared: |
| 5713 | + case SpellCastFailureReason.None: |
| 5714 | + // Probably aren't hard blocking things |
| 5715 | + break; |
| 5716 | + |
| 5717 | + default: throw Exceptions.UnreachableInvalidEnum(spellCastFailureReason); |
| 5718 | + } |
| 5719 | + |
5691 | 5720 | if (!spellDescriptor.Combat.Friendly) |
5692 | 5721 | { |
5693 | 5722 | return; |
|
0 commit comments