ID:2429712
 
(See the best response by Kaiochao.)
Greetings everyone,

First I should note I have been gone from Byond for a long time and can't remember my old key, now then... I am working on a traditional MUD, in the past I wrote a simple MUD using byond but I handled most of the dice results manually (basically it was a fancy table top simulator.)

What I am trying to figure out now is how to build a combat/skill system based on dice(d10 specifically nWoD) with contested rolls in a turn-based manner.

An example:

PersonA has 3 Strength, 3 Dex, 4 Stamina, 2 Defense, 2 Brawl

PersonB has 4 Str, 2 Dex, 5 Stam, 3 Def, 3 Brawl

PersonA attacks PersonB. The roll would be PersonA's Str + Brawl - PersonB's defense d10 (5 - 3 =2) 2d10. But there is a base level of difficulty for success for sake of this conversation let us assume it is 8.

IF one of the two dice rolled >= 8 the attack hits its target and then the damage is calculated by the number of successes plus any modifiers so let's say it was just the 2 successes, we would have 2 damage, then that damage is reduced by PersonB's armor which lets pretend is 1.

So our end result is PersonB suffers 1 point of damage.

I looked at multiple roller examples and couldn't find anything that led me down the path to figuring out a solution, any thoughts and or links would be greatly appreciated,
Best response
What have you tried? How much of an entire dice-rolling turn-based combat system are you asking for?

Like, do you know how to give those stats as variables to types that represent combatants, how to repeat a bit of code N times, how to get a random number from 1 to 10, and do a tiny bit of arithmetic involving those variables to calculate the damage dealt?
As far as writing the code for this, it'd be fairly straightforward. First you'd calculate the number of dice to roll, then you'd roll each one individually to build up a damage total, then you'd modify the total based on armor, then you'd do the damage.

mob/proc/CombatRoll(mob/defender)
var/dice = strength + brawl - defender.defense
if(dice <= 0) return // failed
var/damage = 0
while(dice--)
damage += (rand(1,10) >= 8) // 1 is true
damage -= defender.armor
if(damage > 0) defender.TakeDamage(src, damage)

A more robust system would tell you if you hit but did no damage.

For what it's worth, I think a system where you roll dice for both parties would be a little more interesting. E.g., you might roll the attacker's strength and the defender's defense, all in d10s, and count a point for each die that's 8 or over. Add points to the defender's total for their armor. Any difference in the attacker's favor becomes damage. In this way you end up with more chaotic rolls as stats go up, allowing for occasional excellent hits or great blocks.