diff --git a/doc/EFFECT_ON_CONDITION.md b/doc/EFFECT_ON_CONDITION.md index bbabbce5eb935..9784df93843d3 100644 --- a/doc/EFFECT_ON_CONDITION.md +++ b/doc/EFFECT_ON_CONDITION.md @@ -1139,6 +1139,7 @@ Every event EOC passes context vars with each of their key value pairs that the | broken_bone_mends | Triggered when `mending` effect is removed by expiry (Character::mend) | { "character", `character_id` },
{ "part", `body_part` }, | character / NONE | | buries_corpse | Triggers when item with flag CORPSE is located on same tile as construction with post-special `done_grave` is completed | { "character", `character_id` },
{ "corpse_type", `mtype_id` },
{ "corpse_name", `string` }, | character / NONE | | causes_resonance_cascade | Triggers when resonance cascade option is activated via "old lab" finale's computer | NONE | avatar / NONE | +| character_butchered_corpse | Triggers after succesful butchering action. Possible values of butcher_type are `ACT_BLEED`, `ACT_BUTCHER`, `ACT_BUTCHER_FULL`, `ACT_FIELD_DRESS`, `ACT_SKIN`, `ACT_QUARTER`, `ACT_DISMEMBER`, `ACT_DISSECT` | { "character", `character_id` }, { "monster_id", `mtype_id` }, { "butcher_type", `string` }, | character / NONE | | character_casts_spell | Triggers when a character casts spells. When a spell with multiple effects is cast, the number of effects will be triggered | { "character", `character_id` },
{ "spell", `spell_id` },
{ "school", `trait_id` },
{ "difficulty", `int` },
{ "cost", `int` },
{ "cast_time", `int` },
{ "damage", `int` }, | character / NONE | | character_consumes_item | | { "character", `character_id` },
{ "itype", `itype_id` }, | character / NONE | | character_dies | | { "character", `character_id` }, | character / NONE | diff --git a/src/activity_handlers.cpp b/src/activity_handlers.cpp index 85430a0dbdd7d..669bdb58b40f4 100644 --- a/src/activity_handlers.cpp +++ b/src/activity_handlers.cpp @@ -1394,6 +1394,9 @@ void activity_handlers::butcher_finish( player_activity *act, Character *you ) you->recoil = MAX_RECOIL; + get_event_bus().send( you->getID(), + corpse_item.get_mtype()->id, act->id().str() ); + // Ready to move on to the next item, if there is one (for example if multibutchering) act->index = true; // if it's mutli-tile butchering, then restart the backlog. diff --git a/src/event.cpp b/src/event.cpp index 9d0a35cedb888..50d0440356848 100644 --- a/src/event.cpp +++ b/src/event.cpp @@ -115,6 +115,7 @@ std::string enum_to_string( event_type data ) case event_type::uses_debug_menu: return "uses_debug_menu"; case event_type::u_var_changed: return "u_var_changed"; case event_type::vehicle_moves: return "vehicle_moves"; + case event_type::character_butchered_corpse: return "character_butchered_corpse"; // *INDENT-ON* case event_type::num_event_types: break; @@ -138,7 +139,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 ) == 101, +static_assert( static_cast( event_type::num_event_types ) == 102, "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." ); @@ -210,6 +211,7 @@ DEFINE_EVENT_FIELDS( teleports_into_wall ) DEFINE_EVENT_FIELDS( uses_debug_menu ) DEFINE_EVENT_FIELDS( u_var_changed ) DEFINE_EVENT_FIELDS( vehicle_moves ) +DEFINE_EVENT_FIELDS( character_butchered_corpse ) } // namespace event_detail diff --git a/src/event.h b/src/event.h index dddd9f08a90b2..64620ef2664f7 100644 --- a/src/event.h +++ b/src/event.h @@ -127,6 +127,7 @@ enum class event_type : int { uses_debug_menu, u_var_changed, vehicle_moves, + character_butchered_corpse, num_event_types // last }; @@ -187,7 +188,7 @@ struct event_spec_character_item { }; }; -static_assert( static_cast( event_type::num_event_types ) == 101, +static_assert( static_cast( event_type::num_event_types ) == 102, "This static_assert is to remind you to add a specialization for your new " "event_type below" ); @@ -491,6 +492,16 @@ struct event_spec { }; }; +template<> +struct event_spec { + static constexpr std::array, 3> fields = { { + { "character", cata_variant_type::character_id }, + { "monster_id", cata_variant_type::mtype_id }, + { "butcher_type", cata_variant_type::string }, + } + }; +}; + template<> struct event_spec : event_spec_character_item {}; diff --git a/src/memorial_logger.cpp b/src/memorial_logger.cpp index 412f7c460e538..0144a0f025dea 100644 --- a/src/memorial_logger.cpp +++ b/src/memorial_logger.cpp @@ -1143,6 +1143,7 @@ void memorial_logger::notify( const cata::event &e ) case event_type::game_begin: case event_type::u_var_changed: case event_type::vehicle_moves: + case event_type::character_butchered_corpse: break; case event_type::num_event_types: { debugmsg( "Invalid event type" );