Skip to content

Commit

Permalink
Merge pull request #77419 from RenechCDDA/custom_mutation_activation_msg
Browse files Browse the repository at this point in the history
Mutations can have a custom activation message
  • Loading branch information
Maleclypse authored Oct 30, 2024
2 parents e29afb5 + 164c3f3 commit d9d7796
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/MUTATIONS.md
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,7 @@ Note that **all new traits that can be obtained through mutation must be purifia
}
],
"active": true, // When set the mutation is an active mutation that the player needs to activate (default: false).
"activation_msg": "Time to rock and roll", // Optional, default "You activate your %s." where %s is replaced with the mutation's name.
"starts_active": true, // When true, this 'active' mutation starts active (default: false, requires 'active').
"cost": 8, // Cost to activate this mutation. Needs one of the hunger, thirst, or sleepiness values set to true (default: 0).
"time": 100, // Sets the amount of (turns * current player speed ) time units that need to pass before the cost is to be paid again. Needs to be higher than one to have any effect (default: 0).
Expand Down
1 change: 1 addition & 0 deletions src/mutation.h
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,7 @@ struct mutation_branch {
bool mixed_effect = false;
bool startingtrait = false;
bool activated = false;
translation activation_msg;
// Should it activate as soon as it is gained?
bool starts_active = false;
// Should it destroy gear on restricted body parts? (otherwise just pushes it off)
Expand Down
2 changes: 2 additions & 0 deletions src/mutation_data.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -399,6 +399,8 @@ void mutation_branch::load( const JsonObject &jo, const std::string_view src )
optional( jo, was_loaded, "can_only_eat", can_only_eat );
optional( jo, was_loaded, "can_only_heal_with", can_only_heal_with );
optional( jo, was_loaded, "can_heal_with", can_heal_with );
optional( jo, was_loaded, "activation_msg", activation_msg,
to_translation( "You activate your %s." ) );

optional( jo, was_loaded, "butchering_quality", butchering_quality, 0 );

Expand Down
6 changes: 4 additions & 2 deletions src/mutation_ui.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -441,7 +441,8 @@ void avatar::power_mutations()
( !mut_data.thirst || get_thirst() <= 400 ) &&
( !mut_data.sleepiness || get_sleepiness() <= 400 ) &&
( !mut_data.mana || magic->available_mana() >= mut_data.cost ) ) {
add_msg_if_player( m_neutral, _( "You activate your %s." ), mutation_name( mut_data.id ) );
add_msg_if_player( m_neutral,
string_format( mut_data.activation_msg, mutation_name( mut_data.id ) ) );
// Reset menu in advance
ui.reset();
activate_mutation( mut_id );
Expand Down Expand Up @@ -615,7 +616,8 @@ void avatar::power_mutations()
( !mut_data.thirst || get_thirst() <= 400 ) &&
( !mut_data.sleepiness || get_sleepiness() <= 400 ) &&
( !mut_data.mana || magic->available_mana() >= mut_data.cost ) ) {
add_msg_if_player( m_neutral, _( "You activate your %s." ), mutation_name( mut_data.id ) );
add_msg_if_player( m_neutral,
string_format( mut_data.activation_msg, mutation_name( mut_data.id ) ) );
// Reset menu in advance
ui.reset();
activate_mutation( mut_id );
Expand Down

0 comments on commit d9d7796

Please sign in to comment.