Putting the 'role' back in role-playing games since 2002.
Donate to Codex
Good Old Games
  • Welcome to rpgcodex.net, a site dedicated to discussing computer based role-playing games in a free and open fashion. We're less strict than other forums, but please refer to the rules.

    "This message is awaiting moderator approval": All new users must pass through our moderation queue before they will be able to post normally. Until your account has "passed" your posts will only be visible to yourself (and moderators) until they are approved. Give us a week to get around to approving / deleting / ignoring your mundane opinion on crap before hassling us about it. Once you have passed the moderation period (think of it as a test), you will be able to post normally, just like all the other retards.

Designing combat formulas for my CRPG

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)
 
Joined
Dec 24, 2018
Messages
1,788
But when the forbidden 4 months are past, then fight and slay the dynamically typed programming language users wherever you find them, and seize them, beleaguer them, and lie in wait for them in every stratagem (of war); but if they repent, and establish a static type system, then open the way for them: for Bjarne is Oft-forgiving, Most Merciful.

(Guild Wars made defense much more powerful than offense, creating a really good meta where combat involved using counters to break an opponent's defensive layer and resulting in combat that was more interesting than just "big damage.")
 

Conan

Arcane
Joined
Dec 18, 2013
Messages
189
Defense being in general more potent is a good way to make combat interesting. However, it could very easily evolve into a tiring repeat the same thing over and over charade.

The solution is that *if* you hit, it should be effectively game over.

So avoid HP bloat, make defense base values higher than attack base values.
 

Egosphere

Arcane
Joined
Jan 25, 2018
Messages
1,909
Location
Hibernia
63% THC for a dex 9, skill 16 character against a dex 10, skill 12 character. Seems alright. I presume there is a floor for the skills/attributes since a 0 defence skill or a 0 dexterity will lead to you getting hit every time even by someone with only 1 attack skill and 1 dex. So those edge cases might need some oversight. I guess you could set def/att skills to be minimum 5 or something, if they go up to 100, and attributes at a minimum of 1 if they go up to 18/40/100 whatever it may be.

I'm not sure if all of those vars are necessary, since you can call the random simply on the sum of two variables, rather than their total. It's also possible to avoid floats altogether and simply have unsigned integers, without having to divide by 10 twice.
I also don't get the first two lines. There's a method to get an attack skill, but getting dexterity also involves passing the dexterity value that you seek as an argument? Is owner_entity.DEX not already a viable way of getting the value?
 

rogerdv

Novice
Joined
Mar 17, 2023
Messages
8
Defense being in general more potent is a good way to make combat interesting. However, it could very easily evolve into a tiring repeat the same thing over and over charade.

The solution is that *if* you hit, it should be effectively game over.

So avoid HP bloat, make defense base values higher than attack base values.
Well, it is an isometric RPG, so I guess that 3-4 hits from each side are good to make the combat not so fast, but not so long. The game is not a Diablo-like mouse breaker, you select the target, click again, and weapon attack repeats until to queue an spell or ability.
 

J1M

Arcane
Joined
May 14, 2008
Messages
14,629
Missing a third of the time feels bad. If you are set on that, maybe each attack or weapon type should have a rider for an effect when it misses. For example, missing with a maul disarms the opponent's shield, missing with a flail performs a trip, etc.
 
Last edited:

As an Amazon Associate, rpgcodex.net earns from qualifying purchases.
Back
Top Bottom