Skip to content

Commit

Permalink
Merge pull request #27106 from John-Candlebury/nanofab-2.0
Browse files Browse the repository at this point in the history
Nanofab 2.0
  • Loading branch information
ZhilkinSerg committed Dec 24, 2018
2 parents cde8b58 + 7edccc9 commit 0c9058b
Show file tree
Hide file tree
Showing 13 changed files with 304 additions and 1 deletion.
6 changes: 6 additions & 0 deletions data/json/flags.json
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,12 @@
"description": "Allows wielding with unarmed fighting styles and trains unarmed when used.",
"info": "This weapon <good>can be used with</good> <info>unarmed fighting styles</info>."
},
{
"id": "NANOFAB_TEMPLATE",
"type": "json_flag",
"context": [ "generic", "TOOL" ],
"info": "This item contains a nanofabricator recipe."
},
{
"id": "BIONIC_FAULTY",
"type": "json_flag",
Expand Down
5 changes: 5 additions & 0 deletions data/json/item_groups.json
Original file line number Diff line number Diff line change
Expand Up @@ -4338,6 +4338,8 @@
"items":[
["purifier", 12],
["plut_cell", 10],
["standard_template_construct", 5],
["nanomaterial", 5],
["ftk93", 1],
["canister_goo", 8],
["UPS_off", 5],
Expand Down Expand Up @@ -5629,6 +5631,7 @@
["eink_tablet_pc", 15],
["mobile_memory_card", 40],
["mobile_memory_card_science", 10],
["standard_template_construct", 5],
["camera", 15],
["camera_pro", 5],
["lighter", 50],
Expand Down Expand Up @@ -6828,6 +6831,7 @@
["eink_tablet_pc", 1],
["mobile_memory_card", 8],
["mobile_memory_card_science", 1],
["standard_template_construct", 8],
["id_military", 3],
["militarymap", 3],
["pistol_bayonet", 4],
Expand Down Expand Up @@ -7493,6 +7497,7 @@
["eink_tablet_pc", 20],
["mobile_memory_card", 50],
["mobile_memory_card_science", 5],
["standard_template_construct", 5],
["camera", 3],
["thermometer", 3],
["hygrometer", 3],
Expand Down
47 changes: 46 additions & 1 deletion data/json/itemgroups/main.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
["knife_rm42", 20],
["l-stick", 10],
["large_repairkit", 20],
["standard_template_construct", 15],
["laser_pack", 100],
["laser_rifle", 10],
["m240", 10],
Expand Down Expand Up @@ -73,7 +74,51 @@
["tool_rdx_charge", 10],
["v29", 10]
]
},{
},
{
"type" : "item_group",
"id" : "nanofab_recipes",
"//" : "Very rare high level loot. This list doesnt spawn anywere directly, it is used to create the recipes inside nanofabricator templates. ",
"magazine": 100,
"items":[
["12mm", 10],
["bot_laserturret", 10],
["alloy_plate", 10],
["ftk93", 10],
["solar_panel_v3", 10],
["q_solarpack", 10],
["can_sealer", 10],
["hk_g80", 10],
["hk_g80mag", 10],
["stillsuit", 10],
["hk_g80mag", 10],
["emp_gun", 10],
["knife_rm42", 10],
["laser_pack", 10],
["laser_rifle", 10],
["mininuke", 10],
["adv_UPS_off", 10],
["optical_cloak", 10],
["holo_cloak", 10],
["plasma_rifle", 10],
["portal", 10],
["atomic_coffeepot", 10],
["power_armor_basic", 10],
["power_armor_frame", 10],
["power_armor_heavy", 10],
["power_armor_helmet_basic", 10],
["power_armor_helmet_heavy", 10],
["power_armor_helmet_light", 10],
["high_density_capacitor", 10],
["beam_scatterer", 10 ],
["power_armor_light", 10],
["control_laptop", 10],
["rm11b_sniper_rifle", 10],
["rm13_armor", 10],
["v29", 10]
]
},
{
"type" : "item_group",
"id" : "player_crafted",
"//" : "items that should only be crafted by the player. Excluded from all other item groups. this is just an FYI list, it's not used to spawn items in game.",
Expand Down
18 changes: 18 additions & 0 deletions data/json/items/chemicals_and_resources.json
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,24 @@
"category" : "chems",
"fun": -20
},
{
"type" : "AMMO",
"id" : "nanomaterial",
"category" : "chems",
"price" : 250000,
"price_postapoc": 1500,
"name" : "nanomaterial canisters",
"name_plural" : "nanomaterial canisters",
"symbol" : "=",
"color" : "light_gray",
"flags" : [ "TRADER_AVOID" ],
"description" : "Steel canisters containing carbon, iron, titanium, copper and other elements in specifically engineered atomic scale configurations. A nanofabricator can assemble them into usable items.",
"material" : "steel",
"volume" : 60,
"weight" : 250,
"ammo_type" : "components",
"count" : 50
},
{
"type" : "AMMO",
"id" : "ash",
Expand Down
16 changes: 16 additions & 0 deletions data/json/items/generic.json
Original file line number Diff line number Diff line change
Expand Up @@ -1171,6 +1171,22 @@
"to_hit": -1,
"flags": [ "TRADER_AVOID" ]
},
{
"type": "GENERIC",
"id": "standard_template_construct",
"symbol": ",",
"color": "cyan",
"name": "nanofabricator template",
"category": "spare_parts",
"description": "A state-of-the-art optical storage system. This small slate of transparent glass holds, inscribed as a miniature pattern, the instructions required to create an item through a nanofabricator.",
"price": 150000,
"price_postapoc": 15000,
"material": [ "steel", "plastic" ],
"weight": 317,
"volume": 1,
"to_hit": -1,
"flags": [ "NANOFAB_TEMPLATE", "TRADER_AVOID" ]
},
{
"type": "GENERIC",
"id": "antenna",
Expand Down
65 changes: 65 additions & 0 deletions data/json/mapgen/lab/lab_floorplans_finale1level.json
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,71 @@
}
},
{
"//": "nano_fabricator room",
"type": "mapgen",
"method": "json",
"om_terrain": [ "lab_finale_1level" ],
"weight": 50,
"object": {
"rotation": [ 0, 3 ],
"fill_ter": "t_thconc_floor",
"rows": [
"CCC..................CCC",
"C..........YY..........C",
"........................",
"....cc............cc....",
"....cc..c......c..cc....",
"....cc..c..//..c..cc....",
"........c..//..c........",
"........c......c........",
"....cc.....YY.....cc....",
"....cc............cc....",
"....cc..--gGGg--..cc....",
"........-,,,,,,-........",
"..YY....g,/,,/,g....YY..",
"........g,?,,?,g........",
"ggGGg----,,,,,,----gGGgg",
".x...-CC-+gggg+-CC-...x.",
".x..x-,,,,,,,,,,,,-x..x.",
".x..C-,r,,,rr,,,r,-C..x.",
".x..C-Y,,,,,,,,,,Y-C..x.",
".x..x----GggggG----x..x.",
".R....G..........G....R.",
"......G....YY....G......",
".Yxx..g..........g..xxY.",
"......g..........g......"
],
"palettes": [
"lab_palette", "lab_loot_research"
],
"furniture": {
"R": "f_rack"
},
"terrain": {
"C": "t_machinery_electronic",
"x": "t_machinery_heavy",
"?": "t_nanofab",
"r": "t_metal_floor",
"/": "t_nanofab_body",
"Y": "t_thconc_floor_olight",
"p": "t_metal_floor"
},
"mapping": {
"r": {
"item": { "item": "standard_template_construct" }
},
"R": {
"item": { "item": "nanomaterial" }
}
},
"place_monster": [
{ "monster": "mon_tripod", "x": [ 1, 4 ], "y": [ 20, 22 ], "chance": 90 },
{ "monster": "mon_tripod", "x": [ 19, 20 ], "y": [ 20, 22 ], "chance": 90 },
{ "monster": "mon_zombie_scientist", "x": [2, 20], "y": [ 1, 9 ], "chance": 90, "repeat": [1,2] }
]
}
},
{
"//": "mutagen tank, ~75% chance normal mutagen, ~25% flavored mutagen",
"type": "mapgen",
"method": "json",
Expand Down
6 changes: 6 additions & 0 deletions data/json/requirements/materials.json
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,12 @@
"//": "Materials required to apply diamond coating (per 250ml volume)",
"components": [ [ [ "plasma", 5 ] ], [ [ "charcoal", 25 ], [ "coal_lump", 25 ] ] ]
},
{
"id": "nanofabricator",
"type": "requirement",
"//": "Materials required by the nanofabricator to create an item (per 250ml volume)",
"components": [ [ [ "nanomaterial", 5 ] ] ]
},
{
"id": "fabric_standard",
"type": "requirement",
Expand Down
60 changes: 60 additions & 0 deletions data/json/terrain.json
Original file line number Diff line number Diff line change
Expand Up @@ -5844,6 +5844,66 @@
]
}
},
{
"type": "terrain",
"id": "t_nanofab_body",
"name": "nanofabricator",
"symbol": "%",
"description": "A great column of advanced machinery. Within this self-contained, miniaturized factory, several 3d printers work in tandem with a robotic assembler to manufacture nearly any inorganic object.",
"color": "dark_gray",
"move_cost": 0,
"flags": [ "PLACE_ITEM" ],
"bash": {
"str_min": 120,
"str_max": 150,
"sound": "crunch!",
"sound_fail": "whack!",
"ter_set": "t_floor",
"items": [
{ "item": "e_scrap", "count": [ 10, 14 ] },
{ "item": "processor", "count": [ 10, 20 ] },
{ "item": "RAM", "count": [ 14, 20 ] },
{ "item": "nanomaterial", "count": 1, "prob": 10 },
{ "item": "bearing", "charges": [ 20, 60 ] },
{ "item": "motor", "count": 4 },
{ "item": "power_supply", "count": [ 4, 16 ] },
{ "item": "amplifier", "count": [ 4, 16 ] },
{ "item": "cable", "charges": [ 250, 500 ] },
{ "item": "circuit", "count": [ 1, 6 ] },
{ "item": "scrap", "count": [ 12, 18 ] }
]
}
},
{
"type": "terrain",
"id": "t_nanofab",
"name": "nanofabricator control panel",
"symbol": "&",
"description": "A small computer panel attached to a nanofabricator. It has a single slot for reading templates.",
"color": "red",
"move_cost": 0,
"flags": [ "WALL", "NOITEM", "PERMEABLE" ],
"examine_action": "nanofab",
"bash": {
"str_min": 8,
"str_max": 150,
"sound": "crunch!",
"sound_fail": "whack!",
"ter_set": "t_console_broken",
"items": [
{ "item": "processor", "prob": 25 },
{ "item": "RAM", "count": [ 0, 2 ], "prob": 50 },
{ "item": "cable", "charges": [ 1, 2 ], "prob": 50 },
{ "item": "small_lcd_screen", "prob": 25 },
{ "item": "e_scrap", "count": [ 1, 4 ], "prob": 50 },
{ "item": "circuit", "count": [ 0, 2 ], "prob": 50 },
{ "item": "power_supply", "prob": 25 },
{ "item": "amplifier", "prob": 25 },
{ "item": "plastic_chunk", "count": [ 4, 10 ], "prob": 50 },
{ "item": "scrap", "count": [ 2, 6 ], "prob": 50 }
]
}
},
{
"type": "terrain",
"id": "t_column",
Expand Down
55 changes: 55 additions & 0 deletions src/iexamine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,60 @@ void iexamine::cvdmachine( player &p, const tripoint & ) {
p.mod_moves( -1000 );
}

/**
* UI FOR LAB_FINALE NANO FABRICATOR.
*/
void iexamine::nanofab( player &p, const tripoint &examp )
{
bool table_exists = false;
tripoint spawn_point;
for( const auto &valid_location : g->m.points_in_radius( examp, 1, 0 ) ) {
if( g->m.ter( valid_location ) == ter_str_id( "t_nanofab_body" ) ) {
spawn_point = valid_location;
table_exists = true;
break;
}
}
if( !table_exists ) {
return;
}

auto nanofab_template= g->inv_map_splice( []( const item &e ) {
return e.has_var( "NANOFAB_ITEM_ID" );
}, _( "Introduce Nanofabricator template" ), PICKUP_RANGE, _( "You don't have any usable templates." ) );

if( !nanofab_template ) {
return;
}

item new_item( nanofab_template->get_var( "NANOFAB_ITEM_ID" ), calendar::turn );

auto qty = std::max( 1, new_item.volume() / 250_ml );
auto reqs = *requirement_id( "nanofabricator" ) * qty;

if( !reqs.can_make_with_inventory( p.crafting_inventory() ) ) {
popup( "%s", reqs.list_missing().c_str() );
return;
}

// Consume materials
for( const auto &e : reqs.get_components() ) {
p.consume_items( e );
}
for( const auto &e : reqs.get_tools() ) {
p.consume_tools( e );
}
p.invalidate_crafting_inventory();

if( new_item.is_armor() && new_item.has_flag( "VARSIZE" ) ) {
new_item.item_tags.insert( "FIT" );
}

g->m.add_item_or_charges( spawn_point, new_item );


}

/**
* Use "gas pump." Will pump any liquids on tile.
*/
Expand Down Expand Up @@ -4184,6 +4238,7 @@ iexamine_function iexamine_function_from_string(const std::string &function_name
{ "none", &iexamine::none },
{ "deployed_furniture", &iexamine::deployed_furniture },
{ "cvdmachine", &iexamine::cvdmachine },
{ "nanofab", &iexamine::nanofab },
{ "gaspump", &iexamine::gaspump },
{ "atm", &iexamine::atm },
{ "vending", &iexamine::vending },
Expand Down
1 change: 1 addition & 0 deletions src/iexamine.h
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ void atm( player &p, const tripoint &examp );
void vending( player &p, const tripoint &examp );
void toilet( player &p, const tripoint &examp );
void elevator( player &p, const tripoint &examp );
void nanofab( player &p, const tripoint &examp );
void controls_gate( player &p, const tripoint &examp );
void cardreader( player &p, const tripoint &examp );
void cvdmachine( player &p, const tripoint &examp );
Expand Down

0 comments on commit 0c9058b

Please sign in to comment.