Jump to content

Range of probability 1 and 2


testlum

Recommended Posts

I'd like to make a small tweak for the Mind Flayer's Devour Brain "attack" item to drain 1-5 INT instead of a static 5. This is what I have in mind:

Effect 1: -1 INT, prob1 = 0, prob2 = 19

Effect 2: -2 INT, prob1 = 20, prob2 = 39

and so on. Is this a correct assumption that the full range is 0-99, or should it be 1-100 instead?

Link to comment

If the game pauses on exactly the wrong frame - which is most common with "auto-pause on spell cast" - the effects of a spell/item that happen on exactly that frame are decoupled. Instead of all using the same random numbers for stuff probability and saves, each effect is rolled separately. So, for your original idea, that's a 20% chance of -1 INT, another independent 20% chance of -2 INT, another independent 20% chance of -3 INT, and so on. You'd get the same average INT loss of 3, but the actual value could be anything from 0 to 15.

The alternate form CamDawg suggests here would still be bugged if the effects got decoupled, but with a much milder effect of squishing the values together instead of spreading them out. INT loss would always be in the 1-5 range, but with a <4% chance of 1, a >43% chance of 3, and a <4% chance of 5 instead of the intended uniform distribution.

Link to comment
52 minutes ago, jmerry said:

If the game pauses on exactly the wrong frame - which is most common with "auto-pause on spell cast" - the effects of a spell/item that happen on exactly that frame are decoupled.

Also "auto pause on hit", which is why it would be relevant for an effect block in an enemy creature's natural attack (but irrelevant for the "target gone" autopause, because that means the victim of the attack is dead anyway).

That said, I have literally never seen this bug with manual pause, only autopause, of which the only one I use is "enemy sighted" ("spell cast" is kinda cheaty, even "badly injured" makes the game easier).

If it can occur due to player pause it's the rarest of bugs, rarer for instance than the "endless spellcasting without a spell ever actually cast" thing that can occasionally be triggered by breaking line of sight for a player controlled character, and which I've never seen mentioned in the "code fixes" thread.

Edited by polytope
Link to comment
32 minutes ago, polytope said:

That said, I have literally never seen this bug with manual pause, only autopause, of which the only one I use is "enemy sighted" ("spell cast" is kinda cheaty, even "badly injured" makes the game easier).

If it can occur due to player pause it's the rarest of bugs...

I've never seen it on manual pause either; it may indeed be only possible on auto-pause. But I don't know, and the frame-perfect nature of triggering it certainly makes that difficult to verify.

Link to comment

Oh, and a bit of math on that INT drain distribution: we can find the measure known as "variance" for the various possibilities. The standard deviation is then the square root of the variance. Variance is calculated as the average of (value - mean)^2. There are lots of tricks for getting at this without doing too much work, of course.

Discrete uniform distribution on {1,2,3,4,5}: mean 3, variance (4+1+0+1+4)/5 = 2.

Original testlum suggestion with decoupling bug: this is the sum of five independent random variables. That independence means the variances add. Mean (1/5+2/5+3/5+4/5+5/5) = 3, variance (4/25+16/25+36/25+64/25+100/25) = 8.8.

CamDawg suggestion with decoupling bug: again, a sum of five independent random variables. Mean (1/5+2/5+3/5+4/5+5/5), variance (4/25+6/25+6/25+4/25+0) = 0.8.

Link to comment

This is almost certainly overkill (Cam's suggestion is fine) and just out of mathematical curiosity, but you could also do this:

- create subspells dwintd1, dwintd2, dwint3.

- The original item drains 1 INT, and then casts dwintd1with probability 80%

- dwintd1 drains 1 INT, and then casts dwintd2 with probability 75%

- dwintd2 drains 1 INT, and then casts dwintd3 with probability 67%

- dwintd3 drains 1 INT, and then drains 1 INT with probability 50%

If I did the math right, that reproduces the desired probability distribution exactly while being immune to the autopause bug (since the probabilities are all being rolled independently anyway).

Link to comment

Join the conversation

You are posting as a guest. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...