Skip to content

Commit

Permalink
Merge pull request #72647 from GuardianDll/butcher_event
Browse files Browse the repository at this point in the history
add character_butchered_corpse event
  • Loading branch information
akrieger authored Mar 27, 2024
2 parents 80560c3 + f230724 commit cb96143
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 2 deletions.
1 change: 1 addition & 0 deletions doc/EFFECT_ON_CONDITION.md
Original file line number Diff line number Diff line change
Expand Up @@ -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` },<br/> { "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` },<br/> { "corpse_type", `mtype_id` },<br/> { "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` },<br/> { "spell", `spell_id` },<br/> { "school", `trait_id` },<br/> { "difficulty", `int` },<br/> { "cost", `int` },<br/> { "cast_time", `int` },<br/> { "damage", `int` }, | character / NONE |
| character_consumes_item | | { "character", `character_id` },<br/> { "itype", `itype_id` }, | character / NONE |
| character_dies | | { "character", `character_id` }, | character / NONE |
Expand Down
3 changes: 3 additions & 0 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1394,6 +1394,9 @@ void activity_handlers::butcher_finish( player_activity *act, Character *you )

you->recoil = MAX_RECOIL;

get_event_bus().send<event_type::character_butchered_corpse>( 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.
Expand Down
4 changes: 3 additions & 1 deletion src/event.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,7 @@ std::string enum_to_string<event_type>( 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;
Expand All @@ -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<int>( event_type::num_event_types ) == 101,
static_assert( static_cast<int>( 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." );
Expand Down Expand Up @@ -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

Expand Down
13 changes: 12 additions & 1 deletion src/event.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,6 +127,7 @@ enum class event_type : int {
uses_debug_menu,
u_var_changed,
vehicle_moves,
character_butchered_corpse,
num_event_types // last
};

Expand Down Expand Up @@ -187,7 +188,7 @@ struct event_spec_character_item {
};
};

static_assert( static_cast<int>( event_type::num_event_types ) == 101,
static_assert( static_cast<int>( event_type::num_event_types ) == 102,
"This static_assert is to remind you to add a specialization for your new "
"event_type below" );

Expand Down Expand Up @@ -491,6 +492,16 @@ struct event_spec<event_type::character_attempt_to_fall_asleep> {
};
};

template<>
struct event_spec<event_type::character_butchered_corpse> {
static constexpr std::array<std::pair<const char *, cata_variant_type>, 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_type::character_wears_item> : event_spec_character_item {};

Expand Down
1 change: 1 addition & 0 deletions src/memorial_logger.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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" );
Expand Down

0 comments on commit cb96143

Please sign in to comment.