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

Perfect blockHit and correct value result #2864

Closed
wants to merge 1 commit into from
Closed

Perfect blockHit and correct value result #2864

wants to merge 1 commit into from

Conversation

MillhioreBT
Copy link
Contributor

This small problem was present for a long time and apparently nobody cares, since no one else plans to fix it, I have done it for you to support this engine to be more perfect every time.
With this change there will no longer be a difference between an object that protects 50% or two objects that protect 25% + 25%
If you test the sources prior to this change, you will notice that the results are different and mathematically wrong.

TEST VISUAL
TestVisual

Lua Example:
local damage50 = 1000
damage50 = damage50 - (damage50 / 100 * 50)
print(damage50)

local damage2525 = 1000
damage2525 = damage2525 - (damage2525 / 100 * 25)
damage2525 = damage2525 - (damage2525 / 100 * 25)
print(damage2525)

-- Print 500 <-- 50%
-- Print 562.5 <--- 25% + 25%

This small problem was present for a long time and apparently nobody cares, since no one else plans to fix it, I have done it for you to support this engine to be more perfect every time.
With this change there will no longer be a difference between an object that protects 50% or two objects that protect 25% + 25%
If you test the sources prior to this change, you will notice that the results are different and mathematically wrong.

TEST VISUAL
![TestVisual](https://image.prntscr.com/image/KlRygeOgQ6aLqgWBR4HOew.png)
@Leo32onGIT
Copy link
Contributor

Leo32onGIT commented Mar 20, 2020

This is because the amount is multiplicative.
25% of 1000 = 750
25% of 750 = 187.5
= 750 - 187.5 = 562.5

This isn't incorrect, this is intentional.
If you want to use absolute percentages you should define that logic in your lua script that is reducing the damage.

local sourceDamage = 1000
local reduce25 = sourceDamage / 100 * 25
local reduce30 = sourceDamage / 100 * 30
print(sourceDamage - reduce25 - reduce30) -- 55% absolute reduction

This is how Tibia works.

@nekiro
Copy link
Member

nekiro commented Mar 20, 2020

Despite @Leo32onGIT comment, seems like your code does nothing either? You are creating new integer that copies damage variable and then uses it to reduce
Its value, so you broke the code, because that integer isnt used anywhere else. Did I miss something?

@MillhioreBT
Copy link
Contributor Author

MillhioreBT commented Mar 20, 2020

Well the truth I see no reason for it to be intentional, 50 is 50, 25 is 25 without more.
It is not a script as @Leo32onGIT mentions, it is the source code.
Be that as it may, when some conscious person sees this, they like it and they will agree with me.

Is it I think about it one more time and it makes me laugh XD, how can it be possible that 50 is different from 25 + 25? ajajajajja Greetings loves

@nekiro
Copy link
Member

nekiro commented Apr 30, 2020

This feature/code is working as intended, so there is no need to change it.

@nekiro nekiro closed this Apr 30, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants