Advertisement

RPG game engine algorithms

Started by September 18, 2003 10:20 AM
0 comments, last by Neo Genesis10 21 years, 4 months ago
Hiya. Need some good algorithms for dealing damage to enemies in a Final Fantasy style combat. My mathematical skills are still fledgling in comparison to professional programmers, so any assistance would be appreciated. Here are a list of the player statistics. These stats also apply to the enemies. Hitpoints - Total life energy of the character Strength - Self explanatory Defense - Used for BOTH magic AND physical attacks Magic Strength - This will boost the base value of spells. Agility - The more agile the character, the more chance of hitting your opponent (checked against evasion). Also helps with critical hits. Evasion - How easily dodged attacks are. Also prevents enemies scoring critical hits as often. Luck - Helps with critical hits. Also helps players gain rarer items. Another algorithm which would be useful is a level up algorithm. What I would like this to do is take the existing stats of the player and increase them. I dont want a fixed amount, but I would like a gradual increase. Help with any of the above would be great. Thanks people.
Worship the holy trinity that is Blitz, Babes and Beers!
Algorythms for RPG stuff aren''t exactly complicated. You only listed strength, but I''ll take liberty and assume theres an "Attack" thats provided by weapons. You can try this several ways depending on need, for instance:

HpDamage =
Strength + Attack - Defense
Strength * Attack * (100-Defense) / 100
( or the next one if you go three digit 8-bit ala'' FF. )
Strength * Attack * (256-Defense) / 256

Then you ask about random, thats easily done if you have a rnd() random function. (I''ll assume this one does 0.0 to 1.0)

Variance = rnd() * HpDamage / 8
HpDamage = HpDamage + Variance

and then that illusive CRITICAL damage white screen flash everyone seems to like.

if ((rnd()*100) <= Agility) { HpDamage = HpDamage * 1.5; FlashToggle = 1 }

Oh, and Evade. That one can be done a lot of ways actually, like you could go if((rnd()*100)<=(100+Agility-Evade)) or if((rnd()*Agility)>=Evade) ... That one you''ll have to figure out.

Never very complicated, just figure out what you want.
william bubel

This topic is closed to new replies.

Advertisement