Jump to content
  • 0

Regarding "bonus2 bSkillAtk,sk,n;"


Question

Posted (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 by aadritch2

3 answers to this question

Recommended Posts

  • 0
Posted

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.

  • 0
Posted

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"

 

  • Upvote 1

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Answer this question...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...