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

XP trait effects are not calculated correctly (18-2=17) when playing with XP modifier #1796

Open
sevu opened this Issue Jun 16, 2017 · 5 comments

Comments

Projects
None yet
4 participants
@sevu
Member

sevu commented Jun 16, 2017

maths

the effect for this trait was -2 xp
using -5% xp instead - which means per 20xp 1 point less - didn't reduce xp - I would expect to take some rounding taking place, and reduce xp by 1, if the max_xp are >=10)

This happens in a game with 70% xp modifier, the unit has normally 26 xp (26*0.7 = 18,2)
In a game with 100% xp modifier and the unit having 18 xp it is really reduced by 2, and by 1 if using -5%.

Must be an old bug, present in 1.12 too.

@gfgtdf

This comment has been minimized.

Show comment
Hide comment
@gfgtdf

gfgtdf Jun 16, 2017

Contributor

this is probably due to the way how expereince_modifer is currently applied: I think it calculates: (26 -2) *0.7 = 16.8 -> rounded to 17

Note however that this depend on how the unit got that trait, if the trait is applied ba an event a different rule might apply.

Contributor

gfgtdf commented Jun 16, 2017

this is probably due to the way how expereince_modifer is currently applied: I think it calculates: (26 -2) *0.7 = 16.8 -> rounded to 17

Note however that this depend on how the unit got that trait, if the trait is applied ba an event a different rule might apply.

@gfgtdf

This comment has been minimized.

Show comment
Hide comment
@gfgtdf

gfgtdf Jun 16, 2017

Contributor

I personally have no objections againt changign that code so that xp_modifer will just effect the unit_types base max_experience and nothing else though.

Contributor

gfgtdf commented Jun 16, 2017

I personally have no objections againt changign that code so that xp_modifer will just effect the unit_types base max_experience and nothing else though.

@Lanternglow

This comment has been minimized.

Show comment
Hide comment
@Lanternglow

Lanternglow Aug 8, 2017

Code for modifying max experience by a percentage: max_experience_ = lexical_cast_default<int>(set)*max_experience_/100;
I think this is due to floating point truncation. Which isn't what is expected. In real number math, the calculation would be correct, but not when dealing with discrete values.
What would be more expected is to calculate the experience change and truncate that. Then adjust the max experience by that.

Lanternglow commented Aug 8, 2017

Code for modifying max experience by a percentage: max_experience_ = lexical_cast_default<int>(set)*max_experience_/100;
I think this is due to floating point truncation. Which isn't what is expected. In real number math, the calculation would be correct, but not when dealing with discrete values.
What would be more expected is to calculate the experience change and truncate that. Then adjust the max experience by that.

@gfgtdf

This comment has been minimized.

Show comment
Hide comment
@gfgtdf

gfgtdf Aug 10, 2017

Contributor

Code for modifying max experience by a percentage: max_experience_ = lexical_cast_default<int>(set)*max_experience_/100;

I think you are looking at the wrong code there, the more comon way to modify a unit expierience by percentage is by doing things like increase=20% not set=120%, also the code in in the first post does no midify the exierirnce by percentage, it jus says +2 not +2%

Contributor

gfgtdf commented Aug 10, 2017

Code for modifying max experience by a percentage: max_experience_ = lexical_cast_default<int>(set)*max_experience_/100;

I think you are looking at the wrong code there, the more comon way to modify a unit expierience by percentage is by doing things like increase=20% not set=120%, also the code in in the first post does no midify the exierirnce by percentage, it jus says +2 not +2%

@sevu

This comment has been minimized.

Show comment
Hide comment
@sevu

sevu Mar 12, 2018

Member

Any chance for this still going into 1.14 ?

Member

sevu commented Mar 12, 2018

Any chance for this still going into 1.14 ?

@sevu sevu added Help Docs labels May 21, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment