I have custom built as a little personal project a website coded in php that is a MMORPG.

It is at the minute just a personal private project but I am stuck as what to do when it comes to users battling each others' accounts!

I have four stats for each user which they can train at a gym if they wish too, so the differences in stats could be huge or not so much.

The stats are:

Speed - How fast they can hit

Strength - How hard they hit

Agility - How well they can dodge attacks

Endurance - How long they can fight for / How good their defence is

All these numbers are floats with upto 6 decimals, I was wondering if anyone on gamedev SO could point me into a good direction of how writing a script so each player could battle each other with all these factors involved.

At the minute I am just working out percentage differences of the two and using that, but it is isn't very consistent!


  • 1
    \$\begingroup\$ Basically you need to do pretty much everything, starting from game design itself. You could search for some game design courses online, such as gamedesignconcepts.wordpress.com \$\endgroup\$
    – o0'.
    Dec 5, 2011 at 13:28
  • \$\begingroup\$ I am not so much stuck on the design but the actual logic that goes on behind the scenes. \$\endgroup\$ Dec 5, 2011 at 13:32
  • \$\begingroup\$ That's a big part the design. \$\endgroup\$
    – o0'.
    Dec 5, 2011 at 14:42
  • 6
    \$\begingroup\$ The game design is the logic that goes on behind the scenes, and (unless you are building a clone game) will be different for each game. My advice, decide how you want the game to work and try (prototyping) it, then if it isn't fun try something different until you have something fun to play. \$\endgroup\$
    – Elva
    Dec 5, 2011 at 14:56
  • 1
    \$\begingroup\$ The first thing you need to make up your mind about is how you want your game to feel for the player. Then you design game mechanics which make the game feel like it. \$\endgroup\$
    – Philipp
    Mar 31, 2015 at 14:53

2 Answers 2


I think the same algorithm as used in warcraft could help you in your way. in warcraft there are these parameters:

  • hitpoint : which means how much can one take damages without dying!
  • armor : which is basically telling you how much can damage is taken from attack (the higher armor means less damage).
  • damage : which means how much damage can player deal in one attack
  • attack speed : means how many attacks can one deal in one second
  • life regen : which means how much hitpoint will player regain every second
  • strength : which directly affects health and life regen
  • agility : which directly affects armor

knowing these parameters there are two variables which will determine battle results

  1. dps (which is damage per second) is equal to attackspeed*damage
  2. ehp (which means effective hitpoint) is equal to hitpoint * (1+constant*armor)

while in warcraft engine the battle takes place in real time, you can directly compute results in your game, as a note every variable with number 1 is related to player 1 and every thing I assume 1/(1+constant * armor) * dps > liferegen:

  • t1 = hitpoint2 * (1 + constant * armor2) / (dps1 - liferegen2 * (1 + constant * armor2));
  • t2 = hitpoint1 * (1 + constant * armor1) / (dps2 - liferegen1 * (1 + constant * armor1));

t1 and t2 will represent how much time does it take for player1 to kill player2 and time needed for player2 to kill player1. you can easily check if t1>t2 or t2>t1 and declare results.


Don't create an algorithm!

Determine what you want to happen, first.

Do you want player skill to trump stats? How much of a level difference should a skillful player be able to overcome? How much benefit should high level/experience/age in a character make? Does strength trump armor, or agility trump strength?

Set the parameters of exactly what you -want- to happen, and then create tests of the behavior that you expect. Then when you create the actual algorithm, you won't just be shooting in the dark, you'll know whether it's doing what you want.


Not the answer you're looking for? Browse other questions tagged .