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

Expose instability to json #75330

Merged
merged 3 commits into from
Aug 2, 2024
Merged
Show file tree
Hide file tree
Changes from all 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
5 changes: 5 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1204,6 +1204,11 @@
"type": "json_flag",
"//": "This mutation does not count toward thresholds at all."
},
{
"id": "ROBUST_GENETIC",
"type": "json_flag",
"//": "Applies robust genetic bonus - mutations give only 1 unit of instability for all traits instead of 1 unit for your current tree, and 2 for any outer tree."
},
{
"id": "HIDDEN_HALLU",
"type": "json_flag",
Expand Down
1 change: 1 addition & 0 deletions data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1261,6 +1261,7 @@
"vitamin_cost": 260,
"description": "Your genome has rapidly adapted to the Cataclysm and can handle the strain of mutation better. Taking different kinds of mutagen won't result in more defective mutations than normal.",
"starting_trait": true,
"flags": [ "ROBUST_GENETIC" ],
"cancels": [ "CHAOTIC_BAD", "RESTRICTED" ],
"category": [ "FISH", "SLIME", "MEDICAL", "PLANT" ]
},
Expand Down
3 changes: 2 additions & 1 deletion doc/MAGIC.md
Original file line number Diff line number Diff line change
Expand Up @@ -856,8 +856,9 @@ Character status value | Description
`METABOLISM` | Multiplier for `metabolic_rate_base`, which respond for default bmi rate; Formula for basic bmi is `metabolic_rate_base * ( (weight_in_kg / 10 ) + (6.25 * height) - (5 * age) + 5 )`; Since it's a percent, using `multiply` is recommended; Since metabolism is directly connected to weariness, at this moment decreasing it makes you more weary the less metabolism you have; zero metabolism (`multiply: -1`) is handled separately, and makes you never wear
`MOD_HEALTH` | If this is anything other than zero (which it defaults to) you will to mod your health to a max/min of `MOD_HEALTH_CAP` every half hour.
`MOD_HEALTH_CAP` | If this is anything other than zero (which it defaults to) you will cap your `MOD_HEALTH` gain/loss at this every half hour.
`MOTION_VISION_RANGE` | Reveals all monsters as a red `?` within the specified radius.
`MOTION_VISION_RANGE` | Reveals all monsters as a red `?` within the specified radius.
`MOVE_COST` |
`MUT_INSTABILITY_MOD` | Modifies your instability score, which affects the chance to get bad mutation (scales with amount of good mutations you have, capping at 67%, check `Character::roll_bad_mutation` for more information). `add: 1` would be equal to having 1 good mutation more, increasing the chance to get bad mutation, `add: -1` would be like you have one good mutation less, decreasing the chance to get bad mutation.
`MOVECOST_FLATGROUND_MOD`| How many moves you spend to move 1 tile on flat ground; shown in UI
`MOVECOST_OBSTACLE_MOD` | How many moves you spend to move 1 tile, if this tile has a movecost more than 105 moves; not shown in UI
`MOVECOST_SWIM_MOD` | How many moves you spend to move 1 tile in water; not shown in UI
Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ namespace io
case enchant_vals::mod::MAX_HP: return "MAX_HP";
case enchant_vals::mod::REGEN_HP: return "REGEN_HP";
case enchant_vals::mod::REGEN_HP_AWAKE: return "REGEN_HP_AWAKE";
case enchant_vals::mod::MUT_INSTABILITY_MOD: return "MUT_INSTABILITY_MOD";
case enchant_vals::mod::HUNGER: return "HUNGER";
case enchant_vals::mod::THIRST: return "THIRST";
case enchant_vals::mod::SLEEPINESS: return "SLEEPINESS";
Expand Down
1 change: 1 addition & 0 deletions src/magic_enchantment.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ enum class mod : int {
REGEN_STAMINA,
FAT_TO_MAX_HP,
CARDIO_MULTIPLIER,
MUT_INSTABILITY_MOD,
MAX_HP, // for all limbs! use with caution
REGEN_HP,
REGEN_HP_AWAKE,
Expand Down
6 changes: 4 additions & 2 deletions src/mutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ static const itype_id itype_fake_burrowing( "fake_burrowing" );
static const json_character_flag json_flag_CHLOROMORPH( "CHLOROMORPH" );
static const json_character_flag json_flag_HUGE( "HUGE" );
static const json_character_flag json_flag_LARGE( "LARGE" );
static const json_character_flag json_flag_ROBUST_GENETIC( "ROBUST_GENETIC" );
static const json_character_flag json_flag_ROOTS2( "ROOTS2" );
static const json_character_flag json_flag_ROOTS3( "ROOTS3" );
static const json_character_flag json_flag_SHAPESHIFT_SIZE_HUGE( "SHAPESHIFT_SIZE_HUGE" );
Expand Down Expand Up @@ -84,7 +85,6 @@ static const trait_id trait_M_BLOOM( "M_BLOOM" );
static const trait_id trait_M_FERTILE( "M_FERTILE" );
static const trait_id trait_M_PROVENANCE( "M_PROVENANCE" );
static const trait_id trait_NAUSEA( "NAUSEA" );
static const trait_id trait_ROBUST( "ROBUST" );
static const trait_id trait_SLIMESPAWNER( "SLIMESPAWNER" );
static const trait_id trait_SNAIL_TRAIL( "SNAIL_TRAIL" );
static const trait_id trait_TREE_COMMUNION( "TREE_COMMUNION" );
Expand Down Expand Up @@ -180,7 +180,7 @@ bool Character::has_base_trait( const trait_id &b ) const
int Character::get_instability_per_category( const mutation_category_id &categ ) const
{
int mut_count = 0;
bool robust = has_trait( trait_ROBUST );
bool robust = has_flag( json_flag_ROBUST_GENETIC );
// For each and every trait we have...
for( const trait_id &mut : get_mutations() ) {
// only count muts that have 0 or more points, aren't a threshold, have a category, and aren't a base trait.
Expand All @@ -205,6 +205,8 @@ int Character::get_instability_per_category( const mutation_category_id &categ )
}
}
}
mut_count = enchantment_cache->modify_value( enchant_vals::mod::MUT_INSTABILITY_MOD, mut_count );
mut_count = std::max( mut_count, 0 );
return mut_count;
}

Expand Down
Loading