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

Improve monsters turning to target behaviour #4296

Closed
wants to merge 1 commit into from

Conversation

marmichalski
Copy link
Contributor

Pull Request Prelude

Changes Proposed

  • Simplify updateLookDirection logic removing 2-step turning in some cases.
  • Update look direction on successful attack or when melee was out of reach

There is still some room for improvement when it comes to ranged creatures more than necessarily turning to you while they're running to keep distance. I may or may not fix it in separate PR, as this is another issue.

@emil92b pls test

Issues addressed: #4255

@emil92b
Copy link
Contributor

emil92b commented Jan 22, 2023

seem to work for melee, not sure about ranged, also noticed in real tibia they move more frequently, but thats another issue too. btw you don't need to rename and bool flip

@marmichalski
Copy link
Contributor Author

btw you don't need to rename and bool flip

Without flipping the bool they would still be turning twice most of the times, as this method is fired more often than the actual attack. And it seemed like they turn on attack in vanilla. 🙈

@emil92b
Copy link
Contributor

emil92b commented Jan 22, 2023

btw you don't need to rename and bool flip

Without flipping the bool they would still be turning twice most of the times, as this method is fired more often than the actual attack. And it seemed like they turn on attack in vanilla. 🙈

isn't it same logic tho, only difference is this lastMeleeAttack == 0 which i assume takes care of the double turning

@marmichalski
Copy link
Contributor Author

marmichalski commented Jan 22, 2023

btw you don't need to rename and bool flip

Without flipping the bool they would still be turning twice most of the times, as this method is fired more often than the actual attack. And it seemed like they turn on attack in vanilla. 🙈

isn't it same logic tho, only difference is this lastMeleeAttack == 0 which i assume takes care of the double turning

Nope. With true as default the creature would turn anytime this method is called, which IIRC was through game.checkCreatures. lastMeleeAttack == 0 is for ranged/non-hostile creatures to face you - this means the target was out of range for melee, or the creature has no melee at all (and also that it's the first ever melee attack of this monster, but thats of no importance).

Edit: Hold on. I'm a little bit slower today. Yes, not flipping the bool and leaving the && would actually work the same. Thought rename + flip makes it a little bit more explicit.

@EPuncker EPuncker added the enhancement Increase or improvement in quality, value, or extent label Jan 26, 2023
@EPuncker EPuncker linked an issue Jan 26, 2023 that may be closed by this pull request
2 tasks
@ranisalt
Copy link
Member

I prefer the new name nevertheless. lookUpdated is clear, it has been updated, while updateLook to me means that it should be updated, which is not the case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.4.x enhancement Increase or improvement in quality, value, or extent
Projects
None yet
Development

Successfully merging this pull request may close these issues.

monster atk direction update
4 participants