Skip to content
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

Target enemies based on walk progress #7473

Closed

Conversation

kphoenix137
Copy link
Collaborator

@kphoenix137 kphoenix137 commented Oct 10, 2024

Fixes: #7473

When using melee, players target the tile that the enemy is "most inside" by tracking walk progress. Previously, only the future tile was tracked. This caused a problem where while a melee player could technically hit an escaping enemy, the player instead chose to pursue the target because the future tile was more than a tile away from the player. This targeting behavior also caused hitting stone cursed monsters that were in a walking animation to face a strange direction. This change does not affect spell or ranged targeting.

@kphoenix137 kphoenix137 marked this pull request as draft October 10, 2024 22:20
@julealgon
Copy link
Contributor

This caused a problem where while a melee player could technically hit an escaping enemy, the player instead chose to pursue the target because the future tile was more than a tile away from the player.

I would be very careful with this change. You might be changing to the much less desired behavior (IMHO) that D2 uses, which results in constant whiffing when attack a fleeing target, even when the target is super slow like zombies. I've always found that behavior to be incredibly frustrating and terrible gameplay-wise. It is especially bad when coupled with skills that force enemies to flee (which is not a behavior that is prevalent in D1, but it might be in a mod...).

I don't necessarily think your change will be as aggravating as that (because the issue in D2 is driven by weapon range plus the much more fine-grained grid) but I wanted to point it out so you can try testing it thoroughly before committing.

To me, neither approach is "great". I think the "best" way to handle this would be to do a predictive check based on attack speed of the current weapon and the enemy speed, to see whether attempting to hit on current or target tile is the best option, considering that the swing happens on frame 0 while the hit check happens on frame X of the animation.

Applying a predictive check like this to ranged attacks would also make the game less frustrating as the attacks would "follow" the target's current path, but maybe that would remove too much "skill" from the game, so it's a balancing act.

This prediction would of course only be applied to a moving monster.

Another (more interesting) option would be to allow attacks to "follow" the target during the pre-hitframe animation: if you start an attack against a monster on tile X, but the monster moves to tile Y which is still in range of the character, the character would turn towards tile Y mid-animation and continue the attack, now targetting that tile. This is the approach I'd like to try the most, so just throwing the idea here in case it also catches your interest. I think this would not only feel better to play, but also look more interesting/realistic.

@kphoenix137 kphoenix137 marked this pull request as ready for review October 10, 2024 22:48
Copy link
Member

@StephenCWills StephenCWills left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This naive approach seems okay. You could get fancy by comparing the total number of frames in the walking animation to the total number of frames in the character's attack animation, but maybe it's okay to be a bit sloppy.

Source/player.cpp Outdated Show resolved Hide resolved
Source/player.cpp Outdated Show resolved Hide resolved
@kphoenix137
Copy link
Collaborator Author

This caused a problem where while a melee player could technically hit an escaping enemy, the player instead chose to pursue the target because the future tile was more than a tile away from the player.

I would be very careful with this change. You might be changing to the much less desired behavior (IMHO) that D2 uses, which results in constant whiffing when attack a fleeing target, even when the target is super slow like zombies. I've always found that behavior to be incredibly frustrating and terrible gameplay-wise. It is especially bad when coupled with skills that force enemies to flee (which is not a behavior that is prevalent in D1, but it might be in a mod...).

I don't necessarily think your change will be as aggravating as that (because the issue in D2 is driven by weapon range plus the much more fine-grained grid) but I wanted to point it out so you can try testing it thoroughly before committing.

To me, neither approach is "great". I think the "best" way to handle this would be to do a predictive check based on attack speed of the current weapon and the enemy speed, to see whether attempting to hit on current or target tile is the best option, considering that the swing happens on frame 0 while the hit check happens on frame X of the animation.

Applying a predictive check like this to ranged attacks would also make the game less frustrating as the attacks would "follow" the target's current path, but maybe that would remove too much "skill" from the game, so it's a balancing act.

This prediction would of course only be applied to a moving monster.

Another (more interesting) option would be to allow attacks to "follow" the target during the pre-hitframe animation: if you start an attack against a monster on tile X, but the monster moves to tile Y which is still in range of the character, the character would turn towards tile Y mid-animation and continue the attack, now targetting that tile. This is the approach I'd like to try the most, so just throwing the idea here in case it also catches your interest. I think this would not only feel better to play, but also look more interesting/realistic.

I would like to see this PR tested as is to determine any ill effects

@StephenCWills
Copy link
Member

I would like to see this PR tested as is to determine any ill effects

Succubus has a walking animation of 8. Warrior using a sword without swiftness, speed, or haste will probably be affected the most. If you properly corner the succubi or use Teleslash with a haste weapon, you may not notice much difference.

@kphoenix137
Copy link
Collaborator Author

kphoenix137 commented Oct 10, 2024

@kphoenix137
Copy link
Collaborator Author

kphoenix137 commented Oct 10, 2024

Modifying the behavior to be desirable in all cases would involve doing fancy stuff like precalculating ahead of time if the monster will still be in the targeted tile when the player's action frame occurs and deciding on the fly whether or not to begin the attack or continue chasing the monster. It's going to be unnecessarily complicated and isn't really worth it. This would start to creep into the realm of changing core game mechanics in an attempt to fix something that isn't necessarily broken.

@StephenCWills
Copy link
Member

I guess Hellfire players will just have to use Shift+Click on Torchants.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants