Martial Arts (and Melee/Dodge too) - How do they actually work, code-wise?

So I’ve been trying to figure out EXACTLY how Martial Arts work, especially now that you’re able to trigger some of them with melee weapons (other than with the melee weapon techniques).

The thing is, the wiki is being pretty vague with how melee attacks and melee blocks are triggered. I know that you need the proper melee level to access certain attacks and blocks but the wiki talk about stuff like: “If targeting a character with Grab break, checks the attacker’s (DEX + melee skill) 10 sided dice vs. the defender’s (DEX + melee skill) 12 sided dice for success.”

The way this is phrased is pretty counter-intuitive.

I also don’t understand how “crit” attacks are dertermined and how exactly the game determines which attack and block will be used.

I love this game but it has a lot of obscure calculations that lack context.

If someone could use an example by going through a whole scenario with pure character and monster stats and do some number crunching, it would be greatly appreciated.

Perhaps you could even start with how basic melee and dodge are calculated, because (3) melee and (2) dodge as stats don’t mean much to me without context.

Wiki is outdated on martial arts.

Martial arts attack techniques are quite straightforward: if you get a crit, only crit tecs are considered, otherwise non-crits. Then a random one is picked (equal weights). Some techniques have extra requirements to be considered, for example AoE attacks require more enemies around. Some martial arts techniques can be used with weapons (brawling’s power hit, for example), some weapons have their techniques.
Some martial arts are fully compatible with weapons (all techs will work) and unarmed weapons are also compatible with all martial arts.

Technique levels on wiki are outdated, you’ll need to check out jsons:

They work like this: a martial art has a list of techniques, a list of buffs (if any), an arm block level and leg block level. Two first seem straightforward to me, arm and leg block are levels when this type of block is unlocked. I think -1 doesn’t mean “never”, but “always”.

Crits result from high accuracy and are rolled separately from regular attack to-hit. Calculation is quite complex and I suggest reading the source:

You can expect to melee crit all the time later in game, unless you burden your torso heavily.

EDIT: Not sure where is the part below used. Not in ability dodges at least.
Dodge roll involves rolling dice(dodge_stat, 10) vs. hit accuracy.
You can dodge only once per turn, unless something allows more. Those extra dodges are penalized (check out melee.cpp I linked above).

EDIT: This one is for special abilities, like smash. It’s not limited by number of dodges.
Dodge_stat (for player) is dex/2 + dodge_skill - torso encumbrance (+/- other effects).
Now subtract a random number from 0 to monster’s melee_skill (a flat number, read up monsters.json for exact values) and cap at 0 so that it doesn’t get negative. Name this number dodge_check.
Then if random number from 0 to 10000 is lower than 10000 / (1 + 99 * exp(-0.6 * dodge_check) ), you dodge. Otherwise you don’t. Monsters don’t crit (I think).
The formula above looks intimidating, but if you plug it in (with dodge_check replaced by n), it gives you a nice table somewhere below on the page.
EDIT: Monsters have dodge rolls, so they probably can dodge something. They certainly can use it make crits less likely, and avoid AoE techniques, but can’t find anything else a monster could dodge.

As for example (of dodge roll - it’s simpler) - brute with melee skill 4 tries to SMASH an 8 dex, 5 dodge survivor with 1 torso encumbrance. Survivor’s dodge is 8/2+5-1=9.
Brute gets a 3 on its melee rng(0, melee_skill), so dodge_check is 6. Now look up the formula: 10000 / (1 + 99 * exp(-0.6 * 6) ) = 2699. Chance for rng(0, 100000) to be smaller than 2699 is 2699/1000=27%.

Thanks for the infodump. Sometimes I just wonder how a certain mechanic in the game functions. I appreciate you taking the time to write this little guide and for diving a bit in the code.

It’d look well in the wiki. :wink:

Yeah, the wiki is in major need of some revamping.

If I had some more free time I’d probably do something about it but I barely got the time to even play Cataclysm.

EDIT: Wanted to edit, quoted instead.
Anyway, I re-read some of those formulas to make sure. Apparently I was wrong about some of them. Updated the big post.

[quote=“Coolthulhu, post:6, topic:7930”]EDIT: Wanted to edit, quoted instead.
Anyway, I re-read some of those formulas to make sure. Apparently I was wrong about some of them. Updated the big post.[/quote]

Ah, thanks again for going the extra mile!