Resting outside is nearly always interrupted

Everything about development and the OpenMW source code.
User avatar
Mesons
Posts: 11
Joined: 15 Jun 2014, 23:43

Resting outside is nearly always interrupted

Post by Mesons »

Beginning recently (since April 24th, the last time I played before today), sleeping outside is interrupted something like 85-95% of the time.

I was trying to restore my magicka before entering a cave and I racked up such a huge pile of bodies I began to wonder if I would ever be able to rest uninterrupted. I thought about filing a bug report, but I'm not sure what the intended behavior is--I never played the original Morrowind--but it seems like being encouraged to sleep indoors might be somewhat intentional. Before today, resting outside was interrupted a fair bit less, but I admit I don't know what percentage of the time.

Now, even 1 hr rests are very often interrupted. Is this dependent on location? I was resting outside of a cave (Minabi) SE of Suran.
Golken
Posts: 27
Joined: 04 May 2015, 05:03

Re: Resting outside is nearly always interrupted

Post by Golken »

I think the location mostly determines what creatures can spawn, but not the chance of interruption. That is governed by a GMST (Game Setting) which can be altered by mods. So check out your loaded mods for the culprit. What you are describing should not happen so often in Morrowind, especially with 1-hour rests.
Many balance and difficulty mods are likely to alter this setting as resting anywhere can be seen as an unbalanced and abusable mechanic, so a mod you use may cause this behavior. BTB's Game Improvements will cause constant waking up in the wild, but it tries to prevent you from being able to sleep through the rest/wait button in the first place (by setting all cells in the game to be illegal to rest in).
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: Resting outside is nearly always interrupted

Post by wareya »

My testing:

Stand under a certain vine under a certain tree right outside of seyda neen with a female dark elf character. Rest 16 times with 1 or 24 hours on both engines. Same configuration of expansion packs. OpenMW using a vanilla data esp/esm set. Post results.

Morrowind, 1 hour:
Two encounters. Both were dual encounters with a random mob and an assassin.

Morrowind, 24-hour:
One dual encounter. Three mob encounters. One assassin encounter. One scrib encounter.

OpenMW, 1 hour:
No dual encounters. Seven assassin enconuters. Four mob encounters. Two scrib encounters.

OpenMW, 24-hour:
No dual encounters. Two assassin encounters. Six mob encounters. Four scrib encounters.

Results:
This isn't very statistically significant, but it implies that the issue is worth looking into. Also, do we handle assassins the way Morrowind does?
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Resting outside is nearly always interrupted

Post by scrawl »

Good catch, fixed. This should work in 0.35.1, only the master branch was broken.
Also, do we handle assassins the way Morrowind does?
Assassins are scripted. If there are differences here then the problem would be in the getPcSleep / wakeUpPc script functions. I'm not aware of any differences though.
Golken
Posts: 27
Joined: 04 May 2015, 05:03

Re: Resting outside is nearly always interrupted

Post by Golken »

Yeah, the behavior Mesons is getting does not sound like it should happen, unless a mod altering the relevant GMST(s) is loaded. I may be mistaken, though. Additionally, maybe my hunch is wrong and the rate does depend on the area / local levelled list...
Just tested outside Seyda Neen in original engine, sometimes were interrupted but I could also get some full 24-hour rests without interruption. Probably wasn't in quite the same area as you were, if it matters.

By the way, assassins are a separate Tribunal feature but are implemented in the same manner as a mod would've done (through a script) and so have nothing to do with sleep interruption mechanics (they're done through a leveled list in the cell you are in spawning hostile creatures). Assassins can happen anywhere (except the Census and Excise Office) you sleep, even in odd and totally out of the way places where nothing spawns.

Damn it, ninja'd! :D
User avatar
Mesons
Posts: 11
Joined: 15 Jun 2014, 23:43

Re: Resting outside is nearly always interrupted

Post by Mesons »

Irrelevant now that Scrawl has fixed it, but I'm not running any mods. Thanks for collecting the data sample, Wareya!
dteviot
Posts: 144
Joined: 17 Dec 2014, 20:29

Re: Resting outside is nearly always interrupted

Post by dteviot »

@scrawl
scrawl wrote:Good catch, fixed. This should work in 0.35.1, only the master branch was broken.
Are you sure that fix works?
I think your change has the same probability distribution as the previous version, it's just more complicated (you're just multiplying both sides of the inequality by the number of hours sleeping).
User avatar
Mesons
Posts: 11
Joined: 15 Jun 2014, 23:43

Re: Resting outside is nearly always interrupted

Post by Mesons »

Looking at the patch, it seems like fSleepRandMod is a probability; multiplying it by hoursToWait defines a threshold between 0 and hoursToWait. I'm guessing rollDice(hoursToWait) returns a random number in the same range (0 to hoursToWait? 1 to hoursToWait? Something else?).

I think dteviot is right, why not just generate a random probability and check it against fSleepRandMod? How is rollDice different from rollProbability? It doesn't seem like resting for more than 1 hour would increase the rate of interruption, unless fSleepRandMod is greater than 50% and rollDice(x) returns only integers from 0 to x inclusive. If fSleepRandMod is intended to be the probability that each passing hour incurs an interruption, the probability of interruption should be
1 - fSleepRandMod^hoursToWait.
User avatar
wareya
Posts: 338
Joined: 09 May 2015, 13:07

Re: Resting outside is nearly always interrupted

Post by wareya »

I did stats again.

In a 24-hour MW sleep interval, I seem to have a one in four chance of getting attacked. I disabled tribunal and bloodmoon and stood under the same fine. I slept 32 times. I was attacked 1ce by a rat, 3 times by foragers, and 4 times by scribs.

1-hour interval in MW seems to scale strongly. I slept 16 times and wasn't attacked once.

This is original research and easily wrong, but getting attacked eight times out of 32 makes me think that fSleepRandMod is the likelyness of getting attacked if you sleep for a 24-hour interval, and shorter than that scales with how long the sleep is; though I have no insight on the manner of scaling they would use.

In the latest RC (via viewtopic.php?f=20&t=2771&start=60) for OpenMW, I was only not attacked once in a 16-sleep 24hr test. I cut it off at 16 because of that.

However, OpenMW 1hr sleeps only got me attacked zero times in 16 tests.

Fun fact: 24-hour sleep was always interrupted at the 17th hour.

If the OpenMW code accurately reflects the research on the wiki, I would re-reverse-engineer this.
User avatar
scrawl
Posts: 2152
Joined: 18 Feb 2012, 11:51

Re: Resting outside is nearly always interrupted

Post by scrawl »

Are you sure that fix works?
I think your change has the same probability distribution as the previous version, it's just more complicated (you're just multiplying both sides of the inequality by the number of hours sleeping).
The patch changes the mechanic drastically, because the roll is now an integer.

Example, with hoursToRest = 1, fSleepRandMod = 0.25:

x = rollProbability() = floating point number in the range [0, 1)

if (x > fSleepRandMod)
<=> if (x > 0.25)

will evaluate true 75% of the time.

After the change:

x = rollDice(1) = 0
rollDice(1) returns an integer up to but not including 1, i.e. always 0.

if (x > fSleepRandMod * hoursRested)
<=> if (0 > 0.25)

will always evaluate false.
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'll ask Hrnchamd about this.
Post Reply