From ccf9589ed3fdc1893eb2e02820294f9c85b978db Mon Sep 17 00:00:00 2001 From: Jim Huynh Date: Fri, 1 Oct 2021 16:42:29 -0700 Subject: [PATCH 1/4] Change charges consumed for hacksaw activity to use ammo scaling - fixing firearm repair kit hacksaw activity --- src/activity_actor.cpp | 10 ++++++++-- src/activity_actor_definitions.h | 1 + 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index 494a58e2bf2b4..c8aa98f733f86 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -1052,8 +1052,14 @@ 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 ); + if( tool->ammo_sufficient( &who, method ) ) { + int ammo_consumed = tool->ammo_required(); + std::map::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! diff --git a/src/activity_actor_definitions.h b/src/activity_actor_definitions.h index fbe8ed9af7ea7..6526a6bbc0e82 100644 --- a/src/activity_actor_definitions.h +++ b/src/activity_actor_definitions.h @@ -308,6 +308,7 @@ class hacksaw_activity_actor : public activity_actor private: tripoint target; item_location tool; + std::string method = "HACKSAW"; bool can_resume_with_internal( const activity_actor &other, const Character &/*who*/ ) const override { From ccc799359a58c5503dcf08b34ea509162df10272 Mon Sep 17 00:00:00 2001 From: Jim Huynh Date: Fri, 1 Oct 2021 19:05:26 -0700 Subject: [PATCH 2/4] Resolving clang errors --- src/activity_actor.cpp | 2 ++ src/activity_actor_definitions.h | 1 - 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/src/activity_actor.cpp b/src/activity_actor.cpp index c8aa98f733f86..206db0bd65af4 100644 --- a/src/activity_actor.cpp +++ b/src/activity_actor.cpp @@ -1052,6 +1052,8 @@ void hacksaw_activity_actor::start( player_activity &act, Character &/*who*/ ) void hacksaw_activity_actor::do_turn( player_activity &/*act*/, Character &who ) { + std::string method = "HACKSAW"; + if( tool->ammo_sufficient( &who, method ) ) { int ammo_consumed = tool->ammo_required(); std::map::const_iterator iter = tool->type->ammo_scale.find( method ); diff --git a/src/activity_actor_definitions.h b/src/activity_actor_definitions.h index 6526a6bbc0e82..fbe8ed9af7ea7 100644 --- a/src/activity_actor_definitions.h +++ b/src/activity_actor_definitions.h @@ -308,7 +308,6 @@ class hacksaw_activity_actor : public activity_actor private: tripoint target; item_location tool; - std::string method = "HACKSAW"; bool can_resume_with_internal( const activity_actor &other, const Character &/*who*/ ) const override { From 206bf3bef645d3aa0d6e3f9ee9b11370c137fe6e Mon Sep 17 00:00:00 2001 From: Jim Huynh Date: Fri, 1 Oct 2021 22:29:32 -0700 Subject: [PATCH 3/4] json fixes to correct unit tests for hacksaw charge use --- data/json/items/tool/workshop.json | 2 +- data/mods/TEST_DATA/items.json | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/data/json/items/tool/workshop.json b/data/json/items/tool/workshop.json index 59f5034475b92..779d06565dbf3 100644 --- a/data/json/items/tool/workshop.json +++ b/data/json/items/tool/workshop.json @@ -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": [ { diff --git a/data/mods/TEST_DATA/items.json b/data/mods/TEST_DATA/items.json index 3d47563667ec3..ef3f0d64d90c9 100644 --- a/data/mods/TEST_DATA/items.json +++ b/data/mods/TEST_DATA/items.json @@ -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", From 60aa2c3c5c11e0e9096210401a3cbcb50587ab4e Mon Sep 17 00:00:00 2001 From: Jim Huynh Date: Fri, 1 Oct 2021 22:35:29 -0700 Subject: [PATCH 4/4] json style fix --- data/json/items/tool/workshop.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/tool/workshop.json b/data/json/items/tool/workshop.json index 779d06565dbf3..e7c532e4fff62 100644 --- a/data/json/items/tool/workshop.json +++ b/data/json/items/tool/workshop.json @@ -886,7 +886,7 @@ [ "CHISEL", 3 ], [ "CHISEL_WOOD", 3 ] ], - "use_action": [ "GUN_REPAIR", [ "CROWBAR", 0 ], [ "HAMMER", 0 ], [ "HACKSAW", 0] ], + "use_action": [ "GUN_REPAIR", [ "CROWBAR", 0 ], [ "HAMMER", 0 ], [ "HACKSAW", 0 ] ], "flags": [ "ALLOWS_REMOTE_USE" ], "pocket_data": [ {