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

[RDY] Stop NPCs from stealing from your vehicles #22144

Merged
merged 11 commits into from
Nov 5, 2017
67 changes: 61 additions & 6 deletions data/json/vehicle_parts.json
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@
"item" : "sheet_metal",
"difficulty" : 1,
"location" : "center",
"flags" : ["AISLE", "BOARDABLE", "CARGO", "COVERED"],
"flags" : ["AISLE", "BOARDABLE", "CARGO", "CARGO_LOCKING", "COVERED"],
"breaks_into": "ig_vp_sheet_metal"
},{
"type" : "vehicle_part",
Expand Down Expand Up @@ -517,7 +517,7 @@
"item" : "frame",
"difficulty" : 2,
"location" : "center",
"flags" : ["CARGO", "OBSTACLE", "OPENABLE", "MULTISQUARE", "BOARDABLE", "COVERED", "TOOL_WRENCH"],
"flags" : ["CARGO", "CARGO_LOCKING", "OBSTACLE", "OPENABLE", "MULTISQUARE", "BOARDABLE", "COVERED", "TOOL_WRENCH"],
"breaks_into": "ig_vp_frame"
},{
"type" : "vehicle_part",
Expand All @@ -533,7 +533,7 @@
"item" : "frame",
"difficulty" : 2,
"location" : "center",
"flags" : ["CARGO", "OBSTACLE", "OPENABLE", "MULTISQUARE", "BOARDABLE", "COVERED", "TOOL_WRENCH", "OPAQUE"],
"flags" : ["CARGO", "CARGO_LOCKING", "OBSTACLE", "OPENABLE", "MULTISQUARE", "BOARDABLE", "COVERED", "TOOL_WRENCH", "OPAQUE"],
"breaks_into": "ig_vp_frame"
},{
"type" : "vehicle_part",
Expand All @@ -549,7 +549,7 @@
"item" : "hdframe",
"difficulty" : 3,
"location" : "center",
"flags" : ["CARGO", "OBSTACLE", "OPENABLE", "MULTISQUARE", "BOARDABLE", "COVERED"],
"flags" : ["CARGO", "CARGO_LOCKING", "OBSTACLE", "OPENABLE", "MULTISQUARE", "BOARDABLE", "COVERED"],
"breaks_into": "ig_vp_hdframe"
},{
"type" : "vehicle_part",
Expand All @@ -565,7 +565,7 @@
"item" : "hdframe",
"difficulty" : 3,
"location" : "center",
"flags" : ["CARGO", "OBSTACLE", "OPENABLE", "MULTISQUARE", "BOARDABLE", "COVERED", "OPAQUE"],
"flags" : ["CARGO", "CARGO_LOCKING", "OBSTACLE", "OPENABLE", "MULTISQUARE", "BOARDABLE", "COVERED", "OPAQUE"],
"breaks_into": "ig_vp_hdframe"
},{
"type" : "vehicle_part",
Expand Down Expand Up @@ -706,7 +706,7 @@
"item" : "frame",
"difficulty" : 1,
"location" : "center",
"flags" : ["CARGO", "COVERED"],
"flags" : ["CARGO", "CARGO_LOCKING", "COVERED"],
"breaks_into": "ig_vp_frame"
},{
"type" : "vehicle_part",
Expand All @@ -724,6 +724,22 @@
"location" : "center",
"flags" : ["CARGO", "TOOL_SCREWDRIVER", "BOARDABLE", "COVERED"],
"breaks_into": "ig_vp_frame"
},{
"type" : "vehicle_part",
"id" : "box_locking",
"name" : "locked box",
"symbol" : "o",
"color" : "brown",
"broken_symbol" : "#",
"broken_color" : "brown",
"damage_modifier" : 60,
"durability" : 100,
"size" : 275,
"item" : "frame",
"difficulty" : 2,
"location" : "center",
"flags" : ["CARGO", "CARGO_LOCKING", "TOOL_SCREWDRIVER", "BOARDABLE", "COVERED"],
"breaks_into": "ig_vp_frame"
},{
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Vehicle parts support "copy-from". Don't specify everything from scratch.
Check out data/json/vehicleparts/battery.json for an example.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point. I will do this

"type" : "vehicle_part",
"id" : "travois",
Expand Down Expand Up @@ -772,6 +788,25 @@
{"item": "splinter", "count": [3, 5]},
{"item": "nail", "charges": [10, 15]}
]
},{
"type" : "vehicle_part",
"id" : "wood_box_locking",
"name" : "locked wood box",
"symbol" : "o",
"color" : "brown",
"broken_symbol" : "#",
"broken_color" : "brown",
"damage_modifier" : 60,
"durability" : 70,
"size" : 150,
"item" : "frame_wood",
"difficulty" : 1,
"location" : "center",
"flags" : ["CARGO", "CARGO_LOCKING", "BOARDABLE", "COVERED", "NAILABLE"],
"breaks_into" : [
{"item": "splinter", "count": [3, 5]},
{"item": "nail", "charges": [10, 15]}
]
},{
"type" : "vehicle_part",
"id" : "folding wood box",
Expand All @@ -792,6 +827,26 @@
{"item": "splinter", "count": [3, 5]},
{"item": "nail", "charges": [10, 15]}
]
},{
"type" : "vehicle_part",
"id" : "folding_locked_wood_box",
"name" : "folding locked wood box",
"symbol" : "o",
"color" : "brown",
"broken_symbol" : "#",
"broken_color" : "brown",
"damage_modifier" : 60,
"durability" : 65,
"folded_volume": 6,
"size" : 120,
"item" : "foldwoodframe",
"difficulty" : 2,
"location" : "center",
"flags" : ["CARGO", "CARGO_LOCKING", "BOARDABLE", "COVERED", "NAILABLE", "FOLDABLE"],
"breaks_into" : [
{"item": "splinter", "count": [3, 5]},
{"item": "nail", "charges": [10, 15]}
]
},{
"type" : "vehicle_part",
"id" : "cargo_bag",
Expand Down
4 changes: 3 additions & 1 deletion src/npcmove.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1805,7 +1805,9 @@ void npc::find_item()

veh_part = veh->part_with_feature( veh_part, VPFLAG_CARGO, true );
static const std::string locked_string( "LOCKED" );
if( veh_part < 0 || veh->part_flag( veh_part, locked_string ) ) {
//TODO Let player know what parts are safe from NPC thieves
static const std::string cargo_locking_string( "CARGO_LOCKING" );
if( veh_part < 0 || veh->part_flag( veh_part, locked_string ) || veh->part_flag( veh_part, cargo_locking_string ) ) {
continue;
}

Expand Down