Skip to content

Commit

Permalink
Add solar panels and storage batteries to the power grid (CleverRaven…
Browse files Browse the repository at this point in the history
  • Loading branch information
Fris0uman authored Feb 14, 2022
1 parent 078e9fc commit c7ffe3e
Show file tree
Hide file tree
Showing 7 changed files with 162 additions and 17 deletions.
55 changes: 55 additions & 0 deletions data/json/construction.json
Original file line number Diff line number Diff line change
Expand Up @@ -3129,6 +3129,17 @@
"pre_special": "check_empty",
"post_special": "done_appliance"
},
{
"type": "construction",
"id": "app_solar",
"group": "place_solar_panel",
"category": "APPLIANCE",
"required_skills": [ [ "fabrication", 1 ] ],
"time": "6 m",
"components": [ [ [ "solar_panel", 1 ] ] ],
"pre_special": "check_empty",
"post_special": "done_appliance"
},
{
"type": "construction",
"id": "app_heater_large",
Expand All @@ -3151,6 +3162,50 @@
"pre_special": "check_empty",
"post_special": "done_appliance"
},
{
"type": "construction",
"id": "app_battery_small",
"group": "place_small_battery",
"category": "APPLIANCE",
"required_skills": [ [ "electronics", 1 ] ],
"time": "6 m",
"components": [ [ [ "small_storage_battery", 1 ] ] ],
"pre_special": "check_empty",
"post_special": "done_appliance"
},
{
"type": "construction",
"id": "app_battery_medium",
"group": "place_medium_battery",
"category": "APPLIANCE",
"required_skills": [ [ "electronics", 1 ] ],
"time": "6 m",
"components": [ [ [ "medium_storage_battery", 1 ] ] ],
"pre_special": "check_empty",
"post_special": "done_appliance"
},
{
"type": "construction",
"id": "app_battery",
"group": "place_battery",
"category": "APPLIANCE",
"required_skills": [ [ "electronics", 1 ] ],
"time": "6 m",
"components": [ [ [ "storage_battery", 1 ] ] ],
"pre_special": "check_empty",
"post_special": "done_appliance"
},
{
"type": "construction",
"id": "app_battery_large",
"group": "place_large_battery",
"category": "APPLIANCE",
"required_skills": [ [ "electronics", 1 ] ],
"time": "6 m",
"components": [ [ [ "large_storage_battery", 1 ] ] ],
"pre_special": "check_empty",
"post_special": "done_appliance"
},
{
"type": "construction",
"id": "app_standing_lamp",
Expand Down
25 changes: 25 additions & 0 deletions data/json/construction_group.json
Original file line number Diff line number Diff line change
Expand Up @@ -1139,6 +1139,31 @@
"id": "place_standing_lamp",
"name": "Place Standing Lamp"
},
{
"type": "construction_group",
"id": "place_solar_panel",
"name": "Place Solar Panel"
},
{
"type": "construction_group",
"id": "place_small_battery",
"name": "Place Small Battery"
},
{
"type": "construction_group",
"id": "place_medium_battery",
"name": "Place Medium Battery"
},
{
"type": "construction_group",
"id": "place_battery",
"name": "Place Battery"
},
{
"type": "construction_group",
"id": "place_large_battery",
"name": "Place Large Battery"
},
{
"type": "construction_group",
"id": "place_standing_floodlight",
Expand Down
55 changes: 55 additions & 0 deletions data/json/furniture_and_terrain/appliances.json
Original file line number Diff line number Diff line change
Expand Up @@ -183,5 +183,60 @@
"durability": 20,
"description": "Electric wires embedded in the wall.",
"flags": [ "APPLIANCE" ]
},
{
"type": "vehicle_part",
"id": "ap_solar_panel",
"name": { "str": "solar panel" },
"symbol": "#",
"location": "structure",
"color": "yellow",
"flags": [ "SOLAR_PANEL", "OBSTACLE", "APPLIANCE" ],
"description": "A solar panel mounted on a frame and ready to power other appliances.",
"copy-from": "solar_panel"
},
{
"type": "vehicle_part",
"id": "ap_battery_small",
"name": { "str": "small grid battery" },
"symbol": "b",
"location": "structure",
"color": "white",
"flags": [ "APPLIANCE" ],
"description": "A small battery to store electrical power in a static power grid.",
"copy-from": "small_storage_battery"
},
{
"type": "vehicle_part",
"id": "ap_battery_medium",
"name": { "str": "medium grid battery" },
"symbol": "B",
"location": "structure",
"color": "yellow",
"flags": [ "APPLIANCE" ],
"description": "A medium battery to store electrical power in a static power grid.",
"copy-from": "medium_storage_battery"
},
{
"type": "vehicle_part",
"id": "ap_battery",
"name": { "str": "grid battery" },
"symbol": "B",
"location": "structure",
"color": "light_red",
"flags": [ "OBSTACLE", "APPLIANCE" ],
"description": "A battery to store electrical power in a static power grid.",
"copy-from": "storage_battery"
},
{
"type": "vehicle_part",
"id": "ap_battery_large",
"name": { "str": "large grid battery" },
"symbol": "B",
"location": "structure",
"color": "red",
"flags": [ "OBSTACLE", "APPLIANCE" ],
"description": "A large battery to store electrical power in a static power grid.",
"copy-from": "large_storage_battery"
}
]
12 changes: 1 addition & 11 deletions data/json/furniture_and_terrain/furniture-appliances.json
Original file line number Diff line number Diff line change
Expand Up @@ -571,17 +571,7 @@
"move_cost_mod": 2,
"required_str": -1,
"flags": [ "TRANSPARENT" ],
"deconstruct": {
"items": [
{ "item": "scrap", "count": [ 4, 6 ] },
{ "item": "plastic_chunk", "count": [ 1, 2 ] },
{ "item": "steel_chunk", "count": 3 },
{ "item": "pipe", "count": 4 },
{ "item": "2x4", "count": 4 },
{ "item": "pipe_fittings", "count": [ 1, 3 ] },
{ "item": "solar_panel", "count": 1 }
]
},
"deconstruct": { "items": [ { "item": "solar_panel", "count": 1 } ] },
"bash": {
"str_min": 10,
"str_max": 20,
Expand Down
6 changes: 3 additions & 3 deletions data/json/items/vehicle/battery.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@
"copy-from": "storage_battery",
"type": "MAGAZINE",
"name": { "str": "large storage battery", "str_pl": "large storage batteries" },
"description": "A huge storage battery containing many lithium-ion cells. Holds a tremendous amount of energy. Could be installed into a storage battery case for easy removal from a vehicle, or just welded straight in.",
"description": "A huge storage battery containing many lithium-ion cells. Holds a tremendous amount of energy. Could be installed into a storage battery case for easy removal from a vehicle, or just welded straight in. Can also be plugged in a static power grid.",
"weight": "400 kg",
"volume": "50 L",
"price": 400000,
Expand All @@ -97,7 +97,7 @@
"copy-from": "storage_battery",
"type": "MAGAZINE",
"name": { "str": "medium storage battery", "str_pl": "medium storage batteries" },
"description": "A medium storage battery containing multiple lithium-ion cells.",
"description": "A medium storage battery containing multiple lithium-ion cells. Can be plugged in a static power grid.",
"weight": "35000 g",
"volume": "6250 ml",
"price": 50000,
Expand All @@ -111,7 +111,7 @@
"copy-from": "storage_battery",
"type": "MAGAZINE",
"name": { "str": "small storage battery", "str_pl": "small storage batteries" },
"description": "A small storage battery created with pre-Cataclysm lithium-ion technology. Useful for crafting.",
"description": "A small storage battery created with pre-Cataclysm lithium-ion technology. Useful for crafting. Can be plugged in a static power grid.",
"weight": "2500 g",
"volume": "500 ml",
"price": 5000,
Expand Down
2 changes: 1 addition & 1 deletion data/json/items/vehicle/solar.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"type": "GENERIC",
"id": "solar_panel",
"name": { "str": "solar panel" },
"description": "Electronic device that can convert solar radiation into electric power. Useful for a vehicle.",
"description": "Electronic device that can convert solar radiation into electric power. Useful for a vehicle or static power grids.",
"weight": "14000 g",
"to_hit": -4,
"color": "yellow",
Expand Down
24 changes: 22 additions & 2 deletions src/construction.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,7 @@ static const activity_id ACT_BUILD( "ACT_BUILD" );
static const activity_id ACT_MULTIPLE_CONSTRUCTION( "ACT_MULTIPLE_CONSTRUCTION" );

static const construction_category_id construction_category_ALL( "ALL" );
static const construction_category_id construction_category_APPLIANCE( "APPLIANCE" );
static const construction_category_id construction_category_FILTER( "FILTER" );
static const construction_category_id construction_category_REPAIR( "REPAIR" );

Expand Down Expand Up @@ -1061,7 +1062,13 @@ void complete_construction( Character *you )
if( here.tr_at( terp ) == tr_unfinished_construction ) {
here.remove_trap( terp );
}
here.partial_con_remove( terp );

//We need to keep the partial_con when building appliance to get the component items
//It will be removed in done_appliance()
if( pc->id->category != construction_category_APPLIANCE ) {
here.partial_con_remove( terp );
}

// Some constructions are allowed to have items left on the tile.
if( built.post_flags.count( "keep_items" ) == 0 ) {
// Move any items that have found their way onto the construction site.
Expand Down Expand Up @@ -1353,9 +1360,22 @@ void construct::done_appliance( const tripoint &p )
veh->add_tag( flag_CANT_DRAG );
} else {
const vpart_id &vpart = vpart_appliance_from_item( get_avatar().lastconsumed );
veh->install_part( point_zero, vpart );
partial_con *pc = here.partial_con_at( p );
if( pc ) {
item base;
for( item &obj : pc->components ) {
if( obj.typeId() == vpart->base_item ) {
base = obj;
}
}
veh->install_part( point_zero, vpart, std::move( base ) );
} else {
debugmsg( "partial construction not found" );
veh->install_part( point_zero, vpart );
}
veh->name = vpart->name();
}
here.partial_con_remove( p );

veh->add_tag( flag_APPLIANCE );

Expand Down

0 comments on commit c7ffe3e

Please sign in to comment.