Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor battery usage #48608

Merged
merged 87 commits into from
Jul 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
87 commits
Select commit Hold shift + click to select a range
d89a3c9
convert electrick jackhammer
Hirmuolio Apr 19, 2021
b94fa40
item pwr drain refactor
Hirmuolio Apr 19, 2021
d78c3c4
jackhammering works
Hirmuolio Apr 19, 2021
ae7263d
ammo req
Hirmuolio Apr 19, 2021
5491d15
has_enough_electr
Hirmuolio Apr 19, 2021
c409944
maybe works now
Hirmuolio Apr 19, 2021
0992ef8
it compiles
Hirmuolio Apr 20, 2021
b79085d
use has_enough_electr
Hirmuolio Apr 20, 2021
c92187b
lint
Hirmuolio Apr 20, 2021
3dc28fd
UPS ammo does not exist anymore
Hirmuolio Apr 20, 2021
29a275e
use new method in places
Hirmuolio Apr 20, 2021
2dab75a
use new method in ranged
Hirmuolio Apr 20, 2021
822a4c4
ups in generic_game_turn_handler
Hirmuolio Apr 20, 2021
d7ece5a
new methods in more places
Hirmuolio Apr 20, 2021
448ca88
why is tis 2x I do not know
Hirmuolio Apr 20, 2021
39cb825
fix comparison
Hirmuolio Apr 20, 2021
af501ee
use new method
Hirmuolio Apr 20, 2021
360f6dd
astyle
Hirmuolio Apr 20, 2021
d92544c
fix item process
Hirmuolio Apr 20, 2021
313f58c
probably safe
Hirmuolio Apr 20, 2021
aa7572f
astyle
Hirmuolio Apr 20, 2021
6ffa402
cleanup
Hirmuolio Apr 20, 2021
a300df9
unused line
Hirmuolio Apr 20, 2021
1a01e10
reqrite
Hirmuolio Apr 20, 2021
52ba316
astyle
Hirmuolio Apr 20, 2021
6d2b4ac
ammo_consume(
Hirmuolio Apr 20, 2021
34e0065
astyle
Hirmuolio Apr 20, 2021
b99d6d2
ammo_remaining(
Hirmuolio Apr 20, 2021
58a2a9b
fix ups weapon
Hirmuolio Apr 20, 2021
e0e5086
unused variables
Hirmuolio Apr 21, 2021
0cd8c18
fix grenade
Hirmuolio Apr 21, 2021
f965076
wrong statement
Hirmuolio Apr 21, 2021
0d04c09
random fixes
Hirmuolio Apr 21, 2021
2183686
fix ammo count
Hirmuolio Apr 21, 2021
60b66bf
misc adjustments
Hirmuolio Apr 21, 2021
70d042c
fix grenade (again)
Hirmuolio Apr 21, 2021
0faffab
Use Character
Hirmuolio Apr 21, 2021
499b168
electr firestarter
Hirmuolio Apr 21, 2021
11fd91a
electr firestarter
Hirmuolio Apr 21, 2021
5d41aaf
astyle
Hirmuolio Apr 21, 2021
d855061
revert jackhammer
Hirmuolio Apr 22, 2021
a186738
seems like dead code
Hirmuolio Apr 22, 2021
f0be867
not used anymore
Hirmuolio Apr 22, 2021
45dae0f
unused ups code
Hirmuolio Apr 22, 2021
e0f0dc1
simplify check
Hirmuolio Apr 22, 2021
9a58010
small miss
Hirmuolio Apr 22, 2021
d5534f8
fix crafting with ups
Hirmuolio Apr 22, 2021
75ea210
crafting ups use
Hirmuolio Apr 22, 2021
b03ae52
cleaner
Hirmuolio Apr 22, 2021
815bef1
minimal improvements
Hirmuolio Apr 22, 2021
e8938d6
code that shouldn't run gives debug msg if it is spotted
Hirmuolio Apr 22, 2021
752accf
minor comment
Hirmuolio Apr 23, 2021
a32d59b
these parts are still used
Hirmuolio Apr 23, 2021
c9d7e75
duplicate check
Hirmuolio Apr 23, 2021
65a4334
available_ups()
Hirmuolio Apr 25, 2021
7119ffd
consume_ups faster
Hirmuolio Apr 25, 2021
95d3fb5
just call available_ups
Hirmuolio Apr 25, 2021
3ebbbbe
prevent overdrain
Hirmuolio May 1, 2021
70de4d2
large UPS rewrites
Hirmuolio May 3, 2021
65a6dbd
fix things
Hirmuolio May 3, 2021
b83b005
ups map drain
Hirmuolio May 3, 2021
d073d22
cleaner
Hirmuolio May 3, 2021
f1a1bf9
astyle
Hirmuolio May 3, 2021
8ac075b
unnecessary const
Hirmuolio May 3, 2021
1500c7d
fix bionic power for crafting tools
Hirmuolio May 3, 2021
4659148
ups from map and inventory
Hirmuolio May 6, 2021
c1498af
don't run this twice
Hirmuolio May 6, 2021
a45817a
mandatory carrier for ammo_sufficient
Hirmuolio May 7, 2021
d3fb832
unnecessary double check
Hirmuolio May 7, 2021
eb49809
obsolete adv ups
Hirmuolio May 14, 2021
38721c4
ups bionic for crafting
Hirmuolio Jun 19, 2021
d18daef
return pure ups power only
Hirmuolio Jun 19, 2021
c8cfbd4
removed comment
Hirmuolio Jun 19, 2021
3f00f7f
unnecessary is_tool check
Hirmuolio Jun 30, 2021
6a3e3cb
improved charges_of_internal
Hirmuolio Jun 30, 2021
47fb870
force-push improvements
Hirmuolio Jul 4, 2021
5d7fa38
astyle
Hirmuolio Jul 4, 2021
8c15666
fix starting repair
Hirmuolio Jul 7, 2021
1185428
fix repair bionic consumption
Hirmuolio Jul 7, 2021
1bb36f0
rebase fixes
Hirmuolio Jul 12, 2021
42ce4c1
unused itype_toolset
Hirmuolio Jul 12, 2021
14a87cd
aftershock migration
Hirmuolio Jul 12, 2021
60ffaf5
info in json
Hirmuolio Jul 12, 2021
bf0ebce
astyle
Hirmuolio Jul 12, 2021
c0f9a4b
unused variable
Hirmuolio Jul 13, 2021
cc0bdb2
adv ups not more efficient
Hirmuolio Jul 14, 2021
cc25bc5
remove Character::has_enough_charges
Hirmuolio Jul 16, 2021
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1419,7 +1419,8 @@
{
"id": "IS_UPS",
"type": "json_flag",
"context": [ ]
"context": [ ],
"info": "This item provides power to <info>UPS compatible items</info>."
},
{
"id": "LEAK_DAM",
Expand Down
9 changes: 3 additions & 6 deletions data/json/itemgroups/Clothing_Gear/clothing.json
Original file line number Diff line number Diff line change
Expand Up @@ -1948,8 +1948,7 @@
[ "optical_cloak", 1 ],
[ "holo_cloak", 1 ],
[ "backpack", 38 ],
{ "item": "UPS_off", "prob": 5, "charges": [ 0, 1000 ] },
[ "adv_UPS_off", 3 ],
{ "item": "UPS_off", "prob": 8, "charges": [ 0, 1000 ] },
[ "tacvest", 10 ],
[ "molle_pack", 8 ],
[ "duffelbag", 15 ],
Expand Down Expand Up @@ -1989,8 +1988,7 @@
{ "item": "mil_mess_kit", "prob": 1, "charges": [ 0, 500 ] },
[ "backpack", 38 ],
[ "briefcase", 10 ],
{ "item": "UPS_off", "prob": 5, "charges": [ 0, 1000 ] },
[ "adv_UPS_off", 3 ],
{ "item": "UPS_off", "prob": 8, "charges": [ 0, 1000 ] },
[ "chestguard_hard", 20 ],
[ "armguard_hard", 20 ],
[ "legguard_hard", 15 ],
Expand Down Expand Up @@ -2111,8 +2109,7 @@
[ "legpouch_large", 6 ],
[ "chestpouch", 9 ],
[ "ammo_satchel", 4 ],
{ "item": "UPS_off", "prob": 5, "charges": [ 0, 1000 ] },
[ "adv_UPS_off", 3 ],
{ "item": "UPS_off", "prob": 8, "charges": [ 0, 1000 ] },
[ "tacvest", 10 ],
[ "molle_pack", 8 ],
[ "legrig", 10 ],
Expand Down
5 changes: 2 additions & 3 deletions data/json/itemgroups/Clothing_Gear/gear.json
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,7 @@
[ "knee_pads", 5 ],
[ "elbow_pads", 5 ],
[ "legrig", 5 ],
{ "item": "UPS_off", "prob": 5, "charges": [ 0, 1000 ] },
[ "adv_UPS_off", 2 ],
{ "item": "UPS_off", "prob": 7, "charges": [ 0, 1000 ] },
[ "emer_blanket", 5 ],
{ "group": "ammo_pocket_batteries_full", "prob": 50 },
[ "tool_belt", 5 ],
Expand All @@ -154,7 +153,7 @@
{ "item": "rad_monitor", "prob": 10, "charges": [ 0, 100 ] },
{ "item": "oxygen_tank", "prob": 10, "charges-min": 0 },
{ "item": "smoxygen_tank", "prob": 15, "charges-min": 0 },
[ "adv_UPS_off", 2 ],
[ "UPS_off", 2 ],
{ "item": "prussian_blue", "prob": 25, "charges": [ 1, 10 ] },
{ "item": "iodine", "prob": 50, "charges": [ 1, 10 ] }
]
Expand Down
2 changes: 1 addition & 1 deletion data/json/itemgroups/Locations_MapExtras/locations.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@
{ "group": "gunmod_energy", "prob": 40 },
{ "item": "plut_cell", "prob": 30, "charges": [ 1, 5 ] },
[ "plasma", 30 ],
[ "adv_UPS_off", 20 ]
[ "UPS_off", 20 ]
]
},
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,7 @@
{ "item": "bot_grenade_hack", "prob": 1 },
{ "item": "bot_flashbang_hack", "prob": 1 },
{ "item": "bot_gasbomb_hack", "prob": 1 },
{ "item": "UPS_off", "prob": 5 },
{ "item": "adv_UPS_off", "prob": 3 },
{ "item": "UPS_off", "prob": 8 },
{ "item": "bio_power_storage", "prob": 10 },
{ "item": "bio_flashlight", "prob": 10 },
{ "item": "bio_lighter", "prob": 10 },
Expand Down
3 changes: 1 addition & 2 deletions data/json/itemgroups/activities_hobbies.json
Original file line number Diff line number Diff line change
Expand Up @@ -249,8 +249,7 @@
{ "item": "water_purifier", "prob": 5, "charges": [ 0, 100 ] },
{ "item": "radio", "prob": 20, "charges": [ 0, 100 ] },
[ "beartrap", 5 ],
{ "item": "UPS_off", "prob": 5, "charges": [ 0, 1000 ] },
[ "adv_UPS_off", 3 ],
{ "item": "UPS_off", "prob": 8, "charges": [ 0, 1000 ] },
[ "string_36", 40 ],
[ "longbow", 5 ],
[ "compbow", 1 ],
Expand Down
2 changes: 1 addition & 1 deletion data/json/itemgroups/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@
{ "item": "knife_rm42", "prob": 10 },
{ "item": "laser_rifle", "prob": 10 },
{ "item": "mininuke", "prob": 10 },
{ "item": "adv_UPS_off", "prob": 10 },
{ "item": "UPS_off", "prob": 10 },
{ "item": "optical_cloak", "prob": 10 },
{ "item": "superalloy_harness_dog", "prob": 10 },
{ "item": "holo_cloak", "prob": 10 },
Expand Down
3 changes: 1 addition & 2 deletions data/json/itemgroups/military.json
Original file line number Diff line number Diff line change
Expand Up @@ -552,8 +552,7 @@
{ "item": "v8_combustion", "prob": 10 },
{ "item": "extinguisher", "prob": 20, "charges": 100 },
{ "item": "radio", "prob": 20, "charges": [ 0, 100 ] },
{ "item": "UPS_off", "prob": 5, "charges": [ 0, 1000 ] },
{ "item": "adv_UPS_off", "prob": 3 },
{ "item": "UPS_off", "prob": 8, "charges": [ 0, 1000 ] },
{ "item": "tacvest", "prob": 10 },
{ "item": "molle_pack", "prob": 8 },
{ "item": "legrig", "prob": 10 },
Expand Down
3 changes: 1 addition & 2 deletions data/json/itemgroups/science_and_tech.json
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,7 @@
[ "flux_comp_gen", 3 ],
[ "portal", 2 ],
[ "bot_manhack", 1 ],
{ "item": "UPS_off", "prob": 5, "charges": [ 0, 1000 ] },
[ "adv_UPS_off", 3 ],
{ "item": "UPS_off", "prob": 8, "charges": [ 0, 1000 ] },
{ "item": "tazer", "prob": 3, "charges": [ 0, 500 ] },
{ "item": "plasma", "prob": 8, "charges": [ 1, 25 ] },
[ "usb_drive", 5 ],
Expand Down
6 changes: 0 additions & 6 deletions data/json/items/ammo_types.json
Original file line number Diff line number Diff line change
Expand Up @@ -467,12 +467,6 @@
"name": "ferrous rail projectile",
"default": "rebar_rail"
},
{
"type": "ammunition_type",
"id": "UPS",
"name": "UPS",
"default": "UPS"
},
{
"type": "ammunition_type",
"id": "thrown",
Expand Down
7 changes: 6 additions & 1 deletion data/json/items/migration.json
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
{
"id": "adv_UPS_on",
"type": "MIGRATION",
"replace": "adv_UPS_off"
"replace": "UPS_off"
},
{
"id": "battery_truck",
Expand Down Expand Up @@ -1420,5 +1420,10 @@
"id": "gloves_xlsurvivor",
"type": "MIGRATION",
"replace": "xl_gloves_survivor"
},
{
"id": "adv_UPS_off",
"type": "MIGRATION",
"replace": "UPS_off"
}
]
26 changes: 0 additions & 26 deletions data/json/items/tool/electronics.json
Original file line number Diff line number Diff line change
@@ -1,30 +1,4 @@
[
{
"id": "adv_UPS_off",
"type": "TOOL",
"name": { "str": "advanced UPS", "str_pl": "advanced UPS's" },
"description": "This is an advanced version of the unified power supply, or UPS. This device has been significantly redesigned to provide better efficiency as well as to consume plutonium fuel batteries rather than regular batteries. Sadly, its plutonium reactor can't be charged in UPS charging station.",
"weight": "453 g",
"volume": "2 L",
"price": 560000,
"price_postapoc": 3000,
"to_hit": -1,
"bashing": 8,
"material": [ "aluminum", "plastic" ],
"symbol": ";",
"color": "light_green",
"ammo": [ "battery" ],
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
"holster": true,
"max_contains_volume": "20 L",
"max_contains_weight": "20 kg",
"item_restriction": [ "heavy_atomic_battery_cell" ]
}
],
"flags": [ "IS_UPS" ]
},
{
"id": "camera",
"type": "TOOL",
Expand Down
3 changes: 1 addition & 2 deletions data/json/npcs/NC_SOLDIER.json
Original file line number Diff line number Diff line change
Expand Up @@ -136,8 +136,7 @@
{ "item": "goggles_nv", "prob": 1 },
{ "item": "goggles_ir", "prob": 1 },
{ "item": "optical_cloak", "prob": 1 },
{ "item": "UPS_off", "prob": 5 },
{ "item": "adv_UPS_off", "prob": 3 },
{ "item": "UPS_off", "prob": 8 },
{ "item": "tacvest", "prob": 10 },
{ "item": "backpack", "prob": 8 },
{ "item": "dump_pouch", "prob": 20 },
Expand Down
3 changes: 1 addition & 2 deletions data/json/npcs/items_generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,6 @@
[ "adderall", 2 ],
[ "adjustable_stock", 1 ],
[ "adv_chemistry", 1 ],
[ "adv_UPS_off", 1 ],
[ "advanced_ecig", 5 ],
[ "advanced_electronics", 1 ],
[ "airhorn", 3 ],
Expand Down Expand Up @@ -1082,7 +1081,7 @@
[ "trappers_companion", 2 ],
[ "triple_sec", 2 ],
[ "two_way_radio", 10 ],
[ "UPS_off", 3 ],
[ "UPS_off", 4 ],
[ "umbrella", 3 ],
[ "usb_drive", 3 ],
[ "V8", 3 ],
Expand Down
26 changes: 26 additions & 0 deletions data/json/obsolete.json
Original file line number Diff line number Diff line change
Expand Up @@ -1547,5 +1547,31 @@
],
"tools": [ [ [ "tongs", -1 ] ], [ [ "swage", -1 ] ], [ [ "surface_heat", 1, "LIST" ], [ "forge", 1 ], [ "oxy_torch", 1 ] ] ],
"components": [ [ [ "copper", 1 ] ], [ [ "duct_tape", 1 ] ] ]
},
{
"id": "adv_UPS_off",
"type": "TOOL",
"name": { "str": "advanced UPS", "str_pl": "advanced UPS's" },
"description": "This is an advanced version of the unified power supply, or UPS. This device has been significantly redesigned to provide better efficiency as well as to consume plutonium fuel batteries rather than regular batteries. Sadly, its plutonium reactor can't be charged in UPS charging station.",
"weight": "453 g",
"volume": "2 L",
"price": 560000,
"price_postapoc": 3000,
"to_hit": -1,
"bashing": 8,
"material": [ "aluminum", "plastic" ],
"symbol": ";",
"color": "light_green",
"ammo": [ "battery" ],
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
"holster": true,
"max_contains_volume": "20 L",
"max_contains_weight": "20 kg",
"item_restriction": [ "heavy_atomic_battery_cell" ]
}
],
"flags": [ "IS_UPS" ]
}
]
17 changes: 0 additions & 17 deletions data/json/recipes/other/power_supplies.json
Original file line number Diff line number Diff line change
Expand Up @@ -76,23 +76,6 @@
"qualities": [ { "id": "SCREW", "level": 1 } ],
"components": [ [ [ "power_supply", 4 ] ], [ [ "amplifier", 3 ] ], [ [ "scrap", 4 ] ], [ [ "cable", 10 ] ] ]
},
{
"type": "recipe",
"activity_level": "LIGHT_EXERCISE",
"result": "adv_UPS_off",
"category": "CC_ELECTRONIC",
"subcategory": "CSC_ELECTRONIC_COMPONENTS",
"skill_used": "electronics",
"skills_required": [ "mechanics", 1 ],
"difficulty": 9,
"time": "1 h 25 m",
"reversible": true,
"decomp_learn": 4,
"book_learn": [ [ "recipe_lab_elec", 7 ] ],
"using": [ [ "soldering_standard", 24 ] ],
"qualities": [ { "id": "SCREW", "level": 1 } ],
"components": [ [ [ "power_supply", 6 ] ], [ [ "amplifier", 5 ] ], [ [ "scrap", 4 ] ], [ [ "cable", 14 ] ], [ [ "plut_cell", 2 ] ] ]
},
{
"type": "recipe",
"activity_level": "LIGHT_EXERCISE",
Expand Down
8 changes: 8 additions & 0 deletions data/mods/Aftershock/items/migration.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
[
{
"id": "adv_UPS_off",
"type": "MIGRATION",
"replace": "adv_UPS_off",
"//": "Overrides migration from CDDA."
}
]
2 changes: 1 addition & 1 deletion data/mods/Aftershock/items/tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
"type": "TOOL_ARMOR",
"copy-from": "adv_UPS_off",
"name": { "str": "advanced UPS", "str_pl": "advanced UPS's" },
"description": "This is an advanced version of the unified power supply, or UPS. This device has been significantly redesigned to provide better efficiency as well as to consume plutonium fuel cells rather than batteries, and is both slimmer and lighter to wear. Sadly, its plutonium reactor can't be charged in UPS charging station.",
"description": "This is an advanced version of the unified power supply, or UPS. This device has been significantly redesigned to consume plutonium fuel cells rather than batteries, and is both slimmer and lighter to wear. Sadly, its plutonium reactor can't be charged in UPS charging station.",
"sided": true,
"flags": [ "WAIST", "FRAGILE", "OVERSIZE", "IS_UPS" ],
"armor": [ { "encumbrance": 1, "coverage": 5, "covers": [ "leg_l", "leg_r" ] } ]
Expand Down
33 changes: 11 additions & 22 deletions src/activity_handlers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -205,7 +205,6 @@ static const itype_id itype_splinter( "splinter" );
static const itype_id itype_stick_long( "stick_long" );
static const itype_id itype_steel_chunk( "steel_chunk" );
static const itype_id itype_steel_plate( "steel_plate" );
static const itype_id itype_UPS( "UPS" );
static const itype_id itype_wire( "wire" );
static const itype_id itype_chain( "chain" );

Expand Down Expand Up @@ -1697,13 +1696,7 @@ void activity_handlers::generic_game_turn_handler( player_activity *act, player
if( calendar::once_every( 1_minutes ) ) {
if( !act->targets.empty() ) {
item &game_item = *act->targets.front();
const int ammo_required = game_item.ammo_required();
bool fail = false;
if( game_item.has_flag( flag_USE_UPS ) ) {
fail = !p->use_charges_if_avail( itype_UPS, ammo_required );
} else {
fail = game_item.ammo_consume( ammo_required, p->pos() ) == 0;
}
bool fail = game_item.ammo_consume( game_item.ammo_required(), tripoint_zero, p ) == 0;
if( fail ) {
act->moves_left = 0;
add_msg( m_info, _( "The %s runs out of batteries." ), game_item.tname() );
Expand Down Expand Up @@ -1922,9 +1915,8 @@ void activity_handlers::start_fire_finish( player_activity *act, player *p )
return;
}

if( it.type->can_have_charges() ) {
p->consume_charges( it, it.type->charges_to_use() );
}
it.ammo_consume( it.type->charges_to_use(), tripoint_zero, p );

p->practice( skill_survival, act->index, 5 );

firestarter_actor::resolve_firestarter_use( *p, act->placement );
Expand Down Expand Up @@ -2132,10 +2124,10 @@ void activity_handlers::vibe_do_turn( player_activity *act, player *p )
}

if( calendar::once_every( 1_minutes ) ) {
if( vibrator_item.ammo_remaining() > 0 ) {
vibrator_item.ammo_consume( 1, p->pos() );
if( vibrator_item.ammo_remaining( p ) > 0 ) {
vibrator_item.ammo_consume( 1, p->pos(), p );
p->add_morale( MORALE_FEELING_GOOD, 3, 40 );
if( vibrator_item.ammo_remaining() == 0 ) {
if( vibrator_item.ammo_remaining( p ) == 0 ) {
add_msg( m_info, _( "The %s runs out of batteries." ), vibrator_item.tname() );
}
} else {
Expand Down Expand Up @@ -2236,7 +2228,7 @@ void activity_handlers::oxytorch_do_turn( player_activity *act, player *p )
// act->values[0] is the number of charges yet to be consumed
const int charges_used = std::min( act->values[0], it.ammo_required() );

it.ammo_consume( charges_used, p->pos() );
it.ammo_consume( charges_used, p->pos(), p );
act->values[0] -= static_cast<int>( charges_used );

sfx::play_activity_sound( "tool", "oxytorch", sfx::get_heard_volume( act->placement ) );
Expand All @@ -2253,7 +2245,7 @@ void activity_handlers::oxytorch_finish( player_activity *act, player *p )
const ter_id ter = here.ter( pos );
const furn_id furn = here.furn( pos );
// fast players might still have some charges left to be consumed
act->targets.front()->ammo_consume( act->values[0], p->pos() );
act->targets.front()->ammo_consume( act->values[0], p->pos(), p );

if( furn == f_rack ) {
here.furn_set( pos, f_null );
Expand Down Expand Up @@ -2480,7 +2472,7 @@ void activity_handlers::repair_item_finish( player_activity *act, player *p )
const repair_item_actor::attempt_hint attempt = actor->repair( *p, *used_tool, fix_location );
if( attempt != repair_item_actor::AS_CANT ) {
if( ploc && ploc->where() == item_location::type::map ) {
used_tool->ammo_consume( used_tool->ammo_required(), ploc->position() );
used_tool->ammo_consume( used_tool->ammo_required(), ploc->position(), p );
} else {
p->consume_charges( *used_tool, used_tool->ammo_required() );
}
Expand Down Expand Up @@ -2569,10 +2561,7 @@ void activity_handlers::repair_item_finish( player_activity *act, player *p )
ammo_name = item::nname( used_tool->ammo_current() );
}

int ammo_remaining = used_tool->ammo_remaining();
if( used_tool->has_flag( flag_USE_UPS ) ) {
ammo_remaining = p->charges_of( itype_UPS );
}
int ammo_remaining = used_tool->ammo_remaining( p );

std::set<itype_id> valid_entries = actor->get_valid_repair_materials( fix );
const inventory &crafting_inv = p->crafting_inventory();
Expand Down Expand Up @@ -3817,7 +3806,7 @@ void activity_handlers::jackhammer_finish( player_activity *act, player *p )
act->set_to_null();
if( !act->targets.empty() ) {
item &it = *act->targets.front();
p->consume_charges( it, it.ammo_required() );
it.ammo_consume( it.ammo_required(), tripoint_zero, p );
} else {
debugmsg( "jackhammer activity targets empty" );
}
Expand Down
Loading