rogerdv
Novice
- Joined
- Mar 17, 2023
- Messages
- 8
Im working on a game project and Im testing the combat rolls formulas I designed and I would like to hear some suggestions to improve it. My current approach uses attacker skill level for the equipped weapon and dexterity to get an attack value, target's dodge and dexterity to get another value, add both and use the total to calculate a random inside 0-total range. If random<attack value, it is a hit. I tweaked the formula a bit to avoid long, boring combats: attack value is always larger than defense (unless the target dodge/dexterity are way too above attacker's). My combat sort of works, but I would like to hear some suggestion to improve this. Here you can see my actual code:
var att_lvl = owner_entity.get_skill(skill)
var att_dex = owner_entity.attrib[entity.DEX]
var def_lvl = body.get_skill("dodge")
var def_dex = body.attrib[entity.DEX]
var diff=1.0
if att_lvl>def_lvl: #if attack skill is greater, get an extra bonus
diff=att_lvl-def_lvl
var attack_total:float=(att_lvl*diff)+att_lvl*att_dex/10
var def_total:float = def_lvl*def_dex/10
var total:float = def_total+attack_total
var roll = randf_range(0,total)
if roll<=attack_total:
body.receive_dmg(damage,0)
var att_lvl = owner_entity.get_skill(skill)
var att_dex = owner_entity.attrib[entity.DEX]
var def_lvl = body.get_skill("dodge")
var def_dex = body.attrib[entity.DEX]
var diff=1.0
if att_lvl>def_lvl: #if attack skill is greater, get an extra bonus
diff=att_lvl-def_lvl
var attack_total:float=(att_lvl*diff)+att_lvl*att_dex/10
var def_total:float = def_lvl*def_dex/10
var total:float = def_total+attack_total
var roll = randf_range(0,total)
if roll<=attack_total:
body.receive_dmg(damage,0)