Repository navigation
Cancel refused casts with the type and cast id the client expects #3627
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -63,19 +63,19 @@ public async Task<bool> Hit(IAliveEntity origin, IAliveEntity target, HitArgumen | |
| if (origin is PlayerComponentBundle or MateComponentBundle && CanCast(origin) && !IsStunned(origin) | ||
| && Resolve(origin, arguments) is { SkillVnum: not 0, TargetType: not SkillReach.TargetedSkill and not SkillReach.GroundSkill } supportSkill) | ||
| { | ||
| return await CastOnSelfOrAllyAsync(origin, target, supportSkill); | ||
| return await CastOnSelfOrAllyAsync(origin, target, supportSkill, arguments.SkillId); | ||
| } | ||
|
|
||
| if (!CanAttack(origin, target) || IsStunned(origin)) | ||
| { | ||
| await CancelAsync(origin, target); | ||
| await CancelAsync(origin, arguments.SkillId, AttackRefusal(origin, target)); | ||
| return false; | ||
| } | ||
|
|
||
| var skill = Resolve(origin, arguments); | ||
| if (skill == null) | ||
| { | ||
| await CancelAsync(origin, target); | ||
| await CancelAsync(origin, arguments.SkillId, CancelPacketType.CancelAutoAttack); | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -95,7 +95,7 @@ public async Task<bool> Hit(IAliveEntity origin, IAliveEntity target, HitArgumen | |
|
|
||
| if (!await CastAsync(origin, target, skill)) | ||
| { | ||
| await CancelAsync(origin, target); | ||
| await CancelAsync(origin, arguments.SkillId, AttackRefusal(origin, target)); | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -153,13 +153,13 @@ public async Task<bool> HitArea(IAliveEntity origin, short mapX, short mapY, Hit | |
| var skill = CanCast(origin) && !IsStunned(origin) && mapInstance != null ? Resolve(origin, arguments) : null; | ||
| if (mapInstance == null || skill == null || !(skill.HitsSeveral || skill.TargetType == SkillReach.GroundSkill) || captureService.IsCaptureSkill(skill)) | ||
| { | ||
| await CancelAsync(origin, null); | ||
| await CancelAsync(origin, arguments.SkillId, CancelPacketType.CancelAutoAttack); | ||
| return false; | ||
| } | ||
|
|
||
| if (!await CastAsync(origin, null, skill)) | ||
| { | ||
| await CancelAsync(origin, null); | ||
| await CancelAsync(origin, arguments.SkillId, CancelPacketType.CancelAutoAttack); | ||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -196,14 +196,14 @@ await mapInstance.SendPacketAsync(new BsPacket | |
|
|
||
| // A skill aimed at the caster or a friendly player: a buff for them, a buff for everyone | ||
| // around, or a blow to every enemy around the caster, by its hit type. | ||
| private async Task<bool> CastOnSelfOrAllyAsync(IAliveEntity origin, IAliveEntity target, SkillInfo skill) | ||
| private async Task<bool> CastOnSelfOrAllyAsync(IAliveEntity origin, IAliveEntity target, SkillInfo skill, long castId) | ||
| { | ||
| var mapInstance = origin.MapInstance; | ||
| var recipient = skill.TargetType == SkillReach.AllySkill ? target : origin; | ||
| if (mapInstance == null || !recipient.IsAlive || !ReferenceEquals(recipient.MapInstance, mapInstance) | ||
| || CanAttack(origin, recipient) || !await CastAsync(origin, null, skill)) | ||
| { | ||
| await CancelAsync(origin, target); | ||
| await CancelAsync(origin, castId, CancelPacketType.CancelAutoAttack); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Apply the stunned-caster and dead-target cancel type to support-skill refusals.
Either apply the same stunned and dead-target rule to this path, or document that the trace evidence covers attacks only and keep type 2 for support skills. Cancel-type selection must be consistent across offensive and support casts.
|
||
| return false; | ||
| } | ||
|
|
||
|
|
@@ -621,15 +621,18 @@ private static bool AreAllies(IAliveEntity a, IAliveEntity b) | |
| return aAlly && bAlly; | ||
| } | ||
|
|
||
| private static async Task CancelAsync(IAliveEntity origin, IAliveEntity? target) | ||
| // A dead target, a stunned caster or an attack aimed at the caster itself only ends the cast; | ||
| // any other refusal also stops the auto attack. | ||
| private CancelPacketType AttackRefusal(IAliveEntity origin, IAliveEntity target) => | ||
| IsStunned(origin) || !target.IsAlive || (target.VisualType == origin.VisualType && target.VisualId == origin.VisualId) | ||
| ? CancelPacketType.CancelCast | ||
| : CancelPacketType.CancelAutoAttack; | ||
|
|
||
| private static async Task CancelAsync(IAliveEntity origin, long castId, CancelPacketType type) | ||
| { | ||
| if (origin is PlayerComponentBundle character) | ||
| { | ||
| await character.SendPacketAsync(new CancelPacket | ||
| { | ||
| Type = CancelPacketType.CancelAutoAttack, | ||
| TargetId = target?.VisualId ?? 0, | ||
| }); | ||
| await character.SendPacketAsync(new CancelPacket { Type = type, TargetId = castId, Unknow = -1 }); | ||
| } | ||
| } | ||
| } | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Restore mana before testing range refusal.
The second cast still has insufficient MP. An MP refusal could therefore make this step pass without exercising the out-of-reach refusal. Restore enough MP before moving out of range.
LanguageTool
[style] ~395-~395: ‘out of reach’ might be wordy. Consider a shorter alternative.
Context: ...kill's mana cost and cast it, then back out of reach and cast: each cast is refused an...
(EN_WORDINESS_PREMIUM_OUT_OF_REACH)