From a08e243fc967468090ab04337cb94255e6a7ab55 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Tue, 1 Aug 2023 17:13:16 -0500 Subject: [PATCH 01/14] Documentation --- doc/JSON_FLAGS.md | 2 +- doc/JSON_INFO.md | 1 + src/item.cpp | 1 + 3 files changed, 3 insertions(+), 1 deletion(-) diff --git a/doc/JSON_FLAGS.md b/doc/JSON_FLAGS.md index 46f6753d37738..4725b18d6c2f6 100644 --- a/doc/JSON_FLAGS.md +++ b/doc/JSON_FLAGS.md @@ -1346,7 +1346,7 @@ Melee flags are fully compatible with tool flags, and vice versa. - ```ALLOWS_REMOTE_USE``` This item can be activated or reloaded from adjacent tile without picking it up. - ```BELT_CLIP``` The item can be clipped or hooked on to a belt loop of the appropriate size (belt loops are limited by their max_volume and max_weight properties) - ```BOMB``` It can be a remote controlled bomb. -- ```CABLE_SPOOL``` This item is a cable spool and must be processed as such. It should usually have a "link_up" iuse_action that describes what it can be connected to and how. +- ```CABLE_SPOOL``` This item is a spool of cable and must be processed as such. It should usually have a "link_up" iuse_action, which it has special behavior for. - ```CANNIBALISM``` The item is a food that contains human flesh, and applies all applicable effects when consumed. - ```CHARGEDIM``` If illuminated, light intensity fades with charge, starting at 20% charge left. - ```DIG_TOOL``` If wielded, digs thorough terrain like rock and walls, as player walks into them. If item also has ```POWERED``` flag, then it digs faster, but uses up the item's ammo as if activating it. diff --git a/doc/JSON_INFO.md b/doc/JSON_INFO.md index d59333efe1f7b..a15c056f13146 100644 --- a/doc/JSON_INFO.md +++ b/doc/JSON_INFO.md @@ -4035,6 +4035,7 @@ The contents of use_action fields can either be a string indicating a built-in f }, "use_action": { "type": "link_up", // Connect item to a vehicle or appliance, such as plugging a chargeable device into a power source. + // If the item has the CABLE_SPOOL flag, it has special behaviors available, like connecting vehicles together. "cable_length": 4 // Maximum length of the cable ( Optional, defaults to the item type's maximum charges ). // If extended by other cables, will use the sum of all cables' lengths. "charge_rate": "60 W" // The charge rate of the plugged-in device's batteries in watts. ( Optional, defaults to "0 W" ) diff --git a/src/item.cpp b/src/item.cpp index 76d2a3edb688b..71823e049b3b1 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -13562,6 +13562,7 @@ bool item::process_internal( map &here, Character *carrier, const tripoint &pos, } if( has_flag( flag_CABLE_SPOOL ) && mark_flag() ) { // DO NOT process this as a tool! It really isn't! + // Cables have been reworked and shouldn't be active items anymore. active = false; return false; } From eb39526e99dc33bcfbc309f90bb0b286ec95a6c2 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 02:10:15 -0500 Subject: [PATCH 02/14] Adjust cable descriptions --- data/json/items/tool/cables.json | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/data/json/items/tool/cables.json b/data/json/items/tool/cables.json index bf5e6abc56da1..869438a806d32 100644 --- a/data/json/items/tool/cables.json +++ b/data/json/items/tool/cables.json @@ -61,7 +61,7 @@ "type": "TOOL", "id": "extension_cable", "name": { "str": "extension cord" }, - "description": "A long 30-foot (or about 10 m) orange extension cord for connecting appliances. Could be used on any appliance or other household electrical system.", + "description": "A long 30-foot (or about 10 m) orange extension cord for extending cables or connecting appliances. Could be used on any appliance or other household electrical system.", "to_hit": 1, "color": "light_blue", "symbol": "&", @@ -86,7 +86,7 @@ "type": "TOOL", "id": "long_extension_cable", "name": { "str": "outdoor extension cord" }, - "description": "An extra-long 100-foot (or about 30 m) orange extension cord for connecting outdoor appliances. Could be used on any appliance or other household electrical system.", + "description": "An extra-long 100-foot (or about 30 m) orange extension cord for extending cables or connecting outdoor appliances. Could be used on any appliance or other household electrical system.", "copy-from": "extension_cable", "volume": "3750 ml", "weight": "2500 g", @@ -98,7 +98,7 @@ "type": "TOOL", "id": "hd_tow_cable", "name": { "str": "heavy-duty tow cable" }, - "description": "An extremely heavy-duty 75-foot (or about 24 m) tow cable made from thick steel wire coated in plastic. If attached to a vehicle, it could be used to pull another vehicle of any weight.", + "description": "An extremely heavy-duty 20-foot (or about 6 m) tow cable made from thick steel wire coated in plastic. If attached to a vehicle, it could be used to pull another vehicle of any weight.", "to_hit": -1, "color": "light_blue", "symbol": "&", From 31315b66169f0f8c158d390d01e6ce2dae448f5a Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 02:11:39 -0500 Subject: [PATCH 03/14] Fix being unable to plug in appliances --- src/veh_appliance.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/veh_appliance.cpp b/src/veh_appliance.cpp index fd462952f489c..c3410c454177a 100644 --- a/src/veh_appliance.cpp +++ b/src/veh_appliance.cpp @@ -526,7 +526,7 @@ void veh_app_interact::plug() { const int part = veh->part_at( a_point ); const tripoint pos = veh->global_part_pos3( part ); - veh->plug_in( get_map().getabs( pos ) ); + veh->plug_in( pos ); } void veh_app_interact::populate_app_actions() From 8c63599720b94c6233b6a2d9a0cfde4e5c568031 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 02:13:11 -0500 Subject: [PATCH 04/14] Fix being able to connect appliances more than once --- src/iuse_actor.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index e04cfc17b1635..1fdb751da8cb7 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -4811,7 +4811,7 @@ std::optional link_up_actor::link_to_veh_app( Character *p, item &it, ( it.link->t_abs_pos + prev_veh->coord_translate( it.link->t_mount ) ).raw(), it.link->t_abs_pos.raw() ); - for( const vpart_reference &vpr : sel_veh->get_any_parts( "POWER_TRANSFER" ) ) { + for( const vpart_reference &vpr : prev_veh->get_any_parts( "POWER_TRANSFER" ) ) { if( vpr.part().target.first == prev_part_target.first && vpr.part().target.second == prev_part_target.second ) { p->add_msg_if_player( m_warning, _( "The %1$s and %2$s are already connected." ), From 23d1acebdc0b588c28cc2df6758a6797071a4c02 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 02:14:35 -0500 Subject: [PATCH 05/14] Fix appliance links having more than 2 tiles of slack --- data/json/items/tool/cables.json | 6 +++--- src/vehicle_use.cpp | 1 + 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/data/json/items/tool/cables.json b/data/json/items/tool/cables.json index 869438a806d32..e0f2c06f852da 100644 --- a/data/json/items/tool/cables.json +++ b/data/json/items/tool/cables.json @@ -98,7 +98,7 @@ "type": "TOOL", "id": "hd_tow_cable", "name": { "str": "heavy-duty tow cable" }, - "description": "An extremely heavy-duty 20-foot (or about 6 m) tow cable made from thick steel wire coated in plastic. If attached to a vehicle, it could be used to pull another vehicle of any weight.", + "description": "An extremely heavy-duty 30-foot (or about 9 m) tow cable made from thick steel wire coated in plastic. If attached to a vehicle, it could be used to pull another vehicle of any weight.", "to_hit": -1, "color": "light_blue", "symbol": "&", @@ -108,8 +108,8 @@ "category": "tools", "price": 80, "price_postapoc": 500, - "max_charges": 6, - "initial_charges": 6, + "max_charges": 8, + "initial_charges": 8, "use_action": { "type": "link_up", "menu_text": "Attach / Manage connections", diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index dfe43546610f3..d0554fda5a963 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -550,6 +550,7 @@ item vehicle::init_cord( const tripoint &pos ) cord.link->t_veh_safe = get_safe_reference(); cord.link->t_abs_pos = get_map().getglobal( pos ); cord.set_link_traits(); + cord.link->max_length = 2; return cord; } From b7f3017ffff9c295b98c84d95bed755e8f52cdd1 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 02:15:08 -0500 Subject: [PATCH 06/14] Reformat `vehicle::connect` to match `link_up_actor::link_to_veh_app` --- src/vehicle_use.cpp | 47 +++++++++++++++++++++++++++------------------ 1 file changed, 28 insertions(+), 19 deletions(-) diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index d0554fda5a963..5595498cc9bbb 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -569,34 +569,43 @@ void vehicle::connect( const tripoint &source_pos, const tripoint &target_pos ) item cord = init_cord( source_pos ); map &here = get_map(); - const optional_vpart_position target_vp = here.veh_at( target_pos ); - const optional_vpart_position source_vp = here.veh_at( source_pos ); + const optional_vpart_position sel_vp = here.veh_at( target_pos ); + const optional_vpart_position prev_vp = here.veh_at( source_pos ); - if( !target_vp ) { + if( !sel_vp ) { return; } - vehicle *const target_veh = &target_vp->vehicle(); - vehicle *const source_veh = &source_vp->vehicle(); - if( source_veh == target_veh ) { + vehicle *const sel_veh = &sel_vp->vehicle(); + vehicle *const prev_veh = &prev_vp->vehicle(); + if( prev_veh == sel_veh ) { return ; } tripoint target_global = here.getabs( target_pos ); const vpart_id vpid( cord.typeId().str() ); - point vcoords = source_vp->mount(); - vehicle_part source_part( vpid, item( cord ) ); - source_part.target.first = target_global; - source_part.target.second = target_veh->global_square_location().raw(); - source_veh->install_part( vcoords, std::move( source_part ) ); - source_veh->precalc_mounts( 1, source_veh->pivot_rotation[1], source_veh->pivot_anchor[1] ); - - vcoords = target_vp->mount(); - vehicle_part target_part( vpid, item( cord ) ); - target_part.target.first = cord.link->t_abs_pos.raw(); - target_part.target.second = source_veh->global_square_location().raw(); - target_veh->install_part( vcoords, std::move( target_part ) ); - target_veh->precalc_mounts( 1, target_veh->pivot_rotation[1], target_veh->pivot_anchor[1] ); + // Prepare target tripoints for the cable parts that'll be added to the selected/previous vehicles + const std::pair prev_part_target = std::make_pair( + here.getabs( target_pos ), + sel_veh->global_square_location().raw() ); + const std::pair sel_part_target = std::make_pair( + ( cord.link->t_abs_pos + prev_veh->coord_translate( cord.link->t_mount ) ).raw(), + cord.link->t_abs_pos.raw() ); + + const point vcoords1 = cord.link->t_mount; + const point vcoords2 = sel_vp->mount(); + + vehicle_part prev_veh_part( vpid, item( cord ) ); + prev_veh_part.target.first = prev_part_target.first; + prev_veh_part.target.second = prev_part_target.second; + prev_veh->install_part( vcoords1, std::move( prev_veh_part ) ); + prev_veh->precalc_mounts( 1, prev_veh->pivot_rotation[1], prev_veh->pivot_anchor[1] ); + + vehicle_part sel_veh_part( vpid, item( cord ) ); + sel_veh_part.target.first = sel_part_target.first; + sel_veh_part.target.second = sel_part_target.second; + sel_veh->install_part( vcoords2, std::move( sel_veh_part ) ); + sel_veh->precalc_mounts( 1, sel_veh->pivot_rotation[1], sel_veh->pivot_anchor[1] ); } double vehicle::engine_cold_factor( const vehicle_part &vp ) const From 9733e13ef047e7902a1210849acacb745c303b8a Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 05:45:10 -0500 Subject: [PATCH 07/14] Fix cables not drawing power --- src/item.cpp | 9 ++++++++- src/savegame_json.cpp | 2 +- 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/src/item.cpp b/src/item.cpp index 71823e049b3b1..2cb4b05352666 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -12965,7 +12965,7 @@ void item::set_link_traits( const bool assign_t_state ) const link_up_actor *it_actor = static_cast ( get_use( "link_up" )->get_actor_ptr() ); link->max_length = it_actor->cable_length == -1 ? type->maximum_charges() : it_actor->cable_length; - link->efficiency = it_actor->efficiency < MIN_LINK_EFFICIENCY ? 0.0f : link->efficiency; + link->efficiency = it_actor->efficiency < MIN_LINK_EFFICIENCY ? 0.0f : it_actor->efficiency; // Reset s_bub_pos to force the item to check the length during process_link. link->s_bub_pos = tripoint_min; @@ -12981,6 +12981,13 @@ void item::set_link_traits( const bool assign_t_state ) link->efficiency * actor->efficiency; } + link->charge_rate = link->efficiency < MIN_LINK_EFFICIENCY ? 0 : it_actor->charge_rate.value(); + // Convert charge_rate to how long it takes to charge 1 kW, the unit batteries use. + // 0 means batteries won't be charged, but it can still provide power to devices unless efficiency is also 0. + link->charge_interval = link->efficiency < MIN_LINK_EFFICIENCY || it_actor->charge_rate == 0_W ? 0 : + std::max( static_cast( std::floor( 1000000.0 / abs( it_actor->charge_rate.value() ) + 0.5 ) ), + 1 ); + if( assign_t_state && link->t_veh_safe ) { // Assign t_state based on the parts available at the connected mount point. if( it_actor->targets.find( link_state::vehicle_port ) != it_actor->targets.end() && diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 5914508845df7..e94b9b4a96a72 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -2870,8 +2870,8 @@ void item::link_data::serialize( JsonOut &jsout ) const jsout.member( "link_max_length", max_length ); jsout.member( "link_last_processed", last_processed ); jsout.member( "link_charge_rate", charge_rate ); - jsout.member( "link_charge_interval", charge_interval ); jsout.member( "link_charge_efficiency", efficiency ); + jsout.member( "link_charge_interval", charge_interval ); jsout.end_object(); } From f9fbe0e88598a66ce28d41fbf3cb91998aff6eec Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 06:22:36 -0500 Subject: [PATCH 08/14] Fix now-too-big extended devices not dropping immediately --- src/iuse_actor.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 1fdb751da8cb7..4a44e389f7588 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -5146,6 +5146,8 @@ std::optional link_up_actor::link_extend_cable( Character *p, item &it ) co extended_ptr->type_name(), extension->type_name() ); extension.remove_item(); p->invalidate_inventory_validity_cache(); + p->invalidate_weight_carried_cache(); + p->drop_invalid_inventory(); p->moves -= move_cost; return 0; } From d06abd13bcabad64a02c5a604cac4ad7f4e259fb Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 06:24:13 -0500 Subject: [PATCH 09/14] Fix error from extending a device with ALLOWS_REMOTE_USE --- src/iuse_actor.cpp | 11 ++++++----- src/iuse_actor.h | 4 ++-- 2 files changed, 8 insertions(+), 7 deletions(-) diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 4a44e389f7588..305404467cb9b 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -4387,7 +4387,7 @@ std::string link_up_actor::get_name() const return iuse_actor::get_name(); } -std::optional link_up_actor::use( Character *p, item &it, bool t, const tripoint & ) const +std::optional link_up_actor::use( Character *p, item &it, bool t, const tripoint &pnt ) const { if( t ) { return std::nullopt; @@ -4595,7 +4595,7 @@ std::optional link_up_actor::use( Character *p, item &it, bool t, const tri } else if( choice == 30 ) { // Selection: Attach to another cable, resulting in a longer one. - return link_extend_cable( p, it ); + return link_extend_cable( p, it, pnt ); } else if( choice == 31 ) { // Selection: Remove all cable extensions and give the individual cables to the player. @@ -5041,7 +5041,8 @@ std::optional link_up_actor::link_tow_cable( Character *p, item &it, } } -std::optional link_up_actor::link_extend_cable( Character *p, item &it ) const +std::optional link_up_actor::link_extend_cable( Character *p, item &it, + const tripoint &pnt ) const { avatar *you = p->as_avatar(); if( !you ) { @@ -5082,8 +5083,8 @@ std::optional link_up_actor::link_extend_cable( Character *p, item &it ) co return std::nullopt; } - item_location extension = is_cable_item ? form_loc( *p, tripoint_min, it ) : selected; - item_location extended = is_cable_item ? selected : form_loc( *p, tripoint_min, it ); + item_location extension = is_cable_item ? form_loc( *p, pnt, it ) : selected; + item_location extended = is_cable_item ? selected : form_loc( *p, pnt, it ); std::optional extended_copy; // We'll make a copy of the extended item and check pocket weight/volume capacity if: diff --git a/src/iuse_actor.h b/src/iuse_actor.h index ff4b9b8992354..e674c6ddc7943 100644 --- a/src/iuse_actor.h +++ b/src/iuse_actor.h @@ -1072,14 +1072,14 @@ class link_up_actor : public iuse_actor std::optional link_to_veh_app( Character *p, item &it, bool to_ports ) const; std::optional link_tow_cable( Character *p, item &it, bool to_towing ) const; - std::optional link_extend_cable( Character *p, item &it ) const; + std::optional link_extend_cable( Character *p, item &it, const tripoint &pnt ) const; std::optional remove_extensions( Character *p, item &it ) const; link_up_actor() : iuse_actor( "link_up" ) {} ~link_up_actor() override = default; void load( const JsonObject &jo ) override; - std::optional use( Character *p, item &it, bool t, const tripoint & ) const override; + std::optional use( Character *p, item &it, bool t, const tripoint &pnt ) const override; std::unique_ptr clone() const override; void info( const item &, std::vector & ) const override; std::string get_name() const override; From 2f88a6687c14c7ecf48bd3f23ea5c441daada820 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 06:54:55 -0500 Subject: [PATCH 10/14] Fix error caused by items with ALLOWS_REMOTE_USE getting deleted during their use action --- src/avatar_action.cpp | 7 ++++--- src/iuse_actor.cpp | 18 +++++++++--------- 2 files changed, 13 insertions(+), 12 deletions(-) diff --git a/src/avatar_action.cpp b/src/avatar_action.cpp index 7a74abdadabd7..23dfb93ee4807 100644 --- a/src/avatar_action.cpp +++ b/src/avatar_action.cpp @@ -1154,9 +1154,10 @@ void avatar_action::use_item( avatar &you, item_location &loc, std::string const if( use_in_place ) { update_lum( loc, false ); you.use( loc, pre_obtain_moves, method ); - update_lum( loc, true ); - - loc.make_active(); + if( loc ) { + update_lum( loc, true ); + loc.make_active(); + } } else { you.use( loc, pre_obtain_moves, method ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 305404467cb9b..3a778666cdb8f 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -5122,24 +5122,24 @@ std::optional link_up_actor::link_extend_cable( Character *p, item &it, if( extended_copy ) { // Check if there's another pocket on the same container that can hold the extended item, respecting pocket settings. - if( extended.has_parent() && - extended.parent_item()->can_contain( *extended_ptr, false, false, false, - item_location(), 10000000_ml, false ).success() ) { - if( !extended.parent_item()->put_in( *extended_ptr, - item_pocket::pocket_type::CONTAINER ).success() ) { + item_location parent = extended.parent_item(); + if( parent->can_contain( *extended_ptr, false, false, false, + item_location(), 10000000_ml, false ).success() ) { + if( !parent->put_in( *extended_ptr, item_pocket::pocket_type::CONTAINER ).success() ) { debugmsg( "Failed to put %s inside %s!", extended_ptr->type_name(), - extended.parent_item()->type_name() ); + parent->type_name() ); return std::nullopt; } - extended.remove_item(); } else { if( !query_yn( _( "The %1$s can't contain the %2$s with the %3$s attached. Continue?" ), - extended.parent_item()->type_name(), extended_ptr->type_name(), extension->type_name() ) ) { + parent->type_name(), extended_ptr->type_name(), extension->type_name() ) ) { return std::nullopt; } + // Attach the cord, even though it won't fit, and let it spill out naturally. extended.parent_pocket()->add( *extended_ptr ); - extended.remove_item(); } + extended.make_active(); + extended.remove_item(); } p->add_msg_if_player( is_cable_item ? _( "You extend the %1$s with the %2$s." ) : From a2b0b1acbaca449dd13b14f003c29b2ed3e384f4 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 08:27:15 -0500 Subject: [PATCH 11/14] Allow linked power for some iuse functions --- src/iuse.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/iuse.cpp b/src/iuse.cpp index 276d89694c626..f136a10702d7f 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -3861,7 +3861,7 @@ std::optional iuse::tazer( Character *p, item *it, bool, const tripoint &po std::optional iuse::tazer2( Character *p, item *it, bool b, const tripoint &pos ) { - if( it->ammo_remaining( p ) >= 2 ) { + if( it->ammo_remaining( p, true ) >= 2 ) { // Instead of having a ctrl+c+v of the function above, spawn a fake tazer and use it // Ugly, but less so than copied blocks item fake( "tazer", calendar::turn_zero ); @@ -7614,7 +7614,7 @@ std::optional iuse::multicooker( Character *p, item *it, bool t, const trip if( t ) { //stop action before power runs out and iuse deletes the cooker - if( it->ammo_remaining( p ) < charge_buffer ) { + if( it->ammo_remaining( p, true ) < charge_buffer ) { it->active = false; it->erase_var( "RECIPE" ); it->convert( itype_multi_cooker ); @@ -7709,7 +7709,7 @@ std::optional iuse::multicooker( Character *p, item *it, bool t, const trip menu.addentry( mc_stop, true, 's', _( "Stop cooking" ) ); } else { if( dish_it == nullptr ) { - if( it->ammo_remaining( p ) < charges_to_start ) { + if( it->ammo_remaining( p, true ) < charges_to_start ) { p->add_msg_if_player( _( "Batteries are low." ) ); return 0; } @@ -7845,7 +7845,7 @@ std::optional iuse::multicooker( Character *p, item *it, bool t, const trip const int all_charges = charges_to_start + mealtime / 1000 * units::to_watt( it->type->tool->power_draw ) / 1000; - if( it->ammo_remaining( p ) < all_charges ) { + if( it->ammo_remaining( p, true ) < all_charges ) { p->add_msg_if_player( m_warning, _( "The multi-cooker needs %d charges to cook this dish." ), From fa9b7e87e2a453fd8e67013f77fe1b262ff3c720 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 08:41:40 -0500 Subject: [PATCH 12/14] Skip cable pockets in `get_item_with()` --- src/item_contents.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/item_contents.cpp b/src/item_contents.cpp index 52ca61e065b4a..8761b490c7474 100644 --- a/src/item_contents.cpp +++ b/src/item_contents.cpp @@ -1558,6 +1558,9 @@ const item &item_contents::only_item() const item *item_contents::get_item_with( const std::function &filter ) { for( item_pocket &pocket : contents ) { + if( pocket.is_type( item_pocket::pocket_type::CABLE ) ) { + continue; + } item *it = pocket.get_item_with( filter ); if( it != nullptr ) { return it; From b63639ed16f810737209c62069995f47b6470919 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 08:51:42 -0500 Subject: [PATCH 13/14] Give multicooker ALLOWS_REMOTE_USE --- data/json/items/tool/cooking.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data/json/items/tool/cooking.json b/data/json/items/tool/cooking.json index c5497334c8db5..960cd70b4e2bd 100644 --- a/data/json/items/tool/cooking.json +++ b/data/json/items/tool/cooking.json @@ -662,7 +662,7 @@ "symbol": ";", "color": "red", "ammo": [ "battery" ], - "flags": [ "WATER_BREAK", "ELECTRONIC" ], + "flags": [ "WATER_BREAK", "ELECTRONIC", "ALLOWS_REMOTE_USE" ], "power_draw": "100 W", "qualities": [ [ "CONTAIN", 1 ] ], "use_action": [ "MULTICOOKER", { "type": "link_up", "cable_length": 2, "charge_rate": "1000 W" } ], From 73d3975754704608da9aaa267ec90936640d4580 Mon Sep 17 00:00:00 2001 From: Kamayana Date: Wed, 2 Aug 2023 08:53:18 -0500 Subject: [PATCH 14/14] Remove unused variable --- src/vehicle_use.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/vehicle_use.cpp b/src/vehicle_use.cpp index 5595498cc9bbb..397a112a7c84a 100644 --- a/src/vehicle_use.cpp +++ b/src/vehicle_use.cpp @@ -581,7 +581,6 @@ void vehicle::connect( const tripoint &source_pos, const tripoint &target_pos ) return ; } - tripoint target_global = here.getabs( target_pos ); const vpart_id vpid( cord.typeId().str() ); // Prepare target tripoints for the cable parts that'll be added to the selected/previous vehicles