Any RPG programmers about?

Soldato
Joined
17 Oct 2002
Posts
7,439
Location
Stoke-on-Trent
Working on a little project and need to work on some algorithms.

I am looking for a basic attack / defend formula based on the following elements:

  • Attack Points
  • Defence Points
  • Level
  • Health

Where Health cannot be greater than 100.

Any tips or help appreciated.
 
Last edited:
Is there a limit on attack/defence points and level?

In principle one ultrasimple way to go is to write, if AP is the attack points of the attacker, DP is the defence points of the defender, LA is the level of the attacker and LB is the level of the defender,

BasicAttackValue = (AP+LA) - (DP+LB)

So this formula scales linearly with level and attack/defence point values. I have no idea how you intend on 'levelling up' but this allows you to implement a simple way of scaling all of those variables.

Now if health is then capped out at 100 the easiest way to balance this is by just 'normalising' it by dividing the whole thing by some constant that balances the overall damage dealt in the game to some reasonable level that you think is appropriate.

So you end up with,

HPLost = (AP + LA - (DP + LB))/NormalConst



Now, an alternative strategy is one involving randomisation, where you generate random 'attack roll' and a 'defence roll' values. For example, in a near D&D-esque strategy you may write:

Attacker rolls to generate a number between 1 & 20, call it r1. Defender rolls the same 'die', generating r2.

IF r1 > r2 damage is dealt.
(you can also add a critical hit criterion here based on r1 = 19 or 20 or a critical failure in r2?)
To generate damage you could write something simple like Damage = (AP - DP). If you want to add levelling in as a modifier you could say Damage = (AP - DP) + (LA - LB) which is the same statement used above in the first example. Again consider a normalisation constant in this calculation for balance.
ELSE
so if we're here then the attack roll was less than or equal to defence so no damage is dealt, the next round (or other general effects from your attack may still be dealt?) can continue.
End If.

Of course this may not actually be appropriate to your levelling system. More detail is needed, but this is just a toy strategy for you to work with. For example you could consider adding direct modifiers to the attack and defence rolls based on level or the number of AP/DP.


/latenightbrainfart.

EDIT: preferable to writing a whole new post :p
 
Last edited:
Not entirely sure what your asking - you want some kind of formula to modifiy the health of the target based on the skill level of the attacker and defender and their respective points in attack and defence capabilities?

EDIT: If your making an RPG I'd probably use the attack and defence points to calculate a "chance" to hit then use the level as a modifier for the damage amount.
 
Last edited:
Do not use this kind of thing for wizards or archers though, one of the most retarded things in my opinion in RPG games; is when a Wizard can one shot a Warrior with melee just because they are a few levels higher. Code the level scaling carefully, other than that, I wish you the best!
 
Back
Top Bottom