Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JSON-ify sleep-affecting mutations, trying to sleep, and sleep comfort #75852

Merged
merged 17 commits into from
Aug 25, 2024
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"type": "effect_on_condition",
"id": "EOC_PRE_THRESHOLD_SPIDER_SLEEP_MUTATION",
"eoc_type": "EVENT",
"required_event": "character_attempt_to_fall_asleep",
"condition": {
"and": [
{ "u_has_trait": "WEB_WALKER" },
{ "not": { "u_has_trait": "WEB_SPINNER" } },
{ "not": { "u_has_trait": "WEB_WEAVER" } },
{ "math": [ "u_field_strength('fd_web')", "<", "3" ] }
]
},
"deactivate_condition": {
"or": [ { "not": { "u_has_trait": "WEB_WALKER" } }, { "u_has_trait": "WEB_SPINNER" }, { "u_has_trait": "WEB_WEAVER" } ]
},
"effect": [ { "u_transform_radius": 0, "ter_furn_transform": "spider_clear_webs" } ]
},
{
"type": "ter_furn_transform",
"id": "spider_clear_webs",
"field": [ { "result": "fd_null", "valid_field": [ "fd_web" ] } ]
}
]
139 changes: 131 additions & 8 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -2766,7 +2766,17 @@
{ "part": "torso", "ignored": 60 }
],
"armor": [ { "part_types": [ "ALL" ], "cut": 3, "bash": 5 } ],
"enchantments": [ { "condition": "ALWAYS", "values": [ { "value": "SPEED", "multiply": -0.2 } ] } ]
"enchantments": [ { "condition": "ALWAYS", "values": [ { "value": "SPEED", "multiply": -0.2 } ] } ],
"comfort": [
{
"conditions": [ { "type": "terrain", "flag": "FUNGUS" } ],
"comfort": "very_comfortable",
"msg_try": {
"text": "Our fibers meld with the ground beneath us. The gills on our neck begin to seed the air with spores as our awareness fades.",
"rating": "good"
}
}
]
},
{
"type": "mutation",
Expand Down Expand Up @@ -5804,7 +5814,30 @@
"description": "Your body excretes very fine amounts of a chemical which prevents you from sticking to webs. Walking through webs does not affect you at all.",
"leads_to": [ "WEB_WEAVER" ],
"flags": [ "WEBWALK" ],
"category": [ "SPIDER" ]
"category": [ "SPIDER" ],
"comfort": [
{
"conditions": [
{ "type": "field", "id": "fd_web", "intensity": 3 },
{ "type": "trait", "id": "WEB_SPINNER", "invert": true },
{ "type": "trait", "id": "WEB_WEAVER", "invert": true }
],
"comfort": "sleep_aid",
"use_better_comfort": true,
"add_sleep_aids": true,
"msg_try": { "text": "These thick webs support your weight, and are strangely comfortable…", "rating": "good" }
},
{
"conditions": [
{ "type": "field", "id": "fd_web" },
{ "type": "trait", "id": "WEB_SPINNER", "invert": true },
{ "type": "trait", "id": "WEB_WEAVER", "invert": true }
],
"add_human_comfort": true,
"add_sleep_aids": true,
"msg_try": { "text": "You try to sleep, but the webs get in the way. You brush them aside.", "rating": "info" }
}
]
},
{
"type": "mutation",
Expand All @@ -5817,7 +5850,20 @@
"prereqs": [ "WEB_WALKER" ],
"threshreq": [ "THRESH_SPIDER" ],
"changes_to": [ "WEB_WEAVER" ],
"category": [ "SPIDER" ]
"category": [ "SPIDER" ],
"comfort": [
{
"conditions": [ { "type": "field", "id": "fd_web", "intensity": 3, "invert": true } ],
"comfort": "impossible",
"msg_try": { "text": "You try to sleep, but you feel exposed and your spinnerets keep twitching.", "rating": "bad" },
"msg_hint": { "text": "Maybe a nice thick web would help you sleep.", "rating": "info" }
},
{
"conditions": [ { "type": "field", "id": "fd_web", "intensity": 3 } ],
"comfort": "very_comfortable",
"msg_try": { "text": "You relax into your web.", "rating": "good" }
}
]
},
{
"type": "mutation",
Expand All @@ -5835,7 +5881,20 @@
"cost": 69,
"time": "100 s",
"kcal": true,
"thirst": true
"thirst": true,
"comfort": [
{
"conditions": [ { "type": "field", "id": "fd_web", "intensity": 3, "invert": true } ],
"comfort": "impossible",
"msg_try": { "text": "You try to sleep, but you feel exposed and your spinnerets keep twitching.", "rating": "bad" },
"msg_hint": { "text": "Maybe a nice thick web would help you sleep.", "rating": "info" }
},
{
"conditions": [ { "type": "field", "id": "fd_web", "intensity": 3 } ],
"comfort": "very_comfortable",
"msg_try": { "text": "You relax into your web.", "rating": "good" }
}
]
},
{
"type": "mutation",
Expand Down Expand Up @@ -8061,7 +8120,45 @@
"category": [ "PLANT" ],
"scent_type": "sc_flower",
"encumbrance_covered": [ [ "foot_l", 10 ], [ "foot_r", 10 ] ],
"flags": [ "TOUGH_FEET", "ROOTS3" ]
"flags": [ "TOUGH_FEET", "ROOTS3" ],
"comfort": [
{
"conditions": [ { "type": "vehicle" } ],
"comfort": "impossible",
"msg_try": { "text": "It's impossible to sleep in this wheeled pot!", "rating": "bad" }
},
{
"conditions": [ { "type": "furniture", "id": "f_null", "invert": true } ],
"comfort": "impossible",
"msg_try": { "text": "The humans' furniture blocks your roots. You can't get comfortable.", "rating": "bad" }
},
{
"conditions": [
{ "type": "terrain", "flag": "PLOWABLE", "invert": true },
{ "type": "terrain", "flag": "PLANTABLE", "invert": true },
{ "type": "terrain", "id": "t_pit", "invert": true },
{ "type": "terrain", "id": "t_pit_shallow", "invert": true }
],
"comfort": "impossible",
"msg_try": { "text": "Your roots scrabble ineffectively at the unyielding surface.", "rating": "bad" }
},
{
"conditions": [
{ "type": "terrain", "flag": "PLANTABLE" },
{ "type": "terrain", "id": "t_dirt" },
{ "type": "terrain", "id": "t_pit" },
{ "type": "terrain", "id": "t_pit_shallow" }
],
"conditions_any": true,
"comfort": "very_comfortable",
"msg_try": { "text": "You relax as your roots embrace the soil.", "rating": "good" }
},
{
"conditions": [ { "type": "terrain", "flag": "PLOWABLE" } ],
"comfort": "comfortable",
"msg_try": { "text": "You relax as your roots embrace the soil.", "rating": "good" }
}
]
},
{
"type": "mutation",
Expand Down Expand Up @@ -8508,7 +8605,14 @@
"category": [ "CEPHALOPOD", "GASTROPOD" ],
"wet_protection": [ { "part": "torso", "ignored": 26 } ],
"active": true,
"integrated_armor": [ "integrated_shell2" ]
"integrated_armor": [ "integrated_shell2" ],
"comfort": [
{
"conditions": [ { "type": "trait", "id": "SHELL2", "active": true } ],
"comfort": "sleep_aid",
"add_sleep_aids": true
}
]
},
{
"type": "mutation",
Expand All @@ -8526,7 +8630,14 @@
"category": [ "GASTROPOD" ],
"wet_protection": [ { "part": "torso", "ignored": 45 } ],
"active": true,
"integrated_armor": [ "integrated_shell3" ]
"integrated_armor": [ "integrated_shell3" ],
"comfort": [
{
"conditions": [ { "type": "trait", "id": "SHELL3", "active": true } ],
"comfort": "sleep_aid",
"add_sleep_aids": true
}
]
},
{
"type": "mutation",
Expand Down Expand Up @@ -8960,7 +9071,19 @@
"description": "Falling asleep underwater is easy for you, and you spend less time asleep when you rest there. You can also eat underwater, though you can't drink.",
"prereqs": [ "SEESLEEP", "FROG_EYES", "GILLS_CEPH" ],
"category": [ "FISH", "BATRACHIAN", "CEPHALOPOD" ],
"threshreq": [ "THRESH_FISH", "THRESH_BATRACHIAN", "THRESH_CEPHALOPOD" ]
"threshreq": [ "THRESH_FISH", "THRESH_BATRACHIAN", "THRESH_CEPHALOPOD" ],
"comfort": [
{
"conditions": [ { "type": "terrain", "flag": "DEEP_WATER" } ],
"comfort": "very_comfortable",
"msg_try": { "text": "You lay beneath the waves' embrace, gazing up through the water's surface…", "rating": "good" }
},
{
"conditions": [ { "type": "terrain", "flag": "SWIMMABLE" } ],
"comfort": "very_comfortable",
"msg_try": { "text": "You settle into the water and begin to drowse…", "rating": "good" }
}
]
},
{
"type": "mutation",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,19 @@
"prereqs": [ "UNDINE_SKIN_2", "UNDINE_SKIN_3" ],
"prereqs2": [ "BREATH_UNDERWATER" ],
"category": [ "UNDINE" ],
"enchantments": [ { "condition": "u_is_underwater", "values": [ { "value": "SLEEPY", "add": 40 } ] } ]
"enchantments": [ { "condition": "u_is_underwater", "values": [ { "value": "SLEEPY", "add": 40 } ] } ],
"comfort": [
{
"conditions": [ { "type": "terrain", "flag": "DEEP_WATER" } ],
"comfort": "very_comfortable",
"msg_try": { "text": "You lay beneath the waves' embrace, gazing up through the water's surface…", "rating": "good" }
},
{
"conditions": [ { "type": "terrain", "flag": "SWIMMABLE" } ],
"comfort": "very_comfortable",
"msg_try": { "text": "You settle into the water and begin to drowse…", "rating": "good" }
}
]
},
{
"type": "mutation",
Expand Down
51 changes: 51 additions & 0 deletions doc/MUTATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -229,6 +229,25 @@ Note that **all new traits that can be obtained through mutation must be purifia
}
]
],
"comfort": [ // List of comfort data. The first comfort data with passing conditions will apply.
{ // If multiple mutations would apply comfort data, only the data with the worst `comfort` will apply.
"conditions": [ // List of comfort conditions. See 'Comfort Conditions' below. Mandatory.
{ "type": "terrain", "flag": "DEEP_WATER" },
{ "type": "furniture", "id": "f_null", "invert": true },
{ "type": "field", "id": "fd_web", "intensity": 3 },
{ "type": "vehicle" },
{ "type": "trait": "id": "SHELL2", "active": true }
],
"conditions_any": true, // If this comfort data passes when ANY of its conditions are true (true) or when ALL of its conditions are true (false) (default: false).
"comfort": "very_comfortable", // The comfort provided by this comfort data if applied. Can be an integer or any of "very_comfortable" (10), "comfortable" (5), "sleep_aid" (4), "slightly_comfortable" (3), "neutral" (0), "uncomfortable" (-7), or "impossible" (-999) (default: "neutral").
"add_human_comfort": false, // If the furniture/trap/terrain's comfort value should be added to `comfort` (default: false). Not compatible with `use_better_comfort`.
"use_better_comfort": false, // If the furniture/trap/terrain's comfort value should be used INSTEAD OF `comfort` if better (default: false). Not compatible with `add_human_comfort`.
"add_sleep_aids": false, // If sleep aids should add their comfort value to the final result (default: false).
"msg_try": { "text": "You try to sleep.", "rating": "good" }, // Message displayed when trying to sleep.
"msg_hint": { "text": "Maybe you should sleep on a bed?", "rating": "info" }, // Message displayed after the above message. Used to suggest better places for a mutant to sleep.
"msg_sleep": { "text": "You fall asleep.", "rating": "good" } // Message displayed when falling asleep.
}
],
"activated_is_setup": true, // If this is true the bellow activated EOC runs then the mutation turns on for processing every turn. If this is false the below "activated_eocs" will run and then the mod will turn itself off.
"activated_eocs": [ "eoc_id_1" ], // List of effect_on_conditions that attempt to activate when this mutation is successfully activated.
"processed_eocs": [ "eoc_id_1" ], // List of effect_on_conditions that attempt to activate every time (defined above) units of time. Time of 0 means every turn it processes. Processed when the mutation is active for activatable mutations and always for non-activatable ones.
Expand Down Expand Up @@ -289,6 +308,38 @@ These fields are optional, but are very frequently used in mutations and their c

There are many, many optional fields present for mutations to let them do all sorts of things. You can see them documented above.

### Comfort Conditions

Comfort data can have one or more `conditions`. Comfort data passes (is true) when **any** of its conditions pass, if `conditions_any` is `true`, or when **all** of its conditions pass, if `conditions_any` is `false`.

#### Fields

Conditions have the following fields. `type` is mandatory and determines which other fields are mandatory. `invert` is always optional.

| Identifier | Type | Description
|-------------|---------|-------------
| `type` | string | One of `"terrain"`, `"furniture"`, `"trap"`, `"field"`, `"vehicle"`, `"character"`, or `"trait"`. Always mandatory.
| `id` | string | The ID of a terrain, furniture, trap, field, or trait.
| `flag` | string | A terrain, furniture, vehicle part, or character flag.
| `intensity` | integer | A field's intensity.
| `active` | boolean | If a trait must be active.
| `invert` | boolean | If a condition should pass when it would fail and fail when it would pass. Always optional.

#### Types

A condition's `type` determines what it checks for in a location. A condition passes (is true) according to it's `type`.

| Type | Mandatory | Optional | Passes
|-------------|----------------|-------------|-------------
| `terrain` | `id` or `flag` | | Passes if on terrain with the given `id` or `flag`.
| `furniture` | `id` or `flag` | | Passes if on furniture with the given `id` or `flag`.
| `trap` | `id` | | Passes if on a trap with the given `id`.
| `field` | `id` | `intensity` | Passes if in a field with the given `id`. If `intensity` is defined, the field's intensity must be greater than or equal to `intensity`.
| `vehicle` | | `flag` | Passes if in/on a part of a vehicle. If `flag` is defined, the part must have the given `flag` and cannot be broken.
| `character` | `flag` | | Passes if the character has the given `flag`.
| `trait` | `id` | `active` | Passes if the character has a trait with the given `id`. If `active` is defined, the trait must be active.
| all types | | `invert` | Passes if the condition would fail. Fails if the condition would pass.

### EOC details

Mutations support EOC on activate, deactivate and for processing. As well for each of those the EOC has access to the context variable `this` which is the ID of the mutation itself.
Expand Down
2 changes: 1 addition & 1 deletion msvc-full-features/Cataclysm-lib-vcpkg-static.vcxproj
Original file line number Diff line number Diff line change
Expand Up @@ -187,4 +187,4 @@
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
<ImportGroup Label="ExtensionTargets">
</ImportGroup>
</Project>
</Project>
Maleclypse marked this conversation as resolved.
Show resolved Hide resolved
Loading
Loading