I want to get a formula to calculate pokemon damage

63 views Asked by At

My problem is that I want the result of the total damage to be based on the maximum life of my entity and his level (1-100), I mean that if the damage is 70, and the maximum life of the victim is 70, that a certain percentage be lowered without using floats or percentages.

Those are stats that im trying to use.

damagerDamage = 45
entityLevel = 1
maxEntityHealth = 45

This is the formula that ive been using. totalResult = maxEntityHealth * damagerDamage / entityLevel

Its should be less, since im using the max Health in the formula, it goes crazy, so yeah i dont know what to do. Can anyone help me?

The problems results:

maxEntity: 45
totalResult: 2025
1

There are 1 answers

1
Bhavy Ladani On BEST ANSWER

Here is something you are looking for.

damagerDamage = 45
entityLevel = 1
maxEntityHealth = 45

//Calculate the percentage of maxEntityHealth based on damagerDamage
percentageOfMaxHealth = damagerDamage / maxEntityHealth

//Apply the reduction based on entityLevel
reducedDamage = percentageOfMaxHealth * (100 - entityLevel)

//Round down the result to the nearest integer
totalResult = int(reducedDamage)

console.log("maxEntity:", maxEntityHealth)
console.log("totalResult:", totalResult)