Skip to content

Commit

Permalink
Merge pull request #76312 from Night-Pryanik/beartrap
Browse files Browse the repository at this point in the history
Spawn triggered bear trap only after creature escapes from it
  • Loading branch information
Maleclypse authored Sep 11, 2024
2 parents 368e05b + 1cd6f54 commit e400e20
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
5 changes: 4 additions & 1 deletion src/character_escape.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ static const efftype_id effect_webbed( "webbed" );

static const flag_id json_flag_GRAB( "GRAB" );

static const itype_id itype_beartrap( "beartrap" );
static const itype_id itype_rope_6( "rope_6" );
static const itype_id itype_snare_trigger( "snare_trigger" );

Expand Down Expand Up @@ -89,7 +90,7 @@ void Character::try_remove_bear_trap()
/* Real bear traps can't be removed without the proper tools or immense strength; eventually this should
allow normal players two options: removal of the limb or removal of the trap from the ground
(at which point the player could later remove it from the leg with the right tools).
As such we are currently making it a bit easier for players and NPC's to get out of bear traps.
As such we are currently making it a bit easier for players and NPCs to get out of bear traps.
*/
// If is riding, then despite the character having the effect, it is the mounted creature that escapes.
if( is_avatar() && is_mounted() ) {
Expand All @@ -98,6 +99,7 @@ void Character::try_remove_bear_trap()
if( x_in_y( mon->type->melee_dice * mon->type->melee_sides, 200 ) ) {
mon->remove_effect( effect_beartrap );
remove_effect( effect_beartrap );
get_map().spawn_item( pos_bub(), itype_beartrap );
add_msg( _( "The %s escapes the bear trap!" ), mon->get_name() );
} else {
add_msg_if_player( m_bad,
Expand All @@ -107,6 +109,7 @@ void Character::try_remove_bear_trap()
} else {
if( can_escape_trap( 100 ) ) {
remove_effect( effect_beartrap );
get_map().spawn_item( pos_bub(), itype_beartrap );
add_msg_player_or_npc( m_good, _( "You free yourself from the bear trap!" ),
_( "<npcname> frees themselves from the bear trap!" ) );
} else {
Expand Down
5 changes: 2 additions & 3 deletions src/trapfunc.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -195,8 +195,8 @@ bool trapfunc::beartrap( const tripoint &p, Creature *c, item * )

// Messages
c->add_msg_player_or_npc( m_bad,
string_format( _( "A bear trap closes on your %s" ), body_part_name_accusative( hit ) ),
string_format( _( "A bear trap closes on <npcname>'s %s" ), body_part_name( hit ) ) );
string_format( _( "A bear trap closes on your %s!" ), body_part_name_accusative( hit ) ),
string_format( _( "A bear trap closes on <npcname>'s %s!" ), body_part_name( hit ) ) );

if( c->has_effect( effect_ridden ) ) {
add_msg( m_warning, _( "Your %s is caught by a beartrap!" ), c->get_name() );
Expand All @@ -219,7 +219,6 @@ bool trapfunc::beartrap( const tripoint &p, Creature *c, item * )
c->check_dead_state();
}

here.spawn_item( p, "beartrap" );
return true;
}

Expand Down

0 comments on commit e400e20

Please sign in to comment.