The math behind the combat

+
The math behind the combat

Hey,

I don't understand the underlying math of the combat. Where can I get more information about how mechanics work in The Witcher 3?
Didnt fount anything on the internet.
 
This is, indirectly, yet another call for the RedKit!

As for the answer to your question, I think the general formula is something like:

Damage to Enemy = Base Weapon Damage + ([Character Skills + Mutagen/Decoction/Oil Effetcs] * 0.X)

Effects like runes and whatnot seem to be calculated independently and are added in at their default values when the effect triggers. Those don't seem to scale.

I hate math. How'd I do?
 
Hey,

I don't understand the underlying math of the combat. Where can I get more information about how mechanics work in The Witcher 3?
Didnt fount anything on the internet.
Maybe try and ask @Wasteland_Ghost, she redo all the maths for her Ghost mode so she might still have the original formulaes ;)
 
Hi, haven't been here for a while :)

TW3 formulas are complicated. There isn't one large formula for damage, but tons of different small formulas in damage manager, actor and effects classes that handle specific cases. Makes modding this part of the game a real pain.

Here are my raw notes on some of the damage calculations (from when I just started to dive into damage related code):
Damage calculation:
incomingDmg = (rawDmg + powerMod.valueBase) * powerMod.valueMultiplicative + powerMod.valueAdditive
Note: fistfights ignore player's powerMod and set incomingDmg = rawDmg
finalDmg = (incomingDmg - resistPoints) * (1 - resistPercents)
Note: DoT damage ignores resistPoints but not resistPercents, fistfights ignore resistance completely

Damage reduction:
resistPoints = victimReductionPoints + victimArmor - attackerArmorReductionPoints
resistPercents = victimReductionPercents - attackerArmorReductionPercents
Note: strong attack adds to attackerArmorReductionPoints and special strong attack and oils add to attackerArmorReductionPercents swarm attacks (like bees) and grapeshot3 ignore victimArmor.

Armor reduction effect:
incomingDmg = 1000
armorPts = 100
armorResistPrc = 0.3
armorReductionPts = 50
armorReductionPrc = 0.2
reduction = armorPts - armorReductionPts = 50
reductionPrc = armorResistPrc - armorReductionPrc = 0.1
dmg = (incomingDmg - reduction) * (1 - reductionPrc) = 855 // point and % bonuses
dmg = (incomingDmg - reduction) * (1 - armorResistPrc) = 665 // no % reduction from attacker, only point reduction
dmg = (incomingDmg - armor) * (1 - armorReductionPrc) = 810 // no point reduction, only % reduction
dmg = (incomingDmg - armor) * (1 - armorResistPrc) = 630 // no bonuses

DoT calculation:
dmgPerSec = effectValue.valueAdditive + (effectValue.valueMultiplicative * victimMaxHP)
duration = initialDuration * creatorPowerStat.valueMultiplicative * (1 - durationResistance)
Note: durationResistance is capped at 0.99 for critical effects
This is raw damage which then get passed to damage manager to calculate final damage.

Yrden direct damage is applied when in normal mode only.
Yrden slowdown is not applied when in alternative mode.

Igni damage:
Fire damage from hit: 100 * (1 + igni power).
Burning effect: duration = DoT duration (base = 3 sec), dps = DoT damage (mult = 0.027).
Actual duration seems to be longer than calculated duration (due to stamina regen from potions not being paused).
Both burning duration and DoT are affected by sign power, DoT is based off victimHP, that's why burning is so OP.
Igni power 300% gives about 10 sec of burning with about 550 dps on lvl 34 drowner (about 6500 HP).
One time Igni damage deals about 400 damage to lvl 34 drowner.
Igni channeling: damage on hit = 30 * (1 + igni power), dps = 70 * (1 + igni power)
Burning effect from channeling: duration = DoT duration (base = 1 sec), dps = DoT damage (mult = 0.01)
Burning effect from channeling is applied with dps while channeling. Burning is not stacked, but cumulated (prolonged).
With 300% igni power channeling lasts about 5 secs.
So, on lvl 34 drowner it's about 120 of initial damage + 280 * 5 = 1400 channeling damage + (5 + 2.6) * 65 = 494 DoT = 2014 damage vs 5500 damage from normal burn.

These were my attempts on understanding why armor and armor piercing runes are basically useless and also why alternative Igni is so bad. After I understood that I started modding and stopped taking notes about vanilla formulas, but if you have any questions on specific skills/bonuses, I can try answering them.
 
Hi, haven't been here for a while :)

TW3 formulas are complicated. There isn't one large formula for damage, but tons of different small formulas in damage manager, actor and effects classes that handle specific cases. Makes modding this part of the game a real pain.

Here are my raw notes on some of the damage calculations (from when I just started to dive into damage related code):


These were my attempts on understanding why armor and armor piercing runes are basically useless and also why alternative Igni is so bad. After I understood that I started modding and stopped taking notes about vanilla formulas, but if you have any questions on specific skills/bonuses, I can try answering them.

Wow, that's fantastic! I was looking for something like this for a long time now but had trouble finding the actual numbers. Thanks so much!

I suspect CDPR realizes that most of the userbase isn't really into the hardcore numbers and mostly wants to enjoy the world and the story. Personally, I think there's no excuse not to publicize the numbers, but that's a minor gripe. I'm glad there are dedicated folks like you to dig into the raw data, though!
 

Guest 2364765

Guest
Hi, haven't been here for a while :)

TW3 formulas are complicated. There isn't one large formula for damage, but tons of different small formulas in damage manager, actor and effects classes that handle specific cases. Makes modding this part of the game a real pain.

Here are my raw notes on some of the damage calculations (from when I just started to dive into damage related code):


These were my attempts on understanding why armor and armor piercing runes are basically useless and also why alternative Igni is so bad. After I understood that I started modding and stopped taking notes about vanilla formulas, but if you have any questions on specific skills/bonuses, I can try answering them.
Have you by any chance ran across pieces that handle item level calculation. There's obviously no "required level" override and it seems to be dynamically calculated from all of the weapon stats/sockets and effects it applies. It makes it really hard to add items or to balance them in any way without knowing what numbers exactly drive the logic behind the level requirement calculation.
 
Have you by any chance ran across pieces that handle item level calculation. There's obviously no "required level" override and it seems to be dynamically calculated from all of the weapon stats/sockets and effects it applies. It makes it really hard to add items or to balance them in any way without knowing what numbers exactly drive the logic behind the level requirement calculation.

Yes and I've changed it quite a bit for Ghost Mode. Armor amount and damage amount are two things that define armor and weapon level respectively, no other stats/effects affect it. Look inside def_item_weapons_relic_autogen.xml (it is used for all weapons and armors) for base and per level numbers. The system is kinda complicated and redundant, IMO (not levels themselves, but the math behind). The game generates a level, for example, when item is added to an inventory, and then it adds one base and (level-1) per level abilities to it to boost its armor/damage. Level as a number is not actually saved, but is instead calculated in gameParams.ws by GetItemLevel function each time some piece of the code requests it. Only base armor/damage affects level, so, for example, if you want a weapon to deal more damage, but still be the same level, you can use type="add" attribute instead of type="base". There also is a lot of "hacky" code to reduce/increase item level for some cases. Crossbows and bolts have their level hardcoded by damage multiplier and bolt name respectively.

In inventoryComponent.ws there's GetItemLevel function that uses the one I described above to get item's level. And there is another one called GenerateItemLevel that generates random level for an item and adds per level abilities to it. You also might want to look into both. A word of warning, though, the code is... messy. :)

PS Also, additional sword damage like frost and fire, is not actually being applied in vanilla due to a bug. It doesn't affect item level either (which is intentional), because it uses type="add" attribute.
 
Last edited:
Wow, that's fantastic! I was looking for something like this for a long time now but had trouble finding the actual numbers. Thanks so much!

I suspect CDPR realizes that most of the userbase isn't really into the hardcore numbers and mostly wants to enjoy the world and the story. Personally, I think there's no excuse not to publicize the numbers, but that's a minor gripe. I'm glad there are dedicated folks like you to dig into the raw data, though!
The Witcher 1 and in a way the second installment, where far much better to understand what would happen if you upgrade your character. The Witcher 3 introduces a generic (on the fly adjustable) tile system that I don't like and that is not telling you what something does.
It's such a shame that CDPR choose this character building. And not forget that the combat is'nt balanced and oils and potions are really generic and not fun to use.

Sigh. Lot of frustration. I am sorry.

Back on the topic. Why is it not possible to use tooltips to clarify the math behind the stats. I hate (RPG) games that don't tell users all the rules. So often players make a mistake of investing in too two different skills and realising those both skills don' t stack! So frustrating.
 
Last edited:
I still have to add swords but i don't know what's the main stat that governs level requirement calculation for weapons.

It's a base damage. See GetItemLevel function in inventoryComponent.ws and another GetItemLevel function in gameParams.ws. Basically, it adds up all the base damage values of the sword, like SlashingDamage, BludgeoningDamage, etc., and then calculates a level based on per level damage. Algorithm is a bit off, though, as it assumes that the sword has at least 1 point of each type of damage (that's why they add 1 silver damage to all steel swords and 1 slashing damage to silver ones), but I'm yet to see a sword with at least 1 point of RendingDamage. So, as I result, calculated sword level tends to be less than generated one. And also, since per level attributes are randomized and calculations use fixed values, rolling low attribute makes calculated level lower than generated one. It is one of the reasons why there are so many low level swords in treasure chests.
 

Guest 2364765

Guest
*nevermind*
 
Last edited by a moderator:
By the way, I found a post by another user, Exentryk, who tabulates the actual numerical effects of all the decoctions, based on the game's extracted files. Not many people likely saw the post, so I thought I'd post it here too. It's current as of 1.12.

Here they are, for convenience:

Katakan Decoction - Increases Critical Hit Chance by 5%.
Arachas Decoction - 20% damage reduction bonus while at zero weight, 0% bonus while at full weight.
Cockatrice Decoction - All alchemy creations can be used one additional time (except Decoctions)
Archgriffin Decoction - Consumes 100% Stamina for 5% Enemy HP Reduction using a Strong Attack. Also counts the damage the Strong Attack makes in the total (the damage total on screen does not show the 5%, but only the strong attack damage).
Water Hag Decoction - Damage dealt is increased by 50% when character HP is at its maximum.
Nightwraith Decoction - Geralt's maximum HP is increased by 50 with each foe killed. Effects lasts until meditation or fast travel.
Ekimmara Decoction - Damage dealt to foes regenerates HP. (Health restored = 10% of damage dealt + 1)
Chort Decoction - +40% to knockdown resistance for each 100 points of carry weight. (This got updated in 1.12, so needs to be checked again)
Foglet Decoction - Increases Sign Intensity during Cloudy Weather by 25%.
Wyvern Decoction - Each blow landed increases Attack Power by 1% until fight ends or damage is taken. (No max limit)
Doppler Decoction - Increase critical hit damage by 50% when attacking from behind.
Troll Decoction - Regenerates Vitality during (20) and outside (100) of combat.
Noonwraith Decoction - Sets Blindness, Hypnotized, Knockdown/Stagger/Confusion, Slowdown effects duration to 0.5 sec.
Succubus Decoction - Attack power grows in 1% increments every 2 sec over the course of the fight until reaching a maximum of threshold of 30%.
Alghoul Decoction - Adrenaline Points are generated 50% more quickly until the player receives damage.
Fiend Decoction - Increases the amount of weight the Witcher can carry by 20.
Forktail Decoction - 50% to attack power and spell power after at least three of these actions: counter, attack, sign, bomb, crossbow. Clears buff after the attack, removed at the end of combat.
Grave Hag Decoction - Each foe slain accelerates Vitality regeneration by 5 for the duration of the battle (No Max Limit)
Wraith Decoction - When a single hit reduces HP by 30% or more, a Quen shield is triggered.
Earth Elemental Decoction - Increases resistance to vitality depleting critical effects (burning, poison, bleeding) applied during combat by 10%.
Ekhidna Decoction - Performing actions that consume Stamina regenerates Vitality (100% Stamina Use = 10% HP restore)
Ancient Leshen Decoction - Each Sign cast increases Stamina regen by 2/s until the remainder of the fight (No max limit)
Basilisk Decoction - Applies a random beneficial effect at dusk and dawn. The effect lasts 6 hours.
Werewolf Decoction - Running, sprinting and jumping outside combat does not consume Stamina.
Nekker Warrior Decoction - Mounts never Panic. 50% increase to mounted combat damage.
Leshen Decoction - A portion of the damage dealt by enemies is reflected back on the attacker. (2% of damage taken + 10)
Griffin Decoction - Taking damage increases damage resistance (slashing, piercing, bludgeoning, rending, elemental) in 1% increments up to a maximum of 25% for the remainder of the fight.
Reliever's Decoction - Increases damage dealt by 10% and decreases damage taken by 15% against Wraiths (slashing, piercing, bludgeoning, rending, elemental).


Source: Game files.
Note: I've used Vitality and HP interchangeably.
 
Last edited:
Some corrections to that:

ArchGriffin: any non-zero stamina left decreases HP by 5% * curHP per strong melee hit that deals any damage.
Water Hag: +50% to any damage multiplier while at full health. Multipliers do not increase final damage, they stack and they affect base damage. So when looking at your DPS you won't see 50% increase, because DPS shows your final damage and multiplier affects your base damage.
Foglet: due to weird code behavior works always.
Elemental: +10% to burning, poison and bleeding DoT resists per second, no limit, removed when effect ends.
Ekhidna: heals 10% * maxHP per action that has stamina cost (once per whirl, rend and sign channeling).
Basilisk: adds random place of power effect at dawn and dusk.
Nekker Warrior: +50% to attack power multiplier while fighting on horse, horse never panics.
 
Wow, thanks for this info, I started W3 and was suffering trying to figure out the damages displayed on my character, even thought the items and skills description were incorrect. Exactly on Damage Bonuses from Cat Set
The term "Damage" is vaguely used and is not so explicit as it looked to be.
 
In short terms:
Attack Power = is considered the average weapon damage, not the total damage showed on status screen
Armor piercing ignores amount of enemy armor, if enemy doesnt have armor this is totally useless.
 
Top Bottom