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

Cable rework part 2: Extension cords and more #66871

Merged
merged 69 commits into from
Aug 1, 2023
Merged
Show file tree
Hide file tree
Changes from 44 commits
Commits
Show all changes
69 commits
Select commit Hold shift + click to select a range
0b6eeee
Make "Plug in / Unplug" the default link_up menu text
Kamayana Jun 10, 2023
abf7a8f
Make link_up use default ammo_scale of 0
Kamayana Jun 10, 2023
9e23fd4
cable json cleanup; Remove JUMPSTART from plug cables; change cable m…
Kamayana Jun 10, 2023
a164e9b
Add clear_pockets_if, a flexible function for deleting pocket contents
Kamayana Jun 21, 2023
ea51aca
Simplify links by making devices handle links themselves; split up li…
Kamayana Jul 12, 2023
ee69b98
Add ability to extend cables with other cables
Kamayana Jul 12, 2023
d85d372
Improve link display in inventory, showing current/max length and num…
Kamayana Jul 3, 2023
b61ffd6
Reopen cable menu for convenience if reeling up an already unspooled …
Kamayana Jul 12, 2023
7faf25c
Fix vehicle cables breaking off the turn AFTER they pass the threshold
Kamayana Jul 12, 2023
7c2e584
Drop snapped off vehicle cables at the previous tile position
Kamayana Jul 12, 2023
0ef57fe
Change find_vehicle() into a public map function, use for better link…
Kamayana Jul 12, 2023
1f90e2b
Fix link creation connecting to the wrong point
Kamayana Jul 5, 2023
70ed44f
Immediately process cables on creation if they're linked
Kamayana Jul 6, 2023
4298c4b
Remove tow cable section of shed_loose_parts - Tow cables aren't loos…
Kamayana Jul 12, 2023
8150f5c
Remove UNMOUNT_ON_MOVE from cables, since it's misleading. Don't chan…
Kamayana Jul 6, 2023
32a22b4
Let shed_loose_parts selectively exclude cables
Kamayana Jul 12, 2023
989afc1
Format vehicle cable linking / tow cable linking to match each other
Kamayana Jul 12, 2023
613728e
Split link_length funcs between current and max
Kamayana Jul 12, 2023
344b941
Make efficiency a float to more easily handle extensions
Kamayana Jul 7, 2023
23565bf
Adjust link_up item info
Kamayana Jul 12, 2023
f4c8e82
Add BATTERY flag for battery vehicle parts
Kamayana Jul 12, 2023
9ced353
Astyle
Kamayana Jul 12, 2023
bd9d70a
Revert "wattage" back to "charge_rate", as I scrapped my plans for th…
Kamayana Jul 10, 2023
fdcfe46
Remove the separate link_up function - the use for it was scrapped
Kamayana Jul 12, 2023
17b1dd8
Remove AUTO_DELETE_CABLE, replace with NO_DROP
Kamayana Jul 12, 2023
182c1c6
Show a cable's linked vehicle in the interaction menu
Kamayana Jul 11, 2023
19a3f5c
Add a vehicle part inspect action to disconnect cables attached to it…
Kamayana Jul 20, 2023
088c19e
Improve cable stretch message for circular distances
Kamayana Jul 12, 2023
ad58cb2
Only return items with the CABLE_SPOOL flag with cables(), temporary …
Kamayana Jul 13, 2023
dfbe8b6
Documentation
Kamayana Jul 13, 2023
813b720
Reopen menu on manually detaching cable, as well
Kamayana Jul 13, 2023
4641463
Minor fixes
Kamayana Jul 13, 2023
a8c776d
Improve messaging of CBM/UPS/solar backpack links
Kamayana Jul 13, 2023
e77add0
Lint JSON
Kamayana Jul 13, 2023
c08b1c0
Update newly added cables
Kamayana Jul 14, 2023
6835996
Clang tidying
Kamayana Jul 14, 2023
2bf5eed
Set cable traits and cable part mounts immediately to avoid inaccuracies
Kamayana Jul 14, 2023
973f268
Fix linked repair tools
Kamayana Jul 17, 2023
40a1d84
Fix invoke_item_activity losing the method after cancel_activity
Kamayana Jul 20, 2023
4c0bf5d
Remove debug code
Kamayana Jul 20, 2023
823fa0b
Apply suggestions from code review
Kamayana Jul 20, 2023
ddd2e10
More readable booleans
Kamayana Jul 26, 2023
5223b4c
Update src/item.cpp
Maleclypse Jul 28, 2023
6c268db
Merge branch 'master' into cables_part_2
Maleclypse Jul 28, 2023
cf91cd7
Make cable extensions contribute volume and weight
Kamayana Jul 28, 2023
bfbe889
Minor fixes
Kamayana Jul 28, 2023
10bc846
Use const for minimum link efficiency
Kamayana Jul 29, 2023
93554fa
Revamp how max_length is handled so its recalculated less often
Kamayana Jul 29, 2023
fa5f489
Rework link_extend_cable's weight/volume check to be more readable an…
Kamayana Jul 29, 2023
9e1edc2
Rework link length sorting, moving it to sort_compare
Kamayana Jul 29, 2023
dbafd42
Make AIM sort like inventory_ui does, including using link_sort_key
Kamayana Jul 29, 2023
cd02310
Let debug cables extend debug cables
Kamayana Jul 29, 2023
8a98274
Make getting/removing remote parts two separate functions
Kamayana Jul 30, 2023
a7f5c4f
Change find_vehicle back into a static vehicle function
Kamayana Jul 30, 2023
aee0013
Change properties_to_item into a vehicle function, part_to_item, as i…
Kamayana Jul 30, 2023
5f289ef
Make it more clear you pick up cables you disconnect
Kamayana Jul 30, 2023
9e3107e
Rework shed_loose_parts to fix vehicle connections, particularly out-…
Kamayana Jul 31, 2023
2779685
Cleanup
Kamayana Jul 31, 2023
6badf5f
Make invalidate_towing give the cable directly to the player if they …
Kamayana Jul 31, 2023
88e2f5f
Fix disconnecting tow cables and jumper cables
Kamayana Jul 31, 2023
209b4f1
Unused variable
Kamayana Jul 31, 2023
e0fffb3
Make assign_t_state work with appliances
Kamayana Jul 31, 2023
76c7138
Fix jumper cable -> appliance links
Kamayana Aug 1, 2023
9f1d88f
Reword link_to_veh_app & link_tow_cable variables for clarity, as "ta…
Kamayana Aug 1, 2023
a3a29c6
Fix connection messages
Kamayana Aug 1, 2023
b40a7af
Reword lambda for cable setting & checking
Kamayana Aug 1, 2023
813597f
Cancel link_up if the target point is too far for the cable
Kamayana Aug 1, 2023
c75cda2
Fix error when trying to link a cable immediately after loading or sa…
Kamayana Aug 1, 2023
45463cc
Rename `heavy-duty cable` to `heavy-duty jumper cable`
Kamayana Aug 1, 2023
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
4 changes: 0 additions & 4 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -1241,10 +1241,6 @@
"id": "CABLE_SPOOL",
"type": "json_flag"
},
{
"id": "AUTO_DELETE_CABLE",
"type": "json_flag"
},
{
"id": "CAMERA_PRO",
"type": "json_flag"
Expand Down
2 changes: 1 addition & 1 deletion data/json/furniture_and_terrain/appliances.json
Original file line number Diff line number Diff line change
Expand Up @@ -588,7 +588,7 @@
"durability": 120,
"description": "A power cord sticking out of an appliance. You need to plug it into a powered grid for the appliance to work properly.",
"item": "power_cord",
"flags": [ "NO_INSTALL_HIDDEN", "NO_UNINSTALL", "UNMOUNT_ON_DAMAGE", "UNMOUNT_ON_MOVE", "POWER_TRANSFER" ],
"flags": [ "NO_INSTALL_HIDDEN", "NO_UNINSTALL", "UNMOUNT_ON_DAMAGE", "POWER_TRANSFER" ],
"variants": [ { "symbols": "{", "symbols_broken": "s" } ]
},
{
Expand Down
2 changes: 1 addition & 1 deletion data/json/item_actions.json
Original file line number Diff line number Diff line change
Expand Up @@ -966,7 +966,7 @@
{
"type": "item_action",
"id": "link_up",
"name": { "str": "Attach / Detach" }
"name": { "str": "Plug in / Manage cables" }
},
{
"type": "item_action",
Expand Down
119 changes: 44 additions & 75 deletions data/json/items/tool/cables.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,42 +8,16 @@
"to_hit": 1,
"color": "dark_gray",
"symbol": "&",
"material": [ "steel", "plastic" ],
"material": [ "copper", "plastic" ],
"volume": "500 ml",
"weight": "75 g",
"category": "tools",
"price": 1,
"price_postapoc": 100,
"max_charges": 3,
"initial_charges": 3,
"use_action": {
"type": "link_up",
"menu_text": "Plug in / Unplug",
"is_cable_item": true,
"cable_length": 3,
"targets": [ "vehicle_port" ]
},
"flags": [ "CABLE_SPOOL", "AUTO_DELETE_CABLE", "SINGLE_USE" ],
"melee_damage": { "bash": 2 }
},
{
"type": "TOOL",
"id": "generic_device_cable",
"name": { "str": "device cable" },
"description": "A cable for attaching devices to power or to other devices.",
"//": "This cable is automatically handled by devices and is used for connecting them to vehicles/appliances",
"to_hit": 1,
"color": "dark_gray",
"symbol": "&",
"material": [ "steel", "plastic" ],
"volume": "500 ml",
"weight": "75 g",
"category": "tools",
"price": 1,
"price_postapoc": 70,
"max_charges": 4,
"initial_charges": 4,
"flags": [ "CABLE_SPOOL", "AUTO_DELETE_CABLE" ],
"use_action": { "type": "link_up", "menu_text": "Plug in / Manage connections", "targets": [ "vehicle_port" ] },
"flags": [ "CABLE_SPOOL", "NO_DROP", "SINGLE_USE" ],
"melee_damage": { "bash": 2 }
},
{
Expand All @@ -54,7 +28,7 @@
"to_hit": 1,
"color": "light_blue",
"symbol": "&",
"material": [ "steel", "plastic" ],
"material": [ "copper", "plastic" ],
"volume": "500 ml",
"weight": "75 g",
"category": "tools",
Expand All @@ -64,58 +38,67 @@
"initial_charges": 4,
"use_action": {
"type": "link_up",
"menu_text": "Attach / Detach",
"is_cable_item": true,
"cable_length": 4,
"targets": [ "no_link", "bio_cable", "ups", "solarpack", "vehicle_battery" ]
"menu_text": "Attach / Manage connections",
"targets": [ "no_link", "bio_cable", "ups", "solarpack", "vehicle_battery" ],
"can_extend": [ "jumper_cable", "jumper_cable_heavy" ]
},
"flags": [ "CABLE_SPOOL", "SINGLE_USE" ],
"melee_damage": { "bash": 2 },
"qualities": [ [ "JUMPSTART", 1 ] ]
},
{
"type": "TOOL",
"id": "jumper_cable_heavy",
"name": { "str": "heavy-duty cable" },
"description": "A long, thick, heavy-duty cable with power leads on either end. It looks like you could use it to hook up two vehicles to each other, though you expect the power loss would be noticeable. Can also link other electrical systems.",
"volume": "1500 ml",
"weight": "750 g",
"max_charges": 20,
"initial_charges": 20,
"copy-from": "jumper_cable"
},
{
"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.",
"copy-from": "jumper_cable",
"to_hit": 1,
"color": "light_blue",
"symbol": "&",
"material": [ "copper", "plastic" ],
"volume": "1200 ml",
"weight": "800 g",
"category": "tools",
"price": 1,
"price_postapoc": 100,
"max_charges": 10,
"initial_charges": 10,
"use_action": {
"type": "link_up",
"menu_text": "Plug in / Unplug",
"is_cable_item": true,
"cable_length": 10,
"targets": [ "no_link", "vehicle_port" ]
"menu_text": "Plug in / Manage connections",
"targets": [ "no_link", "vehicle_port" ],
"can_extend": [ "ELECTRICAL_DEVICES", "extension_cable", "long_extension_cable" ]
},
"flags": [ "CABLE_SPOOL", "SINGLE_USE" ]
"flags": [ "CABLE_SPOOL", "SINGLE_USE" ],
"melee_damage": { "bash": 2 }
},
{
"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.",
"copy-from": "jumper_cable",
"copy-from": "extension_cable",
"volume": "3750 ml",
"weight": "2500 g",
"max_charges": 30,
"initial_charges": 30,
"use_action": {
"type": "link_up",
"menu_text": "Plug in / Unplug",
"is_cable_item": true,
"cable_length": 30,
"targets": [ "no_link", "vehicle_port" ]
},
"flags": [ "CABLE_SPOOL", "SINGLE_USE" ]
},
{
"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. If attached to a vehicle, it could be used to pull another vehicle of any weight.",
"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.",
"to_hit": -1,
"color": "light_blue",
"symbol": "&",
Expand All @@ -127,46 +110,32 @@
"price_postapoc": 500,
"max_charges": 6,
"initial_charges": 6,
"use_action": { "type": "link_up", "is_cable_item": true, "cable_length": 6, "targets": [ "no_link", "vehicle_tow" ] },
"qualities": [ [ "ROPE", 2 ] ],
"flags": [ "CABLE_SPOOL", "TOW_CABLE", "SINGLE_USE" ],
"melee_damage": { "bash": 6 }
},
{
"type": "TOOL",
"id": "jumper_cable_heavy",
"name": { "str": "heavy-duty cable" },
"description": "A long, thick, heavy-duty cable with power leads on either end. It looks like you could use it to hook up two vehicles to each other, though you expect the power loss would be noticeable. Can also link other electrical systems.",
"volume": "1500 ml",
"weight": "750 g",
"max_charges": 20,
"initial_charges": 20,
"use_action": {
"type": "link_up",
"menu_text": "Attach / Detach",
"is_cable_item": true,
"cable_length": 20,
"targets": [ "no_link", "bio_cable", "ups", "solarpack", "vehicle_battery" ]
"menu_text": "Attach / Manage connections",
"efficiency": 0.0,
"targets": [ "no_link", "vehicle_tow" ]
},
"copy-from": "jumper_cable"
"qualities": [ [ "ROPE", 2 ] ],
"flags": [ "CABLE_SPOOL", "TOW_CABLE", "SINGLE_USE" ],
"melee_damage": { "bash": 6 }
},
{
"type": "TOOL",
"id": "jumper_cable_debug",
"name": { "str": "shiny debug cable" },
"description": "This is the cable of the gods: 100 meters long, no power loss, light as a feather, and fits in a matchbook. You're sure this wasn't supposed to exist, and the way it shimmers makes you uneasy.",
"copy-from": "jumper_cable",
"weight": "1 g",
"volume": "1 ml",
"max_charges": 100,
"initial_charges": 100,
"use_action": {
"type": "link_up",
"menu_text": "Plug in / Unplug",
"is_cable_item": true,
"cable_length": 100,
"efficiency": 1000,
"targets": [ "no_link", "bio_cable", "ups", "solarpack", "vehicle_port", "vehicle_battery", "vehicle_tow" ]
},
"copy-from": "jumper_cable"
"menu_text": "Attach / Manage connections",
"efficiency": 1.0,
"targets": [ "no_link", "bio_cable", "ups", "solarpack", "vehicle_port", "vehicle_battery", "vehicle_tow" ],
"can_extend": [ "ELECTRICAL_DEVICES" ]
}
}
]
77 changes: 11 additions & 66 deletions data/json/items/tool/cooking.json
Original file line number Diff line number Diff line change
Expand Up @@ -296,16 +296,7 @@
"flags": [ "WATER_BREAK" ],
"charges_per_use": 25,
"qualities": [ [ "BOIL", 1 ] ],
"use_action": [
"HOTPLATE",
{
"type": "link_up",
"menu_text": "Plug in / Unplug",
"ammo_scale": 0,
"cable_length": 2,
"charge_rate": "1 kW"
}
],
"use_action": [ "HOTPLATE", { "type": "link_up", "cable_length": 2, "charge_rate": "1 kW" } ],
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand All @@ -331,7 +322,7 @@
"color": "blue",
"ammo": [ "battery" ],
"flags": [ "ALLOWS_REMOTE_USE", "WATER_BREAK", "ELECTRONIC" ],
"use_action": { "type": "link_up", "menu_text": "Plug in / Unplug", "ammo_scale": 0, "cable_length": 2, "charge_rate": "600 W" },
"use_action": { "type": "link_up", "cable_length": 2, "charge_rate": "600 W" },
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand Down Expand Up @@ -432,7 +423,7 @@
"color": "white",
"ammo": [ "battery" ],
"flags": [ "ALLOWS_REMOTE_USE", "WATER_BREAK", "ELECTRONIC" ],
"use_action": { "type": "link_up", "menu_text": "Plug in / Unplug", "ammo_scale": 0, "cable_length": 2, "charge_rate": "450 W" },
"use_action": { "type": "link_up", "cable_length": 2, "charge_rate": "450 W" },
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand Down Expand Up @@ -511,16 +502,7 @@
"flags": [ "WATER_BREAK" ],
"ammo": [ "battery" ],
"charges_per_use": 35,
"use_action": [
"HOTPLATE",
{
"type": "link_up",
"menu_text": "Plug in / Unplug",
"ammo_scale": 0,
"cable_length": 3,
"charge_rate": "1 kW"
}
],
"use_action": [ "HOTPLATE", { "type": "link_up", "cable_length": 3, "charge_rate": "1 kW" } ],
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand Down Expand Up @@ -549,16 +531,7 @@
"flags": [ "WATER_BREAK", "ELECTRONIC" ],
"ammo": [ "battery" ],
"charges_per_use": 25,
"use_action": [
"HOTPLATE",
{
"type": "link_up",
"menu_text": "Plug in / Unplug",
"ammo_scale": 0,
"cable_length": 3,
"charge_rate": "1500 W"
}
],
"use_action": [ "HOTPLATE", { "type": "link_up", "cable_length": 3, "charge_rate": "1500 W" } ],
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand All @@ -585,7 +558,7 @@
"color": "white",
"ammo": [ "battery" ],
"flags": [ "ALLOWS_REMOTE_USE", "WATER_BREAK" ],
"use_action": { "type": "link_up", "menu_text": "Plug in / Unplug", "ammo_scale": 0, "cable_length": 4, "charge_rate": "55 W" },
"use_action": { "type": "link_up", "cable_length": 4, "charge_rate": "55 W" },
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand Down Expand Up @@ -692,16 +665,7 @@
"flags": [ "WATER_BREAK", "ELECTRONIC" ],
"power_draw": "100 W",
"qualities": [ [ "CONTAIN", 1 ] ],
"use_action": [
"MULTICOOKER",
{
"type": "link_up",
"menu_text": "Plug in / Unplug",
"ammo_scale": 0,
"cable_length": 2,
"charge_rate": "1000 W"
}
],
"use_action": [ "MULTICOOKER", { "type": "link_up", "cable_length": 2, "charge_rate": "1000 W" } ],
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand Down Expand Up @@ -762,7 +726,7 @@
"symbol": ";",
"color": "green",
"ammo": [ "battery" ],
"use_action": { "type": "link_up", "menu_text": "Plug in / Unplug", "ammo_scale": 0, "cable_length": 2, "charge_rate": "1 kW" },
"use_action": { "type": "link_up", "cable_length": 2, "charge_rate": "1 kW" },
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand Down Expand Up @@ -1020,7 +984,7 @@
"color": "white",
"ammo": [ "battery" ],
"flags": [ "ALLOWS_REMOTE_USE", "WATER_BREAK" ],
"use_action": { "type": "link_up", "menu_text": "Plug in / Unplug", "ammo_scale": 0, "cable_length": 2, "charge_rate": "110 W" },
"use_action": { "type": "link_up", "cable_length": 2, "charge_rate": "110 W" },
"pocket_data": [
{
"pocket_type": "MAGAZINE_WELL",
Expand Down Expand Up @@ -1066,16 +1030,7 @@
"color": "light_blue",
"ammo": [ "battery" ],
"charges_per_use": 14,
"use_action": [
"WATER_PURIFIER",
{
"type": "link_up",
"menu_text": "Plug in / Unplug",
"ammo_scale": 0,
"cable_length": 2,
"charge_rate": "30 W"
}
],
"use_action": [ "WATER_PURIFIER", { "type": "link_up", "cable_length": 2, "charge_rate": "30 W" } ],
"flags": [ "ALLOWS_REMOTE_USE" ],
"pocket_data": [
{
Expand Down Expand Up @@ -1143,17 +1098,7 @@
"material": [ "steel", "plastic" ],
"weight": "11339 g",
"volume": "9 L",
"use_action": [
"HOTPLATE",
"HEAT_FOOD",
{
"type": "link_up",
"menu_text": "Plug in / Unplug",
"ammo_scale": 0,
"cable_length": 2,
"charge_rate": "1800 W"
}
],
"use_action": [ "HOTPLATE", "HEAT_FOOD", { "type": "link_up", "cable_length": 2, "charge_rate": "1800 W" } ],
"qualities": [ [ "COOK", 1 ], [ "OVEN", 1 ] ],
"flags": [ "WATER_BREAK" ],
"charges_per_use": 25,
Expand Down
Loading