RPG-type damage calculations

Blitz3D Forums/Blitz3D Programming/RPG-type damage calculations

stayne(Posted 2008) [#1]
Does anyone know where I could read up on designing melee/spell damage calculations for rpg combat? I've searched high and low. I'm sure it involves some clever math based on stats, but I want to do some reading first on some basic ideas (D20 maybe).

Please feel free to post your calculations as well if you feel the urge.


stayne(Posted 2008) [#2]
Found this thread, hits on some good stuff but I'm still up for ideas.

http://www.blitzbasic.com/Community/posts.php?topic=69727#780570


Mortiis(Posted 2008) [#3]
D&D damage calculations? It may help.

http://www.afterlifeguild.org/Thott/nwn/


Ross C(Posted 2008) [#4]
I dunno really. I think it would be a trial and error thing partly. Work out some rough values, and increase strength and defence relating to weapons accordingly. I'm not really sure though. There must a better way...


stayne(Posted 2008) [#5]
Thanks Mortiis but I need to start off with something simple to build on (no mods). Something like (with examples):

Player:
Level = 20
Armor Class = 45
Strength = 30
Stamina = 18
Dexterity = 27

Player's Weapon:
Damage = 5
Delay = 20

Enemy:
Level = 21
Armor Class = 32
Strength = 28
Stamina = 30
Dexterity = 33

Enemy's Weapon:
Damage = 7
Delay = 24

I suppose a random roll will need to be tossed in. I guess a d20 would work :).


H. T. U.(Posted 2008) [#6]
Take each of the player's fields and divide it by the enemy's. That will get you a nice percentage. Plug that in to whatever formula you decide to use. I usually make up these formulas as I go. Try something like this:

Type Player
Field Level=20
Field Armor_Class=45
Field Strength=30
Field Stamina=18
Field Dexterity=27

;Player's Weapon:
Field Damage=5
Field Dellay=20
End Type

Type Enemy
Field Level=21
Field Armor_Class=32
Field Strength=28
Field Stamina=30
Field Dexterity=33

;Enemy's Weapon:
Field Damage=7
Field Dellay=24
End Type

plyr.player=New player
enemy.enemy=New enemy


lvl_fctr#=plyr\level/enemy\level
armr_fctr#=plyr\armor_class/enemy\armor_class
strngh_fctr#=plyr\strength/enemy\strength
stmna_fctr#=plyr\stamina/enemy\stamina
dxtrty_fctr#=plyr\dexterity/enemy\dexterity
dmg_fctr#=plyr\damage/enemy\damage
dly_fctr#=plyr\dellay/enemy\dellay
rndm_fctr#=Rnd(0.8,1.2)

answer#=(lvl_fctr#*armr_fctr#*strngh_fctr#*stmna_fctr#*dxtrty_fctr#*dmg_fctr#/dly_fctr#*rndm_fctr#)

If answer#>1
winner$="player"
damage_done#=2-answer#
Else
winner$="enemy"
damage_done#=answer#
Endif



This is very basic code for determining the winner of a fight and the damage he has suffered.


stayne(Posted 2008) [#7]
Awesome, thanks! I'll need to weave in player and enemy health, timed attacks and then ensure combat continues until one of the combatants is dead. Also weapons will need to be a separate type as they are interchangeable but I can already see how to do that.

This helps out a great deal H.T.U. thanks again.


*(Posted 2008) [#8]
have a looky here

http://www.blitzbasic.com/codearcs/codearcs.php?code=2124


stayne(Posted 2008) [#9]
H.T.U... getting integer divide by zero errors.


H. T. U.(Posted 2008) [#10]
Sorry, I havn't tested it. The only way that I can see though that a divide by zero error would result is if one of the enemy's fields were zero (dellay?) or misspelled (I'm not a very good speller myself :D). Again, this is pretty basic and you will probrably want to change a few things or make up your own method. I am constantly plagued by divide by zero errors in my math code.


Wings(Posted 2008) [#11]
go google for Riddle of Steel.

Its a good rpg calcylation..


stayne(Posted 2008) [#12]
Coming up with my own system here (very very basic framework at the moment without types). Feel free to run it and let me know what you think.

Graphics 800,600,0,2

SeedRnd MilliSecs()
 
level = 11
strength = 22
stamina = 18
dmg = 11
dly = 1400
playerhp = 100

elevel = 7
estrength = 22
estamina = 18
edmg = 11
edly = 1000
enemyhp = 100
 
Locate 0,60

While Not KeyHit(1)

	If enemyhp =< 0
		Text 10,200, "You won! Press a key to start a new battle or ESC to quit"
		WaitKey()
		enemyhp = 100
		playerhp = 100
	Else If playerhp =< 0 
		Text 10,200, "Enemy won! Press a key to start a new battle or ESC to quit"
		WaitKey()
		playerhp = 100
		enemyhp = 100
	EndIf		
	
	If timer + dly < MilliSecs()
		
		dice = Rnd(1,5)
		
		damage = Ceil((strength * stamina * dmg) * dice * level / 10000)
	
		enemyhp = enemyhp - damage

		timer = MilliSecs()
	
	Else If etimer + edly < MilliSecs()

		edice = Rnd(1,5)

		edamage = Ceil((estrength * estamina * edmg) * edice * elevel / 10000)
		
		playerhp = playerhp - edamage

		etimer = MilliSecs()

	EndIf
	
	Cls

	Text 10,10,"Your HP: "
	Color 255,0,0
	Rect 100,10,playerhp,16
	Color 255,255,255
	Text 10,30,"Enemy HP: "
	Color 255,0,0
	Rect 100,30,enemyhp,16
	Color 255,255,255
	
	Text 10,80, "You hit the enemy for "+damage+" points of damage!"	
	Text 10,100, "Enemy HP: "+enemyhp
	
	Text 10,140, "Enemy hits you for "+edamage+" points of damage!"
	Text 10,160, "Your HP: "+playerhp	

Wend

End



andy_mc(Posted 2008) [#13]
check out a game called T.O.M.E (Tales of middle Earth), it's a very old RPG that still get's updated and has all the source code available, you could try pulling some calculations out of that. Otherwise, look up Warcraft calculations, there's a tonne of threads around the net where people have figured all this out and posted the figures you'd need. Just change them a little so you're not directly copying WoW.


Terry B.(Posted 2008) [#14]
Well... I just had Strength and defense, and I just divded the defense by two, subtracted it from the strength, and added a random from the weapon bonus ( so like Rand(-5,5) for a 5 damage weapon)
Then make it at least 0 if its under.... but thats me.