aadritch2 Posted June 11, 2017 Group: Members Topic Count: 13 Topics Per Day: 0.00 Content Count: 23 Reputation: 0 Joined: 04/29/13 Last Seen: April 21, 2018 Share 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 Link to comment Share on other sites More sharing options...
0 crazyarashi Posted June 11, 2017 Group: Developer Topic Count: 50 Topics Per Day: 0.02 Content Count: 776 Reputation: 239 Joined: 02/11/17 Last Seen: Yesterday at 01:17 PM Share Posted June 11, 2017 bonus2 bSkillAtk,"SK_TEST",50/2; Try this :)) Quote Link to comment Share on other sites More sharing options...
0 aadritch2 Posted June 11, 2017 Group: Members Topic Count: 13 Topics Per Day: 0.00 Content Count: 23 Reputation: 0 Joined: 04/29/13 Last Seen: April 21, 2018 Author Share 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 Link to comment Share on other sites More sharing options...
0 Ninja Posted June 13, 2017 Group: Members Topic Count: 54 Topics Per Day: 0.01 Content Count: 513 Reputation: 84 Joined: 08/11/12 Last Seen: July 4, 2024 Share 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 Link to comment Share on other sites More sharing options...
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 aadritch2Link to comment
Share on other sites
3 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.