I'm trying to make a damage calculation formula for my RPG game, there are 12 levels for both the Player and the Enemy, I've come as far as making a Reverse Exponential formula, but I want the damage to go down from slow to faster as the Players level gets closer to the level of the Enemy.
import java.io.File;
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.io.UnsupportedEncodingException;
public class DamageCalc {
private static double defense;
private static double dmg;
private static String teststring;
public static void main(String args[]) throws FileNotFoundException, UnsupportedEncodingException{
for(int i = 1; i <= 12; ++i){
for(int j = 1; j <= 12; ++j){
defense = ((j * 3) * 2 + 11) * 2;
dmg = i * 12;
double totaldmg = getDamage(i,dmg,defense,j);
teststring += "Player Level " + i + "\nMonster Level " + j + "\nTotal Damage " + totaldmg + "\n----------------------------------\n";
}
}
PrintWriter test = new PrintWriter("testvalues.txt","UTF-8");
test.println(teststring);
test.close();
}
public static double getDamage(double level, double dmg, double defense, double enemy){
double intdamage = (((2*level+10) / 128) * (dmg/defense) * 11 + 1) * 10;
double damage = Math.ceil(Math.pow(intdamage,level/12) * 10);
System.out.println(intdamage);
return damage;
}
}
The code just loops through the players level (int i) and the enemies level (int j), then returns the damage done. The difference in damage between level 1 and 2 is significantly higher than between 11 and 12, eventhough that should be the other way around.
EDIT: I'll explain it even further. The player starts with 12 for each stat, every level 12 get's added (dmg = level * 12). Every stat for the player has 128 points and monsters 128 points, so that's why the begin defense of a monster is 11. If the damage stat from the player is lower than the defense of the enemy, the damage will get a penalty, otherwise it will get a boost (double * (dmg/defense)).
I hope this explains it.