From 1cd6f545b117e54bc551cb4df43583a31e5e934c Mon Sep 17 00:00:00 2001 From: Valiant Date: Mon, 9 Sep 2024 20:18:57 +0400 Subject: [PATCH] Spawn deactivated bear trap after the effect ends --- src/character_escape.cpp | 5 ++++- src/trapfunc.cpp | 5 ++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/character_escape.cpp b/src/character_escape.cpp index 55566b17ac552..6f1ff58559878 100644 --- a/src/character_escape.cpp +++ b/src/character_escape.cpp @@ -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" ); @@ -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() ) { @@ -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, @@ -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!" ), _( " frees themselves from the bear trap!" ) ); } else { diff --git a/src/trapfunc.cpp b/src/trapfunc.cpp index 790f0429ef1f6..648374e73fad5 100644 --- a/src/trapfunc.cpp +++ b/src/trapfunc.cpp @@ -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 '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 '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() ); @@ -219,7 +219,6 @@ bool trapfunc::beartrap( const tripoint &p, Creature *c, item * ) c->check_dead_state(); } - here.spawn_item( p, "beartrap" ); return true; }