SANDBOX — this is a test environment. No servers are actually deployed and no real payments are charged.
Back to NxLabs

NxLabs / Vintage Story

Struggle To Sleep

FBy Frepo

Not snuggle, STRUGGLE! You can only sleep if certain conditions are met.

Description

<h3><strong>Sleep conditions</strong></h3> <p>This mod establishes some rules for sleeping. You can't sleep if....<br /><strong>1.</strong> ...<strong>you are wet</strong> (wetness).<br /><strong>2.</strong> ...<strong>you are too cold</strong> (body temperature)<br /><strong>3.</strong> ...<strong>you are starving</strong> (satiety at 0)<br /><strong>4.</strong> ...<strong>hostile creatures are near</strong> (drifters, shivers, wolves, bears etc.)</p> <h3><strong>Beds can break</strong></h3> <p>The straw bed has a 25% chance to break after use, the aged wooden bed has a 10% chance, other beds can't break (by default).</p> <h3><strong>Beds are VERY heavy/cumbersome to carry</strong></h3> <p>All beds except the straw bed will slow you down significantly (-80% walk speed).</p> <h3><strong>Better beds = warmer beds</strong></h3> <p>A simple little mechanic that gives beds a <strong>warmthBonus</strong> attribute that is added to your body temperature for the cold-condition check.<br />I've patched the vanilla beds' <strong>attributesByType</strong> to provide the warmth bonus (straw bed +0℃, aged bed +1.5℃, bed +3℃, cozy bed +4℃, comfy bed (from <span style="color: #2880b9;"><a style="color: #2880b9;" href="https://mods.vintagestory.at/show/mod/48158" target="_blank" rel="noopener">Comfy Beds</a></span>) provides +6℃)<br />Here's the patch for vanilla beds if you want to patch other beds.</p> <div class="spoiler"> <div class="spoiler-toggle">Spoiler!</div> <div class="spoiler-text"> <pre>{<br /> "file": "game:blocktypes/wood/bed.json",<br /> "op": "addmerge",<br /> "path": "/attributesByType",<br /> "value": {<br /> "bed-wood-*": {<br /> "warmthBonus": 3.0<br /> },<br /> "bed-woodaged-*": {<br /> "warmthBonus": 1.5<br /> },<br /> "bed-village-*": {<br /> "warmthBonus": 4.0<br /> },<br /> "*": {<br /> "warmthBonus": 0<br /> }<br /> }<br />}</pre> </div> </div> <h3><strong>- Config file breakdown</strong> (<em>StruggleToSleepConfig.json</em>)<strong> -</strong></h3> <p>&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;Default values<br />"<strong>WetnessPreventsSleep</strong>": <strong>true</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(set to 'false' to ignore wetness)<br />"<strong>ColdPreventsSleep</strong>": <strong>true</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (set to 'false' to ignore cold)<br />"<strong>MobsPreventsSleep</strong>": <strong>true</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (set to 'false' to ignore nearby hostiles)<br />"<strong>HungerPreventsSleep</strong>": <strong>true</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(set to 'false' to ignore hunger)<br />"<strong>BedsCanBreak</strong>": <strong>true</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(set to 'false' to disable bed-breaking)<br />"<strong>DisableSleeping</strong>": <strong>false</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(set to 'true' to prevent sleeping altogether... I know, that's just crazy)<br />"<strong>MaxWetnessLevelToSleep</strong>": <strong>0.1</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (sleeping is prevented if your wetness level is above this value, range: 0 - 1)<br />"<strong>MinBodyTemperatureToSleep</strong>": <strong>36.1</strong>,&nbsp; (sleeping is prevented if your body temperature is below this value)<br />"<strong>CarryBedSlowdown</strong>": <strong>-0.8</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(-0.8 = -80% walk speed while carrying a bed, range -1 - 0, set this to 0 if you wanna carry beds as normal)<br />"<strong>HostileEntityCheckRadius</strong>": <strong>16</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(radius in blocks that is checked for hostile creatures)<br />"<strong>StrawBedBreakChance</strong>": <strong>0.25</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;(chance for the straw bed to break, 0.25 = 25%)<br />"<strong>AgedBedBreakChance</strong>": <strong>0.1</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (chance for the aged wooden bed to break, 0.1 = 10%)<br />"<strong>OtherBedsBreakChance</strong>": <strong>0.0</strong>,&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; (chance for all other types of beds to break, 0 = 0%)</p> <p>"<strong>HostileEntityCodes</strong>": [ ]&nbsp; &nbsp; --- This is a list of entity <strong>codes</strong> that will be considered hostile. You can add your own if you know the code.<br />&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;<em>Example - Make hares prevent sleeping</em>: Goto <strong>Vintagestory\assets\survival\entities\animal\mammal\hare-adult.json</strong>, look for <span style="background-color: #9dddf9;"><strong>code: "hare"</strong></span> (it's the very first line), put <strong>hare</strong> in the list. done.</p> <p>"<strong>HostileEntityTags</strong>": [ ]&nbsp; &nbsp; &nbsp; &nbsp;--- The mod also checks creature's <strong>tags</strong>. Works the same as code, just put a tag in the list, look for the line <span style="background-color: #9dddf9;"><strong>tags: ["rust-creature", "habitat-land"]</strong></span> (example) in the entity's json-file.</p> <h3><strong>- Compatibility -</strong></h3> <p>The mod should work on all beds that are based on the vanilla <strong>BlockBed</strong> (<span style="background-color: #9dddf9;">[HarmonyPatch(typeof(BlockBed), "OnBlockInteractStart")] </span>).<br />Added some entity codes to the config default for some creatures from <span style="color: #8e44ad;"><em>Feverstone Wilds</em></span> and <span style="color: #8e44ad;"><em>Primitive Survival</em></span> since I always play with those mods, and added some from

Ratings & reviews

No ratings yet

Sign in to leave a rating or comment.