Skip to content

Commit

Permalink
Merge pull request CleverRaven#52038 from jim-huynh/firearm_kit_hacks…
Browse files Browse the repository at this point in the history
…aw_fix

Bugfixes Using the firearm repair kit to cut metal uses the battery
  • Loading branch information
Rivet-the-Zombie authored Oct 2, 2021
2 parents 7fae1b5 + 60aa2c3 commit 0436c6d
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 3 deletions.
2 changes: 1 addition & 1 deletion data/json/items/tool/workshop.json
Original file line number Diff line number Diff line change
Expand Up @@ -886,7 +886,7 @@
[ "CHISEL", 3 ],
[ "CHISEL_WOOD", 3 ]
],
"use_action": [ "GUN_REPAIR", [ "CROWBAR", 0 ], [ "HAMMER", 0 ] ],
"use_action": [ "GUN_REPAIR", [ "CROWBAR", 0 ], [ "HAMMER", 0 ], [ "HACKSAW", 0 ] ],
"flags": [ "ALLOWS_REMOTE_USE" ],
"pocket_data": [
{
Expand Down
1 change: 1 addition & 0 deletions data/mods/TEST_DATA/items.json
Original file line number Diff line number Diff line change
Expand Up @@ -1552,6 +1552,7 @@
"description": "Test hacksaw which uses batteries.",
"charges_per_use": 1,
"ammo": [ "battery" ],
"use_action": [ [ "HACKSAW", 1 ] ],
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand Down
12 changes: 10 additions & 2 deletions src/activity_actor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1052,8 +1052,16 @@ void hacksaw_activity_actor::start( player_activity &act, Character &/*who*/ )

void hacksaw_activity_actor::do_turn( player_activity &/*act*/, Character &who )
{
if( tool->ammo_sufficient( &who ) ) {
tool->ammo_consume( tool->ammo_required(), tool.position(), &who );
std::string method = "HACKSAW";

if( tool->ammo_sufficient( &who, method ) ) {
int ammo_consumed = tool->ammo_required();
std::map<std::string, float>::const_iterator iter = tool->type->ammo_scale.find( method );
if( iter != tool->type->ammo_scale.end() ) {
ammo_consumed *= iter->second;
}

tool->ammo_consume( ammo_consumed, tool.position(), &who );
sfx::play_activity_sound( "tool", "hacksaw", sfx::get_heard_volume( target ) );
if( calendar::once_every( 1_minutes ) ) {
//~ Sound of a metal sawing tool at work!
Expand Down

0 comments on commit 0436c6d

Please sign in to comment.