1
\$\begingroup\$

I have created simple damage formula based on source percent, which return fixed percent of damage.

DAMAGE_PERCENT = Exp(Log(100) * (1 - (100 - SOURCE_PERCENT) / 150)

Here is the result:

percent[0]: 4.641589
percent[1]: 4.786301
percent[2]: 4.935525
....
percent[98]: 94.04449
percent[99]: 96.97654
percent[100]: 100

How can I make it return same results but with reversed SOURCE_PERCENT value?

So percent[0] should return 100 and percent[100] return 4.641589?

\$\endgroup\$
3
\$\begingroup\$

Just write a wrapper that takes your input and subtracts it from 100

float GetDamageInverse(int percent) {
    return GetDamage(100-percent);
}

Or you can change your equation to replace the 100 - SOURCE_PERCENT with SOURCE_PERCENT.

\$\endgroup\$
  • \$\begingroup\$ I should add, I'm getting different results from your equation. You sure you entered your formula into your code correctly? \$\endgroup\$ – MichaelHouse Mar 4 '15 at 18:29
  • \$\begingroup\$ Oh God, I have made wrong question. LOL I don't know how, I'm feel so stupid... I am so sorry. About my formula, yes, it was correctly. Here is a code: return exp(log(100) * (1 - (100 - percent) / 150)); \$\endgroup\$ – Never Forget Mar 4 '15 at 19:51
  • \$\begingroup\$ @NeverForget Please don't completely change the question after someone has answered. If you have a new question, ask that as a new question. I took time to answer your question here, changing it to an entirely new question invalidates any answers you received. \$\endgroup\$ – MichaelHouse Mar 4 '15 at 19:53

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.