Click to See Complete Forum and Search --> : TB RPG Attack Algorithm?


nko
07-15-2005, 01:15 PM
I'm making a simple, CLI, turn-based arena fighting game as a fun way to practice OOP (because I can't seem to think nonproceedurally). I need an algorithm for determining the result of when one Person attacks another Person. This, of course, is a fun kind of algorithm to design, especially in a program like this one where you have zero concern over making the thing efficient. There's no right or wrong answer.

I can come up with a perfectly suitable algorithm on my own, but I thought it'd be a lot more fun and a lot more effective to ask the community how *they* would design such an algorithm.

In its current placeholder implementation, the attacker *always* hits his enemy (strength + current weapon's attack power * random number = damage; enemy health -= damage).

So far, the variables involved are the attacker's strength (STR), current weapon's attack power (ATk; something like a simplified XdY of DnD, IIUC), and agility versus enemy's health (HP), current armor's defensive power (AC), and agility. Obviously, the more agile person will have an easier time swaying the results of the attack. Outcomes are either a miss (how probable should this be?) or a hit of varying damage to the enemy's HP. Future possibilities include the enemy's successful use of a shield or deflecting skill, "critical hits", etc., but I'm hoping for those to be drop-in addons to the algorithm.

So if you think this is interesting, please, tell me how your algorithm would go!