Envision, Create, Share

Welcome to HBGames, a leading amateur game development forum and Discord server. All are welcome, and amongst our ranks you will find experts in their field from all aspects of video game design and development.

Problem with a CBA request

hydro

Member

okies, I was requested to make a CBA for someone but in the battle damage algorithm i need to use decimal numbers. I get an error when I do. Can some one help me with this. I have tried to come around it with other equations and such but it seems the algorithm depends too much on the decimal number.
 
Multiply everything by 10 (making 2.3, 23), and then divide everything by 10.

So..

(Weapon Attack +20)/10 + (Strength x2.3) - 400

would become

Weapon Attack +20 / 10 + (Strength x 23) / 1 0 - 400


Or vice versa if you want to divide something by a decimal.

That should workk...?
 
Hmmm, actually this is not needed, here goes an example:
Code:
atk = [attacker.atk - self.pdef / 2.1, 0].max
@dec_damage = atk * (20.9 + attacker.str) / 20
self.damage = [b]Integer(@dec_damage)[/b]
By putting the decimal value inside a Integer(value) object, will cut the decimal value.
eg.
Code:
atk = [100 - 50 / 2.1, 0].max
@dec_damage = 23,809523809523809523809523809524 * (20.9 + 80) / 20
self.damage = Integer(@dec_damage)
self.damage output will be 120 instead 120,11904761904761904761904761905
 

Thank you for viewing

HBGames is a leading amateur video game development forum and Discord server open to all ability levels. Feel free to have a nosey around!

Discord

Join our growing and active Discord server to discuss all aspects of game making in a relaxed environment. Join Us

Content

  • Our Games
  • Games in Development
  • Emoji by Twemoji.
    Top