Monday, February 2, 2009
A new game
So far I haven't done anything except experimenting with some ways to control the battle and functions for calculating attacks.
I made two experiment projects to test whether it is best to do calculations within a specific class or to have an overlooking class that fetch information, which is the only thing the other classes keep track of. Example for an attack the unit class could have the attacked opponent as parameter and return the resulting damage, or the overlooking class can just fetch all neccessary information from both the attacking and defending unit.
The drawback of the overlooking class is that all units will have the same calculation, which sometimes might not be what we want.
I also tried to make up a suitable function for calculating defence. Before I always let the defence be an absolute valute (simplified: attack - defence = damage, and if damage <= 0 it's a miss) but I found the idea of having a defence recalulated to a valute between 0-1 (0-100%) and multiply it with the attack for a damage as well as using defence (or some other variable) to calculate a probability for a miss.
Right now my function looks something like this:
def = defence, lvl = level, diff = level difference, ratio = defence ratio (0-100%)
ratio = 1 - ((def/lvl*0,6)-(def^2/level^2*0,0004))/(10+diff+(def/lvl*0,6)-(def^2/level^2*0,0004))
or as it looks in code:
double partA = defence * 6 / level / 10;
double partB = defence * defence * 4 / level / level / 10000;
double defRatio = 1000 * (1 - ((partA - partB) / ((10 + levelDiff) + (partA - partB))));
this gives something like 100% damage when defence is 1, 50% at around defence 16-17 and around 25% at defence 50. This will multiply with level so a level 10 will need 160-170 defence for 50%.
I made two experiment projects to test whether it is best to do calculations within a specific class or to have an overlooking class that fetch information, which is the only thing the other classes keep track of. Example for an attack the unit class could have the attacked opponent as parameter and return the resulting damage, or the overlooking class can just fetch all neccessary information from both the attacking and defending unit.
The drawback of the overlooking class is that all units will have the same calculation, which sometimes might not be what we want.
I also tried to make up a suitable function for calculating defence. Before I always let the defence be an absolute valute (simplified: attack - defence = damage, and if damage <= 0 it's a miss) but I found the idea of having a defence recalulated to a valute between 0-1 (0-100%) and multiply it with the attack for a damage as well as using defence (or some other variable) to calculate a probability for a miss.
Right now my function looks something like this:
def = defence, lvl = level, diff = level difference, ratio = defence ratio (0-100%)
ratio = 1 - ((def/lvl*0,6)-(def^2/level^2*0,0004))/(10+diff+(def/lvl*0,6)-(def^2/level^2*0,0004))
or as it looks in code:
double partA = defence * 6 / level / 10;
double partB = defence * defence * 4 / level / level / 10000;
double defRatio = 1000 * (1 - ((partA - partB) / ((10 + levelDiff) + (partA - partB))));
this gives something like 100% damage when defence is 1, 50% at around defence 16-17 and around 25% at defence 50. This will multiply with level so a level 10 will need 160-170 defence for 50%.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment