Page 2 of 6

### Re: Resting outside is nearly always interrupted

Posted: 12 May 2015, 18:44
scrawl wrote:The patch changes the mechanic drastically, because the roll is now an integer.
As written, all this does is discretize the probability of interruption. Even if you use rollDice(hoursToWait+1) to return an integer in [0,hoursToWait], forcing the roll to be an integer works the same as only rolling multiples of 1/hoursToWait and checking against fSleepRandMod.

Examples, with rollDice(hoursToWait+1):
• hoursToWait=1, the options are 0 or 1, so you can only ever be over or under fSleepRandMod. Probability of interruption is 50%.
• hoursToWait=2, the options are 0, 1, or 2; fSleepRandMod is multiplied by hoursToWait so now we are comparing against a float between 0 and 2. If fSleepRandMod is between 0 and 0.5, interruptions occur 33% of the time. If it's between 0.5 and 1, interruptions occur 66% of the time.
• hoursToWait=3, 0<fSleepRandMod<0.33, interruptions 25% the time. Increasing in 25% steps.
With rollDice(hoursToWait), the hoursToWait=1 gives 0% interruptions, hoursToWait=2 gives 50% or 100% depending on if fSleepRandMod is above or below 0.5. Even worse.

I don't think this is how the mechanic was intended to work. Why not check rollProbability() against fSleepRandMod for each hour rested?

### Re: Resting outside is nearly always interrupted

Posted: 12 May 2015, 21:23
Mesons wrote:With rollDice(hoursToWait), the hoursToWait=1 gives 0% interruptions
I agree with Mesons, I don't this this is how the mechanic was intended to work. Otherwise, you can just rest for a number of one hour periods and never get interrupted. Seems like an exploitable bug in the game mechanics.

### Re: Resting outside is nearly always interrupted

Posted: 12 May 2015, 21:33
scrawl wrote:
In a 24-hour MW sleep interval, I seem to have a one in four chance of getting attacked.
Confirmed. Whereas the current OpenMW formula would have an attack chance of 17 / 24 = ~70% for a 24-hour rest with the default GMSTs.
I wonder if the probability is inverted.
70% chance of being disturbed = 30% chance of not being disturbed.

If we assume probably is inverted, then would have
70% chance of sleeping, 30% chance of being disturbed.
Which is pretty close to the measured values for vanilla. (75%/25%)

### Re: Resting outside is nearly always interrupted

Posted: 12 May 2015, 22:06
Wouldn't that force you to get attacked for 1hr intervals?

It's already known that you can get attacked for 1hr intervals. So whatever rounding there needs to allow for that to happen, otherwise something's wrong.

### Re: Resting outside is nearly always interrupted

Posted: 12 May 2015, 22:25
In vanilla morrowind (with a mod to change the one setting):

I set fSleepRandMod to 1 and it seems to make it so that all sleep times above a certain value (right around 4, sorry, forgot the exact one) always result in an encounter, and ones below it do not.

(Note: when I first loaded, the RNG seemed to be different? Maybe it was using an old value, or maybe it's tracking some variable across sleeps as a kind of wc3-style PRNG?)

Later, I set it to 0 and that seems to result in never getting attacked.

### Re: Resting outside is nearly always interrupted

Posted: 12 May 2015, 22:39
Regardless of how it worked in vanilla, shouldn't OpenMW have predictable behavior aligned with the intended function?

### Re: Resting outside is nearly always interrupted

Posted: 12 May 2015, 22:40
OpenMW's 1.0 goal is to replicate vanilla gameplay as exactly as is possible, so we should at least get this right. A hotpatch might put off getting it right until later.

### Re: Resting outside is nearly always interrupted

Posted: 12 May 2015, 23:52
wareya wrote:In vanilla morrowind (with a mod to change the one setting):

I set fSleepRandMod to 1 and it seems to make it so that all sleep times above a certain value (right around 4, sorry, forgot the exact one) always result in an encounter, and ones below it do not.

(Note: when I first loaded, the RNG seemed to be different? Maybe it was using an old value, or maybe it's tracking some variable across sleeps as a kind of wc3-style PRNG?)

Later, I set it to 0 and that seems to result in never getting attacked.
Congratulations, you've confirmed my hypothesis that we've got the logic inverted.
Here's the code.

Code: Select all

``````                    if (x > fSleepRandMod * hoursToWait)
{
float fSleepRestMod = world->getStore().get<ESM::GameSetting>().find("fSleepRestMod")->getFloat();
mInterruptAt = hoursToWait - int(fSleepRestMod * hoursToWait);
``````
With this code, a fSleepRandMod value of 0 indicates always attacked, and 1 indicates never attacked.
If we invert the inequality in the if, then we get 1 = always attacked, and 0 = never attacked. Which matches your experimental results.

### Re: Resting outside is nearly always interrupted

Posted: 13 May 2015, 01:18
wareya wrote:OpenMW's 1.0 goal is to replicate vanilla gameplay as exactly as is possible, so we should at least get this right. A hotpatch might put off getting it right until later.
I meant replicating the behavior of vanilla, sans bugs and errors (leaving open the possibility that rest interruption in vanilla has bugs).

So, in vanilla, is the probability of interruption always 25% regardless of hoursToWait, or does it increase with time rested? Let's get the statistics right, at least. If it's 25% per hour, rolling a random float [0,1) greater than 0.25^hoursToWait is an interruption. If it scales weirdly, then it may be hard to match vanilla's behavior without the original coding or collecting a lot of data.

### Re: Resting outside is nearly always interrupted

Posted: 13 May 2015, 01:52
It's around 25% on 24 hours. It's less likely at 1 hour, but can still happen.

Normally I'd be in favor of fixing obvious bugs, not morrowind doesn't exactly have a comprehensive design document, and even if it does, Hard Numeric Mechanics like this have to be replicated exactly.

Except for pickpocketing with literally doesn't work and even the MCP fixes. Targeting MCP is another option rather than vanilla GOTY MW.