-
Notifications
You must be signed in to change notification settings - Fork 97
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
Arrow hit limit #45
Arrow hit limit #45
Conversation
i.e. the second entity hit by an arrow gets dealt less damage
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.
So I think you'll find, if you test it, that this does not work as intended. The tick method is not called every time a separate mob is hit or something, it is called every frame, and an arrow will almost certainly be in contact with a mob for multiple frames at a time. This will increment mobsHit much faster than the number of mobs the arrow actually damages, or more precisely, the number of times the arrow hurts a mob.
The reason mobs are not damaged every tick is because they have an internal hurt cooldown.
What you want to do, then, is make a little refactor of the Mob hurt methods and doHurt method to return whether the mob was actually hurt or not. Then you can use this value to determine if mobsHit should be incremented or not. Also I think 2 mobs is too low, try 3 or 4.
like that? |
Did you test it? think about what happens on a server. If you return false from doHurt for all remote players, then the arrow will never actually go away if it just hits players. But if you return true, then it will damage every frame. So essentially, I can't accept this until you have a way of checking if the player actually got hurt on the server, so the ghost damage doesn't happen. |
Adds a limit to the number of entities an arrow can hit before disappearing. Also reduces the damage for hits after the first.