Quote:
Original post by Spardra
Hello, I am creating a web-based RPG and I need help with the battle class I am creating. I need help thinking of a good way to do the attack forumla... Here is my idea for stats:
Strength - Affects how much damage you do with melee hits.
Intelligence - Affects how much (mana or magic) you have, how much damage you do with skills, chance to hit with skills and (mana or magic) heal rate.
Dexterity - Affects your chance to hit and to be hit.
Constitution - Affects your life level, life healing rate and healing items have a better effect.
There will be defense as well but that will come from the armor... I need to think of a way to make it so the strength,defense and dexterity have an effect with how much damage someone does with their weapons. The weapons will have a minimum/maximum hit value so that needs to be incorporated as well.
Here is what I have tried, but isn't working to my liking as it is very unpredictable.
%Hit = (rand(1, %OffDEX) - rand(1, %DefDEX)); //Hit percentage
%Hit would equal a random number between 1 and the Offenses Dexterity subtract a random number between 1 and the Defenses Dexterity if its greater than zero then an attack will be made, if zero or less it will miss.
%ATK = round(((%OffSTR * rand(%OffWEPMin, %OffWEPMax)) / rand(1, %DefDEF)), 0); //Hit amount
%ATK would equal the Offenses strength multiplied by the weapons min/max attack rating divided by the Defenses defense and if its less than zero it would attack 1.. Just didn't work out how I planned as it always hits 1 or over 10 never in between or nothing. The Weapon min/max value was 1 to 5 and the strength was 5 and the defense was 50.
So yeah, if anyone has a good formula to help with my attacks I would greatly appreciate it.
Thanks in advance.
Surprised no one has pointed this out to you yet:
doing OffDex - DefDex is illogical.
what makes more sense would be doing something like:
OffDex / (OffDex + DefDex)
this means that if their dexterities are equal, there is a 50% chance to hit, if the offensive combatant has twice the dexterity of the defender, then he has a 2/3 chance to hit.
it makes it much more logical and intuitive. statistical things should be in ratios not differences. (usually)