diff --git a/data/json/npcs/tacoma_ranch/NPC_ranch_foreman.json b/data/json/npcs/tacoma_ranch/NPC_ranch_foreman.json index d45cd656d584e..28708e6c53dd9 100644 --- a/data/json/npcs/tacoma_ranch/NPC_ranch_foreman.json +++ b/data/json/npcs/tacoma_ranch/NPC_ranch_foreman.json @@ -244,7 +244,7 @@ { "om_terrain": "ranch_camp_56", "translate_ter": [ { "from": "t_underbrush", "to": "t_dirt", "x": 0, "y": 0 } ], - "place_vehicles": [ { "vehicle": "hippie_van", "x": 10, "y": 10, "rotation": 270, "chance": 100 } ] + "place_vehicles": [ { "vehicle": "hippie_van", "x": 10, "y": 10, "rotation": 270, "chance": 100, "faction": "tacoma_commune" } ] }, { "om_terrain": "ranch_camp_65", @@ -299,7 +299,7 @@ }, { "om_terrain": "ranch_camp_56", - "place_vehicles": [ { "vehicle": "flatbed_truck", "x": 18, "y": 3, "rotation": 0, "chance": 100 } ] + "place_vehicles": [ { "vehicle": "flatbed_truck", "x": 18, "y": 3, "rotation": 0, "chance": 100, "faction": "tacoma_commune" } ] }, { "om_terrain": "ranch_camp_57", @@ -345,7 +345,7 @@ "update_mapgen": [ { "om_terrain": "ranch_camp_56", - "place_vehicles": [ { "vehicle": "car_chassis", "x": 17, "y": 11, "rotation": 90, "chance": 100 } ] + "place_vehicles": [ { "vehicle": "car_chassis", "x": 17, "y": 11, "rotation": 90, "chance": 100, "faction": "tacoma_commune" } ] }, { "om_terrain": "ranch_camp_58", @@ -400,12 +400,12 @@ { "point": "furniture", "id": "f_fireplace", "x": 8, "y": 12 } ], "place_item": [ - { "item": "log", "x": 3, "y": 11 }, - { "item": "log", "x": 3, "y": 12 }, - { "item": "log", "x": 3, "y": 13 }, - { "item": "log", "x": 11, "y": 11 }, - { "item": "log", "x": 11, "y": 12 }, - { "item": "log", "x": 11, "y": 13 } + { "item": "log", "x": 3, "y": 11, "faction": "tacoma_commune" }, + { "item": "log", "x": 3, "y": 12, "faction": "tacoma_commune" }, + { "item": "log", "x": 3, "y": 13, "faction": "tacoma_commune" }, + { "item": "log", "x": 11, "y": 11, "faction": "tacoma_commune" }, + { "item": "log", "x": 11, "y": 12, "faction": "tacoma_commune" }, + { "item": "log", "x": 11, "y": 13, "faction": "tacoma_commune" } ] } ] @@ -646,19 +646,33 @@ { "om_terrain": "ranch_camp_61", "place_vehicles": [ - { "vehicle": "car", "chance": 100, "rotation": 270, "x": 1, "y": 20 }, - { "vehicle": "cube_van_cheap", "chance": 100, "rotation": 90, "x": 10, "y": 10 }, - { "vehicle": "car_sports", "chance": 100, "rotation": 90, "x": 3, "y": 9 }, - { "vehicle": "flatbed_truck", "chance": 100, "rotation": 270, "x": 10, "y": 23 } + { "vehicle": "car", "chance": 100, "rotation": 270, "x": 1, "y": 20, "faction": "tacoma_commune" }, + { + "vehicle": "cube_van_cheap", + "chance": 100, + "rotation": 90, + "x": 10, + "y": 10, + "faction": "tacoma_commune" + }, + { "vehicle": "car_sports", "chance": 100, "rotation": 90, "x": 3, "y": 9, "faction": "tacoma_commune" }, + { + "vehicle": "flatbed_truck", + "chance": 100, + "rotation": 270, + "x": 10, + "y": 23, + "faction": "tacoma_commune" + } ] }, { "om_terrain": "ranch_camp_69", "translate_ter": [ { "from": "t_underbrush", "to": "t_dirt", "x": 0, "y": 0 } ], "place_vehicles": [ - { "vehicle": "car_chassis", "chance": 100, "rotation": 0, "x": 3, "y": 14 }, - { "vehicle": "pickup", "chance": 100, "rotation": 0, "x": 8, "y": 15 }, - { "vehicle": "schoolbus", "chance": 100, "rotation": 135, "x": 22, "y": 13 } + { "vehicle": "car_chassis", "chance": 100, "rotation": 0, "x": 3, "y": 14, "faction": "tacoma_commune" }, + { "vehicle": "pickup", "chance": 100, "rotation": 0, "x": 8, "y": 15, "faction": "tacoma_commune" }, + { "vehicle": "schoolbus", "chance": 100, "rotation": 135, "x": 22, "y": 13, "faction": "tacoma_commune" } ] } ] @@ -696,7 +710,7 @@ { "om_terrain": "ranch_camp_69", "translate_ter": [ { "from": "t_underbrush", "to": "t_dirt", "x": 0, "y": 0 } ], - "place_vehicles": [ { "vehicle": "cube_van", "chance": 100, "rotation": 180, "x": 13, "y": 15 } ] + "place_vehicles": [ { "vehicle": "cube_van", "chance": 100, "rotation": 180, "x": 13, "y": 15, "faction": "tacoma_commune" } ] } ] } @@ -730,7 +744,7 @@ { "om_terrain": "ranch_camp_70", "translate_ter": [ { "from": "t_underbrush", "to": "t_dirt", "x": 0, "y": 0 } ], - "place_vehicles": [ { "vehicle": "car_mini", "chance": 100, "rotation": 45, "x": 8, "y": 3 } ] + "place_vehicles": [ { "vehicle": "car_mini", "chance": 100, "rotation": 45, "x": 8, "y": 3, "faction": "tacoma_commune" } ] } ] } @@ -770,7 +784,7 @@ { "om_terrain": "ranch_camp_61", "translate_ter": [ { "from": "t_underbrush", "to": "t_dirt", "x": 0, "y": 0 } ], - "place_vehicles": [ { "vehicle": "ambulance", "chance": 100, "rotation": 90, "x": 16, "y": 5 } ] + "place_vehicles": [ { "vehicle": "ambulance", "chance": 100, "rotation": 90, "x": 16, "y": 5, "faction": "tacoma_commune" } ] } ] } diff --git a/data/json/npcs/tacoma_ranch/mission_mapgen_tacoma_commune.json b/data/json/npcs/tacoma_ranch/mission_mapgen_tacoma_commune.json index 3dc377ed4ce8a..c8c321cb9da5d 100644 --- a/data/json/npcs/tacoma_ranch/mission_mapgen_tacoma_commune.json +++ b/data/json/npcs/tacoma_ranch/mission_mapgen_tacoma_commune.json @@ -32,11 +32,12 @@ "object": { "mapgensize": [ 2, 2 ], "rows": [ - "##", + "B#", " " ], "terrain": { "#": "t_dirt" }, - "furniture": { "#": "f_makeshift_bed" } + "furniture": { "#": "f_makeshift_bed", "B": "f_makeshift_bed" }, + "item": { "B": { "item": "blanket", "faction": "tacoma_commune" } } } }, { @@ -430,7 +431,7 @@ ], "terrain": { "w": "t_wall", ".": "t_dirtfloor", "+": "t_door_c", "r": "t_dirtfloor", "c": "t_dirtfloor", "b": "t_dirtfloor" }, "furniture": { "r": "f_rack", "c": "f_counter", "b": "f_makeshift_bed" }, - "place_vehicles": [ { "vehicle": "armored_car", "chance": 100, "rotation": 0, "x": 15, "y": 7 } ], + "place_vehicles": [ { "vehicle": "armored_car", "chance": 100, "rotation": 0, "x": 15, "y": 7, "faction": "tacoma_commune" } ], "place_npcs": [ { "class": "ranch_scrapper_1", "x": 13, "y": 12 } ] } }, @@ -525,7 +526,7 @@ " " ], "terrain": { "w": "t_wall", ".": "t_dirt", "[": "t_window_boarded_noglass" }, - "place_item": [ { "item": "ax", "x": 13, "y": 18 } ] + "place_item": [ { "item": "ax", "x": 13, "y": 18, "faction": "tacoma_commune" } ] } }, { @@ -767,7 +768,11 @@ ], "terrain": { "r": "t_dirtfloor", "W": "t_wall_log", ".": "t_dirtfloor" }, "furniture": { "r": "f_rack" }, - "place_item": [ { "item": "frame", "x": 3, "y": 6 }, { "item": "frame", "x": 3, "y": 7 }, { "item": "frame", "x": 3, "y": 8 } ] + "place_item": [ + { "item": "frame", "x": 3, "y": 6, "faction": "tacoma_commune" }, + { "item": "frame", "x": 3, "y": 7, "faction": "tacoma_commune" }, + { "item": "frame", "x": 3, "y": 8, "faction": "tacoma_commune" } + ] } }, { @@ -817,13 +822,13 @@ "terrain": { "r": "t_dirtfloor", "W": "t_wall_log", ".": "t_dirtfloor", "m": "t_dirtfloor", "M": "t_dirtfloor", "c": "t_conveyor" }, "furniture": { "m": "f_machinery_old", "M": "f_machinery_heavy", "r": "f_rack" }, "place_item": [ - { "item": "log", "x": 3, "y": 0 }, - { "item": "log", "x": 3, "y": 1 }, - { "item": "log", "x": 3, "y": 1 }, - { "item": "log", "x": 0, "y": 1, "amount": [ 1, 5 ] }, - { "item": "log", "x": 1, "y": 1, "amount": [ 1, 5 ] }, - { "item": "2x4", "x": 3, "y": 9, "amount": [ 1, 10 ] }, - { "item": "log", "x": 3, "y": 2 } + { "item": "log", "x": 3, "y": 0, "faction": "tacoma_commune" }, + { "item": "log", "x": 3, "y": 1, "faction": "tacoma_commune" }, + { "item": "log", "x": 3, "y": 1, "faction": "tacoma_commune" }, + { "item": "log", "x": 0, "y": 1, "faction": "tacoma_commune", "amount": [ 1, 5 ] }, + { "item": "log", "x": 1, "y": 1, "faction": "tacoma_commune", "amount": [ 1, 5 ] }, + { "item": "2x4", "x": 3, "y": 9, "faction": "tacoma_commune", "amount": [ 1, 10 ] }, + { "item": "log", "x": 3, "y": 2, "faction": "tacoma_commune" } ], "place_npcs": [ { "class": "ranch_woodcutter_1", "x": 4, "y": 7 } ] } diff --git a/doc/MAPGEN.md b/doc/MAPGEN.md index 96aed6e089146..332dd423566e6 100644 --- a/doc/MAPGEN.md +++ b/doc/MAPGEN.md @@ -808,11 +808,12 @@ Places a gas pump with fuel in it. ### Place items from an item group with "items" -| Field | Description -| --- | --- -| item | (required, string or itemgroup object) the item group to use. -| chance | (optional, integer or min/max array) x in 100 chance that a loop will continue to spawn items from the group (which itself may spawn multiple items or not depending on its type, see `ITEM_SPAWN.md`), unless the chance is 100, in which case it will trigger the item group spawn exactly 1 time (see `map::place_items`). -| repeat | (optional, integer or min/max array) the number of times to repeat this placement, default is 1. +| Field | Description +| --- | --- +| item | (required, string or itemgroup object) the item group to use. +| chance | (optional, integer or min/max array) x in 100 chance that a loop will continue to spawn items from the group (which itself may spawn multiple items or not depending on its type, see `ITEM_SPAWN.md`), unless the chance is 100, in which case it will trigger the item group spawn exactly 1 time (see `map::place_items`). +| repeat | (optional, integer or min/max array) the number of times to repeat this placement, default is 1. +| faction | (optional, string) the faction that owns these items. ### Place monsters from a monster group with "monsters" @@ -835,6 +836,7 @@ The actual monsters are spawned when the map is loaded. Fields: | rotation | (optional, integer) the direction the vehicle faces. | fuel | (optional, integer) the fuel status. Default is -1 which makes the tanks 1-7% full. Positive values are interpreted as percentage of the vehicles tanks to fill (e.g. 100 means completely full). | status | (optional, integer) default is -1 (light damage), a value of 0 means perfect condition, 1 means heavily damaged. +| faction | (optional, string) faction this vehicle belongs to. Note that vehicles cannot be placed over overmap boundaries. So it needs to be 24 tiles long at most. diff --git a/src/map.cpp b/src/map.cpp index f7fa8a8468304..063616da4d6f4 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -4378,7 +4378,7 @@ void map::spawn_artifact( const tripoint &p, const relic_procgen_id &id, void map::spawn_item( const tripoint &p, const itype_id &type_id, const unsigned quantity, const int charges, const time_point &birthday, const int damlevel, const std::set &flags, - const std::string &variant ) + const std::string &variant, const std::string &faction ) { if( type_id.is_null() ) { return; @@ -4389,12 +4389,13 @@ void map::spawn_item( const tripoint &p, const itype_id &type_id, const unsigned } // recurse to spawn (quantity - 1) items for( size_t i = 1; i < quantity; i++ ) { - spawn_item( p, type_id, 1, charges, birthday, damlevel, flags ); + spawn_item( p, type_id, 1, charges, birthday, damlevel, flags, variant, faction ); } // migrate and spawn the item itype_id mig_type_id = item_controller->migrate_id( type_id ); item new_item( mig_type_id, birthday ); new_item.set_itype_variant( variant ); + new_item.set_owner( faction_id( faction ) ); if( one_in( 3 ) && new_item.has_flag( flag_VARSIZE ) ) { new_item.set_flag( flag_FIT ); } diff --git a/src/map.h b/src/map.h index 67d9cd1329ca5..1480f65d724dd 100644 --- a/src/map.h +++ b/src/map.h @@ -1215,13 +1215,15 @@ class map void spawn_item( const tripoint &p, const itype_id &type_id, unsigned quantity = 1, int charges = 0, const time_point &birthday = calendar::start_of_cataclysm, int damlevel = 0, - const std::set &flags = {}, const std::string &variant = "" ); + const std::set &flags = {}, const std::string &variant = "", + const std::string &faction = "" ); void spawn_item( const point &p, const itype_id &type_id, unsigned quantity = 1, int charges = 0, const time_point &birthday = calendar::start_of_cataclysm, int damlevel = 0, - const std::set &flags = {}, const std::string &variant = "" ) { + const std::set &flags = {}, const std::string &variant = "", + const std::string &faction = "" ) { spawn_item( tripoint( p, abs_sub.z() ), type_id, quantity, charges, birthday, damlevel, flags, - variant ); + variant, faction ); } // FIXME: remove these overloads and require spawn_item to take an @@ -1229,15 +1231,18 @@ class map void spawn_item( const tripoint &p, const std::string &type_id, unsigned quantity = 1, int charges = 0, const time_point &birthday = calendar::start_of_cataclysm, int damlevel = 0, - const std::set &flags = {}, const std::string &variant = "" ) { - spawn_item( p, itype_id( type_id ), quantity, charges, birthday, damlevel, flags, variant ); + const std::set &flags = {}, const std::string &variant = "", + const std::string &faction = "" ) { + spawn_item( p, itype_id( type_id ), quantity, charges, birthday, damlevel, flags, variant, + faction ); } void spawn_item( const point &p, const std::string &type_id, unsigned quantity = 1, int charges = 0, const time_point &birthday = calendar::start_of_cataclysm, int damlevel = 0, - const std::set &flags = {}, const std::string &variant = "" ) { + const std::set &flags = {}, const std::string &variant = "", + const std::string &faction = "" ) { spawn_item( tripoint( p, abs_sub.z() ), type_id, quantity, charges, birthday, damlevel, flags, - variant ); + variant, faction ); } units::volume max_volume( const tripoint &p ); units::volume free_volume( const tripoint &p ); @@ -1334,12 +1339,14 @@ class map */ std::vector place_items( const item_group_id &group_id, int chance, const tripoint &p1, const tripoint &p2, - bool ongrass, const time_point &turn, int magazine = 0, int ammo = 0 ); + bool ongrass, const time_point &turn, int magazine = 0, int ammo = 0, + const std::string &faction = "" ); std::vector place_items( const item_group_id &group_id, int chance, const point &p1, const point &p2, - bool ongrass, const time_point &turn, int magazine = 0, int ammo = 0 ) { + bool ongrass, const time_point &turn, int magazine = 0, int ammo = 0, + const std::string &faction = "" ) { return place_items( group_id, chance, tripoint( p1, abs_sub.z() ), - tripoint( p2, abs_sub.z() ), ongrass, turn, magazine, ammo ); + tripoint( p2, abs_sub.z() ), ongrass, turn, magazine, ammo, faction ); } /** * Place items from an item group at p. Places as much items as the item group says. @@ -1618,16 +1625,16 @@ class map vehicle *add_vehicle( const vgroup_id &type, const tripoint &p, const units::angle &dir, int init_veh_fuel = -1, int init_veh_status = -1, - bool merge_wrecks = true ); + bool merge_wrecks = true, const std::string &faction = "" ); vehicle *add_vehicle( const vgroup_id &type, const point &p, const units::angle &dir, int init_veh_fuel = -1, int init_veh_status = -1, - bool merge_wrecks = true ); + bool merge_wrecks = true, const std::string &faction = "" ); vehicle *add_vehicle( const vproto_id &type, const tripoint &p, const units::angle &dir, int init_veh_fuel = -1, int init_veh_status = -1, - bool merge_wrecks = true ); + bool merge_wrecks = true, const std::string &faction = "" ); vehicle *add_vehicle( const vproto_id &type, const point &p, const units::angle &dir, int init_veh_fuel = -1, int init_veh_status = -1, - bool merge_wrecks = true ); + bool merge_wrecks = true, const std::string &faction = "" ); // Light/transparency float light_transparency( const tripoint &p ) const; // Assumes 0,0 is light map center diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 89b5a839be3d7..eba2a719f6b25 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -2104,12 +2104,16 @@ class jmapgen_item_group : public jmapgen_piece public: item_group_id group_id; jmapgen_int chance; + std::string faction; jmapgen_item_group( const JsonObject &jsi, const std::string &context ) : chance( jsi, "chance", 1, 1 ) { JsonValue group = jsi.get_member( "item" ); group_id = item_group::load_item_group( group, "collection", "mapgen item group " + context ); repeat = jmapgen_int( jsi, "repeat", 1, 1 ); + if( jsi.has_string( "faction" ) ) { + faction = jsi.get_string( "faction" ); + } } void check( const std::string &context, const mapgen_parameters &, const jmapgen_int &/*x*/, const jmapgen_int &/*y*/ ) const override { @@ -2120,7 +2124,7 @@ class jmapgen_item_group : public jmapgen_piece void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, const std::string &/*context*/ ) const override { dat.m.place_items( group_id, chance.get(), point( x.val, y.val ), point( x.valmax, y.valmax ), true, - calendar::start_of_cataclysm ); + calendar::start_of_cataclysm, 0, 0, faction ); } }; @@ -2356,6 +2360,7 @@ class jmapgen_vehicle : public jmapgen_piece std::vector rotation; int fuel; int status; + std::string faction; jmapgen_vehicle( const JsonObject &jsi, const std::string &/*context*/ ) : type( jsi.get_member( "vehicle" ) ) , chance( jsi, "chance", 1, 1 ) @@ -2370,6 +2375,10 @@ class jmapgen_vehicle : public jmapgen_piece } else { rotation.push_back( units::from_degrees( jsi.get_int( "rotation", 0 ) ) ); } + + if( jsi.has_string( "faction" ) ) { + faction = jsi.get_string( "faction" ); + } } void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, const std::string &/*context*/ ) const override { @@ -2381,7 +2390,7 @@ class jmapgen_vehicle : public jmapgen_piece return; } dat.m.add_vehicle( chosen_id, point( x.get(), y.get() ), random_entry( rotation ), - fuel, status ); + fuel, status, true, faction ); } bool has_vehicle_collision( const mapgendata &dat, const point &p ) const override { return dat.m.veh_at( tripoint( p, dat.zlevel() ) ).has_value(); @@ -2405,6 +2414,7 @@ class jmapgen_spawn_item : public jmapgen_piece public: mapgen_value type; std::string variant; + std::string faction; jmapgen_int amount; jmapgen_int chance; std::set flags; @@ -2416,6 +2426,9 @@ class jmapgen_spawn_item : public jmapgen_piece if( jsi.has_string( "variant" ) ) { variant = jsi.get_string( "variant" ); } + if( jsi.has_string( "faction" ) ) { + faction = jsi.get_string( "faction" ); + } repeat = jmapgen_int( jsi, "repeat", 1, 1 ); } void apply( const mapgendata &dat, const jmapgen_int &x, const jmapgen_int &y, @@ -2435,7 +2448,7 @@ class jmapgen_spawn_item : public jmapgen_piece int spawn_count = ( c == 100 ) ? 1 : roll_remainder( c * spawn_rate / 100.0f ); for( int i = 0; i < spawn_count; i++ ) { dat.m.spawn_item( point( x.get(), y.get() ), chosen_id, amount.get(), - 0, calendar::start_of_cataclysm, 0, flags, variant ); + 0, calendar::start_of_cataclysm, 0, flags, variant, faction ); } } @@ -3751,7 +3764,7 @@ mapgen_palette mapgen_palette::load_internal( const JsonObject &jo, const std::s new_pal.load_place_mapings( jo, "monsters", format_placings, c ); new_pal.load_place_mapings( jo, "vehicles", format_placings, c ); // json member name is not optimal, it should be plural like all the others above, but that conflicts - // with the items entry with refers to item groups. + // with the items entry which refers to item groups. new_pal.load_place_mapings( jo, "item", format_placings, c ); new_pal.load_place_mapings( jo, "remove_vehicles", format_placings, c ); new_pal.load_place_mapings( jo, "remove_all", format_placings, c ); @@ -6480,7 +6493,8 @@ void map::apply_faction_ownership( const point &p1, const point &p2, const facti // the item group should be responsible for determining the amount of items. std::vector map::place_items( const item_group_id &group_id, const int chance, const tripoint &p1, const tripoint &p2, - const bool ongrass, const time_point &turn, const int magazine, const int ammo ) + const bool ongrass, const time_point &turn, const int magazine, const int ammo, + const std::string &faction ) { std::vector res; @@ -6532,6 +6546,8 @@ std::vector map::place_items( e->ammo_set( e->ammo_default() ); } } + + e->set_owner( faction_id( faction ) ); } return res; } @@ -6582,25 +6598,26 @@ void map::add_spawn( const mtype_id &type, int count, const tripoint &p, bool fr } vehicle *map::add_vehicle( const vgroup_id &type, const tripoint &p, const units::angle &dir, - const int veh_fuel, const int veh_status, const bool merge_wrecks ) + const int veh_fuel, const int veh_status, const bool merge_wrecks, const std::string &faction ) { - return add_vehicle( type.obj().pick(), p, dir, veh_fuel, veh_status, merge_wrecks ); + return add_vehicle( type.obj().pick(), p, dir, veh_fuel, veh_status, merge_wrecks, faction ); } vehicle *map::add_vehicle( const vgroup_id &type, const point &p, const units::angle &dir, - int veh_fuel, int veh_status, bool merge_wrecks ) + int veh_fuel, int veh_status, bool merge_wrecks, const std::string &faction ) { - return add_vehicle( type.obj().pick(), p, dir, veh_fuel, veh_status, merge_wrecks ); + return add_vehicle( type.obj().pick(), p, dir, veh_fuel, veh_status, merge_wrecks, faction ); } vehicle *map::add_vehicle( const vproto_id &type, const point &p, const units::angle &dir, - int veh_fuel, int veh_status, bool merge_wrecks ) + int veh_fuel, int veh_status, bool merge_wrecks, const std::string &faction ) { - return add_vehicle( type, tripoint( p, abs_sub.z() ), dir, veh_fuel, veh_status, merge_wrecks ); + return add_vehicle( type, tripoint( p, abs_sub.z() ), dir, veh_fuel, veh_status, merge_wrecks, + faction ); } vehicle *map::add_vehicle( const vproto_id &type, const tripoint &p, const units::angle &dir, - const int veh_fuel, const int veh_status, const bool merge_wrecks ) + const int veh_fuel, const int veh_status, const bool merge_wrecks, const std::string &faction ) { if( !type.is_valid() ) { debugmsg( "Nonexistent vehicle type: \"%s\"", type.c_str() ); @@ -6617,6 +6634,9 @@ vehicle *map::add_vehicle( const vproto_id &type, const tripoint &p, const units tripoint p_ms = p; veh->sm_pos = ms_to_sm_remain( p_ms ); veh->pos = p_ms.xy(); + if( !faction.empty() ) { + veh->set_owner( faction_id( faction ) ); + } veh->place_spawn_items(); veh->face.init( dir ); veh->turn_dir = dir; diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 6e9549cbc6d19..222b970d9b533 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -5526,6 +5526,12 @@ void vehicle::place_spawn_items() e.ammo_set( e.ammo_default() ); } } + + // Copy vehicle owner for items within + if( has_owner() ) { + e.set_owner( get_owner() ); + } + add_item( part, e ); } }