aadritch2 Posted June 11, 2017 Posted June 11, 2017 (edited) It says in item_bonus.txt that it "Increases damage of skill sk by n%". My problem is that since it is n%, it cannot read below 1%. Like 15.52% increase in damage. How can i make so that it is "by n/100%" instead? Edited June 11, 2017 by aadritch2 Quote
0 crazyarashi Posted June 11, 2017 Posted June 11, 2017 bonus2 bSkillAtk,"SK_TEST",50/2; Try this :)) Quote
0 aadritch2 Posted June 11, 2017 Author Posted June 11, 2017 Yes I've tried that. My value was -8868/100, but the result i get is still from -88% rather than -88.68% which are 3410 and 3214 respectively. Its a little difference in percentage but it can be a large gap in bigger numbers. It seems to it keeps rounding off the decimals. Thanks for answering. Quote
0 Ninja Posted June 13, 2017 Posted June 13, 2017 it is because the declaration of the variable that handles the bonus in the src is type short. struct s_skill_bonus { //skillatk raises bonus dmg% of skills, skillheal increases heal%, skillblown increases bonus blewcount for some skills. unsigned short id; short val; Hence, C automatically truncates the decimals that follow after it. If you want to handle decimal values, you have a lot of choices but for me you can do this: change the variable type to any floating type variable (i.e. float, double, etc.) but you should make sure to cap those values to -32768.00 to +32767.00 to accommodate the original non-float type "short" 1 Quote
Question
aadritch2
It says in item_bonus.txt that it "Increases damage of skill sk by n%". My problem is that since it is n%, it cannot read below 1%. Like 15.52% increase in damage. How can i make so that it is "by n/100%" instead?
Edited by aadritch23 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.