Skip to content

Commit

Permalink
Follow-up mutation tweaks (#61684)
Browse files Browse the repository at this point in the history
* some more mutation tweaks and such

* memories broken the truth goes unspoken

* oops all negatives
  • Loading branch information
Ilysen authored Oct 17, 2022
1 parent 92a47e4 commit 245089c
Show file tree
Hide file tree
Showing 10 changed files with 140 additions and 75 deletions.
108 changes: 54 additions & 54 deletions data/json/effects.json

Large diffs are not rendered by default.

49 changes: 36 additions & 13 deletions data/json/mutations/changing_eocs.json
Original file line number Diff line number Diff line change
Expand Up @@ -21,29 +21,19 @@
"type": "effect_on_condition",
"id": "changing_failed",
"condition": { "one_in_chance": 4 },
"effect": [ { "u_message": "You feel a shift in your body, but it quickly reverts.", "type": "bad" } ]
"effect": [ { "u_message": "<CHANGING_FAILED>", "type": "bad" } ]
},
{
"type": "effect_on_condition",
"id": "changing_successful",
"effect": [
{
"u_message": "You begin to feel a sickeningly beautiful ache, the feeling of your cells tearing apart and recombining in strange new patterns.",
"type": "mixed"
},
{ "u_add_trait": "CHANGING" },
{ "u_mutate": 0 }
]
"effect": [ { "u_message": "<CHANGING_SUCCESS>", "type": "mixed" }, { "u_add_trait": "CHANGING" }, { "u_mutate": 0 } ]
},
{
"type": "effect_on_condition",
"id": "changing_reqs_not_met",
"condition": { "one_in_chance": 3 },
"effect": [
{
"u_message": "You can palpably feel the churning sensation within fade, your mutation cut short by a lack of nutrients.",
"type": "bad"
},
{ "u_message": "<CHANGING_ENDS>", "type": "bad" },
{ "u_lose_trait": "CHANGING" },
{ "arithmetic": [ { "u_val": "vitamin", "name": "mutagen" }, "=", { "const": 0 } ] }
]
Expand Down Expand Up @@ -73,5 +63,38 @@
]
}
]
},
{
"type": "snippet",
"category": "<CHANGING_FAILED>",
"text": [
"You feel a shift in your body, but it quickly reverts.",
"Your flesh has taken on an impatient wriggling sensation.",
"Your skin feels like wax. Or wet clay.",
"You feel as though you're on the cusp of something, if you just give it a bit more time…",
"Your vision swims. You feel dizzy.",
"It won't be long now. Your innards flex and twist in anticipatory contortions."
]
},
{
"type": "snippet",
"category": "<CHANGING_SUCCESS>",
"text": [
"You begin to feel a sickeningly beautiful ache, the feeling of your cells tearing apart and recombining in strange new patterns.",
"Your body is slowly reshaping itself!",
"Every muscle you have begins to minutely spasm and cramp as your body starts morphing, slowly, in unearthly new ways.",
"You feel your chest wriggle and begin to palpitate. Here we go.",
"Tiny ripples begin appearing in your skin and radiating outward like waves. It is indescribably uncomfortable."
]
},
{
"type": "snippet",
"category": "<CHANGING_ENDS>",
"text": [
"You can palpably feel the churning sensation within fade, your mutation cut short by a lack of nutrients.",
"The strain of mutation fades, leaving a throbbing sensation like a bad headache. Or an afterglow.",
"You're pulled back to reality as your body stops warping, leaving you in your current state for the time being.",
"Your mutation abruptly ends from a lack of nutrients. Back to Earth for now."
]
}
]
2 changes: 1 addition & 1 deletion data/json/mutations/mutations.json
Original file line number Diff line number Diff line change
Expand Up @@ -1905,7 +1905,7 @@
"name": { "str": "Genetic Downward Spiral" },
"points": -8,
"purifiable": false,
"description": "The events of the Cataclysm have damaged your DNA beyond repair. You mutate frequently, and your genetic instability is rapidly climbing.",
"description": "The events of the Cataclysm have damaged your DNA beyond repair. You mutate frequently, all mutations you receive (from any source) are negative, and your instability is rapidly growing out of control.",
"starting_trait": true,
"cancels": [ "ROBUST" ],
"valid": false,
Expand Down
5 changes: 5 additions & 0 deletions src/distraction_manager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ static const std::vector<std::pair<std::string, std::string>> configurable_distr
{translate_marker( "Hunger" ), translate_marker( "This distraction will interrupt your activity when you're at risk of starving." )},
{translate_marker( "Thirst" ), translate_marker( "This distraction will interrupt your activity when you're dangerously dehydrated." )},
{translate_marker( "Temperature" ), translate_marker( "This distraction will interrupt your activity when your temperature is very high or very low." )},
{translate_marker( "Mutation" ), translate_marker( "This distraction will interrupt your activity when you gain or lose a mutation." )},
};

void distraction_manager_gui::show()
Expand Down Expand Up @@ -75,6 +76,7 @@ void distraction_manager_gui::show()
uistate.distraction_hunger,
uistate.distraction_thirst,
uistate.distraction_temperature,
uistate.distraction_mutation,
};

input_context ctx{ "DISTRACTION_MANAGER" };
Expand Down Expand Up @@ -205,6 +207,9 @@ void distraction_manager_gui::show()
case 11:
uistate.distraction_temperature = !uistate.distraction_temperature;
break;
case 12:
uistate.distraction_mutation = !uistate.distraction_mutation;
break;
default:
return;
}
Expand Down
3 changes: 2 additions & 1 deletion src/enums.h
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,8 @@ enum class distraction_type : int {
dangerous_field,
hunger,
thirst,
temperature
temperature,
mutation
};

enum game_message_type : int {
Expand Down
3 changes: 2 additions & 1 deletion src/handle_action.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1654,7 +1654,8 @@ bool Character::cast_spell( spell &sp, bool fake_spell,
distraction_type::talked_to,
distraction_type::asthma,
distraction_type::motion_alarm,
distraction_type::weather_change
distraction_type::weather_change,
distraction_type::mutation
};
for( const distraction_type ignored : ignored_distractions ) {
spell_act.ignore_distraction( ignored );
Expand Down
2 changes: 2 additions & 0 deletions src/inventory_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -330,6 +330,7 @@ void uistatedata::serialize( JsonOut &json ) const
json.member( "distraction_hunger", distraction_hunger );
json.member( "distraction_thirst", distraction_thirst );
json.member( "distraction_temperature", distraction_temperature );
json.member( "distraction_mutation", distraction_mutation );

json.member( "input_history" );
json.start_object();
Expand Down Expand Up @@ -396,6 +397,7 @@ void uistatedata::deserialize( const JsonObject &jo )
jo.read( "distraction_hunger", distraction_hunger );
jo.read( "distraction_thirst", distraction_thirst );
jo.read( "distraction_temperature", distraction_temperature );
jo.read( "distraction_mutation", distraction_mutation );

if( !jo.read( "vmenu_show_items", vmenu_show_items ) ) {
// This is an old save: 1 means view items, 2 means view monsters,
Expand Down
38 changes: 33 additions & 5 deletions src/mutation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,7 @@ static const mutation_category_id mutation_category_ANY( "ANY" );

static const trait_id trait_BURROW( "BURROW" );
static const trait_id trait_BURROWLARGE( "BURROWLARGE" );
static const trait_id trait_CHAOTIC_BAD( "CHAOTIC_BAD" );
static const trait_id trait_DEBUG_BIONIC_POWER( "DEBUG_BIONIC_POWER" );
static const trait_id trait_DEBUG_BIONIC_POWERGEN( "DEBUG_BIONIC_POWERGEN" );
static const trait_id trait_DEX_ALPHA( "DEX_ALPHA" );
Expand Down Expand Up @@ -985,14 +986,24 @@ void Character::mutate( const int &true_random_chance, const bool use_vitamins )

if( true_random_chance > 0 && one_in( true_random_chance ) ) {
cat = mutation_category_ANY;
allow_good = true; // because i'm WILD YEAH
allow_bad = true;
allow_neutral = true;
} else if( cat_list.get_weight() > 0 ) {
cat = *cat_list.pick();
cat_list.add_or_replace( cat, 0 );
} else {
// This is fairly direct in explaining why it fails - hopefully it'll help folks to learn the system without needing to read docs
add_msg_if_player( m_bad,
_( "Your body tries to shift, tries to change, but only contorts for a moment. You crave a more exotic mutagen." ) );
_( "Your body tries to mutate, but it lacks a primer to do so and only contorts for a moment." ) );
return;
}
// Genetic Downwards Spiral has special logic that makes every possible mutation negative
// Positive mutations can still be gained as prerequisites to a negative, but every targeted mutation will be a negative one
if( has_trait( trait_CHAOTIC_BAD ) ) {
allow_good = false;
allow_bad = true;
}

std::vector<trait_id> valid; // Valid mutations
std::vector<trait_id> dummies; // Dummy mutations
Expand Down Expand Up @@ -1089,7 +1100,7 @@ void Character::mutate( const int &true_random_chance, const bool use_vitamins )
} else {
// every option we have vitamins for is invalid
add_msg_if_player( m_bad,
_( "Your body tries to shift, tries to change, but only contorts for a moment. You crave a more exotic mutagen." ) );
_( "Your body tries to mutate, but it lacks a primer to do so and only contorts for a moment." ) );
return;
}
} else {
Expand Down Expand Up @@ -1335,6 +1346,8 @@ bool Character::mutate_towards( const trait_id &mut, const mutation_category_id
if( mut_vit != vitamin_id::NULL_ID() ) {
if( vitamin_get( mut_vit ) >= mdata.vitamin_cost ) {
vitamin_mod( mut_vit, -mdata.vitamin_cost );
// No instability necessary for true random mutations - they are, after all, true random
vitamin_mod( vitamin_instability, mdata.vitamin_cost );
} else {
return false;
}
Expand Down Expand Up @@ -1371,6 +1384,7 @@ bool Character::mutate_towards( const trait_id &mut, const mutation_category_id
}

bool mutation_replaced = false;
bool do_interrupt = true;

game_message_type rating;

Expand Down Expand Up @@ -1411,6 +1425,10 @@ bool Character::mutate_towards( const trait_id &mut, const mutation_category_id
add_msg_player_or_npc( rating, _( "You lose your %s mutation." ),
_( "<npcname> loses their %s mutation." ), lost_name );
}
// Both new and old mutation invisible
else {
do_interrupt = false;
}
get_event_bus().send<event_type::evolves_mutation>( getID(), replace_mdata.id, mdata.id );
unset_mutation( replacing );
mutation_replaced = true;
Expand All @@ -1435,18 +1453,22 @@ bool Character::mutate_towards( const trait_id &mut, const mutation_category_id
lost_name, gained_name );
}
// New mutation visible, precursor invisible
if( mdata.player_display && !replace_mdata.player_display ) {
else if( mdata.player_display && !replace_mdata.player_display ) {
add_msg_player_or_npc( rating,
_( "You gain a mutation called %s!" ),
_( "<npcname> gains a mutation called %s!" ),
gained_name );
}
// Precursor visible, new mutation invisible
if( !mdata.player_display && replace_mdata.player_display ) {
else if( !mdata.player_display && replace_mdata.player_display ) {
add_msg_player_or_npc( rating,
_( "You lose your %s mutation." ),
_( "<npcname> loses their %s mutation." ), lost_name );
}
// Both new and old mutation invisible
else {
do_interrupt = false;
}
get_event_bus().send<event_type::evolves_mutation>( getID(), replace_mdata.id, mdata.id );
unset_mutation( replacing2 );
mutation_replaced = true;
Expand Down Expand Up @@ -1495,6 +1517,7 @@ bool Character::mutate_towards( const trait_id &mut, const mutation_category_id
_( "You gain a mutation called %s!" ),
_( "<npcname> gains a mutation called %s!" ),
gained_name );
do_interrupt = true;
}
get_event_bus().send<event_type::gains_mutation>( getID(), mdata.id );
}
Expand All @@ -1504,8 +1527,10 @@ bool Character::mutate_towards( const trait_id &mut, const mutation_category_id
if( !mdata.dummy ) {
set_mutation( mut, chosen_var );
}
if( do_interrupt && uistate.distraction_mutation ) {
g->cancel_activity_or_ignore_query( distraction_type::mutation, _( "You mutate!" ) );
}

vitamin_mod( vitamin_instability, mdata.vitamin_cost );
calc_mutation_levels();
drench_mut_calc();
return true;
Expand Down Expand Up @@ -1825,6 +1850,9 @@ void Character::remove_mutation( const trait_id &mut, bool silent )
lost_name );
}
}
if( !silent && uistate.distraction_mutation ) {
g->cancel_activity_or_ignore_query( distraction_type::mutation, _( "You mutate!" ) );
}

calc_mutation_levels();
drench_mut_calc();
Expand Down
1 change: 1 addition & 0 deletions src/uistate.h
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ class uistatedata
bool distraction_hunger = true;
bool distraction_thirst = true;
bool distraction_temperature = true;
bool distraction_mutation = true;

// V Menu Stuff
int list_item_sort = 0;
Expand Down
4 changes: 4 additions & 0 deletions tools/spell_checker/dictionary.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ aerially
aeterna
aetheric
afterbirth
afterglow
afterimage
afterlife
aftermarket
Expand Down Expand Up @@ -538,6 +539,7 @@ dryptosaurus
drywalled
dunderfuck
dyoplosaurus
dysmorphia
dysrhythmia
earthbag
earthbags
Expand Down Expand Up @@ -569,6 +571,7 @@ encumbers
endochitin
endolymph
ener
enervating
enjoyability
envenomations
eocs
Expand Down Expand Up @@ -1356,6 +1359,7 @@ pachyrhinosaurus
packable
paf
palpably
palpitate
panoplosaurus
papyrifera
parabellum
Expand Down

0 comments on commit 245089c

Please sign in to comment.