From 5cab4a4ddc157b1e54ae2ec001e57bee8e443229 Mon Sep 17 00:00:00 2001 From: Ali-Anomma <59798817+Ali-Anomma@users.noreply.github.com> Date: Wed, 15 Nov 2023 05:19:15 +0300 Subject: [PATCH] refactor(content): JSONize Pumps (#3633) * Update mapdata.h * Update mapdata.h * Update iexamine.h * Update iexamine.cpp * Update mapdata.cpp * Update map.cpp * Update furniture-plumbing.json * Update furniture-plumbing.json * Update map.cpp * Update map.cpp * Update json_info.md * style(autofix.ci): automated formatting --------- Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com> --- .../furniture-plumbing.json | 21 +++++++++++++++++++ .../docs/en/mod/json/reference/json_info.md | 6 ++++++ src/iexamine.cpp | 11 ++++++++-- src/iexamine.h | 1 + src/map.cpp | 3 +++ src/mapdata.cpp | 1 + src/mapdata.h | 2 +- 7 files changed, 42 insertions(+), 3 deletions(-) diff --git a/data/json/furniture_and_terrain/furniture-plumbing.json b/data/json/furniture_and_terrain/furniture-plumbing.json index a6fcfb6959d2..be94550a0708 100644 --- a/data/json/furniture_and_terrain/furniture-plumbing.json +++ b/data/json/furniture_and_terrain/furniture-plumbing.json @@ -94,6 +94,27 @@ "items": [ { "item": "cu_pipe", "prob": 50 }, { "item": "ceramic_shard", "count": [ 2, 8 ] }, { "item": "wax", "count": 1 } ] } }, + { + "type": "furniture", + "id": "f_debug_pump", + "name": "debug beer pump", + "symbol": "&", + "color": "white", + "description": "Time to get infinitely drunk", + "move_cost_mod": 2, + "coverage": 30, + "required_str": -1, + "provides_liquids": "beer", + "flags": [ "TRANSPARENT", "FLAMMABLE_HARD" ], + "examine_action": "liquid_source", + "bash": { + "str_min": 8, + "str_max": 30, + "sound": "reality shattering!", + "sound_fail": "whunk!", + "items": [ { "item": "cu_pipe", "prob": 50 }, { "item": "sheet_metal", "count": [ 2, 8 ] }, { "item": "pipe", "count": 1 } ] + } + }, { "type": "furniture", "id": "f_water_heater", diff --git a/doc/src/content/docs/en/mod/json/reference/json_info.md b/doc/src/content/docs/en/mod/json/reference/json_info.md index 08a25e0df6d2..4dcc40f60594 100644 --- a/doc/src/content/docs/en/mod/json/reference/json_info.md +++ b/doc/src/content/docs/en/mod/json/reference/json_info.md @@ -2610,6 +2610,7 @@ entries. "open": "f_foo_open", "lockpick_result": "f_safe_open", "lockpick_message": "With a click, you unlock the safe.", + "provides_liquids": "beer", "bash": "TODO", "deconstruct": "TODO", "max_volume": "1000 L", @@ -2672,6 +2673,11 @@ also add a harvest or growth multiplier if it has the `GROWTH_HARVEST` flag. (Optional) Surgery skill multiplier (float) applied by this furniture to survivor standing next to it for the purpose of surgery. +#### `provides_liquids` + +(Optional) Dispenses infinite amounts of specified liquid item when interacted. Must be used with +`"examine_action": "liquid_source"` to work. + ### Terrain ```json diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 5c0c1e03638f..38343bff559a 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -3810,18 +3810,24 @@ void iexamine::trap( player &p, const tripoint &examp ) here.disarm_trap( examp ); } } -//Note that these two functions are checked by pointer in map::water_from. Yes it's awful. +//Note that these three functions are checked by pointer in map::water_from. Yes it's awful. void iexamine::water_source( player &, const tripoint &examp ) { liquid_handler::handle_liquid( examp ); } -//Note that these two functions are checked by pointer in map::water_from. Yes it's awful. +//Note that these three functions are checked by pointer in map::water_from. Yes it's awful. void iexamine::clean_water_source( player &, const tripoint &examp ) { liquid_handler::handle_liquid( examp ); } +//Note that these three functions are checked by pointer in map::water_from. Yes it's awful. +void iexamine::liquid_source( player &, const tripoint &examp ) +{ + liquid_handler::handle_liquid( examp ); +} + std::vector furn_t::crafting_pseudo_item_types() const { std::vector conversion; @@ -6324,6 +6330,7 @@ iexamine_function iexamine_function_from_string( const std::string &function_nam { "trap", &iexamine::trap }, { "water_source", &iexamine::water_source }, { "clean_water_source", &iexamine::clean_water_source }, + { "liquid_source", &iexamine::liquid_source }, { "reload_furniture", &iexamine::reload_furniture }, { "use_furn_fake_item", &iexamine::use_furn_fake_item }, { "curtains", &iexamine::curtains }, diff --git a/src/iexamine.h b/src/iexamine.h index 058a17b35d06..8d786f588568 100644 --- a/src/iexamine.h +++ b/src/iexamine.h @@ -86,6 +86,7 @@ void recycle_compactor( player &p, const tripoint &examp ); void trap( player &p, const tripoint &examp ); void water_source( player &p, const tripoint &examp ); void clean_water_source( player &, const tripoint &examp ); +void liquid_source( player &p, const tripoint &examp ); void kiln_empty( player &p, const tripoint &examp ); void kiln_full( player &p, const tripoint &examp ); void arcfurnace_empty( player &p, const tripoint &examp ); diff --git a/src/map.cpp b/src/map.cpp index a61dea1bff83..89fe2998fc64 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -4546,6 +4546,9 @@ detached_ptr map::water_from( const tripoint &p ) if( furn( p ).obj().examine == &iexamine::clean_water_source ) { return item::spawn( "water_clean", calendar::start_of_cataclysm, item::INFINITE_CHARGES ); } + if( furn( p ).obj().examine == &iexamine::liquid_source ) { + return item::spawn( furn( p ).obj().provides_liquids, calendar::turn, item::INFINITE_CHARGES ); + } return detached_ptr(); } diff --git a/src/mapdata.cpp b/src/mapdata.cpp index 1de6931afcec..17606a2f220d 100644 --- a/src/mapdata.cpp +++ b/src/mapdata.cpp @@ -1503,6 +1503,7 @@ void furn_t::load( const JsonObject &jo, const std::string &src ) optional( jo, was_loaded, "comfort", comfort, 0 ); optional( jo, was_loaded, "floor_bedding_warmth", floor_bedding_warmth, 0 ); optional( jo, was_loaded, "emissions", emissions ); + optional( jo, was_loaded, "provides_liquids", provides_liquids ); optional( jo, was_loaded, "bonus_fire_warmth_feet", bonus_fire_warmth_feet, 300 ); optional( jo, was_loaded, "keg_capacity", keg_capacity, legacy_volume_reader, 0_ml ); mandatory( jo, was_loaded, "required_str", move_str_req ); diff --git a/src/mapdata.h b/src/mapdata.h index ed50377d66ab..9056f3ba7c14 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -463,7 +463,6 @@ struct ter_t : map_data_common_t { ter_str_id close; // Close action: transform into terrain with matching id ter_str_id lockpick_result; // Lockpick action: transform when successfully lockpicked translation lockpick_message; // Lockpick action: message when successfully lockpicked - std::string trap_id_str; // String storing the id string of the trap. ter_str_id transforms_into; // Transform into what terrain? ter_str_id roof; // What will be the floor above this terrain @@ -501,6 +500,7 @@ struct furn_t : map_data_common_t { furn_str_id transforms_into; // Transform into what furniture? furn_str_id lockpick_result; // Lockpick action: transform when successfully lockpicked translation lockpick_message; // Lockpick action: message when successfully lockpicked + itype_id provides_liquids; // The liquid that is given as liquid source std::set crafting_pseudo_items; units::volume keg_capacity = 0_ml;