diff --git a/data/json/effects_on_condition/mutation_eocs/mutation_effect_eocs.json b/data/json/effects_on_condition/mutation_eocs/mutation_effect_eocs.json index 02d3681f226ea..9c76a81fefe99 100644 --- a/data/json/effects_on_condition/mutation_eocs/mutation_effect_eocs.json +++ b/data/json/effects_on_condition/mutation_eocs/mutation_effect_eocs.json @@ -366,6 +366,53 @@ } ] }, + { + "type": "effect_on_condition", + "id": "EOC_RADIATION_MUTATION", + "eoc_type": "EVENT", + "required_event": "character_radioactively_mutates", + "condition": "u_is_character", + "effect": [ + { + "set_string_var": "", + "target_var": { "context_val": "radiation_mutation_category" }, + "parse_tags": true + }, + { "u_mutate_category": { "context_val": "radiation_mutation_category" }, "use_vitamins": false } + ] + }, + { + "type": "snippet", + "category": "", + "text": [ + { "text": "CHIMERA" }, + { "text": "INSECT" }, + { "text": "ALPHA" }, + { "text": "URSINE" }, + { "text": "CHIROPTERAN" }, + { "text": "BIRD" }, + { "text": "MEDICAL" }, + { "text": "LUPINE" }, + { "text": "RAT" }, + { "text": "SLIME" }, + { "text": "PLANT" }, + { "text": "BATRACHIAN" }, + { "text": "RAPTOR" }, + { "text": "MOUSE" }, + { "text": "CEPHALOPOD" }, + { "text": "ELFA" }, + { "text": "FISH" }, + { "text": "HUMAN" }, + { "text": "RABBIT" }, + { "text": "GASTROPOD" }, + { "text": "BEAST" }, + { "text": "FELINE" }, + { "text": "CATTLE" }, + { "text": "LIZARD" }, + { "text": "TROGLOBITE" }, + { "text": "CRUSTACEAN" } + ] + }, { "type": "effect_on_condition", "id": "EOC_ink_grand_spray", diff --git a/doc/EFFECT_ON_CONDITION.md b/doc/EFFECT_ON_CONDITION.md index f3b04f2da2850..b13c9fb7013ec 100644 --- a/doc/EFFECT_ON_CONDITION.md +++ b/doc/EFFECT_ON_CONDITION.md @@ -1190,6 +1190,7 @@ Every event EOC passes context vars with each of their key value pairs that the | character_loses_effect | | { "character", `character_id` },
{ "effect", `efftype_id` },
{ "bodypart", `bodypart_id` } | character / NONE | | character_melee_attacks_character | | { "attacker", `character_id` },
{ "weapon", `itype_id` },
{ "hits", `bool` },
{ "victim", `character_id` },
{ "victim_name", `string` }, | character (attacker) / character (victim) | | character_melee_attacks_monster | | { "attacker", `character_id` },
{ "weapon", `itype_id` },
{ "hits", `bool` },
{ "victim_type", `mtype_id` },| character / monster | +| character_radioactively_mutates | triggered when a character mutates due to being irradiated | { "character", `character_id` }, | character / NONE | | character_ranged_attacks_character | | { "attacker", `character_id` },
{ "weapon", `itype_id` },
{ "victim", `character_id` },
{ "victim_name", `string` }, | character (attacker) / character (victim) | | character_ranged_attacks_monster | | { "attacker", `character_id` },
{ "weapon", `itype_id` },
{ "victim_type", `mtype_id` }, | character / monster | | character_smashes_tile | | { "character", `character_id` },
{ "terrain", `ter_str_id` }, { "furniture", `furn_str_id` }, | character / NONE | diff --git a/src/event.cpp b/src/event.cpp index 7b16d4ecb1746..9ed44ef28fa17 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -43,6 +43,7 @@ std::string enum_to_string( event_type data ) return "character_melee_attacks_character"; case event_type::character_melee_attacks_monster: return "character_melee_attacks_monster"; + case event_type::character_radioactively_mutates: return "character_radioactively_mutates"; case event_type::character_ranged_attacks_character: return "character_ranged_attacks_character"; case event_type::character_ranged_attacks_monster: @@ -142,7 +143,7 @@ DEFINE_EVENT_HELPER_FIELDS( event_spec_empty ) DEFINE_EVENT_HELPER_FIELDS( event_spec_character ) DEFINE_EVENT_HELPER_FIELDS( event_spec_character_item ) -static_assert( static_cast( event_type::num_event_types ) == 103, +static_assert( static_cast( event_type::num_event_types ) == 104, "This static_assert is a reminder to add a definition below when you add a new " "event_type. If your event_spec specialization inherits from another struct for " "its fields definition then you probably don't need a definition here." ); diff --git a/src/event.h b/src/event.h index b4565b8bbc559..abddc8a9374f1 100644 --- a/src/event.h +++ b/src/event.h @@ -53,6 +53,7 @@ enum class event_type : int { character_loses_effect, character_melee_attacks_character, character_melee_attacks_monster, + character_radioactively_mutates, character_ranged_attacks_character, character_ranged_attacks_monster, character_smashes_tile, @@ -187,7 +188,7 @@ struct event_spec_character_item { }; }; -static_assert( static_cast( event_type::num_event_types ) == 103, +static_assert( static_cast( event_type::num_event_types ) == 104, "This static_assert is to remind you to add a specialization for your new " "event_type below" ); @@ -418,6 +419,9 @@ struct event_spec { }; }; +template<> +struct event_spec : event_spec_character {}; + template<> struct event_spec { static constexpr std::array, 4> fields = {{ diff --git a/src/memorial_logger.cpp b/src/memorial_logger.cpp index 20f8da4c74922..2bb5d73fecfe9 100644 --- a/src/memorial_logger.cpp +++ b/src/memorial_logger.cpp @@ -1130,6 +1130,7 @@ void memorial_logger::notify( const cata::event &e ) case event_type::character_wakes_up: case event_type::character_attempt_to_fall_asleep: case event_type::character_falls_asleep: + case event_type::character_radioactively_mutates: case event_type::character_wears_item: case event_type::character_wields_item: case event_type::character_casts_spell: diff --git a/src/suffer.cpp b/src/suffer.cpp index 05e2626e276df..12deccc32ef40 100644 --- a/src/suffer.cpp +++ b/src/suffer.cpp @@ -1170,7 +1170,7 @@ void suffer::from_radiation( Character &you ) // 1000 rads = 900 / 10000 = 9 / 100 = 10% !!! // 2000 rads = 2000 / 10000 = 1 / 5 = 20% !!! if( get_option( "RAD_MUTATION" ) && rng( 100, 10000 ) < you.get_rad() ) { - you.mutate(); + get_event_bus().send( you.getID() ); } if( you.get_rad() > 50 && rng( 1, 3000 ) < you.get_rad() && ( you.stomach.contains() > 0_ml || radiation_increasing || !you.in_sleep_state() ) ) {