Larian Studios
Posted By: Starlights The Rogue - Maths are WRONG - 23/01/21 05:05 AM
Heh, I was just debating that rogue class is great, on steam, and then went into reviewing sneak attack damage. I took a screenshot to show facts and then ... hey, wait ..

Screenshot - and Evidence !
[img]https://steamcommunity.com/sharedfiles/filedetails/?id=2370648672[/img]

From my screenshot you can see the following:
The operation: 4(1D6 Piercing) * ((4(level) -1)/2 + 1) = 8

Now plain math w/ PEMDAS (hope you guys from the 80's remember that) :

4 * ((4 - 1)/2 + 1) = 8 ---> that's not 8. You can also just paste this operation in google ... my god, the math are wrong, can't believe it

4-1 = 3
3/2 = 1.5
1.5 + 1 = 2.5 ----> was that number round down anyhow ? If you round it .. it should be UP .. not DOWN or was it that in the code the .5 was dropped ?
4 * 2.5 = 10 ---> the answer with no round number.
Posted By: dwig Re: The Rogue - Maths are WRONG - 23/01/21 05:15 AM
No idea what the calculation gibberish is there for, but if your dexterity is 18 and the number rolled on 1D6 is 4 then 8 is the correct damage.
Posted By: Ayvah Re: The Rogue - Maths are WRONG - 23/01/21 05:43 AM
Originally Posted by Starlights
1.5 + 1 = 2.5 ----> was that number round down anyhow ? If you round it .. it should be UP .. not DOWN or was it that in the code the .5 was dropped ?
There's no mathematical rule that says how numbers should be rounded off. Rounding numbers is a social convention for expressing approximate numbers.

As far as I can tell under D&D 5E rules, you ALWAYS round down any time you get a fraction. Even if the fraction is 0.9, you round it down.
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 01:38 PM
Originally Posted by Ayvah
Originally Posted by Starlights
1.5 + 1 = 2.5 ----> was that number round down anyhow ? If you round it .. it should be UP .. not DOWN or was it that in the code the .5 was dropped ?
There's no mathematical rule that says how numbers should be rounded off. Rounding numbers is a social convention for expressing approximate numbers.

Yes, rounding numbers are a convention known throughout the history. Precisely, rounding number 5 UP is also a convention.

Quote
As far as I can tell under D&D 5E rules, you ALWAYS round down any time you get a fraction. Even if the fraction is 0.9, you round it down.

Please quote that rule here. And if true, then, it means D&D doesn't understand math.


To the point though, the decimal is within the operation and you don't round numbers before the end of the operation, and that IS a mathematic rule, hence why you get 10 in google.
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 01:43 PM
Originally Posted by dwig
No idea what the calculation gibberish is there for, but if your dexterity is 18 and the number rolled on 1D6 is 4 then 8 is the correct damage.

Hi Dwig, no need to understand if it's too hard for you. Just open a browser on google and paste the operation from the screenshot showing the damage:
4 * ((4 - 1)/2 + 1)

See the answer it returns, provide your observation. good luck.
Posted By: daMichi Re: The Rogue - Maths are WRONG - 23/01/21 02:21 PM
Larian calculates the Sneak Damage wrong.

For 4th level a rogue should get +2d6 sneak damage once a turn.

So let's assume your rogue is lvl 4 and has 18 Dex.

So for the damage, if you are hitting a target with a dagger (1d4 piercing) and are eligible for a sneak attack, the damage should be:

1d4 + 4 (ability modifier bonus) + 1d6 + 1d6

The last two +1d6 are of course the 2d6 sneak attack damage bonus.
Posted By: DiDiDi Re: The Rogue - Maths are WRONG - 23/01/21 02:22 PM
Originally Posted by Starlights
Quote
As far as I can tell under D&D 5E rules, you ALWAYS round down any time you get a fraction. Even if the fraction is 0.9, you round it down.
Please quote that rule here. And if true, then, it means D&D doesn't understand math.

There's one more general rule you need to know at the outset. Whenever you divide a number in the game, round down if you end up with a fraction, even if the fraction is one-half or greater.

- Page 7 (Introduction) of PH 5e.

It has absolutely nothing to do with (not) understanding math. Perfectly normal for e.g. a software developer.
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 02:24 PM
@daMichi - Hi smile

Well, at least the math would be right .. and simpler. Let see how it progress with upcoming patches and version 1.0.

thanks for the inside.
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 02:30 PM
Originally Posted by DiDiDi
Originally Posted by Starlights
Quote
As far as I can tell under D&D 5E rules, you ALWAYS round down any time you get a fraction. Even if the fraction is 0.9, you round it down.
Please quote that rule here. And if true, then, it means D&D doesn't understand math.

There's one more general rule you need to know at the outset. Whenever you divide a number in the game, round down if you end up with a fraction, even if the fraction is one-half or greater.

- Page 7 (Introduction) of PH 5e.

It has absolutely nothing to do with (not) understanding math. Perfectly normal for e.g. a software developer.

Look, the operation is this: 4 * ((4 - 1)/2 + 1)

Before you think about rounding a number, or throw a D&D card rule on the table, you run the operation as-is. Once you get "the final answer" then you can add whatever gaming rules that pleases you.

And that's how it should be treated by a compiler - at least that's how google treats it.
Posted By: daMichi Re: The Rogue - Maths are WRONG - 23/01/21 02:35 PM
I don't quite get the formula they are using.

Why 1d6 * ((level - 1)/2 + 1) ?

The amount of Sneak Attack damage would be (Level/2 rounded UP) * d6

And you ADD that to your weapon damage, not multiply the weapon damage roll with it ...
Sorry, I am too stupid to understand the formula.

Can somebody explain?
Posted By: daMichi Re: The Rogue - Maths are WRONG - 23/01/21 02:38 PM
If the compiler only works with integers, not with float numbers (as you would use them in C), then it just drops everything after the decimal point.
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 02:47 PM
@daMichi,

The rational as why using this formula will have to come from the dev.

But to explain some of it, it goes as follow:

This is sneak attack, and it looks like your dex modifier doesn't count here. So the formula, as disclose by the log goes like this:

weapon damage X * (((level -1)/2) + 1)
- The parenthesis after 2 is assumed to be there before you go to addition/soustraction;
- The block with the parenthesis is to be solved before the multiplier of the weapon damage integer.
Posted By: daMichi Re: The Rogue - Maths are WRONG - 23/01/21 02:56 PM
I know. And if a compiler stores a number in a variable which classified as integer, then only the numbers before the decimal point get stored.

So my variable DMG is an integer in C.

I calculate something, and the result is 3.14

I store it in the variable DMG.

The next time the program calls on my variable, it will read 3.

Maybe that's what's happening here. So 2.5 becomes 2.
3.643796337899 would become 3.
And 146.953479544 would become 146.
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 03:21 PM
Well with C, if you use the math.h library with "%.2f" format, you will get the decimal you need in your program.

I don't think they'll be a viable reason for justifying 4 * ((4 - 1)/2 + 1) = 8 instead of 4 * ((4 - 1)/2 + 1) = 10. smile
Posted By: SinisterDeath Re: The Rogue - Maths are WRONG - 23/01/21 04:00 PM
Assuming your character is 4th level, you should have 2d6 sneak attack damage, added on top of your regular damage 1d6 damage roll. It should look like (1d6+4)+(2d6). Generally the number of sneak attack dice you get is level/2 rounded UP.

So when I look at what they're trying to do.

Roll result 4(1d6)*((4-1)/2+1)=8

I read it like this.
They rolled a 4 on the weapons 1d6. They're then going to use that same result on all the subsequent sneak attack dice
So if we look at the first part, they rolled a 4 on their weapon damage.

The next set is trying to calculate the number of sneak attack dice.
(4-1)=3
3/2=1.5
1.5+1=2.5
They have to have rounded the result from 2.5 to 2, in order for the result to be 8.


Now wait.
If you're level 4, you should have 2 sneak attack dice, right? (The above formula also works for higher levels. 9 results in 5d6)
1(d6)+2(d6), and d6=4, the result should be 12, not 8.

So the mathematical error I'm seeing is...they subtract 1, divide, then add the 1 back.

If this is supposed to roll 1 dice, and then multiply by the total number of dice, then they should be adding only 1.

Roll result 4.
4*((4/2)+1)=12

Even then, that's actually not correct because we should be adding our dex modifier to our regular damage.
So it should be
4*((4/2)+1)+4=16



----EDIT----

New info
So, I just pulled up the game, and had Astarion sneak attack someone.
I saw two entries for damage.
1 Weapon damage. (1d6+DEX MOD)
and
Sneak Attack damage

Since they aren't actually combining all the damage from regular attack & sneak attack, the math checks out.
I rolled a 1 on my weapon damage, +2 for 3 damage.
And my sneak attack rolled a 4, so I did 4 damage.
Posted By: dwig Re: The Rogue - Maths are WRONG - 23/01/21 04:04 PM
Originally Posted by Starlights
Originally Posted by dwig
No idea what the calculation gibberish is there for, but if your dexterity is 18 and the number rolled on 1D6 is 4 then 8 is the correct damage.

Hi Dwig, no need to understand if it's too hard for you. Just open a browser on google and paste the operation from the screenshot showing the damage:
4 * ((4 - 1)/2 + 1)

See the answer it returns, provide your observation. good luck.

I understood the numbers quite well (physics phd and all), what I do not understand is WHY they are being used. The 5E calculation for damage is weapon die + stat modifier for most hits (there SHOULD be no stat modifier on off hand hits, but BG3 does not follow this rule).

For a sneak attack there should simply be more dice. A level 4 rogue that hits with a valid sneak attack should roll 2D6 and add that to whatever the rest of their hit was. The equation appears to be a multiplier, but there are no multipliers like that in 5E that I am aware of. The hit was not critical, and even if it were the correct procedure would be to roll all damage dice twice (not apply some strange multiplier).

So the equation simply does not follow any rule for 5E that I am aware of.

As an aside regarding round off conventions... it is not all that uncommon to simply drop the fraction, depending on your goal. For instance, if you want to calculate the appropriate number of sneak attack dice then the equation (level -1)/2 + 1 will actually work, IF you drop fractions (this equation would then start at 1 die at level 1, and add a die on every subsequent odd level, which is exactly how it is supposed to work). In fact my best guess is that this is indeed what that equation means... but it is horribly formatted.
Posted By: daMichi Re: The Rogue - Maths are WRONG - 23/01/21 04:13 PM
Yeah it really looks like Larian multiplies the weapon damage die with the number of Sneak Attack dice you get as a rogue at a certain level.

That would explain the notion behind that formula.

*Sigh* another thing that supports that Larian doesn't want to use DnD rules.
It's not like the rules for sneak attack damage would be very complicated, but they just didn't want them in the game.
As to why, I really would like to know.
Posted By: spectralhunter Re: The Rogue - Maths are WRONG - 23/01/21 04:25 PM
Originally Posted by daMichi
Yeah it really looks like Larian multiplies the weapon damage die with the number of Sneak Attack dice you get as a rogue at a certain level.

That would explain the notion behind that formula.

*Sigh* another thing that supports that Larian doesn't want to use DnD rules.
It's not like the rules for sneak attack damage would be very complicated, but they just didn't want them in the game.
As to why, I really would like to know.

I have no idea. Could it be a lazy coding thing? Mind you I don’t have a clue about coding so I could be totally off base.

Is it simpler to use a set equation throughout all levels instead of having to add a die to damage as rogues level up? And does this mean they will be using this type of equation for other classes and their abilities that scale up?
Posted By: daMichi Re: The Rogue - Maths are WRONG - 23/01/21 04:35 PM
Maybe it's a bug, not a feature. We simply don't know,

They calculate the number of Sneak attack dice per level, they just need to set that number to roll that number of 6 sided dice.
It's not that complicated, at least in my opinion.

But I am completely with you here spectralhunter, I also don't know a thing about coding apart from 'Hello world', so I am not in a position to really tell.

I don't know if they use it somewhere else.
My PC broke down before Christmas and I wasn't able to build a new one till now (waiting on the graphics card).

But once again I have a PC I want to play BG3 and have a good look at stuff like this.
Posted By: dwig Re: The Rogue - Maths are WRONG - 23/01/21 05:07 PM
So, my recollection of sneak attack when I played in December... whenever I connected with a sneak attack there would be two damage numbers floating by. I assumed at the time that one was the weapon damage and the other was the sneak attack damage.

IF that is correct, and IF the equation reported by Starlights is JUST the sneak attack portion, then what we have in this equation is a correct calculation of the number of dice, but an incorrect application of that number as a multiplier.

They appear to be taking the result of a single D6 and multiply it by the number of dice. This will give the same range of results as the correct procedure of just rolling extra dice, but it will be a flat distribution rather than a bell curve (meaning that extreme values, both high and low, are more likely). I suppose this isn't the worst thing in the world, but I don't know why they can't just roll the dice more times, there is no way that this "short cut" saves a meaningful amount CPU relative to just doing it correctly.
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 05:20 PM
No no guys, we are sidetracking a bit from the point.

When it comes to mathematics with Arithmetic, the answers should be cut & dry.

Although, I will concede 1 point, since it's a game.

Also, at this point, I don't really care about the level 4 rogue should get 2D6 or 5D10 or a 100D20s. I leave that to Larian & D&D 5th edition. Although our feedback on that should reach them for what's it's worth.

Now to my point, look here:
[Linked Image from i.imgur.com]

Without having to re-write the operation, within the operation, you don't round number, period. That's a math rule. BUT the output of the operation, THAT you can apply that D&D rule about removing the decimal - I concede that point.

As level 4, I would have roll any odd numbers for the "1D6 piercing" and the output would have been with a decimal.

Ex.:
Say I roll 5 instead of 4:
5 * ((4 - 1)/2 + 1) = 12.5 --> ok throw the D&D card and make it 12 instead of 13. I walk away as a player, unhappy of losing 1 point of damage and that's it, no big deal.

Now the part in the middle of the math operation "((4 - 1)/2 + 1)" CAN NOT be rounded until the operation is complete.

Is my point clearer now ?
Posted By: daMichi Re: The Rogue - Maths are WRONG - 23/01/21 05:35 PM
Originally Posted by dwig
So, my recollection of sneak attack when I played in December... whenever I connected with a sneak attack there would be two damage numbers floating by. I assumed at the time that one was the weapon damage and the other was the sneak attack damage.

Is it possible you attacked with dual wield?
There is (was?) a toggle on lower left side to attack with both weapons, this was by default on. That would explain the two damage numbers.

And IF it was the sneak attack portion, then ... meh ... I would prefer actually rolling a certain number of dice, not just one and then multiply it with a number.

Which again leads me to wonder, if Larian does this in purpose because they do not understand what 5d6 means, or do they want a flat distribution? Which would mean more variation than a Gaussian distribution (I hope I use the term variation in the correct mathematical sense here).

Anyway, it very much seems that you are correct @dwig
Posted By: daMichi Re: The Rogue - Maths are WRONG - 23/01/21 05:40 PM
Originally Posted by Starlights
No no guys, we are sidetracking a bit from the point.

When it comes to mathematics with Arithmetic, the answers should be cut & dry.

Although, I will concede 1 point, since it's a game.

Also, at this point, I don't really care about the level 4 rogue should get 2D6 or 5D10 or a 100D20s. I leave that to Larian & D&D 5th edition. Although our feedback on that should reach them for what's it's worth.

Now to my point, look here:
[Linked Image from i.imgur.com]

Without having to re-write the operation, within the operation, you don't round number, period. That's a math rule. BUT the output of the operation, THAT you can apply that D&D rule about removing the decimal - I concede that point.

As level 4, I would have roll any odd numbers for the "1D6 piercing" and the output would have been with a decimal.

Ex.:
Say I roll 5 instead of 4:
5 * ((4 - 1)/2 + 1) = 12.5 --> ok throw the D&D card and make it 12 instead of 13. I walk away as a player, unhappy of losing 1 point of damage and that's it, no big deal.

Now the part in the middle of the math operation "((4 - 1)/2 + 1)" CAN NOT be rounded until the operation is complete.

Is my point clearer now ?

Yes, you are mathematically correct.

Why the result differs from the correct one, is what was discussed.

Larian uses the part with the word 'level' in it to just determine the number of Sneak attack dice, or so it seems.
So that equation you see is not everything that is calculated and stored as a variable.

You know what I mean?
Sorry, English is not my native language, and sometimes I am rather clumsy in expressing myself.
Posted By: dwig Re: The Rogue - Maths are WRONG - 23/01/21 05:59 PM
The order of operations convention that you are quoting is a common convention, but it is JUST a convention, not a hard law of nature. Larian should probably change the printout if they want to effectively communicate what is going on in the log, but I do not think that it is evidence that they are math impaired. They are probably just using a different convention for handling the rounding, without explaining that this is what they are doing.

It is a communication failure, not a math failure.
Posted By: Ayvah Re: The Rogue - Maths are WRONG - 23/01/21 07:09 PM
Personally, after some experience with programming, I've started to believe that BODMAS/PEMDAS is a bad convention.

I prefer a simple left to right convention for order of operations.

Originally Posted by daMichi
But I am completely with you here spectralhunter, I also don't know a thing about coding apart from 'Hello world', so I am not in a position to really tell.
Computers are really good at maths. smile

This is not a programming limitation. It's the way it's been programmed.

I'm not going to be able to say whether or not there's a mistake though.
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 07:11 PM
@daMichi, yes, we are on the same page.

And your english is excellent. smile
Posted By: Starlights Re: The Rogue - Maths are WRONG - 23/01/21 07:26 PM
Originally Posted by Ayvah
Personally, after some experience with programming, I've started to believe that BODMAS/PEMDAS is a bad convention.

I prefer a simple left to right convention for order of operations.

haha, you're funny.

ok, we can move on, I made my point.
Posted By: Dexteruse Re: The Rogue - Maths are WRONG - 23/01/21 07:37 PM
The calculation ((Level - 1) / 2 + 1) being number of sneak attack D6s is correct and must be natural number (1..10). Why it looks like this is weird (maybe a dev overthought the formula, it happens, maybe float and rounding shenanigans made it necessary) but if you expand it's really ((Level + 1) / 2) which translates to "half your level rounded up".

This formula only works if the result is rounded. Otherwise it does not match 5E rules for number of sneak attack dice. Of course they roll once and multiply by number instead of rolling a number of times.
Posted By: SinisterDeath Re: The Rogue - Maths are WRONG - 24/01/21 05:14 AM
Originally Posted by daMichi
Originally Posted by dwig
So, my recollection of sneak attack when I played in December... whenever I connected with a sneak attack there would be two damage numbers floating by. I assumed at the time that one was the weapon damage and the other was the sneak attack damage.

Is it possible you attacked with dual wield?
There is (was?) a toggle on lower left side to attack with both weapons, this was by default on. That would explain the two damage numbers.

And IF it was the sneak attack portion, then ... meh ... I would prefer actually rolling a certain number of dice, not just one and then multiply it with a number.

Which again leads me to wonder, if Larian does this in purpose because they do not understand what 5d6 means, or do they want a flat distribution? Which would mean more variation than a Gaussian distribution (I hope I use the term variation in the correct mathematical sense here).

Anyway, it very much seems that you are correct @dwig

In my earlier post I confirmed what was happening via edit.

The game is in fact, making two damage calculations. 1 for weapon damage, and one with sneak attack. Meaning, if you scroll up in your combat log, you'll see
1. "Piercing" damage1d6+Dex damage - Weapon Damage
2. "Piercing" damage, with that above complex formula - Sneak Attack
Posted By: daMichi Re: The Rogue - Maths are WRONG - 24/01/21 09:22 AM
Thanks for clearing that up (for me 😊 )!
© Larian Studios forums