Files
LonaRPG-Online-Games/ModScripts/_Mods/LonaCraft/docs/RESEARCH_REST.md
T
2026-10-29 21:59:06 +04:00

22 KiB

Rest tiers, food and bath on sleep (board R12 + R14) - research and design

Status: research done, design PROPOSED (2026-10-06). Owner decisions taken as fixed: ground poorer and riskier than a Bedroll; a Bed inside walls = full rest; a Bed does NOT refill food by itself (only the inn does); a COOKED dish in a chest inside the walls -> eat one meal from the chest and get the inn's food refill; something to bathe with inside the walls -> sleeping cleans Lona like the inn.

Paths: G/ = LonaRPG/Data/, E/ = G/Scripts/Editables/, F/ = G/Scripts/Frames/, M/ = LonaCraft_dev/LonaCraft/Scripts/. All line numbers from B.0.10.8.26 and the dev copy as read today.

1. Facts: how a nap works today

1.1 Entry points (all end in one funnel)

Path What runs File:line
Bed / Bedroll piece, action "Sleep" lonacraft_furniture_action(:sleep) -> load_script(Command_AreaNap.rb) M/90_Furniture.rb:1125-1127, :169
Game's own camp bed ("PlayerBed", Action_BuildCamp) summons PlayerBed, which runs Command_AreaNap.rb G/HCGframes/Action_BuildCamp.rb:12-16; Map001 holds the one Command_AreaNap.rb string
Command_AreaNap.rb, choice "Sleep" napEventId.nil? ? handleNap : $game_map.call_nap_event G/HCGframes/Command_AreaNap.rb:69-75
Nap skill with Shift (sleep anywhere = GROUND) BasicNap summons EffectMCBasicNap, autorun -> Command_Nap.rb E/480_EventCharacterBatch.rb:1983-2013; G/HCGframes/Command_Nap.rb:2-10
Field / base map NapEvent region_map_wildness_nap -> roll region_map_wildness_nap_stats (OnRegionMap >= 1) -> handleNap E/34_Functions_RegionMap.rb:1645, :1832-1833
Home with no NapEvent (shack, stone house) Command_AreaNap.rb -> handleNap directly M/100_Homes.rb:65-67
Inn room (rented) NapEvent -> NoerTavern_Nap.rb (redirected with keys counted held) -> handleNap M/100_Homes.rb:1367-1387; G/HCGframes/event/NoerTavern_Nap.rb:129-136
Deep Sewer its own NapEvent lonacraft_sewer_nap -> Sewer.nap_roll (35 % day / 60 % night) -> handleNap M/130_Sewer.rb:97-98, :380-396, :618-626
Funnel handleNap: NPC nap changes, pre_nap, $game_map.nap (date shift), $game_player.actor.process_nap_change, $game_map.setup, spriteset, check_wakeup_event F/Game_InterpreterModifies/Game_Interpreter_Modifies_OM.rb:12-47 (actor :23, setup :24, wake :42)
Refusals (raid running) call_nap_event and region_map_wildness_nap aliases return early M/120_Raids.rb:1461-1470, :1485-1494, :1338-1345

Every nap that changes Lona's stats goes through Game_Actor#process_nap_change exactly once (E/97_Game_Actor_Stats&State&Nap.rb:63), called only from handleNap (OM.rb:23). The danger roll runs BEFORE handleNap (34_Functions_RegionMap.rb:1832-1833).

1.2 What a plain nap does to Lona (vanilla)

Stat (range, E/94_Game_Actor_Stats.rb:233-236) Nap change File:line
Stamina (-100..100) += 20+rand(20)+sat TWICE (once in process_nap_change, once in update_nap_sat_vs_health_and_sta) E/97:75, :164
Health (-100..200) += -20 + 0.6*sat (sat before the drop; negative = hunger damage) E/97:166-172
Satiety (0..100) -= 18 (WeakSoul 15, captured WeakSoul 12), -= 12 more on Hardcore, -= 3+2*preg when pregnant E/97:177-183, :84
Dirt (0..255) += 26 every nap; DirtState stack = dirt/100 (max 2) E/97:86, :435-438, :447; G/Effects/States/DirtState.json
Mood (-100..100) from satiety after the drop: 0 -> -30, <=10 -> -20, 20 -> 0, >=20 +10, >=40 +20, >=80 +30; Pessimist -20 E/97:192-200
Daily states one stack of each daily state removed (FeelsSick is daily) E/97:90-91, :389-404
Rot Hardcore only, Lona's bag + boxes 65533/65535; mod chests (66000+) never rot E/97:128-135; M/90_Furniture.rb:166

RolePlayS replaces process_nap_change: stamina is added ONCE (+= 20+rand(20)+sat), rest the same (ModScripts/_Mods/RolePlayS/Scripts/25_Skills.rb:476-525). Campsites, CustomDifficulty and BabyProtection alias it (Campsites/10_Campsites.rb:308-315; CustomDifficulty/10_CustomDifficulty.rb:120-137; BabyProtection/10_BabyProtection.rb:81-89). => the mod must scale DELTAS measured around the call, never re-implement the numbers.

Worked example, vanilla, Lona at stamina 0, health 100, satiety 50:

Stamina Health Satiety after Mood Dirt
plain nap 100 (gain ~159, capped) 110 32 +10 +26
same at satiety 20 99 92 2 -20 +26
same at satiety 0 59 80 0 -30 +26

1.3 The inn's paid sleep (what "the inn rest" is)

NoerTavern_Nap.rb, the branch with a room key (:129-136), all BEFORE handleNap:

Step Code Effect
pay lose_item($data_items[106], 1) one Noer inn key (:130)
restore health = attr_dimensions["health"][2], sta = attr_dimensions["sta"][2] full health and stamina (:131-132)
meal sat = attr_dimensions["sat"][2] satiety to max (100) (:133); no food item is involved
bath 4.times{ load_script("Data/Batch/Command_Bath.rb") } then dirt = 0 (:134-135), see 1.4
nap handleNap the normal nap math then runs on top: sat 100 -> 82, health +40, dirt 0 -> 26, mood +30

1.4 The bath

Function Effect File:line
batch_take_bath(scale) body cum meters x(1-scale), CreamPie/MoonPie x(1-0.1*scale), mouth cleared, dirt -= dirt*scale; erases EffectWet, EffectBleedVag, EffectBleedAnal, EffectScat, Masturbationed E/480_GameActorBatch.rb:4-25
Batch/Command_Bath.rb (inn, x4) batch_take_bath(0.5) (0.25 if cuffed) + a little EXP G/Batch/Command_Bath.rb:2-6, :15-26
Inn total dirt -> 0 (forced), body cum x1/16, groin cum x0.81, the five states erased NoerTavern_Nap.rb:134-135
Water spot / Water Trough "Bathe" HCGframes/Command_bath.rb: the scene (strip, spotted check, mood loss if seen, sta -15) G/HCGframes/Command_bath.rb:6-71; M/90_Furniture.rb:170, :1128-1130

The game has no "filthy" state other than DirtState (dirt/100) and EffectWet; "smell" is dirt itself.

1.5 Sickness (the only "cold-like" state)

FeelsSick (G/Effects/States/FeelsSick.json): max 3 stacks, daily (one stack goes each nap), stamina max x0.9, stamina drain 0.3 x stacks per step (E/100_Game_Player_handle_on_move.rb:301-303). The game already gives it on a nap at satiety <= 1 on Hardcore (50 %, same JSON player_nap_get_state_when). No cold/weather state exists.

1.6 The danger roll

WildDangerous += clamp(rand(10) + WorldDifficulty/2 - survival*2, 10, 50); a group comes if WildDangerous >= rand(100) + survival (E/34_Functions_RegionMap.rb:237-245). WildDangerous persists on the map, -50 when the group is cleared (:1860), 0 on map change (E/34_Functions_ChangeMap.rb:184). The mod adds the base bonus min(10, value/10) the same way (M/120_Raids.rb:500-511). Raiders spawn only outside the walls (M/110_Bases.rb:1484-1509). Homes have no NapEvent, so no roll there.

1.7 Food: what a "cooked dish" is

The game has no "cooked" flag: dishes carry tags like RawMeat / RawPlant (for rotting) and most carry pot_data (they can go back into the pot: SopGood {"Fat":1}, SmokedMeat {"Fat":2,"SmokedMeat":1}), so neither tag nor pot_data separates dish from ingredient. The one clean source is the dark pot's recipe OUTPUTS: the live pot runs $data_AlchemyRecipes (E/29_Functions_DarkPot.rb:494-498, loaded from G/Effects/Alchemy/*.json by F/103_FileGetter.rb:526-544; the hard-coded pot in E/29_Functions_DarkPot.rb:3-290 is commented out). Food recipes live in 2000_darkPot_UniqueFoodFormula.json and 6000_darkPot_MeatAndSoups.json.

PROPOSED definition: a cooked dish = an output of a food recipe (files 2000 and 6000) whose item type is "Food" (item type from tag_main_settings.type, F/Modules/ItemConfig.rb:121-126). The inn has no meal items (the meal is sat = max, NoerTavern_Nap.rb:133), so it adds nothing to the list.

Item (item_name) Item JSON (G/Effects/Items/) Satiety Mood Side effect when eaten Default eatable from chest
ItemMeatSalad (rgss 153) food_SF_MeatSalad.json 80 +40 DailyPlusHealthy yes (*)
ItemSopGood (good soup) food_SoupLv2.json 32 +20 - yes
ItemSmokedMeat food_SmokedMeat.json 26 - - yes
ItemSopMeat (meat soup) food_SoupLv1_meat.json 16 +10 - yes
ItemSopPlant (plant soup) food_SoupLv1_plant.json 16 +10 - yes
ItemDryFood food_DryFood.json 16 - - yes
ItemSopGoodMystery food_MysticGoodCook.json 24 - FeelsSick (95 %) no (knob)
ItemSmokedMeatMystery food_SmokedMeatMystery.json 18 - FeelsSick no (knob)
ItemSopMeatMystery food_MysticCook.json 12 - FeelsSick no (knob)
ItemSopGoodHuman food_HumanGoodCook.json 32 +20 Cannibal: mood -100 no (knob)
ItemSmokedMeatHuman food_SmokedMeatHuman.json 32 - Cannibal no (knob)
ItemSopMeatHuman food_HumanCook.json 16 +10 Cannibal no (knob)
ItemSopGoodHumanMystery food_HumanMysticGoodCook.json 24 - Cannibal + FeelsSick no (knob)
ItemSmokedMeatHumanMystery food_SmokedMeatHumanMystery.json 18 - Cannibal + FeelsSick no (knob)
ItemSopMeatHumanMystery food_HumanMysticCook.json 12 - Cannibal + FeelsSick no (knob)

Not dishes (excluded): ItemJunkFood (pot output but type FoodBad, sat 1); ItemCheese (pot output of 7000_darkPot_ToolsAndOthers.json from Milk, sat 32: a processed food, not in a food-recipe file; owner choice C7); ItemDryProtein (FoodSemen); Bread, Sausage, fruit, vegetables, nuts, raw meat, fish, herbs, milk, beer (ingredients or bought goods, never pot outputs). (*) Game data bug: food_SF_MeatSalad.json:2 has "ItemOil": "ItemMeatSalad" instead of "item_name", so the name may not be registered (ItemConfig.rb:118); match it by $data_items[153].

Satiety values are the first use_item_effect entry with attribute_name "sat" and no stats_key (ItemConfig.rb:296-317; read at runtime from item.use_item_effect, F/25_Game_Actor.rb:1372-1377).

1.8 Chests, bath pieces, beds (the mod)

Piece Kind key / item Facts File:line
Bed, Dark Bed (2x2 double), Blue Bed Bed / BedDark / BedBlue :sleep, solid: Lona sleeps BESIDE it, never on it M/90_Furniture.rb:76-78, :600-605
Bedroll kind "PottedPlant" (ItemLonaCraftFurniturePottedPlant, ENG name "Bedroll") :sleep, :walk (Lona may stand on it) M/90_Furniture.rb:108; Text/ENG/Furniture.txt:347-354
Chest, Wardrobe :storage own box id from 66000 (rec["box"]) M/90_Furniture.rb:79-80, :164, :759
Water Trough :bathe runs the water-spot bath scene M/90_Furniture.rb:88, :1128-1130
Wash Tub no action today pick up only M/90_Furniture.rb:87
Box contents Hash{RPG::Item => count}; remove_item(item, n, box_id) F/203_Storage Boxes.rb:87-92, :129-138, :427-429
Records $game_system.lonacraft_data["furniture"], rec["map_id"] == map.map_id M/90_Furniture.rb:504-528, :779-784; base: M/110_Bases.rb:2523-2527

"Inside the walls" today: Bases.inside_tiles(map, rec, rm) = walkable tiles inside the base's bounds that a flood from the play-area edge and the exit ring cannot reach, doors counted closed, wall tiles excluded, on the sewer the black ceiling excluded (M/110_Bases.rb:1561-1631). Furniture are events, not tiles, so a bed's floor tile is counted (the flood uses tile passability, M/110_Bases.rb:1634-1638).

2. Design (PROPOSED)

2.1 Three tiers

Tier When Recovery Mood Dirt / sickness Raid roll
GROUND a nap with no bed: the Shift nap skill anywhere on a field or base map, or a bed that is none of the below stamina gain x0.6 and capped at 80 % of max; health GAIN x0.5 (hunger damage unchanged) -10 dirt +15 on top of the +26; 10 % chance of 1 FeelsSick stack WildDangerous +10 before the roll (kept, like the game's own increment)
BEDROLL the Bedroll's "Sleep", or the Shift nap while standing on a Bedroll, or the game's own camp bed (PlayerBed) plain nap plain plain plain
BED a Bed / Dark Bed / Blue Bed whose own tile is inside the walls (or any bed in an owned home) health and stamina set to max BEFORE the nap math (as the inn, NoerTavern_Nap.rb:131-132); no satiety refill +10 plain WildDangerous x0.75 for this roll only (not kept)

A Bed standing outside the walls counts as BEDROLL. Towns, dungeons, quest and captured naps are untouched (guard: OnRegionMap >= 1 or a base / owned home map, and Captured == 0, RapeLoop == 0). Mood steps of 10 match the game's own nap steps (E/97:192-200); "1" would be invisible on the -100..100 scale.

Worked example, vanilla math, stamina 0, health 100, satiety 50:

Tier Stamina Health Satiety after Mood Dirt Sick
GROUND 80 (gain 95, cap 80) 105 32 0 +41 10 %
BEDROLL 100 110 32 +10 +26 -
BED 100 200 32 +20 +26 -
BED + dish in chest 100 200 82 +40 +26 -
BED + dish + trough 100 200 82 +40 0 -> 26 -
Inn (reference) 100 200 82 +30 0 -> 26 -

At satiety 20 the ground stamina is 59 (bedroll 99); at satiety 0 it is 35 (bedroll 59). With RolePlayS (single stamina gain) ground at satiety 50 gives about 48.

Raid chance per nap 1..6 on one field map (40,000 runs, WorldDifficulty 30, survival 5, cleared raid = -50, same model as docs/RESEARCH_RAIDS.md:130-135; scratch simulation):

Base bonus BEDROLL (plain) GROUND +10 kept GROUND x1.5 roll BED x0.75 roll BED -10 kept
0 (no base) 7 17 25 28 28 28 % 17 34 42 44 46 45 % 12 27 35 35 34 34 % 4 12 18 22 23 24 % 7 8 9 9 10 10 %
3 (value 30) 10 22 30 33 33 34 % 20 39 45 49 50 51 % 17 34 41 40 39 40 % 6 16 23 26 28 29 % 7 11 14 16 18 18 %
10 (value 100+) 17 34 42 44 46 46 % 27 50 57 60 63 63 % 27 50 52 52 53 51 % 12 26 33 37 40 41 % 7 17 24 28 28 28 %

Recommendation: GROUND +10 kept (clearly riskier, same mechanism as the base bonus); BED x0.75 on this roll only (a modest cut; "-10 kept" would almost erase raids at small bases). The Deep Sewer roll (35/60 %, not WildDangerous) stays as it is in this build (C9).

2.2 Food from a chest (R14)

Rule PROPOSED
Who BED tier only (knob food_on_bedroll false)
Where from storage pieces (kind[:storage]) on this map whose own tile is inside the walls (owned home: any chest on the house map). Never Lona's bag.
What counts cooked dishes only (1.7): default the six plain dishes; mystery and human dishes by knobs (off)
One meal meal_sat = 30 points (about one good soup, 32; the nap itself takes 18, +12 on Hardcore, E/97:177-183)
Pick the smallest single dish worth >= 30 (good soup 32 before meat salad 80); if none, add dishes from the largest down until >= 30 (e.g. smoked meat 26 + meat soup 16; or two soups 16+16). Chests in record order.
Not enough fewer than 30 points of dishes inside the walls: nothing is taken, no refill (raw food is ignored even if present)
Effect satiety to max BEFORE the nap math (as NoerTavern_Nap.rb:133), so Lona wakes at 82 like the inn. The dish's own mood/side effects are NOT applied (it is a meal, not an item use).
When taken inside process_nap_change, i.e. only when the nap really happens (a refused nap during a raid takes nothing)
Text queued popup after waking: "Lona ate a meal from the chest." / none when nothing was eaten

2.3 Bath (R14)

Rule PROPOSED
Who BED tier only (knob bath_on_bedroll false)
Bath piece any piece whose actions include :bathe with its own tile inside the walls (owned home: on the house map). Give the Wash Tub the :bathe action (1 line, M/90_Furniture.rb:87) so it counts and can be used awake.
Effect the inn's: 4 x batch_take_bath(0.5) (0.25 if cuffed) then dirt = 0, before the nap math (NoerTavern_Nap.rb:134-135; E/480_GameActorBatch.rb:4-25). No scene, no stripping, no spotted check, no stamina cost; the Batch script's small EXP is skipped (C8).
Text "Lona washed before bed." in the same queued popup

2.4 Scope

Place PROPOSED
Base on a field map all three tiers; inside = Bases.inside_tiles
Field map without a base GROUND for the Shift nap; game camp bed (PlayerBed) = BEDROLL
Old Shack, Stone House (owned) the whole house map counts as inside walls: a placed Bed = BED; dish chest and trough on the house map apply
Rented inn room unchanged: the inn script already gives the full rest; the mod skips while Homes.nap_keys_active is set (M/100_Homes.rb:789-794, :1382-1386)
Deep Sewer base tiers apply; inside = the same flood (ceiling excluded); a pocket without walls is not inside, so a Bed there = BEDROLL; sewer roll unchanged
Towns, dungeons, quest/captured naps untouched

2.5 Interactions

With Effect
Raids (120) nap refusal unchanged; tier danger added in an alias over the Raids alias of region_map_wildness_nap_stats (160 loads after 120); night-kept raid (after_map_nap) unchanged
Away raids / mercs (140/150) none; an away raid that loots a chest may take the dishes
Maid (R13) she cooks the best dishes from the food in chests inside the walls; her outputs are exactly the 1.7 dish list, which is what the bed meal eats. Raw food she has not cooked never feeds a nap.
Other mods RolePlayS/Campsites/CustomDifficulty/BabyProtection hook process_nap_change; the mod measures deltas around the whole chain, so any of their math is scaled, not replaced
Save nothing new (the tier is per nap; chest contents are already saved boxes)
Hardcore rot mod chests never rot (E/97:128-135), dishes keep
Texts Text//Bases.txt: Rest/ate, Rest/bathed, Rest/ground (optional "Lona slept badly on the bare ground."), Rest/no_dish not shown (silent)
Config Config/Bases.json section rest (2.6)

2.6 Config rest (Config/Bases.json)

The config reader takes only numbers >= 0 (M/120_Raids.rb:230-238), so cuts are written as positive values.

Key Default Meaning
enabled true whole feature
ground_sta_mult 0.6 ground stamina gain factor
ground_sta_cap_pct 80 ground stamina never above this % of max
ground_health_mult 0.5 ground health GAIN factor
ground_mood 10 mood taken on the ground
ground_dirt 15 extra dirt on the ground
ground_sick_chance 10 % chance of 1 FeelsSick stack
ground_danger 10 WildDangerous added before a ground roll
bed_mood 10 mood given in a bed inside walls
bed_roll_mult 0.75 WildDangerous factor for a bed roll (this roll only)
meal_sat 30 satiety points of dishes that make one meal
food_on_bedroll false chest meal on a Bedroll too
bath_on_bedroll false bath on a Bedroll too
mystery_dishes false allow mystery-meat dishes
human_dishes false allow human-meat dishes

3. Build breakdown

Hook choice: one stat hook, Game_Actor#process_nap_change (E/97:63), reached by every nap through handleNap (OM.rb:23); one capture hook pair, Game_Map#call_nap_event (F/31_Game_Map.rb:1305) and GIM_OM#handleNap (OM.rb:12), where Command_AreaNap.rb:75 / Command_Nap.rb:10 hand over; one roll hook, GIM_ADDON#region_map_wildness_nap_stats (E/34:237).

Tier detection: the furniture :sleep action records the piece (uid, kind) as "pending" before it loads Command_AreaNap.rb (alias of lonacraft_furniture_action, no edit in 90). At call_nap_event / handleNap, if nothing is pending, the running event ($game_map.interpreter.event_id, F/40_Game_Interpreter.rb:24) named "PlayerBed" -> BEDROLL; else Lona's tile under a Bedroll record -> BEDROLL; else GROUND. Pending holds map id and Lona's x,y and is dropped when they differ or after the nap (a refused or cancelled nap leaves nothing behind). BED needs the bed record's tile in Bases.inside_tiles (base map) or an owned home map.

Item Files Rough size
B1 Rest core NEW M/160_Rest.rb: tier capture (3 aliases), process_nap_change alias (before: bed restore, chest meal, bath; after: ground scaling, mood, dirt, sickness), region_map_wildness_nap_stats alias (ground +danger kept, bed x0.75 temporary), dish list + picker, queued popups + Scene_Map flush (as M/100_Homes.rb:479-491, :1103-1112); loader.rb line after 130 ~280 lines
B2 Config M/120_Raids.rb: DEFAULTS "rest" + merge_user case (:256-280); Config/Bases.json comment block; Bases_defaults.json regenerates. AFTER the M1 builder hands 120 back. ~35 lines
B3 Wash Tub + texts M/90_Furniture.rb:87 add :bathe; Text/<5 langs>/Furniture.txt WashTub/menu gets "Bathe"; Text/<5 langs>/Bases.txt Rest/* lines; README "Furniture" (Wash Tub, beds), "Homes" (bed rest at home), "Raids" (ground/bed roll) ~40 lines
B4 Self-test + checks M/98_SelfTest.rb: methods exist (process_nap_change, handleNap, call_nap_event, region_map_wildness_nap_stats, batch_take_bath), dish items resolve ($data_ItemName / $data_items[153]); static checks; owner checklist (ground vs bedroll vs bed numbers in the console, meal taken from the chest, trough clean) ~30 lines

4. Choices for the owner

# Question Options Recommendation
C1 Ground recovery (a) stamina x0.6 + cap 80 %, health gain x0.5; (b) x0.6 / x0.5 without the cap; (c) cap only (a): without the cap a fed Lona still wakes almost full on the ground
C2 Ground extras (a) mood -10, dirt +15, 10 % FeelsSick; (b) only mood and dirt; (c) none (a)
C3 Ground danger (a) +10 WildDangerous kept; (b) x1.5 on the roll only (a)
C4 Bed danger (a) x0.75 on the roll only; (b) -10 kept; (c) none (a)
C5 Bed restore when starving (a) full restore anyway (hunger still costs 20 health, mood, satiety stays low); (b) no restore at satiety 0 (a), the inn order
C6 One meal (a) dishes worth >= 30 points; (b) any one dish; (c) points = the nap's own drop (18, 30 on Hardcore) (a)
C7 Cheese (a) not a dish; (b) counts (pot output from milk, 32) (a)
C8 Bath EXP (a) skip the Batch script's EXP; (b) keep it (4 small gains like the inn) (a)
C9 Deep Sewer roll (a) unchanged; (b) ground +10 / bed -25 % on its 35/60 % (a)
C10 Food and bath on the Bedroll (a) Bed only; (b) any sleep inside the walls (a): the Bed is the "inn rest at home"
C11 Mystery / human dishes (a) off (side effects skipped would make them free food); (b) on (a)
C12 Wash Tub (a) gets the Bathe action and counts; (b) only the Water Trough counts (a)