-SOLVED-Problem with equations.

Hi,

So, the thing is, how do I get an equation to always return a natural number?

For example, I have this equation right here:

Do + (GlobalVariable(tankgundamagelevel))-(GlobalVariable(bossarmorlevel))

now, I’m implementing some upgrades to both things, but, if at any point the first variable is lower than the seccond it’s going to return a negative number, thus renedring the boss unkillable.

Please let me know if there’s a way to make equations always return a natural number, and if there’s a way to apply this globally to the whole project so I don’t have to change 100000 things.

Thanks! :frowning:

UPDATE: ok so I fixed this in the following way:

I replaced all armor values in equations in order to use a percentage instead of a number:

(turret.Variable(tankgundamage)) + (GlobalVariable(tankgundamageupgrade)) * ((enemy.Variable(enemyarmor)) - GlobalVariable(enemyarmorupgrade)) / (GlobalVariable(percent))

Equation explanation:

Damage dealt + Damage upgrade level * enemy armor - enemy armor upgrade / 100 to variable enemyhealth of enemy

(2 + 1) * (10 + 1) / (100)

It’s complicated but it works perfectly! ( you may want to use higher numbers so you don’t get decimals)

You can use the “max” function to get a positive number:

max( MyValue, 0 )

And round/floor/ceil to get integers:

floor( MyValue )

You can’t make it global, but you can use floats/negative numbers everywhere as now but convert them temporally to a positive number to use in the scale action for example:

[code]Conditions: Enemy damaged
Actions: Do + Variable(damage) - Enemy.Variable(power) to the variable “scale” of Enemy

Conditions: No conditions (Always)
Actions: Do = max(Enemy.Variable(scale), 0.1) to the scale of Enemy[/code]
So you have to change some actions only, the critical ones :slight_smile:

THanks! I’ll try this later, looks like it’s going to be a long night.

UPDATE:

so, I have this:

DO - (GlobalVariable(tankgundamagelevel))-((enemy.Variable(enemyarmorlevel))+(GlobalVariable(enemyarmor))) to variable enemyhealth of enemy

DO I just have to add the MAX thing and that’s it?

DO MAX - (GlobalVariable(tankgundamagelevel))-((enemy.Variable(enemyarmorlevel))+(GlobalVariable(enemyarmor))) to variable enemyhealth of enemy

Also how do I even type in the “MAX” thing, I can’t interact with the line that way.