diff --git a/data/json/effects_on_condition/example_eocs.json b/data/json/effects_on_condition/example_eocs.json index bf9ab4c8dfd9e..8dd5d821883bb 100644 --- a/data/json/effects_on_condition/example_eocs.json +++ b/data/json/effects_on_condition/example_eocs.json @@ -331,8 +331,8 @@ "id": "EOC_query_tile_test_anywhere", "effect": [ { - "if": { "u_query_tile": "anywhere", "target_var": { "context_val": "pos" }, "message": "Select point" }, - "then": { "u_message": "" }, + "if": { "u_query_tile": "anywhere", "target_var": { "global_val": "pos" }, "message": "Select point" }, + "then": { "u_message": "" }, "else": { "u_message": "Canceled" } } ] @@ -342,8 +342,8 @@ "id": "EOC_query_tile_test_line_of_sight", "effect": [ { - "if": { "u_query_tile": "line_of_sight", "target_var": { "context_val": "pos" }, "message": "Select point", "range": 10 }, - "then": { "u_message": "" }, + "if": { "u_query_tile": "line_of_sight", "target_var": { "global_val": "pos" }, "message": "Select point", "range": 10 }, + "then": { "u_message": "" }, "else": { "u_message": "Canceled" } } ] @@ -353,8 +353,8 @@ "id": "EOC_query_tile_test_around", "effect": [ { - "if": { "u_query_tile": "around", "target_var": { "context_val": "pos" }, "message": "Choose direction" }, - "then": { "u_message": "" }, + "if": { "u_query_tile": "around", "target_var": { "global_val": "pos" }, "message": "Choose direction" }, + "then": { "u_message": "" }, "else": { "u_message": "Canceled" } } ] @@ -381,20 +381,20 @@ "id": "EOC_can_see_location_test", "effect": [ { - "if": { "u_query_tile": "anywhere", "target_var": { "context_val": "pos" }, "message": "Select point" }, + "if": { "u_query_tile": "anywhere", "target_var": { "global_val": "pos" }, "message": "Select point" }, "then": [ { - "if": { "u_can_see_location": { "context_val": "pos" } }, - "then": { "u_message": "You can see ." }, - "else": { "u_message": "You can't see ." } + "if": { "u_can_see_location": { "global_val": "pos" } }, + "then": { "u_message": "You can see ." }, + "else": { "u_message": "You can't see ." } }, { "u_run_npc_eocs": [ { "id": "EOC_can_see_location_test_nest", - "condition": { "u_can_see_location": { "context_val": "pos" } }, - "effect": { "message": " can see ." }, - "false_effect": { "message": " can't see ." } + "condition": { "u_can_see_location": { "global_val": "pos" } }, + "effect": { "message": " can see ." }, + "false_effect": { "message": " can't see ." } } ], "local": true @@ -438,10 +438,10 @@ "id": "EOC_teleport_test_other", "effect": [ { - "if": { "u_query_tile": "anywhere", "target_var": { "context_val": "loc" }, "message": "Select point" }, + "if": { "u_query_tile": "anywhere", "target_var": { "global_val": "loc" }, "message": "Select point" }, "then": { "run_eoc_with": { "id": "EOC_teleport_test_other_do", "effect": { "npc_teleport": { "global_val": "teleport_test_pos" } } }, - "beta_loc": { "context_val": "loc" }, + "beta_loc": { "global_val": "loc" }, "false_eocs": { "id": "EOC_teleport_test_other_do_fail_msg", "effect": { "message": "Please select a creature." } } }, "else": { "u_message": "Canceled" } @@ -467,13 +467,13 @@ "effect": [ { "u_set_talker": { "global_val": "player_id" } }, { - "if": { "u_query_tile": "anywhere", "target_var": { "context_val": "loc" }, "message": "Select point" }, + "if": { "u_query_tile": "anywhere", "target_var": { "global_val": "loc" }, "message": "Select point" }, "then": { "run_eoc_with": { "id": "_EOC_control_npc_do", "effect": [ { "if": "npc_is_npc", "then": [ "follow", "take_control" ], "else": { "message": "Please select a NPC." } } ] }, - "beta_loc": { "context_val": "loc" }, + "beta_loc": { "global_val": "loc" }, "false_eocs": { "id": "_EOC_control_npc_fail_msg", "effect": { "message": "Please select a NPC." } } }, "else": { "u_message": "Canceled" } diff --git a/data/json/furniture_and_terrain/LIXA_furniture_and_terrain.json b/data/json/furniture_and_terrain/LIXA_furniture_and_terrain.json index 2ef0ed33087f6..1d574d3c85e8a 100644 --- a/data/json/furniture_and_terrain/LIXA_furniture_and_terrain.json +++ b/data/json/furniture_and_terrain/LIXA_furniture_and_terrain.json @@ -29,7 +29,7 @@ "name": "reinforced concrete wall", "looks_like": "t_concrete_wall", "description": "An extremely resilient wall, filled with concrete and rebar. Best suited for supporting multi-level buildings, only serious explosives and high-speed impacts would be capable of damaging this wall.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -44,7 +44,7 @@ "id": "t_folded_wall", "name": "folded wall", "description": "When looked at out of the side of the eye, this wall seems to bend and curve in on itself and when looked at head on it seems to be a repeating pattern of solid concrete hexagons.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow_cyan", "move_cost": 0, "coverage": 100, @@ -59,7 +59,7 @@ "id": "t_unfolded_wall", "name": "unfolded wall", "description": "This wall tessellates as you view it.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan_red", "move_cost": 0, "coverage": 100, @@ -201,7 +201,7 @@ "name": "reinforced concrete wall", "looks_like": "t_concrete_wall", "description": "You can see every side of every crack in this worn concrete, all the way down. You can't look at it for too long.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, diff --git a/data/json/furniture_and_terrain/furniture-flora.json b/data/json/furniture_and_terrain/furniture-flora.json index ba251f33dfb0b..446c435e5f432 100644 --- a/data/json/furniture_and_terrain/furniture-flora.json +++ b/data/json/furniture_and_terrain/furniture-flora.json @@ -550,7 +550,7 @@ "id": "f_hedge_short", "name": "short hedge", "description": "A shrub with small green leaves, trimmed into a squared shape.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "green", "looks_like": "t_shrub", "move_cost_mod": 3, @@ -576,7 +576,7 @@ "id": "f_hedge_tall", "name": "tall hedge", "description": "A tall shrub with small green leaves, trimmed into a squared shape. You can't see past this thick hedgerow.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "green", "looks_like": "t_shrub", "move_cost_mod": -1, diff --git a/data/json/furniture_and_terrain/special_use/bullet_trailer.json b/data/json/furniture_and_terrain/special_use/bullet_trailer.json index 093fef42f8a31..d3e993b2a6a39 100644 --- a/data/json/furniture_and_terrain/special_use/bullet_trailer.json +++ b/data/json/furniture_and_terrain/special_use/bullet_trailer.json @@ -19,20 +19,20 @@ "connect_groups": "WALL", "connects_to": "WALL", "flags": [ "SUPPORTS_ROOF", "WALL", "REDUCE_SCENT", "AUTO_WALL_SYMBOL", "MINEABLE", "BLOCK_WIND" ], - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray" }, { "type": "terrain", "id": "t_bullettrailer_nwall", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "copy-from": "t_bullettrailer_nwall_westcorner" }, { "type": "terrain", "id": "t_bullettrailer_nwall_window", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "looks_like": "t_window", "connect_groups": "WALL", @@ -43,28 +43,28 @@ { "type": "terrain", "id": "t_bullettrailer_nwall_eastcorner", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "copy-from": "t_bullettrailer_nwall_westcorner" }, { "type": "terrain", "id": "t_bullettrailer_wwall", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "copy-from": "t_bullettrailer_nwall_westcorner" }, { "type": "terrain", "id": "t_bullettrailer_ewall", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "copy-from": "t_bullettrailer_nwall_westcorner" }, { "type": "terrain", "id": "t_bullettrailer_inner_westcorner", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "copy-from": "t_bullettrailer_nwall_westcorner" }, @@ -72,7 +72,7 @@ "type": "terrain", "id": "t_bullettrailer_inner_T", "copy-from": "t_bullettrailer_nwall_westcorner", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "name": "bullet trailer interior wall", "description": "A simple wall paneled in a coarsely textured gray laminate of some sort." @@ -81,7 +81,7 @@ "type": "terrain", "id": "t_bullettrailer_inner_eastcorner", "copy-from": "t_bullettrailer_inner_T", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray" }, { @@ -89,7 +89,7 @@ "id": "t_bullettrailer_swall_westcorner", "name": "bullet trailer exterior wall", "description": "A smooth wall of gleaming chrome, slightly dusty from the road.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "copy-from": "t_bullettrailer_nwall_westcorner" }, @@ -137,14 +137,14 @@ { "type": "terrain", "id": "t_bullettrailer_swall", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "copy-from": "t_bullettrailer_swall_westcorner" }, { "type": "terrain", "id": "t_bullettrailer_swall_eastcorner", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "copy-from": "t_bullettrailer_swall_westcorner" }, diff --git a/data/json/furniture_and_terrain/terrain-doors.json b/data/json/furniture_and_terrain/terrain-doors.json index e30ec5f429eb9..4872921f26146 100644 --- a/data/json/furniture_and_terrain/terrain-doors.json +++ b/data/json/furniture_and_terrain/terrain-doors.json @@ -2452,7 +2452,7 @@ "id": "t_secretdoor_metal_c", "name": "metal wall", "description": "An industrially fabricated thick sheet carefully positioned and joined seamlessly with perimeter sealant, this wall is capable of resisting extreme elements as well as hostile forces. Blast load rated and extremely fire-retardant, breaching it will require specialized tools or an industrial vehicle.", - "symbol": "LINE_OXOX", + "symbol": "#", "looks_like": "t_wall_metal", "color": "cyan", "move_cost": 0, @@ -2499,7 +2499,7 @@ "id": "t_secretdoor_concrete_c", "name": "concrete wall", "description": "A faux concrete wall positioned and joined seamlessly with the wall, this wall is capable of resisting extreme elements as well as hostile forces. Blast load rated and extremely fire-retardant, breaching it will require specialized tools or an industrial vehicle.", - "symbol": "LINE_OXOX", + "symbol": "#", "looks_like": "t_concrete_wall", "color": "light_gray", "move_cost": 0, diff --git a/data/json/furniture_and_terrain/terrain-fences-gates.json b/data/json/furniture_and_terrain/terrain-fences-gates.json index 42f8e70aed3f5..c91d5d3a8f12e 100644 --- a/data/json/furniture_and_terrain/terrain-fences-gates.json +++ b/data/json/furniture_and_terrain/terrain-fences-gates.json @@ -511,7 +511,7 @@ "id": "t_fence", "name": "picket fence", "description": "A barrier made of wood, it's nothing complicated. Mildly suggests where not to go.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 3, "flags": [ @@ -550,7 +550,7 @@ "id": "t_wattle_fence", "name": "woven wattle fence", "description": "A flimsy barrier made of woven sticks. Suitable for small animals.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "looks_like": "t_fence", "move_cost": 0, @@ -604,7 +604,7 @@ "id": "t_chainfence", "name": "chain link fence", "description": "A tall fence made of woven wires. There aren't any gaps big enough for you to fit through, so you'll have to cut it, climb it, or find a way around.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 0, "boltcut": { @@ -671,7 +671,7 @@ "id": "t_chickenwire_fence", "name": "chickenwire fence", "description": "A tall, rather flimsy fence made of planks and woven wire, suitable for containing small livestock like chickens.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "looks_like": "t_chainfence", "move_cost": 0, @@ -697,7 +697,7 @@ "id": "t_screened_porch_wall", "name": "screen mesh wall", "description": "A tall, rather flimsy wall made of planks and screen mesh, suitable for keeping the bugs out.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "looks_like": "t_chickenwire_fence", "move_cost": 0, @@ -836,7 +836,7 @@ "id": "t_splitrail_fence", "name": "split rail fence", "description": "A rather stout fence made of planks and fence posts, suitable for containing livestock like horses, cows and pigs.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "looks_like": "t_fence", "move_cost": 0, @@ -946,7 +946,7 @@ "id": "t_fence_metal", "name": "metal fence", "description": "A simple metal fence.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "looks_like": "t_metal_railing", "move_cost": 0, @@ -1063,7 +1063,7 @@ "id": "t_privacy_fence", "name": "wooden privacy fence", "description": "A rather stout fence made of planks and fence posts, it is tall enough to prevent people from seeing into your yard.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "looks_like": "t_fence", "move_cost": 0, @@ -1164,7 +1164,7 @@ "id": "t_railing", "name": "railing", "description": "A section of wooden railing.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow", "move_cost": 3, "flags": [ "FLAMMABLE_ASH", "TRANSPARENT", "NOITEM", "THIN_OBSTACLE", "MOUNTABLE", "SHORT", "AUTO_WALL_SYMBOL", "BURROWABLE" ], @@ -1189,7 +1189,7 @@ "id": "t_glass_railing", "name": "glass railing", "description": "A section of railing made out of glass.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 3, "flags": [ "TRANSPARENT", "NOITEM", "THIN_OBSTACLE", "MOUNTABLE", "SHORT", "AUTO_WALL_SYMBOL", "BURROWABLE" ], @@ -1214,7 +1214,7 @@ "id": "t_metal_railing", "name": "metal railing", "description": "A section of metal railing.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 3, "flags": [ "TRANSPARENT", "NOITEM", "THIN_OBSTACLE", "MOUNTABLE", "SHORT", "AUTO_WALL_SYMBOL", "BURROWABLE" ], @@ -1239,7 +1239,7 @@ "id": "t_concrete_railing", "name": "concrete railing", "description": "A section of cemented concrete railing.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "looks_like": "t_ponywall", "move_cost": 3, @@ -1320,7 +1320,7 @@ "id": "t_cattle_feeder", "name": "cattle feeder", "description": "A section of tall steel with a solid base and feed spaces above to allow livestock to reach the contained food.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "looks_like": "t_metal_railing", "move_cost": 0, diff --git a/data/json/furniture_and_terrain/terrain-flesh.json b/data/json/furniture_and_terrain/terrain-flesh.json index 51beb3d9b52b9..76d335b402632 100644 --- a/data/json/furniture_and_terrain/terrain-flesh.json +++ b/data/json/furniture_and_terrain/terrain-flesh.json @@ -24,7 +24,7 @@ "id": "t_concrete_wall_flesh", "name": "overgrown wall", "description": "A concrete wall overgrown by a grotesque grid of veins and knotted flesh.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta_yellow", "move_cost": 0, "coverage": 100, diff --git a/data/json/furniture_and_terrain/terrain-floors-indoor.json b/data/json/furniture_and_terrain/terrain-floors-indoor.json index d441fe82ef4f5..4a14f7167b1c5 100644 --- a/data/json/furniture_and_terrain/terrain-floors-indoor.json +++ b/data/json/furniture_and_terrain/terrain-floors-indoor.json @@ -1493,7 +1493,7 @@ "name": "junk metal floor", "looks_like": "t_scrap_floor", "description": "A simple roof of rusty scrap metal bolted and wire-tied to a makeshift frame. Very fashionable in post-apocalyptic shantytowns. Hope you like the sound of rain on corrugated metal. Can support a roof.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 2, "connect_groups": "INDOORFLOOR", diff --git a/data/json/furniture_and_terrain/terrain-fungal.json b/data/json/furniture_and_terrain/terrain-fungal.json index 21d37ffb56278..755ea91cb9cf4 100644 --- a/data/json/furniture_and_terrain/terrain-fungal.json +++ b/data/json/furniture_and_terrain/terrain-fungal.json @@ -86,7 +86,7 @@ "id": "t_fungus_wall_transformed", "name": "fungal wall", "description": "The fungus here has grown thickly and tightly enough to form a solid wall. It feels very stiff to the touch, and seems to be very strong.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, diff --git a/data/json/furniture_and_terrain/terrain-migo.json b/data/json/furniture_and_terrain/terrain-migo.json index e7bc40862c52c..ad9f979919215 100644 --- a/data/json/furniture_and_terrain/terrain-migo.json +++ b/data/json/furniture_and_terrain/terrain-migo.json @@ -4,7 +4,7 @@ "id": "t_wall_resin", "name": "resin wall", "description": "A wall made of a glistening, nearly opaque, plastic-like substance. Deep within, you can barely see a network of pulsating green conduits, snaking through it like blood vessels. The material is hard, warm to the touch, and slightly damp.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, diff --git a/data/json/furniture_and_terrain/terrain-roofs.json b/data/json/furniture_and_terrain/terrain-roofs.json index f83962c438e59..f07fd533a985a 100644 --- a/data/json/furniture_and_terrain/terrain-roofs.json +++ b/data/json/furniture_and_terrain/terrain-roofs.json @@ -43,7 +43,7 @@ "id": "t_gutter", "description": "Channels water from the roof towards the ground, it looks flimsy.", "name": "rain gutter", - "symbol": "LINE_OXOX", + "symbol": "#", "looks_like": "t_metal_floor", "color": "white", "move_cost": 3, diff --git a/data/json/furniture_and_terrain/terrain-triffid.json b/data/json/furniture_and_terrain/terrain-triffid.json index 3a27b45d330e5..aa8d346cec6b1 100644 --- a/data/json/furniture_and_terrain/terrain-triffid.json +++ b/data/json/furniture_and_terrain/terrain-triffid.json @@ -4,7 +4,7 @@ "id": "t_triffid_bark_wall", "name": "solid bark wall", "description": "A solid wall of bark, enclosing the trunk of a massive tree. It will probably burn quite well.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -26,7 +26,7 @@ "id": "t_bark_wall_chipped", "name": "chipped bark wall", "description": "A solid wall of bark enclosing the trunk of a massive tree. Some of it has been broken away.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -67,7 +67,7 @@ "id": "t_triffid_wood_wall", "name": "solid wood wall", "description": "A solid wall of naturally grown wood. Likely very flammable.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, diff --git a/data/json/furniture_and_terrain/terrain-walls.json b/data/json/furniture_and_terrain/terrain-walls.json index 1385c945c22a2..4d5f73c5224e9 100644 --- a/data/json/furniture_and_terrain/terrain-walls.json +++ b/data/json/furniture_and_terrain/terrain-walls.json @@ -19,7 +19,7 @@ "id": "t_wall", "name": "wall", "description": "A standard wall consisting of a wooden support structure filled with insulation and drywalled. Painted a neutral off-white or cream color, it could use some more vibrant paint. Looks flammable.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -78,7 +78,7 @@ "id": "t_ponywall", "name": "pony wall", "description": "A short divider wall consisting of a wooden support structure with drywall. Painted an all-too-common and neutral off-white or cream color. Looks flammable.", - "symbol": "LINE_OXOX", + "symbol": "#", "looks_like": "f_counter", "color": "light_gray", "move_cost": 0, @@ -103,7 +103,7 @@ "looks_like": "t_wall", "name": "red wall", "description": "A wall, painted red.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "red", "move_cost": 0, "coverage": 100, @@ -137,7 +137,7 @@ "looks_like": "t_wall", "name": "white wall", "description": "A wall, painted white.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "move_cost": 0, "coverage": 100, @@ -171,7 +171,7 @@ "looks_like": "t_wall", "name": "blue wall", "description": "A wall, painted blue.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "blue", "move_cost": 0, "coverage": 100, @@ -205,7 +205,7 @@ "looks_like": "t_wall", "name": "green wall", "description": "A wall, painted green.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "green", "move_cost": 0, "coverage": 100, @@ -239,7 +239,7 @@ "looks_like": "t_wall", "name": "yellow wall", "description": "A wall, painted yellow.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow", "move_cost": 0, "coverage": 100, @@ -273,7 +273,7 @@ "looks_like": "t_wall", "name": "pink wall", "description": "A wall, painted pink.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "pink", "move_cost": 0, "coverage": 100, @@ -307,7 +307,7 @@ "looks_like": "t_wall", "name": "purple wall", "description": "A wall, painted purple.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, @@ -341,7 +341,7 @@ "looks_like": "t_wall", "name": "orange wall", "description": "A wall, painted orange.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_red", "move_cost": 0, "coverage": 100, @@ -375,7 +375,7 @@ "looks_like": "t_wall", "name": "gray wall", "description": "A wall, painted gray.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -409,7 +409,7 @@ "looks_like": "t_wall", "name": "brown wall", "description": "A wall, painted brown.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -443,7 +443,7 @@ "looks_like": "t_wall", "name": "cyan wall", "description": "A wall, painted cyan.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 0, "coverage": 100, @@ -477,7 +477,7 @@ "looks_like": "t_wall", "name": "black wall", "description": "A wall, painted black.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow", "move_cost": 0, "coverage": 100, @@ -511,7 +511,7 @@ "name": "blue wood wall", "looks_like": "t_wall_b", "description": "A wooden wall, painted blue.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "blue", "move_cost": 0, "coverage": 100, @@ -539,7 +539,7 @@ "name": "green wood wall", "looks_like": "t_wall_g", "description": "A wooden wall, painted green.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "green", "move_cost": 0, "coverage": 100, @@ -567,7 +567,7 @@ "name": "red wood wall", "looks_like": "t_wall_r", "description": "A wooden wall, painted red.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "red", "move_cost": 0, "coverage": 100, @@ -595,7 +595,7 @@ "name": "white wood wall", "looks_like": "t_wall_w", "description": "A wooden wall, painted white.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "move_cost": 0, "coverage": 100, @@ -623,7 +623,7 @@ "name": "purple wood wall", "looks_like": "t_wall_p", "description": "A wooden wall, painted purple.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, @@ -651,7 +651,7 @@ "name": "pink wood wall", "looks_like": "t_wall_P", "description": "A wooden wall, painted pink.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "pink", "move_cost": 0, "coverage": 100, @@ -679,7 +679,7 @@ "name": "yellow wood wall", "looks_like": "t_wall_y", "description": "A wooden wall, painted yellow.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow", "move_cost": 0, "coverage": 100, @@ -707,7 +707,7 @@ "name": "orange wood wall", "looks_like": "t_wall_orange", "description": "A wooden wall, painted orange.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_red", "move_cost": 0, "coverage": 100, @@ -735,7 +735,7 @@ "name": "gray wood wall", "looks_like": "t_wall_gray", "description": "A wooden wall, painted gray.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -763,7 +763,7 @@ "name": "brown wood wall", "looks_like": "t_wall_brown", "description": "A wooden wall, painted brown.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -791,7 +791,7 @@ "name": "cyan wood wall", "looks_like": "t_wall_cyan", "description": "A wooden wall, painted cyan.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 0, "coverage": 100, @@ -819,7 +819,7 @@ "name": "black wood wall", "looks_like": "t_wall_black", "description": "A wooden wall, painted black.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, @@ -847,7 +847,7 @@ "name": "blue concrete wall", "looks_like": "t_wall_b", "description": "A concrete wall, painted blue.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "blue", "move_cost": 0, "coverage": 100, @@ -870,7 +870,7 @@ "name": "green concrete wall", "looks_like": "t_wall_g", "description": "A concrete wall, painted green.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "green", "move_cost": 0, "coverage": 100, @@ -893,7 +893,7 @@ "name": "red concrete wall", "looks_like": "t_wall_r", "description": "A concrete wall, painted red.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "red", "move_cost": 0, "coverage": 100, @@ -916,7 +916,7 @@ "name": "white concrete wall", "looks_like": "t_wall_w", "description": "A concrete wall, painted white.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "move_cost": 0, "coverage": 100, @@ -939,7 +939,7 @@ "name": "purple concrete wall", "looks_like": "t_wall_p", "description": "A concrete wall, painted purple.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, @@ -962,7 +962,7 @@ "name": "pink concrete wall", "looks_like": "t_wall_P", "description": "A concrete wall, painted pink.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "pink", "move_cost": 0, "coverage": 100, @@ -985,7 +985,7 @@ "name": "yellow concrete wall", "looks_like": "t_wall_y", "description": "A concrete wall, painted yellow.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow", "move_cost": 0, "coverage": 100, @@ -1008,7 +1008,7 @@ "name": "orange concrete wall", "looks_like": "t_wall_orange", "description": "A concrete wall, painted orange.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_red", "move_cost": 0, "coverage": 100, @@ -1031,7 +1031,7 @@ "name": "gray concrete wall", "looks_like": "t_wall_gray", "description": "A concrete wall, painted gray.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -1054,7 +1054,7 @@ "name": "brown concrete wall", "looks_like": "t_wall_brown", "description": "A concrete wall, painted brown.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -1077,7 +1077,7 @@ "name": "cyan concrete wall", "looks_like": "t_wall_cyan", "description": "A concrete wall, painted cyan.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 0, "coverage": 100, @@ -1100,7 +1100,7 @@ "name": "black concrete wall", "looks_like": "t_wall_p", "description": "A concrete wall, painted black.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, @@ -1123,7 +1123,7 @@ "name": "reinforced blue concrete wall", "looks_like": "t_wall_b", "description": "A reinforced concrete wall, painted blue.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "blue", "move_cost": 0, "coverage": 100, @@ -1146,7 +1146,7 @@ "name": "reinforced green concrete wall", "looks_like": "t_wall_g", "description": "A reinforced concrete wall, painted green.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "green", "move_cost": 0, "coverage": 100, @@ -1169,7 +1169,7 @@ "name": "reinforced red concrete wall", "looks_like": "t_wall_r", "description": "A reinforced concrete wall, painted red.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "red", "move_cost": 0, "coverage": 100, @@ -1192,7 +1192,7 @@ "name": "reinforced white concrete wall", "looks_like": "t_wall_w", "description": "A reinforced concrete wall, painted white.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "move_cost": 0, "coverage": 100, @@ -1215,7 +1215,7 @@ "name": "reinforced purple concrete wall", "looks_like": "t_wall_p", "description": "A reinforced concrete wall, painted purple.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, @@ -1238,7 +1238,7 @@ "name": "reinforced pink concrete wall", "looks_like": "t_wall_P", "description": "A reinforced concrete wall, painted pink.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "pink", "move_cost": 0, "coverage": 100, @@ -1261,7 +1261,7 @@ "name": "reinforced yellow concrete wall", "looks_like": "t_wall_y", "description": "A reinforced concrete wall, painted yellow.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow", "move_cost": 0, "coverage": 100, @@ -1284,7 +1284,7 @@ "name": "reinforced orange concrete wall", "looks_like": "t_wall_orange", "description": "A reinforced concrete wall, painted orange.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_red", "move_cost": 0, "coverage": 100, @@ -1307,7 +1307,7 @@ "name": "reinforced gray concrete wall", "looks_like": "t_wall_gray", "description": "A reinforced concrete wall, painted gray.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -1330,7 +1330,7 @@ "name": "reinforced brown concrete wall", "looks_like": "t_wall_brown", "description": "Reinforced concrete wall painted brown.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -1353,7 +1353,7 @@ "name": "reinforced cyan concrete wall", "looks_like": "t_wall_cyan", "description": "A reinforced concrete wall, painted cyan.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 0, "coverage": 100, @@ -1376,7 +1376,7 @@ "name": "reinforced black concrete wall", "looks_like": "t_wall_black", "description": "A reinforced concrete wall, painted black.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, @@ -1399,7 +1399,7 @@ "name": "simple blue concrete wall", "looks_like": "t_wall_b", "description": "A simple concrete wall, painted blue.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "blue", "move_cost": 0, "coverage": 100, @@ -1422,7 +1422,7 @@ "name": "simple green concrete wall", "looks_like": "t_wall_g", "description": "A simple concrete wall, painted green.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "green", "move_cost": 0, "coverage": 100, @@ -1445,7 +1445,7 @@ "name": "simple red concrete wall", "looks_like": "t_wall_r", "description": "A simple concrete wall, painted red.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "red", "move_cost": 0, "coverage": 100, @@ -1468,7 +1468,7 @@ "name": "simple white concrete wall", "looks_like": "t_wall_w", "description": "A simple concrete wall, painted white.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "move_cost": 0, "coverage": 100, @@ -1491,7 +1491,7 @@ "name": "simple purple concrete wall", "looks_like": "t_wall_p", "description": "A simple concrete wall, painted purple.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, @@ -1514,7 +1514,7 @@ "name": "simple pink concrete wall", "looks_like": "t_wall_P", "description": "A simple concrete wall, painted pink.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "pink", "move_cost": 0, "coverage": 100, @@ -1537,7 +1537,7 @@ "name": "simple yellow concrete wall", "looks_like": "t_wall_y", "description": "A simple concrete wall, painted yellow.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow", "move_cost": 0, "coverage": 100, @@ -1560,7 +1560,7 @@ "name": "simple orange concrete wall", "looks_like": "t_wall_orange", "description": "A simple concrete wall, painted orange.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_red", "move_cost": 0, "coverage": 100, @@ -1583,7 +1583,7 @@ "name": "simple gray concrete wall", "looks_like": "t_wall_gray", "description": "A simple concrete wall, painted gray.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -1606,7 +1606,7 @@ "name": "simple brown concrete wall", "looks_like": "t_wall_brown", "description": "A simple concrete wall, painted brown.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "red", "move_cost": 0, "coverage": 100, @@ -1629,7 +1629,7 @@ "name": "simple cyan concrete wall", "looks_like": "t_wall_cyan", "description": "A simple concrete wall, painted cyan.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 0, "coverage": 100, @@ -1652,7 +1652,7 @@ "name": "simple black concrete wall", "looks_like": "t_wall_p", "description": "A simple concrete wall, painted black.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, @@ -1694,7 +1694,7 @@ "id": "t_brick_wall", "name": "brick wall", "description": "A solid brick wall, sturdy enough to support a roof with enough walls and to keep out any unwanted visitors.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -1717,7 +1717,7 @@ "name": "stone wall", "looks_like": "t_rock", "description": "A sturdy stone wall.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -1740,7 +1740,7 @@ "name": "whitewashed stone masonry wall", "looks_like": "t_rock_wall", "description": "A wall of carefully cut and laid stones, joined with mortar. The exterior has been finished with plaster and whitewashed.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -1785,7 +1785,7 @@ "name": "smoothed rock", "looks_like": "t_rock", "description": "A block of stone that's been smoothed and shaped, commonly granite or marble for funerary chapels and mausoleums.", - "symbol": "LINE_OXOX", + "symbol": "#", "//": "use pillars, 't_column', as a compliment.", "color": "white", "move_cost": 0, @@ -1828,7 +1828,7 @@ "id": "t_adobe_brick_wall", "name": "adobe wall", "description": "A solid adobe brick wall that's both sturdy enough to support a roof and keep out any unwanted visitors.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "looks_like": "t_brick_wall", "move_cost": 0, @@ -1852,7 +1852,7 @@ "name": "concrete wall", "looks_like": "t_rock", "description": "An aesthetically pleasing design with simple lines, this type of concrete was used with a weaker chemical mixture in order to have faster setting times. Not ideal for multi-story buildings, but still capable of supporting a roof.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, @@ -1875,7 +1875,7 @@ "name": "concrete wall with ropes", "looks_like": "t_rock", "description": "A boxlike wall of concrete with ropes attached to the exterior edges.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 10, "coverage": 100, @@ -1897,7 +1897,7 @@ "id": "t_wall_metal", "name": "metal wall", "description": "An industrially fabricated thick sheet carefully positioned and joined seamlessly with perimeter sealant, this wall is capable of resisting extreme elements as well as hostile forces. Blast load rated and extremely fire-retardant, breaching it will require specialized tools or an industrial vehicle.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 0, "coverage": 100, @@ -1929,7 +1929,7 @@ "name": "corrugated metal wall", "description": "A wall made from a thin sheet of corrugated steel held in a frame, weather- and windproof but not very insulating or durable.", "looks_like": "t_wall_metal", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "move_cost": 0, "coverage": 100, @@ -1951,7 +1951,7 @@ "id": "t_wall_bulkhead", "name": "bulkhead", "description": "An industrially fabricated thick sheet carefully positioned, this wall is capable of resisting extreme elements as well as hostile forces.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -1979,7 +1979,7 @@ "name": "simple concrete wall", "looks_like": "t_concrete_wall", "description": "A durable and uniform concrete wall, quite drab without decoration. More than capable of supporting a roof, as well as keeping out most anything, save for vehicles.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -2024,7 +2024,7 @@ "name": "reinforced concrete wall", "looks_like": "t_concrete_wall", "description": "An extremely resilient wall, filled with concrete and rebar. Best suited for supporting multi-level buildings, only serious explosives and high-speed impacts would be capable of damaging this wall.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -2100,7 +2100,7 @@ "name": "simple metal wall", "looks_like": "t_wall_metal", "description": "A relatively simple wall made of cobbled-together scrap metal. It's still capable of blocking intruders and supporting a roof with adjacent walls.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, @@ -2143,7 +2143,7 @@ "name": "wooden wall", "looks_like": "t_wall", "description": "A finished wall of planks and support beams, capable of supporting an upper level or roof. Highly flammable.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_red", "move_cost": 0, "coverage": 100, @@ -2171,7 +2171,7 @@ "name": "chipped wood wall", "looks_like": "t_wall_wood", "description": "A wall of aligned planks that's starting to crack and break open. Some replacement wood and a number of nails could patch this up quick.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_red", "move_cost": 0, "coverage": 100, @@ -2249,7 +2249,7 @@ "name": "log wall", "looks_like": "t_wall_wood", "description": "A tall wall of timber suitable for housing and insulating from the weather. Quite flammable.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -2272,7 +2272,7 @@ "name": "chipped log wall", "looks_like": "t_wall_log", "description": "A moderately damaged log wall, it could probably be patched up with some planks and nails.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -2339,7 +2339,7 @@ "name": "wattle-and-daub wall", "looks_like": "t_wall_wood", "description": "A relatively primitive wall made by daubing together a lattice of wooden strips using some combination of wet soil, clay, sand, animal dung, and straw.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_red", "move_cost": 0, "coverage": 100, @@ -2404,7 +2404,7 @@ "name": "junk metal wall", "looks_like": "t_scrap_wall", "description": "A wall of rusty scrap metal bolted and wire-tied to a sturdy frame. Very fashionable in post-apocalyptic shantytowns. Can support a roof.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, @@ -2431,7 +2431,7 @@ "name": "rammed earth wall", "looks_like": "t_rock", "description": "A solid wall of compressed dirt, sturdy enough to support a roof with enough walls and to keep out some unwanted visitors.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -2454,7 +2454,7 @@ "name": "smooth dirt wall", "looks_like": "t_wall_rammed_earth", "description": "A solid wall of compressed dirt, mixed with… something to keep it stable. Its surface glistens slightly, and it smells like rotten milk.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, @@ -2476,7 +2476,7 @@ "id": "t_wall_warped", "name": "warped wall", "description": "At first glance, this looks like a simple stone wall. But the angles don't add up, and the shadows are wrong. Whatever this is, it doesn't belong here.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, @@ -2490,7 +2490,7 @@ "name": "junk metal barrier", "looks_like": "t_scrap_wall_halfway", "description": "A simple wall of rusty scrap metal bolted and wire-tied to a makeshift frame. Very fashionable in post-apocalyptic shantytowns. This one isn't quite strong enough to support a roof, but could be reinforced.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 60, @@ -2512,7 +2512,7 @@ "name": "glass wall", "looks_like": "t_window", "description": "A barrier made of glass, it's nothing complicated, and looks extremely fragile. Some contain glass break sensors or window sensors that trigger an alarm if the glass is damaged.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "coverage": 30, @@ -2539,7 +2539,7 @@ "looks_like": "t_wall_glass", "name": "glass wall", "description": "A barrier made of glass, it's nothing complicated, and looks extremely fragile. Some contain glass break sensors or window sensors that trigger an alarm if the glass is damaged.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "coverage": 30, @@ -2566,7 +2566,7 @@ "name": "laminated glass", "looks_like": "t_reinforced_glass", "description": "A laminated glass barrier, composed of layers of glass and plastic held together by an interlayer.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "roof": "t_flat_roof", @@ -2591,7 +2591,7 @@ "name": "ballistic glass", "looks_like": "t_reinforced_glass", "description": "A ballistic glass barrier, consisting of layers of laminated glass.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "roof": "t_flat_roof", @@ -2620,7 +2620,7 @@ "id": "t_reinforced_glass", "name": "reinforced glass", "description": "A thicker pane of glass with thin metal wires embedded throughout, strengthening the structural properties. Still weaker than other types of walls, and not made to support a roof either.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "roof": "t_flat_roof", @@ -2650,7 +2650,7 @@ "name": "reinforced glass with closed shutters", "looks_like": "t_wall_metal", "description": "A secondary layer of protection over reinforced glass, these metal shutters are typically used to ward off criminals or protect against damage from extreme weather. Looks like it can only be opened from the inside. Even with the installed shutters, it isn't feasible in supporting a roof.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "roof": "t_flat_roof", @@ -2685,7 +2685,7 @@ "name": "reinforced glass with open shutters", "looks_like": "t_reinforced_glass", "description": "Hanging metal shutters that haven't been deployed, exposing the reinforced glass. It appears as though the metal shutters can only be activated from the inside.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "roof": "t_flat_roof", @@ -2720,7 +2720,7 @@ "name": "lighthouse lens", "looks_like": "t_wall_glass", "description": "An intricate arrangement of glass, designed to focus light from within to be visible over long distances.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "connect_groups": "WALL", @@ -3152,7 +3152,7 @@ "name": "field stone wall", "looks_like": "t_rock_wall", "description": "A sturdy, dry stone wall. Just rocks fitted together without mortar.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, diff --git a/data/json/furniture_and_terrain/terrain_nether_monster.json b/data/json/furniture_and_terrain/terrain_nether_monster.json index e177b0661f762..12072a03f7a9c 100644 --- a/data/json/furniture_and_terrain/terrain_nether_monster.json +++ b/data/json/furniture_and_terrain/terrain_nether_monster.json @@ -15,7 +15,7 @@ "id": "t_nm_wall_bone", "name": "bone wall", "description": "An amazingly durable, impregnable wall of bone stands before you, forming the outer shell of the eldritch monster.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta_white", "move_cost": 0, "coverage": 100, @@ -58,7 +58,7 @@ "id": "t_nm_wall_flesh", "name": "flesh wall", "description": "Warm to the touch, the tainted flesh of this monstrous being still twitches.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta_red", "move_cost": 0, "coverage": 100, @@ -81,7 +81,7 @@ "id": "t_nm_wall_cartilage", "name": "flesh wall", "description": "A thick wall of fleshy cartilage. With the proper tools, you could smash right through it.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, @@ -98,7 +98,7 @@ "name": "flesh wall", "//": " is spawning monsters on bashing/destruction of terrain possible? ", "description": "This section of flesh seems hollowed out. You can see silky, translucent larvae wriggling inside, consuming flesh at a prodigious pace.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow_red", "move_cost": 0, "coverage": 100, @@ -147,7 +147,7 @@ "id": "t_nm_brain", "name": "nether brain", "description": "An oozing pile of wrinkled, decomposing flesh.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta_red", "move_cost": 0, "coverage": 100, diff --git a/data/json/furniture_and_terrain/terrain_vitrified.json b/data/json/furniture_and_terrain/terrain_vitrified.json index d26842cc51cb0..11dd95f5c3aad 100644 --- a/data/json/furniture_and_terrain/terrain_vitrified.json +++ b/data/json/furniture_and_terrain/terrain_vitrified.json @@ -17,7 +17,7 @@ "id": "t_quietfarm_border_fence", "name": "chain link fence", "description": "A tall fence made of woven wires. There aren't any gaps big enough for you to fit through, so you'll have to cut it, climb it, or find a way around.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "cyan", "looks_like": "t_chainfence", "move_cost": 0, @@ -177,7 +177,7 @@ "id": "t_vitrified_wall", "name": "black glass wall", "description": "A heavy wall of black glass, textured with the knots and whorls of old and well-loved wood boards.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "connect_groups": "WALL", @@ -227,7 +227,7 @@ "id": "t_vitrified_chickenwire_fence", "name": "black fiberglass fence", "description": "A network of delicate glass threads strung between thicker posts. The wind blowing across them produces a faint, eerie whine.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "looks_like": "t_chainfence", "move_cost": 0, @@ -269,7 +269,7 @@ "name": "translucent black glass wall", "looks_like": "t_vitrified_wall", "description": "An area of black glass translucent enough to allow murky shapes to be seen through it.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 30, diff --git a/data/json/items/tool/cooking.json b/data/json/items/tool/cooking.json index 37a3bd9ffbba3..e3f84341b330c 100644 --- a/data/json/items/tool/cooking.json +++ b/data/json/items/tool/cooking.json @@ -1172,5 +1172,28 @@ "use_action": [ { "type": "link_up", "cable_length": 2, "charge_rate": "1400 W" } ], "flags": [ "WATER_BREAK", "ALLOWS_REMOTE_USE" ], "ammo": [ "battery" ] + }, + { + "id": "crystallizing_sugar", + "type": "TOOL", + "symbol": "*", + "color": "white", + "name": { "str": "crystallizing sugar" }, + "description": "Sweet, sweet sugar in the process of crystallizing. It needs two weeks to form solid crystals.", + "price": "0 cent", + "price_postapoc": "0 cent", + "material": [ "sugar" ], + "weight": "10 g", + "volume": "10 ml", + "use_action": { + "type": "delayed_transform", + "target": "sugar", + "msg": "You break up the crystallized sugar into a coarse powder.", + "not_ready_msg": "The sugar is still crystallizing.", + "moves": 300, + "transform_age": 1209600, + "//": "2 weeks for cristallizing sugar, based on the real-life example" + }, + "flags": [ "NO_SALVAGE" ] } ] diff --git a/data/json/mapgen_palettes/common_parameters.json b/data/json/mapgen_palettes/common_parameters.json index 71bd86cb8fdbe..748e9e5d3f4aa 100644 --- a/data/json/mapgen_palettes/common_parameters.json +++ b/data/json/mapgen_palettes/common_parameters.json @@ -33,6 +33,38 @@ "#": { "param": "exterior_wall_type", "fallback": "t_brick_wall" } } }, + { + "type": "palette", + "id": "parametrized_highrise_walls_palette", + "//": "Intended as a palette for randomized walls for multi-story buildings", + "parameters": { + "interior_highrise_wall_type": { + "type": "ter_str_id", + "default": { + "distribution": [ + [ "t_strconc_wall", 2 ], + [ "t_strconc_wall_b", 1 ], + [ "t_strconc_wall_g", 1 ], + [ "t_strconc_wall_r", 2 ], + [ "t_strconc_wall_w", 1 ], + [ "t_strconc_wall_p", 1 ], + [ "t_strconc_wall_P", 2 ], + [ "t_strconc_wall_y", 1 ], + [ "t_strconc_wall_orange", 1 ], + [ "t_strconc_wall_gray", 2 ], + [ "t_strconc_wall_brown", 1 ], + [ "t_strconc_wall_cyan", 1 ], + [ "t_strconc_wall_black", 1 ] + ] + } + }, + "exterior_highrise_wall_type": { "type": "ter_str_id", "default": { "distribution": [ [ "t_strconc_wall", 1 ] ] } } + }, + "terrain": { + "|": { "param": "interior_highrise_wall_type", "fallback": "t_strconc_wall" }, + "#": { "param": "exterior_highrise_wall_type", "fallback": "t_strconc_wall" } + } + }, { "type": "palette", "id": "parametrized_fences_palette", diff --git a/data/json/recipes/recipe_food.json b/data/json/recipes/recipe_food.json index b3108fab44c7b..3bed7f719de64 100644 --- a/data/json/recipes/recipe_food.json +++ b/data/json/recipes/recipe_food.json @@ -6254,23 +6254,26 @@ { "type": "recipe", "activity_level": "LIGHT_EXERCISE", - "result": "sugar", + "byproducts": [ [ "juice_pulp", 3 ] ], + "result": "crystallizing_sugar", "id_suffix": "from_sweets", "category": "CC_FOOD", "subcategory": "CSC_FOOD_OTHER", "skill_used": "cooking", - "difficulty": 4, - "time": "24 m", - "charges": 11, - "autolearn": true, - "//": [ - "Not sure why the recipe is using cooking skill… Handling lye powder and using CHEM 2 quality ", - "is in line with chemistry, IMHO." - ], - "proficiencies": [ { "proficiency": "prof_intro_chemistry" }, { "proficiency": "prof_inorganic_chemistry" } ], + "difficulty": 5, + "time": "1 h 45 m", + "charges": 10, + "//": [ "The recipe is using cooking skill and no more chemistry here!" ], + "proficiencies": [ { "proficiency": "prof_knife_skills" } ], "batch_time_factors": [ 20, 1 ], - "qualities": [ { "id": "CHEM", "level": 2 } ], - "tools": [ [ [ "surface_heat", 50, "LIST" ] ] ], + "book_learn": { "cookbook_foodfashions": { "skill_level": 5, "recipe_name": "Improvised Fruit Sugar" } }, + "qualities": [ + { "id": "CONTAIN", "level": 1 }, + { "id": "CUT", "level": 2 }, + { "id": "BOIL", "level": 2 }, + { "id": "FILTER", "level": 2 } + ], + "tools": [ [ [ "water_boiling_heat", 8, "LIST" ] ], [ [ "screw_press_tool", -1 ] ] ], "components": [ [ [ "sweet_fruit_like", 2, "LIST" ], @@ -6279,10 +6282,10 @@ [ "rehydrated_corn_kernels", 3 ], [ "honeydew", 3 ], [ "honeycomb", 1 ], - [ "can_corn", 3 ] + [ "can_corn", 3 ], + [ "juice", 3 ] ], - [ [ "lye_powder", 20 ] ], - [ [ "water_clean", 1 ] ] + [ [ "water_clean", 2 ], [ "water", 2 ] ] ] }, { @@ -6295,7 +6298,7 @@ "skill_used": "cooking", "difficulty": 2, "time": "24 m", - "charges": 22, + "charges": 20, "autolearn": true, "batch_time_factors": [ 20, 1 ], "qualities": [ { "id": "BOIL", "level": 2 } ], @@ -6324,7 +6327,7 @@ "skill_used": "cooking", "difficulty": 1, "time": "5 m", - "charges": 19, + "charges": 10, "autolearn": true, "batch_time_factors": [ 50, 1 ], "tools": [ [ [ "food_processor", 20 ] ] ], @@ -6366,7 +6369,8 @@ { "type": "recipe", "activity_level": "LIGHT_EXERCISE", - "result": "sugar", + "byproducts": [ [ "molasses", 2 ] ], + "result": "crystallizing_sugar", "id_suffix": "from_beets", "category": "CC_FOOD", "subcategory": "CSC_FOOD_OTHER", @@ -6376,16 +6380,17 @@ "time": "1 h 30 m", "charges": 10, "batch_time_factors": [ 20, 1 ], - "book_learn": { - "adv_chemistry": { "skill_level": 6 }, - "textbook_chemistry": { "skill_level": 6 }, - "cookbook_foodfashions": { "skill_level": 5, "recipe_name": "Natural Beet Sugar" } - }, - "proficiencies": [ { "proficiency": "prof_intro_chemistry" }, { "proficiency": "prof_inorganic_chemistry" } ], - "qualities": [ { "id": "CONTAIN", "level": 1 }, { "id": "BOIL", "level": 2 }, { "id": "CHEM", "level": 1 } ], - "tools": [ [ [ "water_boiling_heat", 8, "LIST" ] ] ], + "book_learn": { "cookbook_foodfashions": { "skill_level": 5, "recipe_name": "Natural Beet Sugar" } }, + "proficiencies": [ { "proficiency": "prof_knife_skills" } ], + "qualities": [ + { "id": "CONTAIN", "level": 1 }, + { "id": "CUT", "level": 2 }, + { "id": "BOIL", "level": 2 }, + { "id": "FILTER", "level": 2 } + ], + "tools": [ [ [ "water_boiling_heat", 8, "LIST" ] ], [ [ "screw_press_tool", -1 ] ] ], "//1": "1u base + 1u ingredient + 6u evaporation", - "components": [ [ [ "sugar_beet", 3 ] ], [ [ "water_clean", 1 ], [ "water", 1 ] ], [ [ "lye_powder", 20 ] ] ] + "components": [ [ [ "sugar_beet", 3 ] ], [ [ "water_clean", 1 ], [ "water", 1 ] ] ] }, { "type": "recipe", diff --git a/data/mods/Aftershock/maps/furniture_and_terrain/terrain.json b/data/mods/Aftershock/maps/furniture_and_terrain/terrain.json index 48188f52c074d..8540ae4028af2 100644 --- a/data/mods/Aftershock/maps/furniture_and_terrain/terrain.json +++ b/data/mods/Aftershock/maps/furniture_and_terrain/terrain.json @@ -42,7 +42,7 @@ "looks_like": "t_wall_glass", "name": "clearcrete wall", "description": "A barrier made of clearcrete, perfect for greenhouses but looks extremely fragile. It is most definitely not fragile, and it's probably alarmed in the event of a breach.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "roof": "t_clearcrete_roof", diff --git a/data/mods/Aftershock/maps/furniture_and_terrain/terrain_alienciv.json b/data/mods/Aftershock/maps/furniture_and_terrain/terrain_alienciv.json index 515e67faf6db2..6076ec89c600e 100644 --- a/data/mods/Aftershock/maps/furniture_and_terrain/terrain_alienciv.json +++ b/data/mods/Aftershock/maps/furniture_and_terrain/terrain_alienciv.json @@ -23,7 +23,7 @@ "name": "coral floor", "description": "Filaments of white coral grow tall and weave themselves into a sinuous wall. The living surface is ornately grooved, and golden light slowly flows within its gaps.", "roof": "t_coral_floor_no_roof", - "symbol": "LINE_XOXO", + "symbol": "#", "looks_like": "t_rock_wall", "color": "light_gray", "move_cost": 0, diff --git a/data/mods/Aftershock/maps/furniture_and_terrain/terrain_groundxeno.json b/data/mods/Aftershock/maps/furniture_and_terrain/terrain_groundxeno.json index f7299c6bb1ffb..cc589dcd06ba8 100644 --- a/data/mods/Aftershock/maps/furniture_and_terrain/terrain_groundxeno.json +++ b/data/mods/Aftershock/maps/furniture_and_terrain/terrain_groundxeno.json @@ -231,7 +231,7 @@ "name": "basalt wall", "looks_like": "t_rock", "description": "A sturdy basalt wall.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -253,7 +253,7 @@ "id": "t_ice_wall", "name": "glacial ice wall", "description": "A solid wall of glacial ice.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_blue", "move_cost": 0, "coverage": 100, @@ -268,7 +268,7 @@ "id": "t_snow_wall", "name": "snow wall", "description": "A solid mass of piled snow.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "move_cost": 0, "coverage": 100, diff --git a/data/mods/Aftershock/maps/furniture_and_terrain/terrain_habitat_wall.json b/data/mods/Aftershock/maps/furniture_and_terrain/terrain_habitat_wall.json index 56edfb0f6d60e..3adf6bc5e1350 100644 --- a/data/mods/Aftershock/maps/furniture_and_terrain/terrain_habitat_wall.json +++ b/data/mods/Aftershock/maps/furniture_and_terrain/terrain_habitat_wall.json @@ -5,7 +5,7 @@ "name": "habitat wall", "description": "An industrially fabricated assembly of lightweight metallic framing and insulated cover sheets, used to quickly assemble standardized colonial infrastructure. Capable of resisting the merciless cold and not much else.", "roof": "t_metal_flat_roof", - "symbol": "LINE_XOXO", + "symbol": "#", "looks_like": "t_wall_metal", "color": "light_gray", "move_cost": 0, @@ -33,7 +33,7 @@ "name": "habitat window", "description": "A prefabricated porthole style window, equipped with metallic shutters for both protection and privacy purposes. It cannot be opened, but with its shutters are retracted, it could be smashed with no particular difficulty.", "roof": "t_metal_flat_roof", - "symbol": "LINE_XOXO", + "symbol": "#", "color": "light_cyan", "close": "t_wall_prefab_glass_shutters", "move_cost": 0, diff --git a/data/mods/Aftershock/maps/furniture_and_terrain/terrain_spaceship.json b/data/mods/Aftershock/maps/furniture_and_terrain/terrain_spaceship.json index 53c62d6d30942..b849fb004594f 100644 --- a/data/mods/Aftershock/maps/furniture_and_terrain/terrain_spaceship.json +++ b/data/mods/Aftershock/maps/furniture_and_terrain/terrain_spaceship.json @@ -9,7 +9,7 @@ "connect_groups": "WALL", "connects_to": "WALL", "flags": [ "NOITEM", "SUPPORTS_ROOF", "WALL", "NO_SCENT", "AUTO_WALL_SYMBOL", "MINEABLE", "BLOCK_WIND" ], - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "bash": { "str_min": 200, @@ -30,7 +30,7 @@ "name": "broken treads", "description": "A large set of broken and frozen over vehicle treads.", "flags": [ "NOITEM", "NO_SCENT", "AUTO_WALL_SYMBOL", "MINEABLE", "BLOCK_WIND", "TRANSPARENT", "SHORT" ], - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "move_cost": 5, "bash": { @@ -54,7 +54,7 @@ "roof": "t_metal_flat_roof", "copy-from": "t_wall_metal", "flags": [ "NOITEM", "SUPPORTS_ROOF", "WALL", "NO_SCENT", "AUTO_WALL_SYMBOL", "MINEABLE", "BLOCK_WIND" ], - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "bash": { "str_min": 350, @@ -77,7 +77,7 @@ "roof": "t_metal_flat_roof", "copy-from": "t_wall_metal", "flags": [ "SUPPORTS_ROOF", "CONTAINER", "WALL", "NO_SCENT", "AUTO_WALL_SYMBOL", "MINEABLE", "BLOCK_WIND" ], - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "bash": { "str_min": 200, @@ -146,7 +146,7 @@ "roof": "t_metal_flat_roof", "copy-from": "t_wall_metal", "flags": [ "NOITEM", "SUPPORTS_ROOF", "TRANSPARENT", "PERMEABLE", "MINEABLE" ], - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "bash": { "str_min": 20, @@ -169,7 +169,7 @@ "roof": "t_metal_flat_roof", "copy-from": "t_wall_metal", "flags": [ "NOITEM", "SUPPORTS_ROOF", "NO_SCENT", "MINEABLE", "BLOCK_WIND" ], - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "open": "t_afs_gun_ship_hull_hatch_o", "bash": { @@ -602,7 +602,7 @@ "description": "The diamond cubic lattice distorts distant light sources into eight pointed stars. The galactic core is visible through the glass, but no spacer would ever give it more than a passing glance.", "roof": "t_metal_flat_roof", "looks_like": "t_reinforced_glass", - "symbol": "LINE_XOXO", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "coverage": 100, @@ -627,7 +627,7 @@ "connect_groups": "WALL", "connects_to": "WALL", "flags": [ "NOITEM", "SUPPORTS_ROOF", "WALL", "NO_SCENT", "AUTO_WALL_SYMBOL", "BLOCK_WIND" ], - "symbol": "LINE_OXOX", + "symbol": "#", "bash": { "str_min": 4000, "str_max": 8000, "sound": "whump!", "sound_fail": "whump!", "ter_set": "t_afs_augustmoon_hull_wall" }, "color": "white" }, diff --git a/data/mods/Magiclysm/Spells/druid.json b/data/mods/Magiclysm/Spells/druid.json index 7c849a29ce956..79c0bcfac5dbe 100644 --- a/data/mods/Magiclysm/Spells/druid.json +++ b/data/mods/Magiclysm/Spells/druid.json @@ -1115,11 +1115,11 @@ { "if": { "u_query_tile": "around", - "target_var": { "context_val": "druid_treeshape_location" }, + "target_var": { "global_val": "druid_treeshape_location" }, "message": "Select nearby tree" }, "then": { - "if": { "map_terrain_with_flag": "TREE", "loc": { "context_val": "druid_treeshape_location" } }, + "if": { "map_terrain_with_flag": "TREE", "loc": { "global_val": "druid_treeshape_location" } }, "then": [ { "u_message": "The wood of the tree grows and forms as you cast the spell and when it ends, there is a log lying on the ground, entirely covered in bark but otherwise straight and ready to be used in other projects.", diff --git a/data/mods/Magiclysm/furniture_and_terrain/terrain_druid.json b/data/mods/Magiclysm/furniture_and_terrain/terrain_druid.json index 79592304985ea..b3dcc27b7733f 100644 --- a/data/mods/Magiclysm/furniture_and_terrain/terrain_druid.json +++ b/data/mods/Magiclysm/furniture_and_terrain/terrain_druid.json @@ -18,7 +18,7 @@ "looks_like": "t_triffid_wood_wall", "name": "solid wood wall", "description": "A solid wall of naturally grown wood. Likely very flammable.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "brown", "move_cost": 0, "coverage": 100, diff --git a/data/mods/Magiclysm/terrain.json b/data/mods/Magiclysm/terrain.json index 41c19cc6ae3ab..26195dcdd8cd9 100644 --- a/data/mods/Magiclysm/terrain.json +++ b/data/mods/Magiclysm/terrain.json @@ -43,7 +43,7 @@ "id": "t_demon_web_wall", "name": "webbing wall", "description": "This wall seems to be made up of a combination of webbing, wood splinters, detritus, and some kind of dark-colored resin.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, @@ -70,7 +70,7 @@ "looks_like": "t_wall_glass", "name": "glassteel vault wall", "description": "A barrier made of glassteel, it's nothing complicated, and looks extremely fragile. It is most definitely not fragile and it's probably alarmed in the event that someone does break through it.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "roof": "t_flat_roof", @@ -123,7 +123,7 @@ "name": "magically reinforced concrete wall", "looks_like": "t_concrete_wall", "description": "An extremely resilient wall, filled with concrete and rebar and esoteric ingredients. Best suited for supporting multi-level buildings, only serious explosives and high-speed impacts would be capable of damaging this wall.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, diff --git a/data/mods/No_Hope/terrain.json b/data/mods/No_Hope/terrain.json index 4c7ee8c4dc9c3..0ea68cd571866 100644 --- a/data/mods/No_Hope/terrain.json +++ b/data/mods/No_Hope/terrain.json @@ -5,7 +5,7 @@ "//": "TODO: Change to copy-from: t_wall extend: flags: FLAMMABLE_HARD delete: flags: FLAMMABLE once #73211 merges", "name": "wall", "description": "The stereotypical wall with wooden support structure filled with insulation and drywalled. Paint job is the all too common and neutral off-white or cream color, it could use more vibrant paint.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -38,7 +38,7 @@ "looks_like": "t_wall", "name": "red wall", "description": "Wall painted red.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "red", "move_cost": 0, "coverage": 100, @@ -72,7 +72,7 @@ "looks_like": "t_wall", "name": "white wall", "description": "Wall painted white.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "white", "move_cost": 0, "coverage": 100, @@ -106,7 +106,7 @@ "looks_like": "t_wall", "name": "blue wall", "description": "Wall painted blue.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "blue", "move_cost": 0, "coverage": 100, @@ -140,7 +140,7 @@ "looks_like": "t_wall", "name": "green wall", "description": "Wall painted green.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "green", "move_cost": 0, "coverage": 100, @@ -174,7 +174,7 @@ "looks_like": "t_wall", "name": "yellow wall", "description": "Wall painted yellow.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "yellow", "move_cost": 0, "coverage": 100, @@ -208,7 +208,7 @@ "looks_like": "t_wall", "name": "pink wall", "description": "Wall painted pink.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "pink", "move_cost": 0, "coverage": 100, @@ -241,7 +241,7 @@ "looks_like": "t_wall", "name": "purple wall", "description": "Wall painted purple.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, diff --git a/data/mods/Sky_Island/EOCs.json b/data/mods/Sky_Island/EOCs.json index 118f82dc0b6d2..3b8b0290b51e4 100644 --- a/data/mods/Sky_Island/EOCs.json +++ b/data/mods/Sky_Island/EOCs.json @@ -932,15 +932,15 @@ { "if": { "u_query_tile": "around", - "target_var": { "context_val": "warped_pond_location" }, + "target_var": { "global_val": "warped_pond_location" }, "message": "Select nearby water source" }, "then": { "if": { "or": [ - { "map_terrain_with_flag": "LIQUID", "loc": { "context_val": "warped_pond_location" } }, - { "map_terrain_id": "t_wooden_well", "loc": { "context_val": "warped_pond_location" } }, - { "map_terrain_id": "t_water_pump", "loc": { "context_val": "warped_pond_location" } } + { "map_terrain_with_flag": "LIQUID", "loc": { "global_val": "warped_pond_location" } }, + { "map_terrain_id": "t_wooden_well", "loc": { "global_val": "warped_pond_location" } }, + { "map_terrain_id": "t_water_pump", "loc": { "global_val": "warped_pond_location" } } ] }, "then": { diff --git a/data/mods/Sky_Island/furniture_and_terrain.json b/data/mods/Sky_Island/furniture_and_terrain.json index 88994dd31e2df..2090f937ab2d4 100644 --- a/data/mods/Sky_Island/furniture_and_terrain.json +++ b/data/mods/Sky_Island/furniture_and_terrain.json @@ -64,7 +64,7 @@ "looks_like": "t_wall_glass", "name": "warpglass wall", "description": "A shimmering translucent barrier that almost yields to the touch, but adamantly refuses entry.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_cyan", "move_cost": 0, "roof": "t_flat_roof", @@ -176,7 +176,7 @@ "name": "warped rock", "looks_like": "t_rock", "description": "A sparkly-black stone that's glassy smooth to the touch. Seems indestructible by normal means.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "dark_gray", "move_cost": 0, "coverage": 100, diff --git a/data/mods/Xedra_Evolved/effects/effects.json b/data/mods/Xedra_Evolved/effects/effects.json index 1437562a04990..2d0dbed6e5bbf 100644 --- a/data/mods/Xedra_Evolved/effects/effects.json +++ b/data/mods/Xedra_Evolved/effects/effects.json @@ -2296,6 +2296,21 @@ "Triggering your abilities that way has taken their toll on you. You cannot save yourself from death that way a second time yet." ] }, + { + "type": "effect_type", + "id": "effect_lilin_attack_warning_cooldown", + "//": "Hidden effect, used as a blocker", + "name": [ "" ], + "desc": [ "" ] + }, + { + "type": "effect_type", + "id": "effect_lilin_health_effects_of_draining", + "name": [ "" ], + "desc": [ "" ], + "rating": "bad", + "base_mods": { "health_min": [ -1 ], "health_chance": [ 2 ] } + }, { "type": "effect_type", "id": "effect_lilin_vampire_immune", diff --git a/data/mods/Xedra_Evolved/eocs/eoc_strange_events.json b/data/mods/Xedra_Evolved/eocs/eoc_strange_events.json new file mode 100644 index 0000000000000..92dccaf11a32f --- /dev/null +++ b/data/mods/Xedra_Evolved/eocs/eoc_strange_events.json @@ -0,0 +1,72 @@ +[ + { + "type": "effect_on_condition", + "id": "EOC_SLEEPING_SEIZED_BY_LILIT_WARNING", + "eoc_type": "EVENT", + "required_event": "character_wakes_up", + "condition": { + "and": [ + { "not": { "u_has_trait": "LILIN_TRAITS" } }, + { "math": [ "u_characters_nearby('radius': 45)", "==", "0" ] }, + { "not": "u_is_outside" }, + { "x_in_y_chance": { "x": 1, "y": 2 } }, + { "math": [ "time_since('cataclysm', 'unit':'days')", "<=", "20" ] }, + { "not": { "u_has_effect": "effect_lilin_attack_warning_cooldown" } } + ] + }, + "effect": [ + { + "u_message": "The night was a little rough. You tossed and turned, aware of every single noise and creak of wood in a way you never were before all of this happened, before you finally fell asleep. You weren't attacked and woke up without trouble, but you have to wonder if it's really safe, sleeping alone like this in an abandoned building?", + "popup": true + }, + { "u_add_effect": "effect_lilin_attack_warning_cooldown", "duration": "20 days" } + ] + }, + { + "type": "effect_on_condition", + "id": "EOC_SLEEPING_SEIZED_BY_LILIT", + "eoc_type": "EVENT", + "required_event": "character_falls_asleep", + "condition": { + "and": [ + { "not": { "u_has_trait": "LILIN_TRAITS" } }, + { "math": [ "u_characters_nearby('radius': 45)", "==", "0" ] }, + { "not": "is_day" }, + { "not": "u_is_outside" }, + { + "x_in_y_chance": { + "x": { + "math": [ + "1 + min( (u_effect_intensity('effect_lilin_ruach_drain_side_effects') * 90 ), 180) + (u_effect_intensity('common_cold') > -1 ? 15 : 0) + (u_effect_intensity('influenza') > -1 ? 25 : 0) + (u_effect_intensity('pre_common_cold') > -1 ? 7 : 0) + (u_effect_intensity('pre_flu') > -1 ? 12 : 0)" + ] + }, + "y": 365 + } + }, + { "not": { "u_has_worn_with_flag": "WARDING_SYMBOL" } } + ] + }, + "effect": [ { "run_eocs": "EOC_SLEEPING_SEIZED_BY_LILIT_EFFECTS", "time_in_future": [ "3 hours", "5 hours" ] } ] + }, + { + "type": "effect_on_condition", + "id": "EOC_SLEEPING_SEIZED_BY_LILIT_EFFECTS", + "condition": { + "and": [ + { "math": [ "u_characters_nearby('radius': 45)", "==", "0" ] }, + { "u_has_effect": "sleep" }, + { "not": "is_day" }, + { "not": { "u_has_effect": "effect_sleep_shield" } } + ] + }, + "effect": [ + { + "u_add_effect": "effect_lilin_ruach_drain_side_effects", + "intensity": { "math": [ "rand(2) + 1" ] }, + "duration": 259200 + }, + { "u_message": "snippet_drained_by_lilit", "snippet": true, "type": "bad" }, + { "math": [ "u_lilin_ruach_drained_recently", "=", "1" ] } + ] + } +] diff --git a/data/mods/Xedra_Evolved/flags.json b/data/mods/Xedra_Evolved/flags.json index 1ac98330f5733..930e37b2c6709 100644 --- a/data/mods/Xedra_Evolved/flags.json +++ b/data/mods/Xedra_Evolved/flags.json @@ -39,6 +39,11 @@ "type": "json_flag", "info": "You are immune to the evil eye." }, + { + "id": "WARDING_SYMBOL", + "type": "json_flag", + "info": "Wearing this is comforting." + }, { "id": "EVIL_EYE_IMMUNE_MONSTER", "type": "monster_flag" diff --git a/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-doors.json b/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-doors.json index f9bac7b681543..c0f56e2d4f399 100644 --- a/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-doors.json +++ b/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-doors.json @@ -4,7 +4,7 @@ "id": "t_secretdoor_wall_c", "name": "wall", "description": "A faux wall positioned and joined seamlessly with the wall, this wall looks pretty normal.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "looks_like": "t_wall", "move_cost": 0, diff --git a/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-eruption.json b/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-eruption.json index d85ec257c1637..e71582678db2e 100644 --- a/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-eruption.json +++ b/data/mods/Xedra_Evolved/furniture_and_terrain/terrain-eruption.json @@ -5,7 +5,7 @@ "name": "wall of fog", "looks_like": "fd_fog", "description": "A wall of swirling fog. Despite its constant movement, it never spreads out or escapes the rough wall-shape it's in.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "light_gray", "move_cost": 0, "coverage": 100, @@ -19,7 +19,7 @@ "name": "obsidian rock", "looks_like": "t_rock", "description": "A rough wall of igneous stone. It does not look like polished obsidian but you can see some resemblance.", - "symbol": "LINE_OXOX", + "symbol": "#", "//": "use pillars, 't_column_obsidian', as a compliment.", "color": "white", "move_cost": 0, diff --git a/data/mods/Xedra_Evolved/furniture_and_terrain/terrain_abyssal_hunger.json b/data/mods/Xedra_Evolved/furniture_and_terrain/terrain_abyssal_hunger.json index e0a27f7599d76..e2662c8fc85f6 100644 --- a/data/mods/Xedra_Evolved/furniture_and_terrain/terrain_abyssal_hunger.json +++ b/data/mods/Xedra_Evolved/furniture_and_terrain/terrain_abyssal_hunger.json @@ -4,7 +4,7 @@ "id": "t_abyssal_flesh_wall", "name": "warped flesh wall", "description": "Cold to the touch, the deformed flesh of this monstrous being churns as it perceives your presence.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta", "move_cost": 0, "coverage": 100, @@ -40,7 +40,7 @@ "id": "t_abyssal_brain", "name": "Abyssal Hunger's brain", "description": "A gigantic mass of flesh similar to a brain.", - "symbol": "LINE_OXOX", + "symbol": "#", "color": "magenta_red", "move_cost": 0, "coverage": 100, diff --git a/data/mods/Xedra_Evolved/items/clothes.json b/data/mods/Xedra_Evolved/items/clothes.json index e29bff333c675..8e96eba81bedb 100644 --- a/data/mods/Xedra_Evolved/items/clothes.json +++ b/data/mods/Xedra_Evolved/items/clothes.json @@ -430,5 +430,19 @@ "flags": [ "OVERSIZE", "HOOD", "BELTED" ], "armor": [ { "encumbrance": 4, "coverage": 65, "covers": [ "torso", "arm_l", "arm_r", "leg_l", "leg_r" ] } ], "relic_data": { "passive_effects": [ { "id": "ench_verdant_cloak" } ] } + }, + { + "id": "holy_symbol", + "type": "ARMOR", + "copy-from": "holy_symbol", + "name": { "str": "holy symbol" }, + "extend": { "flags": [ "WARDING_SYMBOL" ] } + }, + { + "id": "holy_symbol_wood", + "type": "ARMOR", + "copy-from": "holy_symbol_wood", + "name": { "str": "handmade holy symbol" }, + "extend": { "flags": [ "WARDING_SYMBOL" ] } } ] diff --git a/data/mods/Xedra_Evolved/mutations/paraclesians/arvore_eocs.json b/data/mods/Xedra_Evolved/mutations/paraclesians/arvore_eocs.json index 0c03c0c4c90c6..d1f8de1dc68bd 100644 --- a/data/mods/Xedra_Evolved/mutations/paraclesians/arvore_eocs.json +++ b/data/mods/Xedra_Evolved/mutations/paraclesians/arvore_eocs.json @@ -254,7 +254,7 @@ { "if": { "u_query_tile": "line_of_sight", - "target_var": { "context_val": "arvore_walk_wilds_location" }, + "target_var": { "global_val": "arvore_walk_wilds_location" }, "range": { "math": [ "( ( (u_spell_level('arvore_traverse_the_wilds') * 1.5) + 5) * (scaling_factor(u_val('perception') ) ) )" ] }, @@ -264,12 +264,12 @@ "then": { "if": { "or": [ - { "map_terrain_with_flag": "TREE", "loc": { "context_val": "arvore_walk_wilds_location" } }, - { "map_terrain_with_flag": "YOUNG", "loc": { "context_val": "arvore_walk_wilds_location" } } + { "map_terrain_with_flag": "TREE", "loc": { "global_val": "arvore_walk_wilds_location" } }, + { "map_terrain_with_flag": "YOUNG", "loc": { "global_val": "arvore_walk_wilds_location" } } ] }, "then": [ - { "u_teleport": { "context_val": "arvore_walk_wilds_location" }, "force": true }, + { "u_teleport": { "global_val": "arvore_walk_wilds_location" }, "force": true }, { "u_message": "You step into the tree and step out of another one nearby.", "type": "neutral" } ], "else": { "u_message": "You must select a tree to step to." } @@ -605,11 +605,11 @@ { "if": { "u_query_tile": "around", - "target_var": { "context_val": "arvore_treesung_location" }, + "target_var": { "global_val": "arvore_treesung_location" }, "message": "Select nearby tree" }, "then": { - "if": { "map_terrain_with_flag": "TREE", "loc": { "context_val": "arvore_treesung_location" } }, + "if": { "map_terrain_with_flag": "TREE", "loc": { "global_val": "arvore_treesung_location" } }, "then": { "u_assign_activity": "ACT_ARVORE_TREESINGING", "duration": "45 minutes" }, "else": { "u_message": "You must be near a tree to treesing to it." } }, diff --git a/data/mods/Xedra_Evolved/mutations/vampire_trait_eocs.json b/data/mods/Xedra_Evolved/mutations/vampire_trait_eocs.json index 627730f7af8b4..4f566d1a37ed6 100644 --- a/data/mods/Xedra_Evolved/mutations/vampire_trait_eocs.json +++ b/data/mods/Xedra_Evolved/mutations/vampire_trait_eocs.json @@ -1232,14 +1232,14 @@ { "if": { "u_query_tile": "around", - "target_var": { "context_val": "vampire_mist_door_or_window_seep" }, + "target_var": { "global_val": "vampire_mist_door_or_window_seep" }, "message": "Select door or window, then target the space beyond it." }, "then": { - "if": { "map_terrain_with_flag": "DOOR", "loc": { "context_val": "vampire_mist_door_or_window_seep" } }, + "if": { "map_terrain_with_flag": "DOOR", "loc": { "global_val": "vampire_mist_door_or_window_seep" } }, "then": { "u_cast_spell": { "id": "vampire_mist_form_pass_through_doors_and_windows_teleport" }, "targeted": true }, "else": { - "if": { "map_terrain_with_flag": "WINDOW", "loc": { "context_val": "vampire_mist_door_or_window_seep" } }, + "if": { "map_terrain_with_flag": "WINDOW", "loc": { "global_val": "vampire_mist_door_or_window_seep" } }, "then": { "u_cast_spell": { "id": "vampire_mist_form_pass_through_doors_and_windows_teleport" }, "targeted": true }, "else": { "u_message": "You must be near a door or window to seep through." } } diff --git a/data/mods/Xedra_Evolved/mutations/xe_lilin_eocs.json b/data/mods/Xedra_Evolved/mutations/xe_lilin_eocs.json index f32521d85a40d..5d0025643260e 100644 --- a/data/mods/Xedra_Evolved/mutations/xe_lilin_eocs.json +++ b/data/mods/Xedra_Evolved/mutations/xe_lilin_eocs.json @@ -1,4 +1,54 @@ [ + { + "type": "effect_on_condition", + "id": "EOC_RUACH_DRAINED_AWAKENING_PENALTIES", + "eoc_type": "EVENT", + "required_event": "character_wakes_up", + "condition": { "u_has_effect": "effect_lilin_ruach_drain_side_effects" }, + "effect": [ + { "math": [ "u_val('sleepiness')", "+=", "40 + (u_effect_intensity('effect_lilin_ruach_drain_side_effects') * 20)" ] }, + { + "u_add_effect": "effect_lilin_health_effects_of_draining", + "duration": { "math": [ "10 + (u_effect_intensity('effect_lilin_ruach_drain_side_effects') * rng(10,20) )" ] } + }, + { + "if": { "math": [ "u_lilin_ruach_drained_recently", "==", "1" ] }, + "then": [ + { "math": [ "u_lilin_ruach_drained_recently", "=", "0" ] }, + { + "u_deal_damage": "biological", + "amount": { "math": [ "max(((u_effect_intensity('effect_lilin_ruach_drain_side_effects') / 2)- 3), 0 )" ] }, + "bodypart": "head" + }, + { + "u_deal_damage": "biological", + "amount": { "math": [ "max(((u_effect_intensity('effect_lilin_ruach_drain_side_effects') / 2)- 3), 0 )" ] }, + "bodypart": "arm_l" + }, + { + "u_deal_damage": "biological", + "amount": { "math": [ "max(((u_effect_intensity('effect_lilin_ruach_drain_side_effects') / 2)- 3), 0 )" ] }, + "bodypart": "arm_r" + }, + { + "u_deal_damage": "biological", + "amount": { "math": [ "max(((u_effect_intensity('effect_lilin_ruach_drain_side_effects') / 2)- 3), 0 )" ] }, + "bodypart": "torso" + }, + { + "u_deal_damage": "biological", + "amount": { "math": [ "max(((u_effect_intensity('effect_lilin_ruach_drain_side_effects') / 2)- 3), 0 )" ] }, + "bodypart": "leg_r" + }, + { + "u_deal_damage": "biological", + "amount": { "math": [ "max(((u_effect_intensity('effect_lilin_ruach_drain_side_effects') / 2)- 3), 0 )" ] }, + "bodypart": "leg_l" + } + ] + } + ] + }, { "type": "effect_on_condition", "id": "EOC_LILIN_RUACH_DRAIN_SELF", diff --git a/data/mods/Xedra_Evolved/snippets/dreams.json b/data/mods/Xedra_Evolved/snippets/dreams.json index fbc3b23ecfb53..12d585c61d701 100644 --- a/data/mods/Xedra_Evolved/snippets/dreams.json +++ b/data/mods/Xedra_Evolved/snippets/dreams.json @@ -108,5 +108,18 @@ "You are in a field where the scarecrows come to life and chase you with knives.", "You are in a house where the paintings change every time you look away, showing your worst fears." ] + }, + { + "type": "snippet", + "category": "snippet_drained_by_lilit", + "text": [ + "You dream of falling through darkness.", + "You dream of whistling winds as you stand on a mountaintop.", + "You dream of the moon growing larger and larger, filling the sky.", + "You dream of walking through the forest and suddenly seeing an owl fly past you, so close you could touch it.", + "You dream of something sitting on your chest, suffocating you.", + "You dream of slipping under dark water, none of your attempts to swim keeping you afloat.", + "You dream of standing in a dark room, being buffeted by silent wings." + ] } ] diff --git a/data/mods/Xedra_Evolved/spells/lilin_spell_eocs.json b/data/mods/Xedra_Evolved/spells/lilin_spell_eocs.json index f99e7efa855c2..1cd99259efa46 100644 --- a/data/mods/Xedra_Evolved/spells/lilin_spell_eocs.json +++ b/data/mods/Xedra_Evolved/spells/lilin_spell_eocs.json @@ -7,6 +7,7 @@ "effect": [ { "math": [ "n_vitamin('lilin_ruach_vitamin')", "+=", "rng(200,300)" ] }, { "npc_message": "You feel a rush of warmth as you absorb the ruach.", "type": "good" }, + { "math": [ "u_lilin_ruach_drained_recently", "=", "1" ] }, { "run_eocs": "EOC_LILIN_RUACH_DRAIN_SIDE_EFFECTS" } ], "false_effect": [ diff --git a/doc/MAPGEN.md b/doc/MAPGEN.md index bcd0db3b797f5..9024402d4d1a3 100644 --- a/doc/MAPGEN.md +++ b/doc/MAPGEN.md @@ -1490,6 +1490,7 @@ These are a few palettes that have been generalized to be used in almost any map | Palette | Usage | --- | --- | `parametrized_walls_palette` | For having randomized inner and outer walls +| `parametrized_highrise_walls_palette` | For having randomized inner and outer walls in high-rise buildings | `parametrized_fences_palette` | For having randomized fences | `parametrized_linoleum_palette` | For having randomized linoleum colors | `parametrized_carpets_palette` | For having randomized carpet colors diff --git a/doc/OBSOLETION_AND_MIGRATION.md b/doc/OBSOLETION_AND_MIGRATION.md index 113f0a85358bb..e02cad6d3aba5 100644 --- a/doc/OBSOLETION_AND_MIGRATION.md +++ b/doc/OBSOLETION_AND_MIGRATION.md @@ -200,7 +200,8 @@ Errorlessly obsolete an id # Overmap terrain migration -Overmap terrain migration replaces the location, if it's not generated, and replaces the entry shown on your map even if it's already generated. If you need the map to be removed without alternative, use `omt_obsolete` +Overmap terrain migration replaces the location, if it's not generated, and replaces the entry shown on your map even if it's already generated. +If you need the map to be removed without alternative, use `omt_obsolete`. Mods can override replacement ids by specifying different new ids or cancel them entirely by making the new id the same as the old one. ```json { diff --git a/src/activity_item_handling.cpp b/src/activity_item_handling.cpp index fe26c3348ff4b..b5303a2e82fbc 100644 --- a/src/activity_item_handling.cpp +++ b/src/activity_item_handling.cpp @@ -586,7 +586,7 @@ static bool vehicle_activity( Character &you, const tripoint_bub_ms &src_loc, in // so , NPCs can remove the last part on a position, then there is no vehicle there anymore, // for someone else who stored that position at the start of their activity. // so we may need to go looking a bit further afield to find it , at activities end. - for( const tripoint &pt : veh->get_points( true ) ) { + for( const tripoint_bub_ms &pt : veh->get_points( true ) ) { you.activity.coord_set.insert( here.getglobal( pt ).raw() ); } // values[0] @@ -1056,7 +1056,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara // find out if there is a vehicle part here we can remove. // TODO: fix point types std::vector parts = - veh->get_parts_at( src_loc.raw(), "", part_status_flag::any ); + veh->get_parts_at( src_loc, "", part_status_flag::any ); for( vehicle_part *part_elem : parts ) { const int vpindex = veh->index_of_part( part_elem, true ); // if part is not on this vehicle, or if its attached to another part that needs to be removed first. @@ -1101,7 +1101,7 @@ static activity_reason_info can_do_activity_there( const activity_id &act, Chara } else if( act == ACT_VEHICLE_REPAIR ) { // find out if there is a vehicle part here we can repair. // TODO: fix point types - std::vector parts = veh->get_parts_at( src_loc.raw(), "", part_status_flag::any ); + std::vector parts = veh->get_parts_at( src_loc, "", part_status_flag::any ); for( vehicle_part *part_elem : parts ) { const vpart_info &vpinfo = part_elem->info(); int vpindex = veh->index_of_part( part_elem, true ); diff --git a/src/avatar.cpp b/src/avatar.cpp index 317ce4c1911ce..1915de0bd29c4 100644 --- a/src/avatar.cpp +++ b/src/avatar.cpp @@ -688,7 +688,7 @@ void avatar::grab( object_type grab_type_new, const tripoint_rel_ms &grab_point_ map &m = get_map(); if( gtype == object_type::VEHICLE ) { if( const optional_vpart_position ovp = m.veh_at( pos_bub() + gpoint ) ) { - for( const tripoint &target : ovp->vehicle().get_points() ) { + for( const tripoint_bub_ms &target : ovp->vehicle().get_points() ) { if( erase ) { memorize_clear_decoration( m.getglobal( target ), /* prefix = */ "vp_" ); } diff --git a/src/cata_tiles.cpp b/src/cata_tiles.cpp index 1de25b27124c4..a8a75c0b4ecf7 100644 --- a/src/cata_tiles.cpp +++ b/src/cata_tiles.cpp @@ -1429,12 +1429,12 @@ void cata_tiles::draw( const point &dest, const tripoint ¢er, int width, int if( g->display_overlay_state( ACTION_DISPLAY_VEHICLE_AI ) ) { for( const wrapped_vehicle &elem : here.get_vehicles() ) { const vehicle &veh = *elem.v; - const point veh_pos = veh.global_pos3().xy(); + const point_bub_ms veh_pos = veh.pos_bub().xy(); for( const auto &overlay_data : veh.get_debug_overlay_data() ) { - const point pt = veh_pos + std::get<0>( overlay_data ); + const point_bub_ms pt = veh_pos + std::get<0>( overlay_data ); const int color = std::get<1>( overlay_data ); const std::string &text = std::get<2>( overlay_data ); - overlay_strings.emplace( player_to_screen( pt ), + overlay_strings.emplace( player_to_screen( pt.raw() ), formatted_text( text, color, text_alignment::left ) ); } @@ -3941,7 +3941,7 @@ bool cata_tiles::draw_vpart( const tripoint &p, lit_level ll, int &height_3d, avatar &you = get_avatar(); if( !veh.forward_velocity() && !veh.player_in_control( you ) && !( you.get_grab_type() == object_type::VEHICLE - && veh.get_points().count( ( you.pos_bub() + you.grab_point ).raw() ) ) + && veh.get_points().count( ( you.pos_bub() + you.grab_point ) ) ) && here.memory_cache_dec_is_dirty( p ) ) { you.memorize_decoration( here.getglobal( p ), vd.get_tileset_id(), subtile, rotation ); } diff --git a/src/character.cpp b/src/character.cpp index dfd81f63c6c3b..51d68f0b5a918 100644 --- a/src/character.cpp +++ b/src/character.cpp @@ -11110,7 +11110,7 @@ void Character::stagger() const optional_vpart_position vp_there = here.veh_at( dest ); if( vp_there ) { vehicle &veh = vp_there->vehicle(); - if( veh.enclosed_at( dest.raw() ) ) { + if( veh.enclosed_at( dest ) ) { blocked = true; } } diff --git a/src/character.h b/src/character.h index 07dc4906ec4ec..83169225be830 100644 --- a/src/character.h +++ b/src/character.h @@ -520,6 +520,8 @@ struct run_cost_effect { float plus = 0; }; +nutrients default_character_compute_effective_nutrients( const item &comest ); + class Character : public Creature, public visitable { public: @@ -1131,12 +1133,13 @@ class Character : public Creature, public visitable bool handle_melee_wear( item_location shield, float wear_multiplier = 1.0f ); /** Returns a random technique/vector/contact area set from the possible techs */ std::tuple pick_technique( - Creature &t, const item_location &weap, - bool crit, bool dodge_counter, bool block_counter, const std::vector &blacklist = {} ); + Creature const &t, const item_location &weap, + bool crit, bool dodge_counter, bool block_counter, const std::vector &blacklist = {} ) + const; // Filter techniques per tech, return a tech/vector/sublimb set std::optional> - evaluate_technique( const matec_id &tec_id, Creature &t, const item_location &weap, - bool crit = false, bool dodge_counter = false, bool block_counter = false ); + evaluate_technique( const matec_id &tec_id, Creature const &t, const item_location &weap, + bool crit = false, bool dodge_counter = false, bool block_counter = false ) const; void perform_technique( const ma_technique &technique, Creature &t, damage_instance &di, int &move_cost, item_location &cur_weapon ); @@ -1235,9 +1238,9 @@ class Character : public Creature, public visitable bool can_autolearn( const matype_id &ma_id ) const; private: /** Check if an area-of-effect technique has valid targets */ - bool valid_aoe_technique( Creature &t, const ma_technique &technique ); - bool valid_aoe_technique( Creature &t, const ma_technique &technique, - std::vector &targets ); + bool valid_aoe_technique( Creature const &t, const ma_technique &technique ) const; + bool valid_aoe_technique( Creature const &t, const ma_technique &technique, + std::vector &targets ) const; public: /** This handles giving xp for a skill. Returns true on level-up. */ @@ -2742,7 +2745,7 @@ class Character : public Creature, public visitable // Items currently being hauled std::vector haul_list; - tripoint_rel_ms view_offset; + mutable tripoint_rel_ms view_offset; player_activity stashed_outbounds_activity; player_activity stashed_outbounds_backlog; diff --git a/src/condition.cpp b/src/condition.cpp index 4cf138fa2e6b6..d40e43d8fdb6a 100644 --- a/src/condition.cpp +++ b/src/condition.cpp @@ -381,7 +381,8 @@ str_translation_or_var get_str_translation_or_var( return ret_val; } -tripoint_abs_ms get_tripoint_from_var( std::optional var, dialogue const &d, bool is_npc ) +tripoint_abs_ms get_tripoint_from_var( std::optional var, const_dialogue const &d, + bool is_npc ) { if( var.has_value() ) { std::string value = read_var_value( var.value(), d ); @@ -394,7 +395,7 @@ tripoint_abs_ms get_tripoint_from_var( std::optional var, dialogue con d.get_callstack() ); return tripoint_abs_ms( tripoint_min ); } - return get_map().getglobal( d.actor( is_npc )->pos() ); + return get_map().getglobal( d.const_actor( is_npc )->pos() ); } template @@ -538,6 +539,27 @@ void write_var_value( var_type type, const std::string &name, dialogue *d, } } +void write_var_value( var_type type, const std::string &name, const_dialogue const &d, + const std::string &value ) +{ + switch( type ) { + case var_type::global: + get_globals().set_global_value( name, value ); + break; + case var_type::context: + case var_type::var: + case var_type::u: + case var_type::npc: + case var_type::faction: + case var_type::party: + debugmsg( "Only global variables can be assigned from an eval function.\n%s", d.get_callstack() ); + break; + default: + debugmsg( "Invalid type." ); + break; + } +} + void write_var_value( var_type type, const std::string &name, dialogue *d, double value ) { @@ -560,7 +582,7 @@ static bodypart_id get_bp_from_str( const std::string &ctxt ) void read_condition( const JsonObject &jo, const std::string &member_name, conditional_t::func &condition, bool default_val ) { - const auto null_function = [default_val]( dialogue const & ) { + const auto null_function = [default_val]( const_dialogue const & ) { return default_val; }; @@ -569,13 +591,13 @@ void read_condition( const JsonObject &jo, const std::string &member_name, } else if( jo.has_string( member_name ) ) { const std::string type = jo.get_string( member_name ); conditional_t sub_condition( type ); - condition = [sub_condition]( dialogue & d ) { + condition = [sub_condition]( const_dialogue const & d ) { return sub_condition( d ); }; } else if( jo.has_object( member_name ) ) { JsonObject con_obj = jo.get_object( member_name ); conditional_t sub_condition( con_obj ); - condition = [sub_condition]( dialogue & d ) { + condition = [sub_condition]( const_dialogue const & d ) { return sub_condition( d ); }; } else { @@ -610,8 +632,8 @@ conditional_t::func f_has_any_trait( const JsonObject &jo, std::string_view memb for( JsonValue jv : jo.get_array( member ) ) { traits_to_check.emplace_back( get_str_or_var( jv, member ) ); } - return [traits_to_check, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [traits_to_check, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); for( const str_or_var &trait : traits_to_check ) { if( actor->has_trait( trait_id( trait.evaluate( d ) ) ) ) { return true; @@ -624,8 +646,8 @@ conditional_t::func f_has_any_trait( const JsonObject &jo, std::string_view memb conditional_t::func f_has_trait( const JsonObject &jo, std::string_view member, bool is_npc ) { str_or_var trait_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [trait_to_check, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_trait( trait_id( trait_to_check.evaluate( d ) ) ); + return [trait_to_check, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_trait( trait_id( trait_to_check.evaluate( d ) ) ); }; } @@ -633,8 +655,8 @@ conditional_t::func f_is_trait_purifiable( const JsonObject &jo, std::string_vie bool is_npc ) { str_or_var trait_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [trait_to_check, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_trait_purifiable( trait_id( trait_to_check.evaluate( d ) ) ); + return [trait_to_check, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_trait_purifiable( trait_id( trait_to_check.evaluate( d ) ) ); }; } @@ -642,11 +664,11 @@ conditional_t::func f_has_visible_trait( const JsonObject &jo, std::string_view bool is_npc ) { str_or_var trait_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [trait_to_check, is_npc]( dialogue const & d ) { - const talker *observer = d.actor( !is_npc ); - const talker *observed = d.actor( is_npc ); - int visibility_cap = observer->get_character()->get_mutation_visibility_cap( - observed->get_character() ); + return [trait_to_check, is_npc]( const_dialogue const & d ) { + const_talker const *observer = d.const_actor( !is_npc ); + const_talker const *observed = d.const_actor( is_npc ); + int visibility_cap = observer->get_const_character()->get_mutation_visibility_cap( + observed->get_const_character() ); bool observed_has = observed->has_trait( trait_id( trait_to_check.evaluate( d ) ) ); const mutation_branch &mut_branch = trait_id( trait_to_check.evaluate( d ) ).obj(); bool is_visible = mut_branch.visibility > 0 && mut_branch.visibility >= visibility_cap; @@ -658,8 +680,8 @@ conditional_t::func f_has_martial_art( const JsonObject &jo, std::string_view me bool is_npc ) { str_or_var style_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [style_to_check, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->knows_martial_art( matype_id( style_to_check.evaluate( d ) ) ); + return [style_to_check, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->knows_martial_art( matype_id( style_to_check.evaluate( d ) ) ); }; } @@ -667,8 +689,8 @@ conditional_t::func f_has_flag( const JsonObject &jo, std::string_view member, bool is_npc ) { str_or_var trait_flag_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [trait_flag_to_check, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [trait_flag_to_check, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); if( json_character_flag( trait_flag_to_check.evaluate( d ) ) == json_flag_MUTATION_THRESHOLD ) { return actor->crossed_threshold(); } @@ -680,8 +702,8 @@ conditional_t::func f_has_species( const JsonObject &jo, std::string_view member bool is_npc ) { str_or_var species_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [species_to_check, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [species_to_check, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); return actor->has_species( species_id( species_to_check.evaluate( d ) ) ); }; } @@ -690,16 +712,16 @@ conditional_t::func f_bodytype( const JsonObject &jo, std::string_view member, bool is_npc ) { str_or_var bt_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [bt_to_check, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [bt_to_check, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); return actor->bodytype( bodytype_id( bt_to_check.evaluate( d ) ) ); }; } conditional_t::func f_has_activity( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_activity(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_activity(); }; } @@ -712,15 +734,16 @@ conditional_t::func f_has_proficiency( const JsonObject &jo, std::string_view me bool is_npc ) { str_or_var proficiency_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [proficiency_to_check, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->knows_proficiency( proficiency_id( proficiency_to_check.evaluate( d ) ) ); + return [proficiency_to_check, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->knows_proficiency( proficiency_id( proficiency_to_check.evaluate( + d ) ) ); }; } conditional_t::func f_is_riding( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_mounted(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_mounted(); }; } @@ -733,15 +756,15 @@ conditional_t::func f_npc_has_class( const JsonObject &jo, std::string_view memb bool is_npc ) { str_or_var class_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [class_to_check, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_myclass( npc_class_id( class_to_check.evaluate( d ) ) ); + return [class_to_check, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_myclass( npc_class_id( class_to_check.evaluate( d ) ) ); }; } conditional_t::func f_u_has_mission( const JsonObject &jo, std::string_view member ) { str_or_var u_mission = get_str_or_var( jo.get_member( member ), member, true ); - return [u_mission]( dialogue const & d ) { + return [u_mission]( const_dialogue const & d ) { for( mission *miss_it : get_avatar().get_active_missions() ) { if( miss_it->mission_id() == mission_type_id( u_mission.evaluate( d ) ) ) { return true; @@ -755,7 +778,7 @@ conditional_t::func f_u_monsters_in_direction( const JsonObject &jo, std::string_view member ) { str_or_var dir = get_str_or_var( jo.get_member( member ), member, true ); - return [dir]( dialogue const & d ) { + return [dir]( const_dialogue const & d ) { //This string_to_enum function is defined in widget.h. Should it be moved? const int card_dir = static_cast( io::string_to_enum( dir.evaluate( d ) ) ); @@ -767,7 +790,7 @@ conditional_t::func f_u_monsters_in_direction( const JsonObject &jo, conditional_t::func f_u_safe_mode_trigger( const JsonObject &jo, std::string_view member ) { str_or_var dir = get_str_or_var( jo.get_member( member ), member, true ); - return [dir]( dialogue const & d ) { + return [dir]( const_dialogue const & d ) { //This string_to_enum function is defined in widget.h. Should it be moved? const int card_dir = static_cast( io::string_to_enum( dir.evaluate( d ) ) ); @@ -778,7 +801,7 @@ conditional_t::func f_u_safe_mode_trigger( const JsonObject &jo, std::string_vie conditional_t::func f_u_profession( const JsonObject &jo, std::string_view member ) { str_or_var u_profession = get_str_or_var( jo.get_member( member ), member, true ); - return [u_profession]( dialogue const & d ) { + return [u_profession]( const_dialogue const & d ) { const profession *prof = get_player_character().get_profession(); std::set hobbies = get_player_character().get_hobbies(); if( prof->get_profession_id() == profession_id( u_profession.evaluate( d ) ) ) { @@ -801,8 +824,8 @@ conditional_t::func f_has_strength( const JsonObject &jo, std::string_view membe bool is_npc ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov, is_npc]( dialogue & d ) { - return d.actor( is_npc )->str_cur() >= dov.evaluate( d ); + return [dov, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->str_cur() >= dov.evaluate( d ); }; } @@ -810,8 +833,8 @@ conditional_t::func f_has_dexterity( const JsonObject &jo, std::string_view memb bool is_npc ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov, is_npc]( dialogue & d ) { - return d.actor( is_npc )->dex_cur() >= dov.evaluate( d ); + return [dov, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->dex_cur() >= dov.evaluate( d ); }; } @@ -819,8 +842,8 @@ conditional_t::func f_has_intelligence( const JsonObject &jo, std::string_view m bool is_npc ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov, is_npc]( dialogue & d ) { - return d.actor( is_npc )->int_cur() >= dov.evaluate( d ); + return [dov, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->int_cur() >= dov.evaluate( d ); }; } @@ -828,8 +851,8 @@ conditional_t::func f_has_perception( const JsonObject &jo, std::string_view mem bool is_npc ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov, is_npc]( dialogue & d ) { - return d.actor( is_npc )->per_cur() >= dov.evaluate( d ); + return [dov, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->per_cur() >= dov.evaluate( d ); }; } @@ -839,9 +862,9 @@ conditional_t::func f_has_part_temp( const JsonObject &jo, std::string_view memb dbl_or_var dov = get_dbl_or_var( jo, member ); std::optional bp; optional( jo, false, "bodypart", bp ); - return [dov, bp, is_npc]( dialogue & d ) { + return [dov, bp, is_npc]( const_dialogue const & d ) { bodypart_id bid = bp.value_or( get_bp_from_str( d.reason ) ); - return units::to_legacy_bodypart_temp( d.actor( is_npc )->get_cur_part_temp( + return units::to_legacy_bodypart_temp( d.const_actor( is_npc )->get_cur_part_temp( bid ) ) >= dov.evaluate( d ); }; } @@ -850,16 +873,16 @@ conditional_t::func f_is_wearing( const JsonObject &jo, std::string_view member, bool is_npc ) { str_or_var item_id = get_str_or_var( jo.get_member( member ), member, true ); - return [item_id, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_wearing( itype_id( item_id.evaluate( d ) ) ); + return [item_id, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_wearing( itype_id( item_id.evaluate( d ) ) ); }; } conditional_t::func f_has_item( const JsonObject &jo, std::string_view member, bool is_npc ) { str_or_var item_id = get_str_or_var( jo.get_member( member ), member, true ); - return [item_id, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [item_id, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); return actor->charges_of( itype_id( item_id.evaluate( d ) ) ) > 0 || actor->has_amount( itype_id( item_id.evaluate( d ) ), 1 ); }; @@ -871,15 +894,15 @@ conditional_t::func f_has_items( const JsonObject &jo, const std::string_view me JsonObject has_items = jo.get_object( member ); if( !has_items.has_member( "item" ) || ( !has_items.has_member( "count" ) && !has_items.has_member( "charges" ) ) ) { - return []( dialogue const & ) { + return []( const_dialogue const & ) { return false; }; } else { str_or_var item_id = get_str_or_var( has_items.get_member( "item" ), "item", true ); dbl_or_var count = get_dbl_or_var( has_items, "count", false ); dbl_or_var charges = get_dbl_or_var( has_items, "charges", false ); - return [item_id, count, charges, is_npc]( dialogue & d ) { - const talker *actor = d.actor( is_npc ); + return [item_id, count, charges, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); itype_id id = itype_id( item_id.evaluate( d ) ); if( charges.evaluate( d ) == 0 && item::count_by_charges( id ) ) { return actor->has_charges( id, count.evaluate( d ), true ); @@ -906,7 +929,7 @@ conditional_t::func f_has_items_sum( const JsonObject &jo, const std::string_vie const dbl_or_var amount = get_dbl_or_var( jsobj, "amount", true, 1 ); item_and_amount.emplace_back( item, amount ); } - return [item_and_amount, is_npc]( dialogue & d ) { + return [item_and_amount, is_npc]( const_dialogue const & d ) { add_msg_debug( debugmode::DF_TALKER, "using _has_items_sum:" ); itype_id item_to_find; @@ -918,8 +941,8 @@ conditional_t::func f_has_items_sum( const JsonObject &jo, const std::string_vie for( const auto &pair : item_and_amount ) { item_to_find = itype_id( pair.first.evaluate( d ) ); count_desired = pair.second.evaluate( d ); - count_present = d.actor( is_npc )->get_amount( item_to_find ); - charges_present = d.actor( is_npc )->charges_of( item_to_find ); + count_present = d.const_actor( is_npc )->get_amount( item_to_find ); + charges_present = d.const_actor( is_npc )->charges_of( item_to_find ); total_present = std::max( count_present, charges_present ); percent += total_present / count_desired; @@ -939,8 +962,8 @@ conditional_t::func f_has_item_with_flag( const JsonObject &jo, std::string_view bool is_npc ) { str_or_var flag = get_str_or_var( jo.get_member( member ), member, true ); - return [flag, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_item_with_flag( flag_id( flag.evaluate( d ) ) ); + return [flag, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_item_with_flag( flag_id( flag.evaluate( d ) ) ); }; } @@ -956,8 +979,8 @@ conditional_t::func f_has_item_category( const JsonObject &jo, std::string_view } } - return [category_id, count, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [category_id, count, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); const item_category_id cat_id = item_category_id( category_id.evaluate( d ) ); const auto items_with = actor->const_items_with( [cat_id]( const item & it ) { return it.get_category_shallow().get_id() == cat_id; @@ -970,8 +993,8 @@ conditional_t::func f_has_bionics( const JsonObject &jo, std::string_view member bool is_npc ) { str_or_var bionics_id = get_str_or_var( jo.get_member( member ), member, true ); - return [bionics_id, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [bionics_id, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); if( bionics_id.evaluate( d ) == "ANY" ) { return actor->num_bionics() > 0 || actor->has_max_power(); } @@ -993,11 +1016,11 @@ conditional_t::func f_has_any_effect( const JsonObject &jo, std::string_view mem } else { bp.str_val = ""; } - return [effects_to_check, intensity, bp, is_npc]( dialogue & d ) { + return [effects_to_check, intensity, bp, is_npc]( const_dialogue const & d ) { bodypart_id bid = bp.evaluate( d ).empty() ? get_bp_from_str( d.reason ) : bodypart_id( bp.evaluate( d ) ); for( const str_or_var &effect_id : effects_to_check ) { - effect target = d.actor( is_npc )->get_effect( efftype_id( effect_id.evaluate( d ) ), bid ); + effect target = d.const_actor( is_npc )->get_effect( efftype_id( effect_id.evaluate( d ) ), bid ); if( !target.is_null() && intensity.evaluate( d ) <= target.get_intensity() ) { return true; } @@ -1017,10 +1040,10 @@ conditional_t::func f_has_effect( const JsonObject &jo, std::string_view member, } else { bp.str_val = ""; } - return [effect_id, intensity, bp, is_npc]( dialogue & d ) { + return [effect_id, intensity, bp, is_npc]( const_dialogue const & d ) { bodypart_id bid = bp.evaluate( d ).empty() ? get_bp_from_str( d.reason ) : bodypart_id( bp.evaluate( d ) ); - effect target = d.actor( is_npc )->get_effect( efftype_id( effect_id.evaluate( d ) ), bid ); + effect target = d.const_actor( is_npc )->get_effect( efftype_id( effect_id.evaluate( d ) ), bid ); return !target.is_null() && intensity.evaluate( d ) <= target.get_intensity(); }; } @@ -1040,8 +1063,8 @@ conditional_t::func f_need( const JsonObject &jo, std::string_view member, bool dov.min.dbl_val = static_cast( flevel->second ); } } - return [need, dov, is_npc]( dialogue & d ) { - const talker *actor = d.actor( is_npc ); + return [need, dov, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); int amount = dov.evaluate( d ); return ( actor->get_sleepiness() > amount && need.evaluate( d ) == "sleepiness" ) || ( actor->get_hunger() > amount && need.evaluate( d ) == "hunger" ) || @@ -1053,8 +1076,8 @@ conditional_t::func f_at_om_location( const JsonObject &jo, std::string_view mem bool is_npc ) { str_or_var location = get_str_or_var( jo.get_member( member ), member, true ); - return [location, is_npc]( dialogue const & d ) { - const tripoint_abs_omt omt_pos = d.actor( is_npc )->global_omt_location(); + return [location, is_npc]( const_dialogue const & d ) { + const tripoint_abs_omt omt_pos = d.const_actor( is_npc )->global_omt_location(); const oter_id &omt_ter = overmap_buffer.ter( omt_pos ); const std::string &omt_str = omt_ter.id().str(); std::string location_value = location.evaluate( d ); @@ -1080,8 +1103,8 @@ conditional_t::func f_near_om_location( const JsonObject &jo, std::string_view m { str_or_var location = get_str_or_var( jo.get_member( member ), member, true ); const dbl_or_var range = get_dbl_or_var( jo, "range", false, 1 ); - return [location, range, is_npc]( dialogue & d ) { - const tripoint_abs_omt omt_pos = d.actor( is_npc )->global_omt_location(); + return [location, range, is_npc]( const_dialogue const & d ) { + const tripoint_abs_omt omt_pos = d.const_actor( is_npc )->global_omt_location(); for( const tripoint_abs_omt &curr_pos : points_in_radius( omt_pos, range.evaluate( d ) ) ) { const oter_id &omt_ter = overmap_buffer.ter( curr_pos ); @@ -1119,13 +1142,13 @@ conditional_t::func f_has_var( const JsonObject &jo, std::string_view member, bo const std::string &value = jo.has_member( "value" ) ? jo.get_string( "value" ) : std::string(); if( !jo.has_member( "value" ) ) { jo.throw_error( R"(Missing field: "value")" ); - return []( dialogue const & ) { + return []( const_dialogue const & ) { return false; }; } - return [var_name, value, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [var_name, value, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); return actor->get_value( var_name ) == value; }; } @@ -1139,7 +1162,7 @@ conditional_t::func f_expects_vars( const JsonObject &jo, std::string_view membe } } - return [to_check]( dialogue const & d ) { + return [to_check]( const_dialogue const & d ) { std::string missing_variables; for( const str_or_var &val : to_check ) { if( d.get_context().find( "npctalk_var_" + val.evaluate( d ) ) == d.get_context().end() ) { @@ -1157,11 +1180,11 @@ conditional_t::func f_expects_vars( const JsonObject &jo, std::string_view membe conditional_t::func f_npc_role_nearby( const JsonObject &jo, std::string_view member ) { str_or_var role = get_str_or_var( jo.get_member( member ), member, true ); - return [role]( dialogue const & d ) { + return [role]( const_dialogue const & d ) { const std::vector available = g->get_npcs_if( [&]( const npc & guy ) { - return d.actor( false )->posz() == guy.posz() && + return d.const_actor( false )->posz() == guy.posz() && guy.companion_mission_role_id == role.evaluate( d ) && - ( rl_dist( d.actor( false )->pos(), guy.pos() ) <= 48 ); + ( rl_dist( d.const_actor( false )->pos(), guy.pos() ) <= 48 ); } ); return !available.empty(); }; @@ -1169,8 +1192,8 @@ conditional_t::func f_npc_role_nearby( const JsonObject &jo, std::string_view me conditional_t::func f_npc_is_travelling( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - const Character *traveller = d.actor( is_npc )->get_character(); + return [is_npc]( const_dialogue const & d ) { + const Character *traveller = d.const_actor( is_npc )->get_const_character(); if( !traveller ) { return false; } @@ -1181,7 +1204,7 @@ conditional_t::func f_npc_is_travelling( bool is_npc ) conditional_t::func f_npc_allies( const JsonObject &jo, std::string_view member ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov]( dialogue & d ) { + return [dov]( const_dialogue const & d ) { return g->allies().size() >= static_cast::size_type>( dov.evaluate( d ) ); }; } @@ -1189,7 +1212,7 @@ conditional_t::func f_npc_allies( const JsonObject &jo, std::string_view member conditional_t::func f_npc_allies_global( const JsonObject &jo, std::string_view member ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov]( dialogue & d ) { + return [dov]( const_dialogue const & d ) { const auto all_npcs = overmap_buffer.get_overmap_npcs(); const size_t count = std::count_if( all_npcs.begin(), all_npcs.end(), []( const shared_ptr_fast &ptr ) { @@ -1203,16 +1226,16 @@ conditional_t::func f_npc_allies_global( const JsonObject &jo, std::string_view conditional_t::func f_u_has_cash( const JsonObject &jo, std::string_view member ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov]( dialogue & d ) { - return d.actor( false )->cash() >= dov.evaluate( d ); + return [dov]( const_dialogue const & d ) { + return d.const_actor( false )->cash() >= dov.evaluate( d ); }; } conditional_t::func f_u_are_owed( const JsonObject &jo, std::string_view member ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov]( dialogue & d ) { - return d.actor( true )->debt() >= dov.evaluate( d ); + return [dov]( const_dialogue const & d ) { + return d.const_actor( true )->debt() >= dov.evaluate( d ); }; } @@ -1220,8 +1243,8 @@ conditional_t::func f_npc_aim_rule( const JsonObject &jo, std::string_view membe bool is_npc ) { str_or_var setting = get_str_or_var( jo.get_member( member ), member, true ); - return [setting, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_ai_rule( "aim_rule", setting.evaluate( d ) ); + return [setting, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_ai_rule( "aim_rule", setting.evaluate( d ) ); }; } @@ -1229,8 +1252,8 @@ conditional_t::func f_npc_engagement_rule( const JsonObject &jo, std::string_vie bool is_npc ) { str_or_var setting = get_str_or_var( jo.get_member( member ), member, true ); - return [setting, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_ai_rule( "engagement_rule", setting.evaluate( d ) ); + return [setting, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_ai_rule( "engagement_rule", setting.evaluate( d ) ); }; } @@ -1238,8 +1261,8 @@ conditional_t::func f_npc_cbm_reserve_rule( const JsonObject &jo, std::string_vi bool is_npc ) { str_or_var setting = get_str_or_var( jo.get_member( member ), member, true ); - return [setting, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_ai_rule( "cbm_reserve_rule", setting.evaluate( d ) ); + return [setting, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_ai_rule( "cbm_reserve_rule", setting.evaluate( d ) ); }; } @@ -1247,16 +1270,16 @@ conditional_t::func f_npc_cbm_recharge_rule( const JsonObject &jo, std::string_v bool is_npc ) { str_or_var setting = get_str_or_var( jo.get_member( member ), member, true ); - return [setting, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_ai_rule( "cbm_recharge_rule", setting.evaluate( d ) ); + return [setting, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_ai_rule( "cbm_recharge_rule", setting.evaluate( d ) ); }; } conditional_t::func f_npc_rule( const JsonObject &jo, std::string_view member, bool is_npc ) { str_or_var rule = get_str_or_var( jo.get_member( member ), member, true ); - return [rule, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_ai_rule( "ally_rule", rule.evaluate( d ) ); + return [rule, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_ai_rule( "ally_rule", rule.evaluate( d ) ); }; } @@ -1264,15 +1287,15 @@ conditional_t::func f_npc_override( const JsonObject &jo, std::string_view membe bool is_npc ) { str_or_var rule = get_str_or_var( jo.get_member( member ), member, true ); - return [rule, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_ai_rule( "ally_override", rule.evaluate( d ) ); + return [rule, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_ai_rule( "ally_override", rule.evaluate( d ) ); }; } conditional_t::func f_is_season( const JsonObject &jo, std::string_view member ) { str_or_var season_name = get_str_or_var( jo.get_member( member ), member, true ); - return [season_name]( dialogue const & d ) { + return [season_name]( const_dialogue const & d ) { const season_type season = season_of_year( calendar::turn ); return ( season == SPRING && season_name.evaluate( d ) == "spring" ) || ( season == SUMMER && season_name.evaluate( d ) == "summer" ) || @@ -1285,8 +1308,8 @@ conditional_t::func f_mission_goal( const JsonObject &jo, std::string_view membe bool is_npc ) { str_or_var mission_goal_str = get_str_or_var( jo.get_member( member ), member, true ); - return [mission_goal_str, is_npc]( dialogue const & d ) { - mission *miss = d.actor( is_npc )->selected_mission(); + return [mission_goal_str, is_npc]( const_dialogue const & d ) { + mission *miss = d.const_actor( is_npc )->selected_mission(); if( !miss ) { return false; } @@ -1297,8 +1320,8 @@ conditional_t::func f_mission_goal( const JsonObject &jo, std::string_view membe conditional_t::func f_is_gender( bool is_male, bool is_npc ) { - return [is_male, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_male() == is_male; + return [is_male, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_male() == is_male; }; } @@ -1313,14 +1336,14 @@ conditional_t::func f_is_female( bool is_npc ) conditional_t::func f_is_alive( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->get_is_alive(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_is_alive(); }; } conditional_t::func f_exists( bool is_npc ) { - return [is_npc]( dialogue const & d ) { + return [is_npc]( const_dialogue const & d ) { if( ( is_npc && !d.has_beta ) || ( !is_npc && !d.has_alpha ) ) { return false; } else { @@ -1330,134 +1353,135 @@ conditional_t::func f_exists( bool is_npc ) } conditional_t::func f_is_avatar( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->get_character() && d.actor( is_npc )->get_character()->is_avatar(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_const_character() && + d.const_actor( is_npc )->get_const_character()->is_avatar(); }; } conditional_t::func f_is_npc( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->get_npc(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_const_npc(); }; } conditional_t::func f_is_character( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->get_character(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_const_character(); }; } conditional_t::func f_is_monster( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->get_monster(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_const_monster(); }; } conditional_t::func f_is_item( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->get_item(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_const_item(); }; } conditional_t::func f_is_furniture( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->get_computer(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_const_computer(); }; } conditional_t::func f_player_see( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - const Creature *c = d.actor( is_npc )->get_creature(); + return [is_npc]( const_dialogue const & d ) { + const Creature *c = d.const_actor( is_npc )->get_const_creature(); if( c ) { return get_player_view().sees( *c ); } else { - return get_player_view().sees( d.actor( is_npc )->pos() ); + return get_player_view().sees( d.const_actor( is_npc )->pos() ); } }; } conditional_t::func f_has_alpha() { - return []( dialogue const & d ) { + return []( const_dialogue const & d ) { return d.has_alpha; }; } conditional_t::func f_has_beta() { - return []( dialogue const & d ) { + return []( const_dialogue const & d ) { return d.has_beta; }; } conditional_t::func f_no_assigned_mission() { - return []( dialogue const & d ) { + return []( const_dialogue const & d ) { return d.missions_assigned.empty(); }; } conditional_t::func f_has_assigned_mission() { - return []( dialogue const & d ) { + return []( const_dialogue const & d ) { return d.missions_assigned.size() == 1; }; } conditional_t::func f_has_many_assigned_missions() { - return []( dialogue const & d ) { + return []( const_dialogue const & d ) { return d.missions_assigned.size() >= 2; }; } conditional_t::func f_no_available_mission( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->available_missions().empty(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->available_missions().empty(); }; } conditional_t::func f_has_available_mission( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->available_missions().size() == 1; + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->available_missions().size() == 1; }; } conditional_t::func f_has_many_available_missions( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->available_missions().size() >= 2; + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->available_missions().size() >= 2; }; } conditional_t::func f_mission_complete( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - mission *miss = d.actor( is_npc )->selected_mission(); - return miss && miss->is_complete( d.actor( is_npc )->getID() ); + return [is_npc]( const_dialogue const & d ) { + mission *miss = d.const_actor( is_npc )->selected_mission(); + return miss && miss->is_complete( d.const_actor( is_npc )->getID() ); }; } conditional_t::func f_mission_incomplete( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - mission *miss = d.actor( is_npc )->selected_mission(); - return miss && !miss->is_complete( d.actor( is_npc )->getID() ); + return [is_npc]( const_dialogue const & d ) { + mission *miss = d.const_actor( is_npc )->selected_mission(); + return miss && !miss->is_complete( d.const_actor( is_npc )->getID() ); }; } conditional_t::func f_mission_failed( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - mission *miss = d.actor( is_npc )->selected_mission(); + return [is_npc]( const_dialogue const & d ) { + mission *miss = d.const_actor( is_npc )->selected_mission(); return miss && miss->has_failed(); }; } @@ -1465,65 +1489,65 @@ conditional_t::func f_mission_failed( bool is_npc ) conditional_t::func f_npc_service( const JsonObject &jo, std::string_view member, bool is_npc ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [is_npc, dov]( dialogue & d ) { - return !d.actor( is_npc )->has_effect( effect_currently_busy, bodypart_str_id::NULL_ID() ) && - d.actor( false )->cash() >= dov.evaluate( d ); + return [is_npc, dov]( const_dialogue const & d ) { + return !d.const_actor( is_npc )->has_effect( effect_currently_busy, bodypart_str_id::NULL_ID() ) && + d.const_actor( false )->cash() >= dov.evaluate( d ); }; } conditional_t::func f_npc_available( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return !d.actor( is_npc )->has_effect( effect_currently_busy, bodypart_str_id::NULL_ID() ); + return [is_npc]( const_dialogue const & d ) { + return !d.const_actor( is_npc )->has_effect( effect_currently_busy, bodypart_str_id::NULL_ID() ); }; } conditional_t::func f_npc_following( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_following(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_following(); }; } conditional_t::func f_npc_friend( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_friendly( get_player_character() ); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_friendly( get_player_character() ); }; } conditional_t::func f_npc_hostile( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_enemy(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_enemy(); }; } conditional_t::func f_npc_train_skills( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return !d.actor( is_npc )->skills_offered_to( *d.actor( !is_npc ) ).empty(); + return [is_npc]( const_dialogue const & d ) { + return !d.const_actor( is_npc )->skills_offered_to( *d.const_actor( !is_npc ) ).empty(); }; } conditional_t::func f_npc_train_styles( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return !d.actor( is_npc )->styles_offered_to( *d.actor( !is_npc ) ).empty(); + return [is_npc]( const_dialogue const & d ) { + return !d.const_actor( is_npc )->styles_offered_to( *d.const_actor( !is_npc ) ).empty(); }; } conditional_t::func f_npc_train_spells( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return !d.actor( is_npc )->spells_offered_to( *d.actor( !is_npc ) ).empty(); + return [is_npc]( const_dialogue const & d ) { + return !d.const_actor( is_npc )->spells_offered_to( *d.const_actor( !is_npc ) ).empty(); }; } conditional_t::func f_follower_present( const JsonObject &jo, std::string_view member ) { const std::string &var_name = jo.get_string( std::string( member ) ); - return [var_name]( dialogue const & d ) { + return [var_name]( const_dialogue const & d ) { npc *npc_to_check = nullptr; for( npc &guy : g->all_npcs() ) { if( guy.myclass.str() == var_name ) { @@ -1531,7 +1555,7 @@ conditional_t::func f_follower_present( const JsonObject &jo, std::string_view m break; } } - npc *d_npc = d.actor( true )->get_npc(); + npc const *d_npc = d.const_actor( true )->get_const_npc(); if( npc_to_check == nullptr || d_npc == nullptr ) { return false; } @@ -1549,39 +1573,39 @@ conditional_t::func f_follower_present( const JsonObject &jo, std::string_view m conditional_t::func f_at_safe_space( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return overmap_buffer.is_safe( d.actor( is_npc )->global_omt_location() ) && - d.actor( is_npc )->is_safe(); + return [is_npc]( const_dialogue const & d ) { + return overmap_buffer.is_safe( d.const_actor( is_npc )->global_omt_location() ) && + d.const_actor( is_npc )->is_safe(); }; } conditional_t::func f_can_stow_weapon( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); return !actor->unarmed_attack() && actor->can_stash_weapon(); }; } conditional_t::func f_can_drop_weapon( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); return !actor->unarmed_attack() && !actor->wielded_with_flag( flag_NO_UNWIELD ); }; } conditional_t::func f_has_weapon( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return !d.actor( is_npc )->unarmed_attack(); + return [is_npc]( const_dialogue const & d ) { + return !d.const_actor( is_npc )->unarmed_attack(); }; } conditional_t::func f_is_controlling_vehicle( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); if( const optional_vpart_position &vp = get_map().veh_at( actor->pos() ) ) { return actor->is_in_control_of( vp->vehicle() ); } @@ -1591,8 +1615,8 @@ conditional_t::func f_is_controlling_vehicle( bool is_npc ) conditional_t::func f_is_driving( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); + return [is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); if( const optional_vpart_position &vp = get_map().veh_at( actor->pos() ) ) { return vp->vehicle().is_moving() && actor->is_in_control_of( vp->vehicle() ); } @@ -1602,36 +1626,36 @@ conditional_t::func f_is_driving( bool is_npc ) conditional_t::func f_has_stolen_item( bool /*is_npc*/ ) { - return []( dialogue const & d ) { - return d.actor( false )->has_stolen_item( *d.actor( true ) ); + return []( const_dialogue const & d ) { + return d.const_actor( false )->has_stolen_item( *d.const_actor( true ) ); }; } conditional_t::func f_is_day() { - return []( dialogue const & ) { + return []( const_dialogue const & ) { return !is_night( calendar::turn ); }; } conditional_t::func f_is_outside( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return is_creature_outside( *static_cast( d.actor( is_npc ) )->get_creature() ); + return [is_npc]( const_dialogue const & d ) { + return is_creature_outside( *d.const_actor( is_npc )->get_const_creature() ); }; } conditional_t::func f_is_underwater( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return get_map().is_divable( d.actor( is_npc )->pos() ); + return [is_npc]( const_dialogue const & d ) { + return get_map().is_divable( d.const_actor( is_npc )->pos() ); }; } conditional_t::func f_one_in_chance( const JsonObject &jo, std::string_view member ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov]( dialogue & d ) { + return [dov]( const_dialogue const & d ) { return one_in( dov.evaluate( d ) ); }; } @@ -1640,9 +1664,9 @@ conditional_t::func f_query( const JsonObject &jo, std::string_view member, bool { translation_or_var message = get_translation_or_var( jo.get_member( member ), member, true ); bool default_val = jo.get_bool( "default" ); - return [message, default_val, is_npc]( dialogue const & d ) { - const talker *actor = d.actor( is_npc ); - if( actor->get_character() && actor->get_character()->is_avatar() ) { + return [message, default_val, is_npc]( const_dialogue const & d ) { + const_talker const *actor = d.const_actor( is_npc ); + if( actor->get_const_character() && actor->get_const_character()->is_avatar() ) { std::string translated_message = message.evaluate( d ); return query_yn( translated_message ); } else { @@ -1655,6 +1679,9 @@ conditional_t::func f_query_tile( const JsonObject &jo, std::string_view member, { std::string type = jo.get_string( member.data() ); var_info target_var = read_var_info( jo.get_object( "target_var" ) ); + if( target_var.type != var_type::global ) { + jo.throw_error_at( "target_var", "Only global variables can be used as targets for u_query" ) ; + } std::string message; if( jo.has_member( "message" ) ) { message = jo.get_string( "message" ); @@ -1664,18 +1691,17 @@ conditional_t::func f_query_tile( const JsonObject &jo, std::string_view member, range = get_dbl_or_var( jo, "range" ); } bool z_level = jo.get_bool( "z_level", false ); - return [type, target_var, message, range, z_level, is_npc]( dialogue & d ) { + return [type, target_var, message, range, z_level, is_npc]( const_dialogue const & d ) { std::optional loc; - Character *ch = d.actor( is_npc )->get_character(); + Character const *ch = d.const_actor( is_npc )->get_const_character(); if( ch && ch->as_avatar() ) { - avatar *you = ch->as_avatar(); if( type == "anywhere" ) { if( !message.empty() ) { static_popup popup; popup.on_top( true ); popup.message( "%s", message ); } - tripoint center = d.actor( is_npc )->pos(); + tripoint center = d.const_actor( is_npc )->pos(); const look_around_params looka_params = { true, center, center, false, true, true, z_level }; loc = g->look_around( looka_params ).position; } else if( type == "line_of_sight" ) { @@ -1684,7 +1710,9 @@ conditional_t::func f_query_tile( const JsonObject &jo, std::string_view member, popup.on_top( true ); popup.message( "%s", message ); } - target_handler::trajectory traj = target_handler::mode_select_only( *you, range.evaluate( d ) ); + avatar dummy; + dummy.set_location( get_avatar().get_location() ); + target_handler::trajectory traj = target_handler::mode_select_only( dummy, range.evaluate( d ) ); if( !traj.empty() ) { loc = traj.back().raw(); } @@ -1701,7 +1729,7 @@ conditional_t::func f_query_tile( const JsonObject &jo, std::string_view member, } if( loc.has_value() ) { tripoint_abs_ms pos_global = get_map().getglobal( *loc ); - write_var_value( target_var.type, target_var.name, &d, + write_var_value( target_var.type, target_var.name, d, pos_global.to_string() ); } return loc.has_value(); @@ -1713,7 +1741,7 @@ conditional_t::func f_x_in_y_chance( const JsonObject &jo, const std::string_vie const JsonObject &var_obj = jo.get_object( member ); dbl_or_var dovx = get_dbl_or_var( var_obj, "x" ); dbl_or_var dovy = get_dbl_or_var( var_obj, "y" ); - return [dovx, dovy]( dialogue & d ) { + return [dovx, dovy]( const_dialogue const & d ) { return x_in_y( dovx.evaluate( d ), dovy.evaluate( d ) ); }; @@ -1722,7 +1750,7 @@ conditional_t::func f_x_in_y_chance( const JsonObject &jo, const std::string_vie conditional_t::func f_is_weather( const JsonObject &jo, std::string_view member ) { str_or_var weather = get_str_or_var( jo.get_member( member ), member, true ); - return [weather]( dialogue const & d ) { + return [weather]( const_dialogue const & d ) { return get_weather().weather_id == weather_type_id( weather.evaluate( d ) ); }; } @@ -1737,7 +1765,7 @@ conditional_t::func f_map_ter_furn_with_flag( const JsonObject &jo, std::string_ } else if( member == "map_furniture_with_flag" ) { terrain = false; } - return [terrain, furn_type, loc_var]( dialogue const & d ) { + return [terrain, furn_type, loc_var]( const_dialogue const & d ) { tripoint_bub_ms loc = get_map().bub_from_abs( get_tripoint_from_var( loc_var, d, false ) ); if( terrain ) { return get_map().ter( loc )->has_flag( furn_type.evaluate( d ) ); @@ -1752,7 +1780,7 @@ conditional_t::func f_map_ter_furn_id( const JsonObject &jo, std::string_view me str_or_var furn_type = get_str_or_var( jo.get_member( member ), member, true ); var_info loc_var = read_var_info( jo.get_object( "loc" ) ); - return [member, furn_type, loc_var]( dialogue const & d ) { + return [member, furn_type, loc_var]( const_dialogue const & d ) { tripoint_bub_ms loc = get_map().bub_from_abs( get_tripoint_from_var( loc_var, d, false ) ); if( member == "map_terrain_id" ) { return get_map().ter( loc ) == ter_id( furn_type.evaluate( d ) ); @@ -1771,7 +1799,7 @@ conditional_t::func f_map_ter_furn_id( const JsonObject &jo, std::string_view me conditional_t::func f_map_in_city( const JsonObject &jo, std::string_view member ) { str_or_var target = get_str_or_var( jo.get_member( member ), member, true ); - return [target]( dialogue const & d ) { + return [target]( const_dialogue const & d ) { tripoint_abs_omt target_pos = project_to( tripoint_abs_ms( tripoint::from_string( target.evaluate( d ) ) ) ); @@ -1787,7 +1815,7 @@ conditional_t::func f_map_in_city( const JsonObject &jo, std::string_view member conditional_t::func f_mod_is_loaded( const JsonObject &jo, std::string_view member ) { str_or_var compared_mod = get_str_or_var( jo.get_member( member ), member, true ); - return [compared_mod]( dialogue const & d ) { + return [compared_mod]( const_dialogue const & d ) { mod_id comp_mod = mod_id( compared_mod.evaluate( d ) ); for( const mod_id &mod : world_generator->active_world->active_mod_order ) { if( comp_mod == mod ) { @@ -1801,8 +1829,8 @@ conditional_t::func f_mod_is_loaded( const JsonObject &jo, std::string_view memb conditional_t::func f_has_faction_trust( const JsonObject &jo, std::string_view member ) { dbl_or_var dov = get_dbl_or_var( jo, member ); - return [dov]( dialogue & d ) { - return d.actor( true )->get_faction()->trusts_u >= dov.evaluate( d ); + return [dov]( const_dialogue const & d ) { + return d.const_actor( true )->get_faction()->trusts_u >= dov.evaluate( d ); }; } @@ -1813,9 +1841,6 @@ conditional_t::func f_compare_string( const JsonObject &jo, std::string_view mem JsonArray objects = jo.get_array( member ); if( objects.size() != 2 ) { jo.throw_error( "incorrect number of values. Expected 2 in " + jo.str() ); - return []( dialogue const & ) { - return false; - }; } if( objects.has_object( 0 ) ) { @@ -1829,7 +1854,7 @@ conditional_t::func f_compare_string( const JsonObject &jo, std::string_view mem second.str_val = objects.next_string(); } - return [first, second]( dialogue const & d ) { + return [first, second]( const_dialogue const & d ) { return first.evaluate( d ) == second.evaluate( d ); }; } @@ -1837,7 +1862,7 @@ conditional_t::func f_compare_string( const JsonObject &jo, std::string_view mem conditional_t::func f_get_condition( const JsonObject &jo, std::string_view member ) { str_or_var conditionalToGet = get_str_or_var( jo.get_member( member ), member, true ); - return [conditionalToGet]( dialogue & d ) { + return [conditionalToGet]( const_dialogue const & d ) { return d.evaluate_conditional( conditionalToGet.evaluate( d ), d ); }; } @@ -1845,9 +1870,10 @@ conditional_t::func f_get_condition( const JsonObject &jo, std::string_view memb conditional_t::func f_test_eoc( const JsonObject &jo, std::string_view member ) { str_or_var eocToTest = get_str_or_var( jo.get_member( member ), member, true ); - return [eocToTest]( dialogue & d ) { + return [eocToTest]( const_dialogue const & d ) -> bool { effect_on_condition_id tested( eocToTest.evaluate( d ) ); - if( !tested.is_valid() ) { + if( !tested.is_valid() ) + { debugmsg( "Invalid eoc id: %s", eocToTest.evaluate( d ) ); return false; } @@ -1857,10 +1883,10 @@ conditional_t::func f_test_eoc( const JsonObject &jo, std::string_view member ) conditional_t::func f_has_ammo() { - return []( dialogue & d ) { - item_location *it = d.actor( true )->get_item(); + return []( const_dialogue const & d ) { + item_location const *it = d.const_actor( true )->get_const_item(); if( it ) { - return ( *it )->ammo_sufficient( d.actor( false )->get_character() ); + return ( *it )->ammo_sufficient( d.const_actor( false )->get_const_character() ); } else { debugmsg( "beta talker must be Item" ); return false; @@ -1872,14 +1898,15 @@ conditional_t::func f_math( const JsonObject &jo, const std::string_view member { eoc_math math; math.from_json( jo, member, eoc_math::type_t::compare ); - return [math = std::move( math )]( dialogue & d ) { - return math.act( d ); + return [math = std::move( math )]( const_dialogue const & d ) { + dialogue loosey_goosey( d ); + return math.act( loosey_goosey ); }; } conditional_t::func f_u_has_camp() { - return []( dialogue const & ) { + return []( const_dialogue const & ) { for( const tripoint_abs_omt &camp_tripoint : get_player_character().camps ) { std::optional camp = overmap_buffer.find_camp( camp_tripoint.xy() ); if( !camp ) { @@ -1896,21 +1923,21 @@ conditional_t::func f_u_has_camp() conditional_t::func f_has_pickup_list( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->has_ai_rule( "pickup_rule", "any" ); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->has_ai_rule( "pickup_rule", "any" ); }; } conditional_t::func f_is_by_radio() { - return []( dialogue const & d ) { + return []( const_dialogue const & d ) { return d.by_radio; }; } conditional_t::func f_has_reason() { - return []( dialogue const & d ) { + return []( const_dialogue const & d ) { return !d.reason.empty(); }; } @@ -1920,7 +1947,7 @@ conditional_t::func f_roll_contested( const JsonObject &jo, const std::string_vi dbl_or_var get_check = get_dbl_or_var( jo, member ); dbl_or_var difficulty = get_dbl_or_var( jo, "difficulty", true ); dbl_or_var die_size = get_dbl_or_var( jo, "die_size", false, 10 ); - return [get_check, difficulty, die_size]( dialogue & d ) { + return [get_check, difficulty, die_size]( const_dialogue const & d ) { return rng( 1, die_size.evaluate( d ) ) + get_check.evaluate( d ) > difficulty.evaluate( d ); }; @@ -1929,7 +1956,7 @@ conditional_t::func f_roll_contested( const JsonObject &jo, const std::string_vi conditional_t::func f_u_know_recipe( const JsonObject &jo, std::string_view member ) { str_or_var known_recipe_id = get_str_or_var( jo.get_member( member ), member, true ); - return [known_recipe_id]( dialogue & d ) { + return [known_recipe_id]( const_dialogue const & d ) { const recipe &rep = recipe_id( known_recipe_id.evaluate( d ) ).obj(); // should be a talker function but recipes aren't in Character:: yet return get_player_character().knows_recipe( &rep ); @@ -1938,8 +1965,8 @@ conditional_t::func f_u_know_recipe( const JsonObject &jo, std::string_view memb conditional_t::func f_mission_has_generic_rewards() { - return []( dialogue const & d ) { - mission *miss = d.actor( true )->selected_mission(); + return []( const_dialogue const & d ) { + mission *miss = d.const_actor( true )->selected_mission(); if( miss == nullptr ) { debugmsg( "mission_has_generic_rewards: mission_selected == nullptr" ); return true; @@ -1954,9 +1981,9 @@ conditional_t::func f_has_worn_with_flag( const JsonObject &jo, std::string_view str_or_var flag = get_str_or_var( jo.get_member( member ), member, true ); std::optional bp; optional( jo, false, "bodypart", bp ); - return [flag, bp, is_npc]( dialogue const & d ) { + return [flag, bp, is_npc]( const_dialogue const & d ) { bodypart_id bid = bp.value_or( get_bp_from_str( d.reason ) ); - return d.actor( is_npc )->worn_with_flag( flag_id( flag.evaluate( d ) ), bid ); + return d.const_actor( is_npc )->worn_with_flag( flag_id( flag.evaluate( d ) ), bid ); }; } @@ -1964,8 +1991,8 @@ conditional_t::func f_has_wielded_with_flag( const JsonObject &jo, std::string_v bool is_npc ) { str_or_var flag = get_str_or_var( jo.get_member( member ), member, true ); - return [flag, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->wielded_with_flag( flag_id( flag.evaluate( d ) ) ); + return [flag, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->wielded_with_flag( flag_id( flag.evaluate( d ) ) ); }; } @@ -1974,8 +2001,9 @@ conditional_t::func f_has_wielded_with_weapon_category( const JsonObject &jo, bool is_npc ) { str_or_var w_cat = get_str_or_var( jo.get_member( member ), member, true ); - return [w_cat, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->wielded_with_weapon_category( weapon_category_id( w_cat.evaluate( d ) ) ); + return [w_cat, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->wielded_with_weapon_category( weapon_category_id( w_cat.evaluate( + d ) ) ); }; } @@ -1985,9 +2013,9 @@ conditional_t::func f_has_wielded_with_skill( const JsonObject &jo, std::string_ // ideally all this "u wield with X" should be moved to some mutator // and a single effect should check mutator applied to the item in your hands str_or_var w_skill = get_str_or_var( jo.get_member( member ), member, true ); - return [w_skill, is_npc]( dialogue const & d ) { + return [w_skill, is_npc]( const_dialogue const & d ) { - return d.actor( is_npc )->wielded_with_weapon_skill( skill_id( w_skill.evaluate( d ) ) ); + return d.const_actor( is_npc )->wielded_with_weapon_skill( skill_id( w_skill.evaluate( d ) ) ); }; } @@ -1995,23 +2023,23 @@ conditional_t::func f_has_wielded_with_ammotype( const JsonObject &jo, std::stri bool is_npc ) { str_or_var w_ammotype = get_str_or_var( jo.get_member( member ), member, true ); - return [w_ammotype, is_npc]( dialogue const & d ) { + return [w_ammotype, is_npc]( const_dialogue const & d ) { - return d.actor( is_npc )->wielded_with_item_ammotype( ammotype( w_ammotype.evaluate( d ) ) ); + return d.const_actor( is_npc )->wielded_with_item_ammotype( ammotype( w_ammotype.evaluate( d ) ) ); }; } conditional_t::func f_can_see( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->can_see(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->can_see(); }; } conditional_t::func f_is_deaf( bool is_npc ) { - return [is_npc]( dialogue const & d ) { - return d.actor( is_npc )->is_deaf(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->is_deaf(); }; } @@ -2019,9 +2047,9 @@ conditional_t::func f_is_on_terrain( const JsonObject &jo, std::string_view memb bool is_npc ) { str_or_var terrain_type = get_str_or_var( jo.get_member( member ), member, true ); - return [terrain_type, is_npc]( dialogue const & d ) { + return [terrain_type, is_npc]( const_dialogue const & d ) { map &here = get_map(); - return here.ter( d.actor( is_npc )->pos() ) == ter_id( terrain_type.evaluate( d ) ); + return here.ter( d.const_actor( is_npc )->pos() ) == ter_id( terrain_type.evaluate( d ) ); }; } @@ -2029,9 +2057,9 @@ conditional_t::func f_is_on_terrain_with_flag( const JsonObject &jo, std::string bool is_npc ) { str_or_var terrain_type = get_str_or_var( jo.get_member( member ), member, true ); - return [terrain_type, is_npc]( dialogue const & d ) { + return [terrain_type, is_npc]( const_dialogue const & d ) { map &here = get_map(); - return here.ter( d.actor( is_npc )->pos() )->has_flag( terrain_type.evaluate( d ) ); + return here.ter( d.const_actor( is_npc )->pos() )->has_flag( terrain_type.evaluate( d ) ); }; } @@ -2039,10 +2067,10 @@ conditional_t::func f_is_in_field( const JsonObject &jo, std::string_view member bool is_npc ) { str_or_var field_type = get_str_or_var( jo.get_member( member ), member, true ); - return [field_type, is_npc]( dialogue const & d ) { + return [field_type, is_npc]( const_dialogue const & d ) { map &here = get_map(); field_type_id ft = field_type_id( field_type.evaluate( d ) ); - for( const std::pair &f : here.field_at( d.actor( + for( const std::pair &f : here.field_at( d.const_actor( is_npc )->pos() ) ) { if( f.second.get_field_type() == ft ) { return true; @@ -2056,8 +2084,8 @@ conditional_t::func f_has_move_mode( const JsonObject &jo, std::string_view memb bool is_npc ) { str_or_var mode = get_str_or_var( jo.get_member( member ), member, true ); - return [mode, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->get_move_mode() == move_mode_id( mode.evaluate( d ) ); + return [mode, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_move_mode() == move_mode_id( mode.evaluate( d ) ); }; } @@ -2065,9 +2093,9 @@ conditional_t::func f_can_see_location( const JsonObject &jo, std::string_view m bool is_npc ) { str_or_var target = get_str_or_var( jo.get_member( member ), member, true ); - return [is_npc, target]( dialogue const & d ) { + return [is_npc, target]( const_dialogue const & d ) { tripoint_abs_ms target_pos = tripoint_abs_ms( tripoint::from_string( target.evaluate( d ) ) ); - return d.actor( is_npc )->can_see_location( get_map().bub_from_abs( target_pos ).raw() ); + return d.const_actor( is_npc )->can_see_location( get_map().bub_from_abs( target_pos ).raw() ); }; } @@ -2075,8 +2103,8 @@ conditional_t::func f_using_martial_art( const JsonObject &jo, std::string_view bool is_npc ) { str_or_var style_to_check = get_str_or_var( jo.get_member( member ), member, true ); - return [style_to_check, is_npc]( dialogue const & d ) { - return d.actor( is_npc )->using_martial_art( matype_id( style_to_check.evaluate( d ) ) ); + return [style_to_check, is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->using_martial_art( matype_id( style_to_check.evaluate( d ) ) ); }; } @@ -2084,18 +2112,18 @@ conditional_t::func f_using_martial_art( const JsonObject &jo, std::string_view } // namespace conditional_fun template -static std::function get_get_str_( const JsonObject &jo, +static std::function get_get_str_( const JsonObject &jo, std::function ret_func ) { const std::string &mutator = jo.get_string( "mutator" ); if( mutator == "mon_faction" ) { str_or_var mtypeid = get_str_or_var( jo.get_member( "mtype_id" ), "mtype_id" ); - return [mtypeid, ret_func]( const dialogue & d ) { + return [mtypeid, ret_func]( const_dialogue const & d ) { return ret_func( ( static_cast( mtypeid.evaluate( d ) ) )->default_faction.str() ); }; } else if( mutator == "game_option" ) { str_or_var option = get_str_or_var( jo.get_member( "option" ), "option" ); - return [option, ret_func]( const dialogue & d ) { + return [option, ret_func]( const_dialogue const & d ) { return ret_func( get_option( option.evaluate( d ) ) ); }; } else if( mutator == "valid_technique" ) { @@ -2110,25 +2138,26 @@ static std::function get_get_str_( const JsonObject &jo, bool dodge_counter = jo.get_bool( "dodge_counter", false ); bool block_counter = jo.get_bool( "block_counter", false ); - return [blacklist, crit, dodge_counter, block_counter, ret_func]( const dialogue & d ) { + return [blacklist, crit, dodge_counter, block_counter, ret_func]( const_dialogue const & d ) { std::vector bl; bl.reserve( blacklist.size() ); for( const str_or_var &sv : blacklist ) { bl.emplace_back( sv.evaluate( d ) ); } - return ret_func( d.actor( false )->get_random_technique( *d.actor( true )->get_creature(), + return ret_func( d.const_actor( false )->get_random_technique( *d.const_actor( + true )->get_const_creature(), crit, dodge_counter, block_counter, bl ).str() ); }; } else if( mutator == "u_loc_relative" || mutator == "npc_loc_relative" ) { str_or_var target = get_str_or_var( jo.get_member( "target" ), "target" ); bool use_beta_talker = mutator == "npc_loc_relative"; - return [target, use_beta_talker, ret_func]( const dialogue & d ) { - tripoint_abs_ms char_pos = get_map().getglobal( d.actor( use_beta_talker )->pos() ); + return [target, use_beta_talker, ret_func]( const_dialogue const & d ) { + tripoint_abs_ms char_pos = get_map().getglobal( d.const_actor( use_beta_talker )->pos() ); tripoint_abs_ms target_pos = char_pos + tripoint::from_string( target.evaluate( d ) ); return ret_func( target_pos.to_string() ); }; } else if( mutator == "topic_item" ) { - return [ret_func]( const dialogue & d ) { + return [ret_func]( const_dialogue const & d ) { return ret_func( d.cur_item.str() ); }; } @@ -2137,19 +2166,19 @@ static std::function get_get_str_( const JsonObject &jo, } template -static std::function get_get_translation_( const JsonObject &jo, +static std::function get_get_translation_( const JsonObject &jo, std::function ret_func ) { if( jo.get_string( "mutator" ) == "ma_technique_description" ) { str_or_var ma = get_str_or_var( jo.get_member( "matec_id" ), "matec_id" ); - return [ma, ret_func]( const dialogue & d ) { + return [ma, ret_func]( const_dialogue const & d ) { return ret_func( matec_id( ma.evaluate( d ) )->description ); }; } else if( jo.get_string( "mutator" ) == "ma_technique_name" ) { str_or_var ma = get_str_or_var( jo.get_member( "matec_id" ), "matec_id" ); - return [ma, ret_func]( const dialogue & d ) { + return [ma, ret_func]( const_dialogue const & d ) { return ret_func( matec_id( ma.evaluate( d ) )->name ); }; } @@ -2157,7 +2186,7 @@ static std::function get_get_translation_( const JsonObje return nullptr; } -std::function conditional_t::get_get_translation( +std::function conditional_t::get_get_translation( const JsonObject &jo ) { auto ret_func = get_get_str_( jo, []( const std::string & s ) { @@ -2170,7 +2199,7 @@ std::function conditional_t::get_get_translatio } ); if( !ret_func ) { jo.throw_error( "unrecognized string mutator in " + jo.str() ); - return []( const dialogue & ) { + return []( const_dialogue const & ) { return translation(); }; } @@ -2179,7 +2208,8 @@ std::function conditional_t::get_get_translatio return ret_func; } -std::function conditional_t::get_get_string( const JsonObject &jo ) +std::function conditional_t::get_get_string( + const JsonObject &jo ) { auto ret_func = get_get_str_( jo, []( const std::string & s ) { return s; @@ -2191,7 +2221,7 @@ std::function conditional_t::get_get_string( co } ); if( !ret_func ) { jo.throw_error( "unrecognized string mutator in " + jo.str() ); - return []( const dialogue & ) { + return []( const_dialogue const & ) { return "INVALID"; }; } @@ -2202,110 +2232,110 @@ std::function conditional_t::get_get_string( co namespace { -std::unordered_map const f_get_vals = { - { "activity_level", &talker::get_activity_level }, - { "age", &talker::get_age }, - { "anger", &talker::get_anger }, - { "bmi_permil", &talker::get_bmi_permil }, - { "cash", &talker::cash }, - { "difficulty", &talker::get_difficulty }, - { "dexterity_base", &talker::get_dex_max }, - { "dexterity_bonus", &talker::get_dex_bonus }, - { "dexterity", &talker::dex_cur }, - { "exp", &talker::get_kill_xp }, - { "sleepiness", &talker::get_sleepiness }, - { "fine_detail_vision_mod", &talker::get_fine_detail_vision_mod }, - { "focus", &talker::focus_cur }, - { "friendly", &talker::get_friendly }, - { "grab_strength", &talker::get_grab_strength }, - { "health", &talker::get_health }, - { "height", &talker::get_height }, - { "hunger", &talker::get_hunger }, - { "instant_thirst", &talker::get_instant_thirst }, - { "intelligence_base", &talker::get_int_max }, - { "intelligence_bonus", &talker::get_int_bonus }, - { "intelligence", &talker::int_cur }, - { "mana_max", &talker::mana_max }, - { "mana", &talker::mana_cur }, - { "morale", &talker::morale_cur }, - { "owed", &talker::debt }, - { "perception_base", &talker::get_per_max }, - { "perception_bonus", &talker::get_per_bonus }, - { "perception", &talker::per_cur }, - { "pkill", &talker::get_pkill }, - { "pos_x", &talker::posx }, - { "pos_y", &talker::posy }, - { "pos_z", &talker::posz }, - { "rad", &talker::get_rad }, - { "size", &talker::get_size }, - { "sleep_deprivation", &talker::get_sleep_deprivation }, - { "sold", &talker::sold }, - { "stamina", &talker::get_stamina }, - { "stim", &talker::get_stim }, - { "strength_base", &talker::get_str_max }, - { "strength_bonus", &talker::get_str_bonus }, - { "strength", &talker::str_cur }, - { "thirst", &talker::get_thirst }, - { "count", &talker::get_count } +std::unordered_map const f_get_vals = { + { "activity_level", &const_talker::get_activity_level }, + { "age", &const_talker::get_age }, + { "anger", &const_talker::get_anger }, + { "bmi_permil", &const_talker::get_bmi_permil }, + { "cash", &const_talker::cash }, + { "difficulty", &const_talker::get_difficulty }, + { "dexterity_base", &const_talker::get_dex_max }, + { "dexterity_bonus", &const_talker::get_dex_bonus }, + { "dexterity", &const_talker::dex_cur }, + { "exp", &const_talker::get_kill_xp }, + { "sleepiness", &const_talker::get_sleepiness }, + { "fine_detail_vision_mod", &const_talker::get_fine_detail_vision_mod }, + { "focus", &const_talker::focus_cur }, + { "friendly", &const_talker::get_friendly }, + { "grab_strength", &const_talker::get_grab_strength }, + { "health", &const_talker::get_health }, + { "height", &const_talker::get_height }, + { "hunger", &const_talker::get_hunger }, + { "instant_thirst", &const_talker::get_instant_thirst }, + { "intelligence_base", &const_talker::get_int_max }, + { "intelligence_bonus", &const_talker::get_int_bonus }, + { "intelligence", &const_talker::int_cur }, + { "mana_max", &const_talker::mana_max }, + { "mana", &const_talker::mana_cur }, + { "morale", &const_talker::morale_cur }, + { "owed", &const_talker::debt }, + { "perception_base", &const_talker::get_per_max }, + { "perception_bonus", &const_talker::get_per_bonus }, + { "perception", &const_talker::per_cur }, + { "pkill", &const_talker::get_pkill }, + { "pos_x", &const_talker::posx }, + { "pos_y", &const_talker::posy }, + { "pos_z", &const_talker::posz }, + { "rad", &const_talker::get_rad }, + { "size", &const_talker::get_size }, + { "sleep_deprivation", &const_talker::get_sleep_deprivation }, + { "sold", &const_talker::sold }, + { "stamina", &const_talker::get_stamina }, + { "stim", &const_talker::get_stim }, + { "strength_base", &const_talker::get_str_max }, + { "strength_bonus", &const_talker::get_str_bonus }, + { "strength", &const_talker::str_cur }, + { "thirst", &const_talker::get_thirst }, + { "count", &const_talker::get_count } }; } // namespace // Consider adding new, single-purpose math functions instead of feeding this monster another else-if -std::function conditional_t::get_get_dbl( std::string_view checked_value, - char scope ) +std::function +conditional_t::get_get_dbl( std::string_view checked_value, char scope ) { const bool is_npc = scope == 'n'; if( auto iter = f_get_vals.find( checked_value ); iter != f_get_vals.end() ) { - return [is_npc, func = iter->second ]( dialogue & d ) { - return ( d.actor( is_npc )->*func )(); + return [is_npc, func = iter->second ]( const_dialogue const & d ) { + return ( d.const_actor( is_npc )->*func )(); }; } else if( checked_value == "allies" ) { if( is_npc ) { throw std::invalid_argument( "Can't get allies count for NPCs" ); } - return []( dialogue const & ) { + return []( const_dialogue const & /* d */ ) { return static_cast( g->allies().size() ); }; } else if( checked_value == "dodge" ) { - return [is_npc]( dialogue const & d ) { - return static_cast( d.actor( is_npc ) )->get_character()->get_dodge(); + return [is_npc]( const_dialogue const & d ) { + return d.const_actor( is_npc )->get_const_character()->get_dodge(); }; } else if( checked_value == "power_percentage" ) { - return [is_npc]( dialogue const & d ) { + return [is_npc]( const_dialogue const & d ) { // Energy in milijoule - units::energy::value_type power_max = d.actor( is_npc )->power_max().value(); + units::energy::value_type power_max = d.const_actor( is_npc )->power_max().value(); if( power_max == 0 ) { return 0.0; //Default value if character does not have power, avoids division with 0. } - return static_cast( d.actor( is_npc )->power_cur().value() * 100.0L / power_max ); + return static_cast( d.const_actor( is_npc )->power_cur().value() * 100.0L / power_max ); }; } else if( checked_value == "mana_percentage" ) { - return [is_npc]( dialogue const & d ) { - int mana_max = d.actor( is_npc )->mana_max(); + return [is_npc]( const_dialogue const & d ) { + int mana_max = d.const_actor( is_npc )->mana_max(); if( mana_max == 0 ) { return 0.0; //Default value if character does not have mana, avoids division with 0. } - return d.actor( is_npc )->mana_cur() * 100.0 / mana_max; + return d.const_actor( is_npc )->mana_cur() * 100.0 / mana_max; }; } else if( checked_value == "body_temp" ) { - return [is_npc]( dialogue const & d ) { - return units::to_legacy_bodypart_temp( d.actor( is_npc )->get_body_temp() ); + return [is_npc]( const_dialogue const & d ) { + return units::to_legacy_bodypart_temp( d.const_actor( is_npc )->get_body_temp() ); }; } else if( checked_value == "body_temp_delta" ) { - return [is_npc]( dialogue const & d ) { - return units::to_legacy_bodypart_temp_delta( d.actor( is_npc )->get_body_temp_delta() ); + return [is_npc]( const_dialogue const & d ) { + return units::to_legacy_bodypart_temp_delta( d.const_actor( is_npc )->get_body_temp_delta() ); }; } else if( checked_value == "power" ) { - return [is_npc]( dialogue const & d ) { + return [is_npc]( const_dialogue const & d ) { // Energy in milijoule - return static_cast( d.actor( is_npc )->power_cur().value() ); + return static_cast( d.const_actor( is_npc )->power_cur().value() ); }; } else if( checked_value == "power_max" ) { - return [is_npc]( dialogue const & d ) { + return [is_npc]( const_dialogue const & d ) { // Energy in milijoule - return static_cast( d.actor( is_npc )->power_max().value() ); + return static_cast( d.const_actor( is_npc )->power_max().value() ); }; } @@ -2697,7 +2727,7 @@ conditional_t::conditional_t( const JsonObject &jo ) if( jo.has_array( "and" ) ) { std::vector and_conditionals = parse_array( jo, "and" ); found_sub_member = true; - condition = [acs = std::move( and_conditionals )]( dialogue & d ) { + condition = [acs = std::move( and_conditionals )]( const_dialogue const & d ) { return std::all_of( acs.begin(), acs.end(), [&d]( conditional_t const & cond ) { return cond( d ); } ); @@ -2705,7 +2735,7 @@ conditional_t::conditional_t( const JsonObject &jo ) } else if( jo.has_array( "or" ) ) { std::vector or_conditionals = parse_array( jo, "or" ); found_sub_member = true; - condition = [ocs = std::move( or_conditionals )]( dialogue & d ) { + condition = [ocs = std::move( or_conditionals )]( const_dialogue const & d ) { return std::any_of( ocs.begin(), ocs.end(), [&d]( conditional_t const & cond ) { return cond( d ); } ); @@ -2714,13 +2744,13 @@ conditional_t::conditional_t( const JsonObject &jo ) JsonObject cond = jo.get_object( "not" ); const conditional_t sub_condition = conditional_t( cond ); found_sub_member = true; - condition = [sub_condition]( dialogue & d ) { + condition = [sub_condition]( const_dialogue const & d ) { return !sub_condition( d ); }; } else if( jo.has_string( "not" ) ) { const conditional_t sub_condition = conditional_t( jo.get_string( "not" ) ); found_sub_member = true; - condition = [sub_condition]( dialogue & d ) { + condition = [sub_condition]( const_dialogue const & d ) { return !sub_condition( d ); }; } @@ -2757,7 +2787,7 @@ conditional_t::conditional_t( const JsonObject &jo ) for( const std::string &sub_member : dialogue_data::simple_string_conds() ) { if( jo.has_string( sub_member ) ) { const conditional_t sub_condition( jo.get_string( sub_member ) ); - condition = [sub_condition]( dialogue & d ) { + condition = [sub_condition]( const_dialogue const & d ) { return sub_condition( d ); }; found_sub_member = true; @@ -2791,7 +2821,7 @@ conditional_t::conditional_t( std::string_view type ) } } if( !found ) { - condition = []( dialogue const & ) { + condition = []( const_dialogue const & ) { return false; }; } diff --git a/src/condition.h b/src/condition.h index 79cf24668835f..e139551679c9f 100644 --- a/src/condition.h +++ b/src/condition.h @@ -59,7 +59,7 @@ duration_or_var get_duration_or_var( const JsonObject &jo, const std::string_vie duration_or_var_part get_duration_or_var_part( const JsonValue &jv, const std::string_view &member, bool required = true, time_duration default_val = 0_seconds ); -tripoint_abs_ms get_tripoint_from_var( std::optional var, dialogue const &d, +tripoint_abs_ms get_tripoint_from_var( std::optional var, const_dialogue const &d, bool is_npc ); var_info read_var_info( const JsonObject &jo ); translation_var_info read_translation_var_info( const JsonObject &jo ); @@ -67,13 +67,15 @@ void write_var_value( var_type type, const std::string &name, dialogue *d, const std::string &value, int call_depth = 0 ); void write_var_value( var_type type, const std::string &name, dialogue *d, double value ); +void write_var_value( var_type type, const std::string &name, const_dialogue const &d, + const std::string &value ); std::string get_talk_varname( const JsonObject &jo, std::string_view member, bool check_value, dbl_or_var &default_val ); std::string get_talk_var_basename( const JsonObject &jo, std::string_view member, bool check_value ); // the truly awful declaration for the conditional_t loading helper_function void read_condition( const JsonObject &jo, const std::string &member_name, - std::function &condition, bool default_val ); + std::function &condition, bool default_val ); void finalize_conditions(); @@ -86,19 +88,20 @@ void finalize_conditions(); */ struct conditional_t { public: - using func = std::function; + using func = std::function; conditional_t() = default; explicit conditional_t( std::string_view type ); explicit conditional_t( const JsonObject &jo ); - static std::function get_get_string( const JsonObject &jo ); - static std::function get_get_translation( const JsonObject &jo ); - static std::function get_get_dbl( std::string_view checked_value, + static std::function get_get_string( const JsonObject &jo ); + static std::function get_get_translation( + const JsonObject &jo ); + static std::function get_get_dbl( std::string_view checked_value, char scope ); std::function static get_set_dbl( std::string_view checked_value, char scope ); - bool operator()( dialogue &d ) const { + bool operator()( const_dialogue const &d ) const { if( !condition ) { return false; } diff --git a/src/construction.cpp b/src/construction.cpp index 0bdcbb24901ce..b81155362faa4 100644 --- a/src/construction.cpp +++ b/src/construction.cpp @@ -1733,7 +1733,8 @@ void construct::done_vehicle( const tripoint_bub_ms &p, Character & ) const item &base = components.front(); veh->name = name; - const int partnum = veh->install_part( point_zero, vpart_from_item( base.typeId() ), item( base ) ); + const int partnum = veh->install_part( point_rel_ms_zero, vpart_from_item( base.typeId() ), + item( base ) ); veh->part( partnum ).set_flag( vp_flag::unsalvageable_flag ); // Update the vehicle cache immediately, diff --git a/src/consumption.cpp b/src/consumption.cpp index d978ddac22d0c..73a76e90fa68d 100644 --- a/src/consumption.cpp +++ b/src/consumption.cpp @@ -224,7 +224,7 @@ static int compute_default_effective_kcal( const item &comest, const Character & } // As float to avoid rounding too many times - float kcal = comest.get_comestible()->default_nutrition.kcal(); + float kcal = comest.get_comestible()->default_nutrition_read_only().kcal(); // Many raw foods give less calories, as your body has expends more energy digesting them. bool cooked = comest.has_flag( flag_COOKED ) || extra_flags.count( flag_COOKED ); @@ -262,7 +262,7 @@ static std::map compute_default_effective_vitamins( return {}; } - std::map res = it.get_comestible()->default_nutrition.vitamins(); + std::map res = it.get_comestible()->default_nutrition_read_only().vitamins(); // for actual vitamins convert RDA to a internal value for( std::pair &vit : res ) { @@ -312,6 +312,12 @@ static nutrients compute_default_effective_nutrients( const item &comest, return ret; } +extern nutrients default_character_compute_effective_nutrients( const item &comest ) +{ + static npc dummy; + return dummy.compute_effective_nutrients( comest ); +} + // Calculate the nutrients that the given character would receive from consuming // the given item, taking into account the item components and the character's // traits. diff --git a/src/creature.cpp b/src/creature.cpp index bb372e7eb82cd..ad5bd25cb4c4a 100644 --- a/src/creature.cpp +++ b/src/creature.cpp @@ -247,7 +247,7 @@ bool Creature::will_be_cramped_in_vehicle_tile( const tripoint_abs_ms &loc ) con } if( capacity > 0_ml ) { // First, we'll try to squeeze in. Open-topped vehicle parts have more room to step over cargo. - if( !veh.enclosed_at( here.bub_from_abs( loc ).raw() ) ) { + if( !veh.enclosed_at( here.bub_from_abs( loc ) ) ) { free_cargo *= 1.2; } const creature_size size = get_size(); @@ -644,10 +644,10 @@ bool Creature::sees( const tripoint_bub_ms &t, bool is_avatar, int range_mod ) c // Helper function to check if potential area of effect of a weapon overlaps vehicle // Maybe TODO: If this is too slow, precalculate a bounding box and clip the tested area to it -static bool overlaps_vehicle( const std::set &veh_area, const tripoint &pos, +static bool overlaps_vehicle( const std::set &veh_area, const tripoint_bub_ms &pos, const int area ) { - for( const tripoint &tmp : tripoint_range( pos - tripoint( area, area, 0 ), + for( const tripoint_bub_ms &tmp : tripoint_range( pos - tripoint( area, area, 0 ), pos + tripoint( area - 1, area - 1, 0 ) ) ) { if( veh_area.count( tmp ) > 0 ) { return true; @@ -789,7 +789,7 @@ Creature *Creature::auto_find_hostile_target( int range, int &boo_hoo, int area continue; // Handle this late so that boo_hoo++ can happen } // Expensive check for proximity to vehicle - if( self_area_iff && overlaps_vehicle( in_veh->get_points(), m->pos(), area ) ) { + if( self_area_iff && overlaps_vehicle( in_veh->get_points(), tripoint_bub_ms( m->pos() ), area ) ) { continue; } @@ -3449,22 +3449,23 @@ std::unique_ptr get_talker_for( Creature &me ) return std::make_unique( me.as_npc() ); } else if( me.is_avatar() ) { return std::make_unique( me.as_avatar() ); - } else { - debugmsg( "Invalid creature type %s.", me.get_name() ); - return std::make_unique(); } + debugmsg( "Invalid creature type %s.", me.get_name() ); + return std::make_unique(); } -std::unique_ptr get_talker_for( const Creature &me ) +std::unique_ptr get_const_talker_for( const Creature &me ) { - if( !me.is_monster() ) { - return std::make_unique( me.as_character() ); - } else if( me.is_monster() ) { + if( me.is_monster() ) { return std::make_unique( me.as_monster() ); - } else { - debugmsg( "Invalid creature type %s.", me.get_name() ); - return std::make_unique(); + } else if( me.is_npc() ) { + return std::make_unique( me.as_npc() ); + } else if( me.is_avatar() ) { + return std::make_unique( me.as_avatar() ); } + + debugmsg( "Invalid creature type %s.", me.get_name() ); + return std::make_unique(); } std::unique_ptr get_talker_for( Creature *me ) @@ -3472,14 +3473,6 @@ std::unique_ptr get_talker_for( Creature *me ) if( !me ) { debugmsg( "Null creature type." ); return std::make_unique(); - } else if( me->is_monster() ) { - return std::make_unique( me->as_monster() ); - } else if( me->is_npc() ) { - return std::make_unique( me->as_npc() ); - } else if( me->is_avatar() ) { - return std::make_unique( me->as_avatar() ); - } else { - debugmsg( "Invalid creature type %s.", me->get_name() ); - return std::make_unique(); } + return get_talker_for( *me ); } diff --git a/src/creature.h b/src/creature.h index 3f75db8814263..e8f08b6644a3f 100644 --- a/src/creature.h +++ b/src/creature.h @@ -50,6 +50,7 @@ class monster; class nc_color; class npc; class talker; +class const_talker; class translation; namespace catacurses { @@ -1346,6 +1347,6 @@ class Creature : public viewer void print_proj_avoid_msg( Creature *source, viewer &player_view ) const; }; std::unique_ptr get_talker_for( Creature &me ); -std::unique_ptr get_talker_for( const Creature &me ); +std::unique_ptr get_const_talker_for( const Creature &me ); std::unique_ptr get_talker_for( Creature *me ); #endif // CATA_SRC_CREATURE_H diff --git a/src/dialogue.h b/src/dialogue.h index 80bcd090bf4ae..42482c5906c2e 100644 --- a/src/dialogue.h +++ b/src/dialogue.h @@ -3,7 +3,6 @@ #define CATA_SRC_DIALOGUE_H #include -#include #include #include #include @@ -14,10 +13,8 @@ #include "cata_lazy.h" #include "dialogue_helpers.h" #include "dialogue_win.h" -#include "global_vars.h" #include "npc_opinion.h" #include "talker.h" -#include "translations.h" #include "type_id.h" /** @@ -71,12 +68,12 @@ using trial_mod = std::pair; struct talk_trial { talk_trial_type type = TALK_TRIAL_NONE; int difficulty = 0; - std::function condition; + std::function condition; // If this talk_trial is skill check, this is the string ID of the skill that we check the level of. std::string skill_required; - int calc_chance( dialogue &d ) const; + int calc_chance( const_dialogue const &d ) const; /** * Returns a user-friendly representation of @ref type */ @@ -179,7 +176,7 @@ struct talk_response { */ translation truetext; translation falsetext; - std::function truefalse_condition; + std::function truefalse_condition; talk_trial trial; /** @@ -187,14 +184,14 @@ struct talk_response { */ //copy of json_talk_response::condition, optional - std::function condition; + std::function condition; //whether to display this response in normal gameplay even if condition is false bool show_always = false; //appended to response if condition fails or show_always/show_condition std::string show_reason; //show_always, but on show_condition being true - std::function show_condition; + std::function show_condition; //flag to hold result of show_anyways (not read from JSON) bool ignore_conditionals = false; @@ -221,39 +218,80 @@ struct talk_response { /** * A collection of talk_topics and talk_responses that make up a conversation. */ -struct dialogue { +struct const_dialogue { + const_talker *const_actor( bool is_beta ) const; + bool has_actor( bool is_beta ) const; + + const_dialogue() = default; + ~const_dialogue() = default; + const_dialogue( const const_dialogue & ); + const_dialogue( const_dialogue && ) = default; + const_dialogue &operator=( const const_dialogue & ) = delete; + const_dialogue &operator=( const_dialogue && ) = default; + const_dialogue( + std::unique_ptr alpha_in, std::unique_ptr beta_in, + const std::unordered_map> &cond = {}, + const std::unordered_map &ctx = {} ); + + bool has_beta{}; + bool has_alpha{}; + + mutable itype_id cur_item; + mutable std::string reason; + /** Missions that have been assigned by this npc to the player they currently speak to. */ + std::vector missions_assigned; + /** This dialogue is happening over a radio */ + bool by_radio = false; + + // Methods for setting/getting misc key/value pairs. + void set_value( const std::string &key, const std::string &value ); + void remove_value( const std::string &key ); + + void set_conditional( const std::string &key, + const std::function &value ); + std::string get_value( const std::string &key ) const; + std::optional maybe_get_value( const std::string &key ) const; + + bool evaluate_conditional( const std::string &key, const_dialogue const &d ) const; + + const std::unordered_map &get_context() const; + const std::unordered_map> + &get_conditionals() const; + void amend_callstack( const std::string &value ); + std::string get_callstack() const; + + private: + std::unique_ptr alpha, beta; + + lazy> context; + mutable std::string callstack; + + lazy>> conditionals; +}; + +struct dialogue: public const_dialogue { /** * If true, we are done talking and the dialog ends. */ bool done = false; std::vector topic_stack; - /** Missions that have been assigned by this npc to the player they currently speak to. */ - std::vector missions_assigned; - talk_topic opt( dialogue_window &d_win, const talk_topic &topic ); dialogue() = default; + ~dialogue() = default; dialogue( const dialogue &d ); + explicit dialogue( const_dialogue const &d ); dialogue( dialogue && ) = default; dialogue &operator=( const dialogue & ); dialogue &operator=( dialogue && ) = default; - dialogue( std::unique_ptr alpha_in, std::unique_ptr beta_in ); - dialogue( std::unique_ptr alpha_in, std::unique_ptr beta_in, - const std::unordered_map> &cond ); dialogue( std::unique_ptr alpha_in, std::unique_ptr beta_in, - const std::unordered_map> &cond, - const std::unordered_map &ctx ); + const std::unordered_map> &cond = {}, + const std::unordered_map &ctx = {} ); talker *actor( bool is_beta ) const; - bool has_actor( bool is_beta ) const; - - mutable itype_id cur_item; - mutable std::string reason; std::string dynamic_line( const talk_topic &topic ); void apply_speaker_effects( const talk_topic &the_topic ); - /** This dialogue is happening over a radio */ - bool by_radio = false; /** * Possible responses from the player character, filled in @ref gen_responses. */ @@ -262,26 +300,11 @@ struct dialogue { void add_topic( const std::string &topic ); void add_topic( const talk_topic &topic ); - bool has_beta; - bool has_alpha; bool debug_conditionals = true; bool debug_effects = true; bool debug_ignore_conditionals = false; - // Methods for setting/getting misc key/value pairs. - void set_value( const std::string &key, const std::string &value ); - void remove_value( const std::string &key ); - std::string get_value( const std::string &key ) const; - std::optional maybe_get_value( const std::string &key ) const; - - void set_conditional( const std::string &key, const std::function &value ); - bool evaluate_conditional( const std::string &key, dialogue &d ); - - const std::unordered_map &get_context() const; - const std::unordered_map> &get_conditionals() const; - void amend_callstack( const std::string &value ); - std::string get_callstack() const; private: /** * The talker that speaks (almost certainly representing the avatar, ie get_avatar() ) @@ -292,14 +315,6 @@ struct dialogue { */ std::unique_ptr beta; - // dialogue specific variables that can be passed down to additional EOCs but are one way - lazy> context; - // Weirdly unnecessarily in context. - std::string callstack; - - // conditionals that were set at the upper level - lazy>> conditionals; - /** * Add a simple response that switches the topic to the new one. If first == true, force * this topic to the front of the responses. @@ -412,7 +427,7 @@ class json_talk_response { private: talk_response actual_response; - std::function condition; + std::function condition; bool has_condition_ = false; bool is_switch = false; bool is_default = false; diff --git a/src/dialogue_helpers.cpp b/src/dialogue_helpers.cpp index ab373b0e554d0..27e449fc7e724 100644 --- a/src/dialogue_helpers.cpp +++ b/src/dialogue_helpers.cpp @@ -8,7 +8,7 @@ template std::optional maybe_read_var_value( - const abstract_var_info &info, const dialogue &d, int call_depth ) + const abstract_var_info &info, const_dialogue const &d, int call_depth ) { global_variables &globvars = get_globals(); switch( info.type ) { @@ -17,9 +17,9 @@ std::optional maybe_read_var_value( case var_type::context: return d.maybe_get_value( info.name ); case var_type::u: - return d.actor( false )->maybe_get_value( info.name ); + return d.const_actor( false )->maybe_get_value( info.name ); case var_type::npc: - return d.actor( true )->maybe_get_value( info.name ); + return d.const_actor( true )->maybe_get_value( info.name ); case var_type::var: { std::optional const var_val = d.maybe_get_value( info.name ); if( call_depth > 1000 && var_val ) { @@ -40,20 +40,19 @@ std::optional maybe_read_var_value( } template -std::optional maybe_read_var_value( const var_info &, const dialogue &, - int call_depth ); -template -std::optional maybe_read_var_value( const translation_var_info &, const dialogue &, +std::optional maybe_read_var_value( const var_info &, const_dialogue const &, int call_depth ); +template std::optional maybe_read_var_value( const translation_var_info &, + const_dialogue const &, int call_depth ); template<> -std::string read_var_value( const var_info &info, const dialogue &d ) +std::string read_var_value( const var_info &info, const_dialogue const &d ) { return maybe_read_var_value( info, d ).value_or( info.default_val ); } template<> -std::string read_var_value( const translation_var_info &info, const dialogue &d ) +std::string read_var_value( const translation_var_info &info, const_dialogue const &d ) { return maybe_read_var_value( info, d ).value_or( info.default_val.translated() ); } @@ -93,7 +92,7 @@ var_info process_variable( const std::string &type ) } template<> -std::string str_or_var::evaluate( dialogue const &d ) const +std::string str_or_var::evaluate( const_dialogue const &d ) const { if( function.has_value() ) { return function.value()( d ); @@ -123,7 +122,7 @@ std::string str_or_var::evaluate( dialogue const &d ) const } template<> -std::string translation_or_var::evaluate( dialogue const &d ) const +std::string translation_or_var::evaluate( const_dialogue const &d ) const { if( function.has_value() ) { return function.value()( d ).translated(); @@ -152,14 +151,14 @@ std::string translation_or_var::evaluate( dialogue const &d ) const return ""; } -std::string str_translation_or_var::evaluate( dialogue const &d ) const +std::string str_translation_or_var::evaluate( const_dialogue const &d ) const { return std::visit( [&d]( auto &&val ) { return val.evaluate( d ); }, val ); } -double dbl_or_var_part::evaluate( dialogue &d ) const +double dbl_or_var_part::evaluate( const_dialogue const &d ) const { if( dbl_val.has_value() ) { return dbl_val.value(); @@ -182,13 +181,14 @@ double dbl_or_var_part::evaluate( dialogue &d ) const return 0; } if( math_val ) { - return math_val->act( d ); + dialogue loosey_goosey( d ); + return math_val->act( loosey_goosey ); } debugmsg( "No valid value for dbl_or_var_part. %s", d.get_callstack() ); return 0; } -double dbl_or_var::evaluate( dialogue &d ) const +double dbl_or_var::evaluate( const_dialogue const &d ) const { if( pair ) { return rng( min.evaluate( d ), max.evaluate( d ) ); @@ -196,7 +196,7 @@ double dbl_or_var::evaluate( dialogue &d ) const return min.evaluate( d ); } -time_duration duration_or_var_part::evaluate( dialogue &d ) const +time_duration duration_or_var_part::evaluate( const_dialogue const &d ) const { if( dur_val.has_value() ) { return dur_val.value(); @@ -221,13 +221,14 @@ time_duration duration_or_var_part::evaluate( dialogue &d ) const return 0_seconds; } if( math_val ) { - return time_duration::from_turns( math_val->act( d ) ); + dialogue loosey_goosey( d ); + return time_duration::from_turns( math_val->act( loosey_goosey ) ); } debugmsg( "No valid value for duration_or_var_part. %s", d.get_callstack() ); return 0_seconds; } -time_duration duration_or_var::evaluate( dialogue &d ) const +time_duration duration_or_var::evaluate( const_dialogue const &d ) const { if( pair ) { return rng( min.evaluate( d ), max.evaluate( d ) ); diff --git a/src/dialogue_helpers.h b/src/dialogue_helpers.h index 24ff4527fc71a..87ee6df1964e7 100644 --- a/src/dialogue_helpers.h +++ b/src/dialogue_helpers.h @@ -22,6 +22,7 @@ class JsonObject; class math_exp; class npc; struct dialogue; +struct const_dialogue; using talkfunction_ptr = std::add_pointer_t; using dialogue_fun_ptr = std::add_pointer_t; @@ -52,8 +53,8 @@ struct abstract_str_or_var { std::optional str_val; std::optional> var_val; std::optional default_val; - std::optional> function; - std::string evaluate( dialogue const & ) const; + std::optional> function; + std::string evaluate( const_dialogue const & ) const; }; using str_or_var = abstract_str_or_var; @@ -61,7 +62,7 @@ using translation_or_var = abstract_str_or_var; struct str_translation_or_var { std::variant val; - std::string evaluate( dialogue const & ) const; + std::string evaluate( const_dialogue const & ) const; }; struct talk_effect_fun_t { @@ -91,10 +92,10 @@ struct talk_effect_fun_t { }; template -std::string read_var_value( const abstract_var_info &info, const dialogue &d ); +std::string read_var_value( const abstract_var_info &info, const_dialogue const &d ); template std::optional maybe_read_var_value( - const abstract_var_info &info, const dialogue &d, int call_depth = 0 ); + const abstract_var_info &info, const_dialogue const &d, int call_depth = 0 ); var_info process_variable( const std::string &type ); @@ -141,7 +142,7 @@ struct dbl_or_var_part { std::optional var_val; std::optional default_val; std::optional math_val; - double evaluate( dialogue &d ) const; + double evaluate( const_dialogue const &d ) const; bool is_constant() const { return dbl_val.has_value(); @@ -169,7 +170,7 @@ struct dbl_or_var { bool pair = false; dbl_or_var_part min; dbl_or_var_part max; - double evaluate( dialogue &d ) const; + double evaluate( const_dialogue const &d ) const; bool is_constant() const { return !max && min.is_constant(); @@ -194,14 +195,14 @@ struct duration_or_var_part { std::optional var_val; std::optional default_val; std::optional math_val; - time_duration evaluate( dialogue &d ) const; + time_duration evaluate( const_dialogue const &d ) const; }; struct duration_or_var { bool pair = false; duration_or_var_part min; duration_or_var_part max; - time_duration evaluate( dialogue &d ) const; + time_duration evaluate( const_dialogue const &d ) const; }; #endif // CATA_SRC_DIALOGUE_HELPERS_H diff --git a/src/effect_on_condition.cpp b/src/effect_on_condition.cpp index 268ea51f73551..0084c75df6171 100644 --- a/src/effect_on_condition.cpp +++ b/src/effect_on_condition.cpp @@ -346,7 +346,7 @@ bool effect_on_condition::activate( dialogue &d, bool require_callstack_check ) return retval; } -bool effect_on_condition::check_deactivate( dialogue &d ) const +bool effect_on_condition::check_deactivate( const_dialogue const &d ) const { if( !has_deactivate_condition || has_false_effect ) { return false; @@ -354,7 +354,7 @@ bool effect_on_condition::check_deactivate( dialogue &d ) const return deactivate_condition( d ); } -bool effect_on_condition::test_condition( dialogue &d ) const +bool effect_on_condition::test_condition( const_dialogue const &d ) const { return !has_condition || condition( d ); } diff --git a/src/effect_on_condition.h b/src/effect_on_condition.h index 9055eb6928a71..0ac5b68bc268f 100644 --- a/src/effect_on_condition.h +++ b/src/effect_on_condition.h @@ -61,8 +61,8 @@ struct effect_on_condition { effect_on_condition_id id; std::vector> src; eoc_type type; - std::function condition; - std::function deactivate_condition; + std::function condition; + std::function deactivate_condition; talk_effect_t true_effect; talk_effect_t false_effect; bool has_deactivate_condition = false; @@ -71,8 +71,8 @@ struct effect_on_condition { event_type required_event; duration_or_var recurrence; bool activate( dialogue &d, bool require_callstack_check = true ) const; - bool check_deactivate( dialogue &d ) const; - bool test_condition( dialogue &d ) const; + bool check_deactivate( const_dialogue const &d ) const; + bool test_condition( const_dialogue const &d ) const; void apply_true_effects( dialogue &d ) const; void load( const JsonObject &jo, std::string_view src ); void finalize(); diff --git a/src/emit.h b/src/emit.h index 8d5510bca3222..bb1bdf00f937c 100644 --- a/src/emit.h +++ b/src/emit.h @@ -27,22 +27,22 @@ class emit bool is_valid() const; /** Type of field to emit @see emit::is_valid */ - field_type_id field( dialogue &d ) const { + field_type_id field( const_dialogue const &d ) const { return field_type_id( field_.evaluate( d ) ); } /** Intensity of output fields, range [1..maximum_intensity] */ - int intensity( dialogue &d ) const { + int intensity( const_dialogue const &d ) const { return intensity_.evaluate( d ); } /** Units of field to generate per turn subject to @ref chance */ - int qty( dialogue &d ) const { + int qty( const_dialogue const &d ) const { return qty_.evaluate( d ); } /** Chance to emit each turn, range [1..100] */ - int chance( dialogue &d ) const { + int chance( const_dialogue const &d ) const { return chance_.evaluate( d ); } diff --git a/src/end_screen.h b/src/end_screen.h index 78d092c3da818..d9b0722347b9d 100644 --- a/src/end_screen.h +++ b/src/end_screen.h @@ -21,7 +21,7 @@ struct end_screen { end_screen_id id; ascii_art_id picture_id; - std::function condition; + std::function condition; int priority; std::vector, std::string>> added_info; std::string last_words_label; diff --git a/src/faction_camp.cpp b/src/faction_camp.cpp index d60ada1c02e86..72246755e5f05 100644 --- a/src/faction_camp.cpp +++ b/src/faction_camp.cpp @@ -5760,16 +5760,10 @@ item basecamp::make_fake_food( const nutrients &to_use ) const item food_item( food_id ); // Set the default nutritional of the item. // This doesn't persist through save/load, but that's ok, we will be eating it immediately. - food_item.get_comestible()->default_nutrition = to_use; + food_item.get_comestible()->set_default_nutrition( to_use ); return food_item; } -static const npc &getAverageJoe() -{ - static npc averageJoe; - return averageJoe; -} - // mission support bool basecamp::distribute_food( bool player_command ) { @@ -5843,7 +5837,7 @@ bool basecamp::distribute_food( bool player_command ) if( it.rotten() ) { return false; } - nutrients from_it = getAverageJoe().compute_effective_nutrients( it ) * it.count(); + nutrients from_it = default_character_compute_effective_nutrients( it ) * it.count(); // Do this multiplication separately to make sure we're using the *= operator with double argument.. from_it *= rot_multip( it, container ); // Can distribute COMESTIBLE type items with 0kcal, if they have vitamins and player selected option to do so diff --git a/src/game.cpp b/src/game.cpp index fa9dc06cd8978..01192b1e1c59f 100644 --- a/src/game.cpp +++ b/src/game.cpp @@ -2716,8 +2716,8 @@ void game::setremoteveh( vehicle *veh ) } std::stringstream remote_veh_string; - const tripoint vehpos = veh->global_pos3(); - remote_veh_string << vehpos.x << ' ' << vehpos.y << ' ' << vehpos.z; + const tripoint_bub_ms vehpos = veh->pos_bub(); + remote_veh_string << vehpos.x() << ' ' << vehpos.y() << ' ' << vehpos.z(); u.set_value( "remote_controlling_vehicle", remote_veh_string.str() ); } @@ -5576,7 +5576,7 @@ void game::control_vehicle() { if( vehicle *remote_veh = remoteveh() ) { // remote controls have priority for( const vpart_reference &vpr : remote_veh->get_avail_parts( "REMOTE_CONTROLS" ) ) { - remote_veh->interact_with( vpr.pos() ); + remote_veh->interact_with( vpr.pos_bub() ); return; } } @@ -5690,7 +5690,7 @@ void game::control_vehicle() if( veh ) { // If we reached here, we gained control of a vehicle. // Clear the map memory for the area covered by the vehicle to eliminate ghost vehicles. - for( const tripoint &target : veh->get_points() ) { + for( const tripoint_bub_ms &target : veh->get_points() ) { u.memorize_clear_decoration( m.getglobal( target ), "vp_" ); m.memory_cache_dec_set_dirty( target, true ); } @@ -10026,7 +10026,7 @@ void game::reload_weapon( bool try_everything ) // If we make it here and haven't found anything to reload, start looking elsewhere. const optional_vpart_position ovp = m.veh_at( u.pos_bub() ); if( ovp ) { - const turret_data turret = ovp->vehicle().turret_query( ovp->pos() ); + const turret_data turret = ovp->vehicle().turret_query( ovp->pos_bub() ); if( turret.can_reload() ) { item::reload_option opt = u.select_ammo( turret.base(), true ); if( opt ) { diff --git a/src/grab.cpp b/src/grab.cpp index d92fed314076d..43729ceeceb57 100644 --- a/src/grab.cpp +++ b/src/grab.cpp @@ -148,7 +148,7 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) if( str_req <= str ) { if( str_req == max_str_req ) { //if vehicle has no wheels, make a noise. - sounds::sound( grabbed_vehicle->global_pos3(), str_req * 2, sounds::sound_t::movement, + sounds::sound( grabbed_vehicle->pos_bub(), str_req * 2, sounds::sound_t::movement, _( "a scraping noise." ), true, "misc", "scraping" ); } //calculate exertion factor and movement penalty @@ -217,7 +217,7 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) precalc_dir = mdir.dir(); } grabbed_vehicle->precalc_mounts( 1, precalc_dir, grabbed_vehicle->pivot_point() ); - grabbed_vehicle->pos -= grabbed_vehicle->pivot_displacement(); + grabbed_vehicle->pos -= grabbed_vehicle->pivot_displacement().raw(); // Grabbed part has to stay at distance 1 to the player // and in roughly the same direction. @@ -257,7 +257,7 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) const tripoint player_prev = u.pos(); u.setpos( tripoint_zero ); std::vector colls; - failed = grabbed_vehicle->collision( colls, actual_dir.raw(), true ); + failed = grabbed_vehicle->collision( colls, actual_dir, true ); u.setpos( player_prev ); if( !colls.empty() ) { blocker_name = colls.front().target_name; @@ -308,7 +308,7 @@ bool game::grabbed_veh_move( const tripoint_rel_ms &dp ) for( int p : wheel_indices ) { if( one_in( 2 ) ) { vehicle_part &vp_wheel = grabbed_vehicle->part( p ); - tripoint wheel_p = grabbed_vehicle->global_part_pos3( vp_wheel ); + tripoint_bub_ms wheel_p = grabbed_vehicle->bub_part_pos( vp_wheel ); grabbed_vehicle->handle_trap( wheel_p, vp_wheel ); } } diff --git a/src/handle_action.cpp b/src/handle_action.cpp index 27fefdaf1e496..cff4366343f47 100644 --- a/src/handle_action.cpp +++ b/src/handle_action.cpp @@ -567,7 +567,7 @@ static void pldrive( const tripoint &p ) return; } } - veh->pldrive( get_avatar(), p.xy(), p.z ); + veh->pldrive( get_avatar(), p.x, p.y, p.z ); } static void pldrive( point d ) @@ -763,7 +763,7 @@ static void grab() //solid vehicles can't be grabbed while boarded const optional_vpart_position vp_boarded = here.veh_at( you.pos_bub() ); if( vp_boarded ) { - const std::set grabbed_veh_points = vp->vehicle().get_points(); + const std::set grabbed_veh_points = vp->vehicle().get_points(); if( &vp_boarded->vehicle() == &vp->vehicle() && !empty( vp->vehicle().get_avail_parts( VPFLAG_OBSTACLE ) ) ) { add_msg( m_info, _( "You can't move the %s while you're boarding it." ), veh_name ); @@ -1769,7 +1769,7 @@ static void fire() } // try firing turrets if( const optional_vpart_position ovp = here.veh_at( you.pos_bub() ) ) { - if( turret_data turret_here = ovp->vehicle().turret_query( you.pos() ) ) { + if( turret_data turret_here = ovp->vehicle().turret_query( you.pos_bub() ) ) { if( avatar_action::fire_turret_manual( you, here, turret_here ) ) { return; } diff --git a/src/handle_liquid.cpp b/src/handle_liquid.cpp index 11f11fe5f62c6..1682aa2a9fcb4 100644 --- a/src/handle_liquid.cpp +++ b/src/handle_liquid.cpp @@ -54,9 +54,9 @@ static void serialize_liquid_source( player_activity &act, const vehicle &veh, c act.values.push_back( static_cast( liquid_source_type::VEHICLE ) ); act.values.push_back( part_num ); if( part_num != -1 ) { - act.coords.push_back( veh.global_part_pos3( part_num ) ); + act.coords.push_back( veh.bub_part_pos( part_num ).raw() ); } else { - act.coords.push_back( veh.global_pos3() ); + act.coords.push_back( veh.pos_bub().raw() ); } act.str_values.push_back( serialize( liquid ) ); } @@ -84,7 +84,7 @@ static void serialize_liquid_target( player_activity &act, const vpart_reference { act.values.push_back( static_cast( liquid_target_type::VEHICLE ) ); act.values.push_back( 0 ); // dummy - act.coords.push_back( vp.vehicle().global_part_pos3( 0 ) ); + act.coords.push_back( vp.vehicle().bub_part_pos( 0 ).raw() ); act.values.push_back( vp.part_index() ); // tank part index } diff --git a/src/iexamine.cpp b/src/iexamine.cpp index 8db1d010ba701..7c4a79bf7eec2 100644 --- a/src/iexamine.cpp +++ b/src/iexamine.cpp @@ -1365,7 +1365,8 @@ void iexamine::elevator( Character &you, const tripoint_bub_ms &examp ) } for( vehicle *v : vehs.v ) { - tripoint_bub_ms const p = tripoint_bub_ms( _rotate_point_sm( { v->global_pos3().xy(), movez }, erot, + tripoint_bub_ms const p = tripoint_bub_ms( _rotate_point_sm( { v->pos_bub().xy().raw(), movez}, + erot, sm_orig.raw() ) ); here.displace_vehicle( *v, p - v->pos_bub() ); v->turn( erot * 90_degrees ); diff --git a/src/item.cpp b/src/item.cpp index a87619a3c355d..8e216705754fd 100644 --- a/src/item.cpp +++ b/src/item.cpp @@ -7661,10 +7661,7 @@ bool item::has_vitamin( const vitamin_id &v ) const if( !this->is_comestible() ) { return false; } - // We need this function to get all vitamins including from inheritance. - // But we don't care about calories, so we can just pass a dummy. - npc dummy; - const nutrients food_item = dummy.compute_effective_nutrients( *this ); + const nutrients food_item = default_character_compute_effective_nutrients( *this ); for( auto const& [vit_id, amount] : food_item.vitamins() ) { if( vit_id == v ) { if( amount > 0 ) { @@ -8675,8 +8672,8 @@ bool item::made_of_any_food_components( bool deep_search ) const for( const std::pair> pair : components ) { for( const item &it : pair.second ) { const auto &maybe_food = it.get_comestible(); - bool must_be_food = maybe_food && ( maybe_food->default_nutrition.kcal() > 0 || - !maybe_food->default_nutrition.vitamins().empty() ); + bool must_be_food = maybe_food && ( maybe_food->default_nutrition_read_only().kcal() > 0 || + !maybe_food->default_nutrition_read_only().vitamins().empty() ); bool has_food_component = false; if( deep_search && !it.components.empty() ) { // make true if any component has food values, even if some don't @@ -13685,12 +13682,12 @@ ret_val item::link_to( vehicle &veh, const point_rel_ms &mount, link_state } // Prepare target tripoints for the cable parts that'll be added to the selected/previous vehicles - const std::pair prev_part_target = std::make_pair( - ( veh.global_square_location() + veh.coord_translate( mount ) ).raw(), - veh.global_square_location().raw() ); - const std::pair sel_part_target = std::make_pair( - ( link().t_abs_pos + prev_veh->coord_translate( link().t_mount ) ).raw(), - link().t_abs_pos.raw() ); + const std::pair prev_part_target = std::make_pair( + veh.global_square_location() + veh.coord_translate( mount ), + veh.global_square_location() ); + const std::pair sel_part_target = std::make_pair( + link().t_abs_pos + prev_veh->coord_translate( link().t_mount ), + link().t_abs_pos ); for( const vpart_reference &vpr : prev_veh->get_any_parts( VPFLAG_POWER_TRANSFER ) ) { if( vpr.part().target.first == prev_part_target.first && diff --git a/src/item_location.cpp b/src/item_location.cpp index b4ed5a80fd490..76190f63e349e 100644 --- a/src/item_location.cpp +++ b/src/item_location.cpp @@ -485,7 +485,7 @@ class item_location::impl::item_on_vehicle : public item_location::impl } tripoint position() const override { - return cur.veh.global_part_pos3( cur.part ); + return cur.veh.bub_part_pos( cur.part ).raw(); } Character *carrier() const override { @@ -534,7 +534,7 @@ class item_location::impl::item_on_vehicle : public item_location::impl item *obj = target(); int mv = ch.item_handling_cost( *obj, true, VEHICLE_HANDLING_PENALTY, qty ); - mv += 100 * rl_dist( ch.pos(), cur.veh.global_part_pos3( cur.part ) ); + mv += 100 * rl_dist( ch.pos_bub(), cur.veh.bub_part_pos( cur.part ) ); // TODO: handle unpacking costs @@ -1165,7 +1165,7 @@ std::unique_ptr get_talker_for( item_location &it ) { return std::make_unique( &it ); } -std::unique_ptr get_talker_for( const item_location &it ) +std::unique_ptr get_const_talker_for( const item_location &it ) { return std::make_unique( &it ); } diff --git a/src/item_location.h b/src/item_location.h index 23a662f18dbe7..c5f4d5bec1728 100644 --- a/src/item_location.h +++ b/src/item_location.h @@ -16,6 +16,7 @@ class item_pocket; class map_cursor; class vehicle_cursor; class talker; +class const_talker; struct tripoint; template class ret_val; @@ -170,6 +171,6 @@ class item_location std::shared_ptr ptr; }; std::unique_ptr get_talker_for( item_location &it ); -std::unique_ptr get_talker_for( const item_location &it ); +std::unique_ptr get_const_talker_for( const item_location &it ); std::unique_ptr get_talker_for( item_location *it ); #endif // CATA_SRC_ITEM_LOCATION_H diff --git a/src/itype.h b/src/itype.h index 6c502a79b8e9b..99c12781cc565 100644 --- a/src/itype.h +++ b/src/itype.h @@ -133,10 +133,6 @@ struct islot_comestible { /** effect on character thirst (may be negative) */ int quench = 0; - /** Nutrition values to use for this type when they aren't calculated from - * components */ - nutrients default_nutrition; - /** Time until becomes rotten at standard temperature, or zero if never spoils */ time_duration spoils = 0_turns; @@ -155,6 +151,19 @@ struct islot_comestible { /** Reference to item that will be received after smoking current item */ itype_id smoking_result; + /* + * For the few rare cases where default nutrition needs to be accessible. Prefer using + * default_character_compute_effective_nutrients unless absolutely necessary. + */ + nutrients default_nutrition_read_only() const { + return default_nutrition; + } + + /** For the one case where default nutrition needs to be overridden. */ + void set_default_nutrition( nutrients new_nutrition ) { + default_nutrition = std::move( new_nutrition ); + }; + /** TODO: add documentation */ int healthy = 0; @@ -204,6 +213,10 @@ struct islot_comestible { std::pair rot_spawn_monster_amount = {1, 1}; private: + /** Nutrition values to use for this type when they aren't calculated from + * components */ + nutrients default_nutrition; + /** effect on morale when consuming */ int fun = 0; diff --git a/src/iuse.cpp b/src/iuse.cpp index 58ef64e436764..92d30ae8741ae 100644 --- a/src/iuse.cpp +++ b/src/iuse.cpp @@ -1234,7 +1234,7 @@ std::optional iuse::purify_smart( Character *p, item *it, const tripoint & item syringe( "syringe", it->birthday() ); p->i_add( syringe ); - p->vitamins_mod( it->get_comestible()->default_nutrition.vitamins() ); + p->vitamins_mod( default_character_compute_effective_nutrients( *it ).vitamins() ); get_event_bus().send( p->getID(), mutagen_technique::injected_smart_purifier ); return 1; @@ -1615,7 +1615,7 @@ std::optional iuse::petfood( Character *p, item *it, const tripoint & ) p->add_msg_if_player( _( "You feed your %1$s to the %2$s." ), it->tname(), mon->get_name() ); if( !mon->has_fully_eaten() && mon->has_flag( mon_flag_EATS ) ) { - int kcal = it->get_comestible()->default_nutrition.kcal(); + int kcal = default_character_compute_effective_nutrients( *it ).kcal(); mon->mod_amount_eaten( kcal ); if( mon->has_fully_eaten() ) { p->add_msg_if_player( _( "The %1$s seems full now." ), mon->get_name() ); @@ -3858,13 +3858,36 @@ static std::string get_music_description() } void iuse::play_music( Character *p, const tripoint &source, const int volume, - const int max_morale ) + const int max_morale, bool play_sounds ) { - // TODO: what about other "player", e.g. when a NPC is listening or when the PC is listening, - // the other characters around should be able to profit as well. - const bool do_effects = p && p->can_hear( source, volume ) && !p->in_sleep_state(); std::string sound = "music"; + auto lambda_should_do_effects = [&source, &volume]( Character * p ) { + return p && p->can_hear( source, volume ) && !p->in_sleep_state(); + }; + + auto lambda_add_music_effects = [&max_morale, &volume]( Character & guy ) { + guy.add_effect( effect_music, 1_turns ); + guy.add_morale( morale_music, 1, max_morale, 5_minutes, 2_minutes, true ); + // mp3 player reduces hearing + if( volume == 0 ) { + guy.add_effect( effect_earphones, 1_turns ); + } + }; + + // check NPCs that can hear the source of the music + for( npc &guy : g->all_npcs() ) { + if( guy.is_active() && lambda_should_do_effects( &guy ) ) { + lambda_add_music_effects( guy ); + } + } + + // player is not a NPC so they need to check separately + Character &player_character = get_player_character(); + if( lambda_should_do_effects( &player_character ) ) { + lambda_add_music_effects( player_character ); + } + if( calendar::once_every( time_duration::from_minutes( get_option( "DESCRIBE_MUSIC_FREQUENCY" ) ) ) ) { // Every X minutes, describe the music @@ -3872,24 +3895,15 @@ void iuse::play_music( Character *p, const tripoint &source, const int volume, if( !music.empty() ) { sound = music; // descriptions aren't printed for sounds at our position - if( do_effects && p->pos() == source ) { + if( lambda_should_do_effects( p ) && p->pos() == source ) { p->add_msg_if_player( _( "You listen to %s" ), music ); } } } - if( volume != 0 ) { + if( volume != 0 && play_sounds ) { sounds::ambient_sound( source, volume, sounds::sound_t::music, sound ); } - - if( do_effects ) { - p->add_effect( effect_music, 1_turns ); - p->add_morale( morale_music, 1, max_morale, 5_minutes, 2_minutes, true ); - // mp3 player reduces hearing - if( volume == 0 ) { - p->add_effect( effect_earphones, 1_turns ); - } - } } std::optional iuse::mp3_on( Character *p, item *, const tripoint &pos ) @@ -7356,7 +7370,7 @@ static vehicle *pickveh( const tripoint ¢er, bool advanced ) for( wrapped_vehicle &veh : get_map().get_vehicles() ) { vehicle *&v = veh.v; - if( rl_dist( center, v->global_pos3() ) < 40 && + if( rl_dist( center, v->pos_bub().raw() ) < 40 && v->fuel_left( itype_battery ) > 0 && ( !empty( v->get_avail_parts( advctrl ) ) || ( !advanced && !empty( v->get_avail_parts( ctrl ) ) ) ) ) { @@ -7366,7 +7380,7 @@ static vehicle *pickveh( const tripoint ¢er, bool advanced ) std::vector locations; for( int i = 0; i < static_cast( vehs.size() ); i++ ) { vehicle *veh = vehs[i]; - locations.push_back( veh->global_pos3() ); + locations.push_back( veh->pos_bub().raw() ); pmenu.addentry( i, true, MENU_AUTOASSIGN, veh->name ); } @@ -7461,9 +7475,9 @@ std::optional iuse::remoteveh( Character *p, item *it, const tripoint &pos const auto electronics_parts = veh->get_avail_parts( "CTRL_ELECTRONIC" ); // Revert to original behavior if we can't find remote controls. if( empty( rctrl_parts ) ) { - veh->interact_with( electronics_parts.begin()->pos() ); + veh->interact_with( electronics_parts.begin()->pos_bub() ); } else { - veh->interact_with( rctrl_parts.begin()->pos() ); + veh->interact_with( rctrl_parts.begin()->pos_bub() ); } } diff --git a/src/iuse.h b/src/iuse.h index df15797bcb200..1136195e78b84 100644 --- a/src/iuse.h +++ b/src/iuse.h @@ -224,7 +224,8 @@ std::optional disassemble( Character *, item *, const tripoint & ); // Helper functions for other iuse functions void cut_log_into_planks( Character & ); -void play_music( Character *p, const tripoint &source, int volume, int max_morale ); +void play_music( Character *p, const tripoint &source, int volume, int max_morale, + bool play_sounds = true ); std::optional purify_water( Character *p, item *purifier, item_location &water ); int towel_common( Character *, item *, bool ); diff --git a/src/iuse_actor.cpp b/src/iuse_actor.cpp index 6f8cdc4a183f2..5a996d5f2060b 100644 --- a/src/iuse_actor.cpp +++ b/src/iuse_actor.cpp @@ -137,7 +137,6 @@ static const itype_id itype_syringe( "syringe" ); static const json_character_flag json_flag_BIONIC_LIMB( "BIONIC_LIMB" ); static const json_character_flag json_flag_MANUAL_CBM_INSTALLATION( "MANUAL_CBM_INSTALLATION" ); -static const morale_type morale_music( "morale_music" ); static const morale_type morale_pyromania_nofire( "morale_pyromania_nofire" ); static const morale_type morale_pyromania_startfire( "morale_pyromania_startfire" ); @@ -2265,14 +2264,14 @@ std::optional musical_instrument_actor::use( Character *p, item &it, if( !p->has_effect( effect_music ) && p->can_hear( p->pos(), volume ) ) { // Sound code doesn't describe noises at the player position - if( p->is_avatar() && desc != "music" ) { - add_msg( m_info, desc ); + if( desc != "music" ) { + p->add_msg_if_player( m_info, desc ); } - p->add_effect( effect_music, 1_turns ); - const int sign = morale_effect > 0 ? 1 : -1; - p->add_morale( morale_music, sign, morale_effect, 5_minutes, 2_minutes, true ); } + // We already played the sounds, just handle applying effects now + iuse::play_music( p, p->pos(), volume, morale_effect, /*play_sounds=*/false ); + return 0; } diff --git a/src/magic.cpp b/src/magic.cpp index c44009cca5b70..c27c5b2eb9bd3 100644 --- a/src/magic.cpp +++ b/src/magic.cpp @@ -722,7 +722,7 @@ skill_id spell::skill() const int spell::field_intensity( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return std::min( static_cast( type->max_field_intensity.evaluate( d ) ), static_cast( type->min_field_intensity.evaluate( d ) + std::round( get_effective_level() * type->field_intensity_increment.evaluate( d ) ) ) ); @@ -730,7 +730,7 @@ int spell::field_intensity( const Creature &caster ) const double spell::bash_scaling( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); const double leveled_scaling = type->min_bash_scaling.evaluate( d ) + get_effective_level() * type->bash_scaling_increment.evaluate( d ); if( has_flag( spell_flag::RANDOM_DAMAGE ) ) { @@ -749,7 +749,7 @@ double spell::bash_scaling( const Creature &caster ) const int spell::min_leveled_damage( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return type->min_damage.evaluate( d ) + std::round( get_effective_level() * type->damage_increment.evaluate( d ) ); @@ -769,7 +769,7 @@ float spell::dps( const Character &caster, const Creature & ) const int spell::damage( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); const int leveled_damage = min_leveled_damage( caster ); if( has_flag( spell_flag::RANDOM_DAMAGE ) ) { @@ -790,14 +790,14 @@ int spell::damage( const Creature &caster ) const int spell::min_leveled_accuracy( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return type->min_accuracy.evaluate( d ) + std::round( get_effective_level() * type->accuracy_increment.evaluate( d ) ); } int spell::accuracy( Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); const int leveled_accuracy = min_leveled_accuracy( caster ); if( type->min_accuracy.evaluate( d ) >= 0 || type->max_accuracy.evaluate( d ) >= type->min_accuracy.evaluate( d ) ) { @@ -809,14 +809,14 @@ int spell::accuracy( Creature &caster ) const double spell::min_leveled_dot( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return type->min_dot.evaluate( d ) + std::round( get_effective_level() * type->dot_increment.evaluate( d ) ); } double spell::damage_dot( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); const double leveled_dot = min_leveled_dot( caster ); if( type->min_dot.evaluate( d ) >= 0.0 || type->max_dot.evaluate( d ) >= type->min_dot.evaluate( d ) ) { @@ -840,7 +840,7 @@ damage_over_time_data spell::damage_over_time( const std::vector &b std::string spell::damage_string( const Character &caster ) const { std::string damage_string; - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); if( has_flag( spell_flag::RANDOM_DAMAGE ) ) { damage_string = string_format( "%d-%d", min_leveled_damage( caster ), static_cast( type->max_damage.evaluate( d ) ) ); @@ -914,14 +914,14 @@ std::optional spell::select_target( Creature *source ) int spell::min_leveled_aoe( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return type->min_aoe.evaluate( d ) + std::round( get_effective_level() * type->aoe_increment.evaluate( d ) ); } int spell::aoe( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); const int leveled_aoe = min_leveled_aoe( caster ); int return_value; @@ -953,7 +953,7 @@ std::set spell::effect_area( const tripoint_bub_ms &source, bool spell::in_aoe( const tripoint_bub_ms &source, const tripoint_bub_ms &target, const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); if( has_flag( spell_flag::RANDOM_AOE ) ) { return rl_dist( source, target ) <= type->max_aoe.evaluate( d ); } else { @@ -963,7 +963,7 @@ bool spell::in_aoe( const tripoint_bub_ms &source, const tripoint_bub_ms &target std::string spell::aoe_string( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); if( has_flag( spell_flag::RANDOM_AOE ) ) { return string_format( "%d-%d", min_leveled_aoe( caster ), type->max_aoe.evaluate( d ) ); } else { @@ -973,7 +973,7 @@ std::string spell::aoe_string( const Creature &caster ) const int spell::range( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); const int leveled_range = type->min_range.evaluate( d ) + std::round( get_effective_level() * type->range_increment.evaluate( d ) ); float range; @@ -1026,14 +1026,14 @@ std::vector spell::targetable_locations( const Character &sourc int spell::min_leveled_duration( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return type->min_duration.evaluate( d ) + std::round( get_effective_level() * type->duration_increment.evaluate( d ) ); } int spell::duration( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); const int leveled_duration = min_leveled_duration( caster ); int return_value; if( has_flag( spell_flag::RANDOM_DURATION ) ) { @@ -1053,7 +1053,7 @@ int spell::duration( const Creature &caster ) const std::string spell::duration_string( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); if( has_flag( spell_flag::RANDOM_DURATION ) ) { return string_format( "%s - %s", moves_to_string( min_leveled_duration( caster ) ), moves_to_string( type->max_duration.evaluate( d ) ) ); @@ -1094,7 +1094,7 @@ void spell::set_level( const Character &guy, int nlevel ) bool spell::is_max_level( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return get_level() >= type->max_level.evaluate( d ); } @@ -1108,14 +1108,14 @@ bool spell::can_learn( const Character &guy ) const int spell::get_amount_of_projectiles( const Creature &guy ) const { - dialogue d( get_talker_for( guy ), nullptr ); + const_dialogue d( get_const_talker_for( guy ), nullptr ); return type->multiple_projectiles.evaluate( d ); } int spell::energy_cost( const Character &guy ) const { int cost; - dialogue d( get_talker_for( guy ), nullptr ); + const_dialogue d( get_const_talker_for( guy ), nullptr ); if( type->base_energy_cost.evaluate( d ) < type->final_energy_cost.evaluate( d ) ) { cost = std::min( static_cast( type->final_energy_cost.evaluate( d ) ), static_cast( std::round( type->base_energy_cost.evaluate( d ) + @@ -1229,7 +1229,7 @@ bool spell::check_if_component_in_hand( Character &guy ) const int spell::get_difficulty( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return type->difficulty.evaluate( d ) + temp_difficulty_adjustment; } @@ -1242,7 +1242,7 @@ int spell::casting_time( const Character &guy, bool ignore_encumb ) const { // casting time in moves int casting_time = 0; - dialogue d( get_talker_for( guy ), nullptr ); + const_dialogue d( get_const_talker_for( guy ), nullptr ); if( type->base_casting_time.evaluate( d ) < type->final_casting_time.evaluate( d ) ) { casting_time = std::min( static_cast( type->final_casting_time.evaluate( d ) ), static_cast( std::round( type->base_casting_time.evaluate( d ) + @@ -1517,7 +1517,7 @@ void spell::create_field( const tripoint_bub_ms &at, Creature &caster ) const if( !type->field ) { return; } - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); const int intensity = field_intensity( caster ) + rng( -type->field_intensity_variance.evaluate( d ) * field_intensity( caster ), type->field_intensity_variance.evaluate( d ) * field_intensity( caster ) ); @@ -1690,7 +1690,7 @@ int spell::get_effective_level() const int spell::get_max_level( const Creature &caster ) const { - dialogue d( get_talker_for( caster ), nullptr ); + const_dialogue d( get_const_talker_for( caster ), nullptr ); return type->max_level.evaluate( d ); } @@ -2416,7 +2416,7 @@ int known_magic::time_to_learn_spell( const Character &guy, const std::string &s int known_magic::time_to_learn_spell( const Character &guy, const spell_id &sp ) const { - dialogue d( get_talker_for( guy ), nullptr ); + const_dialogue d( get_const_talker_for( guy ), nullptr ); const int base_time = to_moves( 30_minutes ); const double int_modifier = ( guy.get_int() - 8.0 ) / 8.0; const double skill_modifier = guy.get_skill_level( sp->skill ) / 10.0; diff --git a/src/magic_enchantment.cpp b/src/magic_enchantment.cpp index e3a88192cb6c3..f6e9ddb67cfdd 100644 --- a/src/magic_enchantment.cpp +++ b/src/magic_enchantment.cpp @@ -316,7 +316,7 @@ bool enchantment::is_active( const Character &guy, const bool active ) const } if( active_conditions.second == condition::DIALOG_CONDITION ) { - dialogue d( get_talker_for( guy ), nullptr ); + const_dialogue d( get_const_talker_for( guy ), nullptr ); return dialog_condition( d ); } return false; @@ -734,7 +734,7 @@ void enchant_cache::force_add( const enchant_cache &rhs ) void enchant_cache::force_add( const enchantment &rhs, const Character &guy ) { - dialogue d( get_talker_for( guy ), nullptr ); + const_dialogue d( get_const_talker_for( guy ), nullptr ); for( const std::pair &pair_values : rhs.values_add ) { values_add[pair_values.first] += pair_values.second.evaluate( d ); @@ -796,7 +796,7 @@ void enchant_cache::force_add( const enchantment &rhs, const Character &guy ) void enchant_cache::force_add( const enchantment &rhs, const monster &mon ) { - dialogue d( get_talker_for( mon ), nullptr ); + const_dialogue d( get_const_talker_for( mon ), nullptr ); for( const std::pair &pair_values : rhs.values_add ) { values_add[pair_values.first] += pair_values.second.evaluate( d ); @@ -948,7 +948,7 @@ double enchantment::get_value_add( const enchant_vals::mod value, const Characte if( found == values_add.cend() ) { return 0; } - dialogue d( get_talker_for( guy ), nullptr ); + const_dialogue d( get_const_talker_for( guy ), nullptr ); return found->second.evaluate( d ); } @@ -958,7 +958,7 @@ double enchantment::get_value_multiply( const enchant_vals::mod value, const Cha if( found == values_multiply.cend() ) { return 0; } - dialogue d( get_talker_for( guy ), nullptr ); + const_dialogue d( get_const_talker_for( guy ), nullptr ); return found->second.evaluate( d ); } diff --git a/src/magic_enchantment.h b/src/magic_enchantment.h index fb66518bac207..9beb4286cac7b 100644 --- a/src/magic_enchantment.h +++ b/src/magic_enchantment.h @@ -273,7 +273,7 @@ class enchantment std::map> intermittent_activation; std::pair active_conditions; - std::function dialog_condition; // NOLINT(cata-serialize) + std::function dialog_condition; // NOLINT(cata-serialize) void add_activation( const time_duration &dur, const fake_spell &fake ); }; diff --git a/src/map.cpp b/src/map.cpp index 920f3105e8862..17515049eb394 100644 --- a/src/map.cpp +++ b/src/map.cpp @@ -389,7 +389,7 @@ void map::memory_cache_ter_set_dirty( const tripoint_bub_ms &p, bool value ) con void map::memory_clear_vehicle_points( const vehicle &veh ) const { avatar &player_character = get_avatar(); - for( const tripoint &p : veh.get_points() ) { + for( const tripoint_bub_ms &p : veh.get_points() ) { if( !inbounds( p ) ) { continue; } @@ -625,7 +625,7 @@ std::unique_ptr map::detach_vehicle( vehicle *veh ) level_cache &ch = get_cache( z ); for( size_t i = 0; i < current_submap->vehicles.size(); i++ ) { if( current_submap->vehicles[i].get() == veh ) { - for( const tripoint &pt : veh->get_points() ) { + for( const tripoint_bub_ms &pt : veh->get_points() ) { if( inbounds( pt ) ) { memory_cache_dec_set_dirty( pt, true ); } @@ -669,7 +669,7 @@ void map::vehmove() VehicleList vehicle_list; int minz = zlevels ? -OVERMAP_DEPTH : abs_sub.z(); int maxz = zlevels ? OVERMAP_HEIGHT : abs_sub.z(); - const tripoint_bub_ms player_pos = get_player_character().pos_bub(); + const tripoint_abs_ms player_pos = get_player_character().get_location(); for( int zlev = minz; zlev <= maxz; ++zlev ) { level_cache *cache_lazy = get_cache_lazy( zlev ); if( !cache_lazy ) { @@ -678,7 +678,7 @@ void map::vehmove() level_cache &cache = *cache_lazy; for( vehicle *veh : cache.vehicle_list ) { if( veh->is_following ) { - veh->drive_to_local_target( getglobal( player_pos ).raw(), true ); + veh->drive_to_local_target( player_pos, true ); } else if( veh->is_patrolling ) { veh->autopilot_patrol(); } @@ -770,7 +770,7 @@ bool map::vehproceed( VehicleList &vehicle_list ) static bool sees_veh( const Creature &c, vehicle &veh, bool force_recalc ) { const auto &veh_points = veh.get_points( force_recalc ); - return std::any_of( veh_points.begin(), veh_points.end(), [&c]( const tripoint & pt ) { + return std::any_of( veh_points.begin(), veh_points.end(), [&c]( const tripoint_bub_ms & pt ) { return c.sees( pt ); } ); } @@ -835,7 +835,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const tiler size_t collision_attempts = 10; do { collisions.clear(); - veh.collision( collisions, dp1.raw(), false ); + veh.collision( collisions, dp1, false ); // Vehicle collisions std::map > veh_collisions; @@ -896,7 +896,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const tiler veh.stop_autodriving(); const int volume = std::min( 100, std::sqrt( impulse ) ); // TODO: Center the sound at weighted (by impulse) average of collisions - sounds::sound( veh.global_pos3(), volume, sounds::sound_t::combat, _( "crash!" ), + sounds::sound( veh.pos_bub(), volume, sounds::sound_t::combat, _( "crash!" ), false, "smash_success", "hit_vehicle" ); } @@ -909,7 +909,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const tiler if( !vertical && !veh.valid_wheel_config() && !( veh.is_watercraft() && veh.can_float() ) && !veh.is_flying_in_air() && dp.z() == 0 ) { veh.velocity -= std::clamp( veh.velocity, -2000, 2000 ); // extra drag - for( const tripoint &p : veh.get_points() ) { + for( const tripoint_bub_ms &p : veh.get_points() ) { const ter_id &pter = ter( p ); if( pter == ter_t_dirt || pter == ter_t_grass ) { ter_set( p, ter_t_dirtmound ); @@ -983,7 +983,7 @@ vehicle *map::move_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const tiler "environment", "splash" ); } - veh.handle_trap( wheel_p.raw(), vp_wheel ); + veh.handle_trap( wheel_p, vp_wheel ); // dont use vp_wheel or vp_wheel_idx below this - handle_trap might've removed it from parts if( !has_flag( ter_furn_flag::TFLAG_SEALED, wheel_p ) ) { @@ -1076,16 +1076,16 @@ float map::vehicle_vehicle_collision( vehicle &veh, vehicle &veh2, 0.5 * m2 * velo_veh2.magnitude() * velo_veh2.magnitude(); // Collision_axis - point cof1 = veh .rotated_center_of_mass(); - point cof2 = veh2.rotated_center_of_mass(); - int &x_cof1 = cof1.x; - int &y_cof1 = cof1.y; - int &x_cof2 = cof2.x; - int &y_cof2 = cof2.y; + point_rel_ms cof1 = veh .rotated_center_of_mass(); + point_rel_ms cof2 = veh2.rotated_center_of_mass(); + int &x_cof1 = cof1.x(); + int &y_cof1 = cof1.y(); + int &x_cof2 = cof2.x(); + int &y_cof2 = cof2.y(); rl_vec2d collision_axis_y; - collision_axis_y.x = ( veh.global_pos3().x + x_cof1 ) - ( veh2.global_pos3().x + x_cof2 ); - collision_axis_y.y = ( veh.global_pos3().y + y_cof1 ) - ( veh2.global_pos3().y + y_cof2 ); + collision_axis_y.x = ( veh.pos_bub().x() + x_cof1 ) - ( veh2.pos_bub().x() + x_cof2 ); + collision_axis_y.y = ( veh.pos_bub().y() + y_cof1 ) - ( veh2.pos_bub().y() + y_cof2 ); collision_axis_y = collision_axis_y.normalized(); rl_vec2d collision_axis_x = collision_axis_y.rotated( M_PI / 2 ); // imp? & delta? & final? reworked: @@ -1324,7 +1324,7 @@ VehicleList map::get_vehicles( const tripoint_bub_ms &start, const tripoint_bub_ elem->sm_pos.z = cz; wrapped_vehicle w; w.v = elem.get(); - w.pos = w.v->global_pos3(); + w.pos = w.v->pos_bub().raw(); vehs.push_back( w ); } } @@ -1608,7 +1608,7 @@ bool map::displace_vehicle( vehicle &veh, const tripoint_rel_ms &dp, const bool if( src_submap != dst_submap ) { dst_submap->ensure_nonuniform(); - veh.set_submap_moved( tripoint( dst.x() / SEEX, dst.y() / SEEY, dst.z() ) ); + veh.set_submap_moved( { dst.x() / SEEX, dst.y() / SEEY, dst.z() } ); auto src_submap_veh_it = src_submap->vehicles.begin() + our_i; dst_submap->vehicles.push_back( std::move( *src_submap_veh_it ) ); src_submap->vehicles.erase( src_submap_veh_it ); @@ -5848,8 +5848,8 @@ void map::process_items() level_cache &cache = access_cache( gz ); std::set submaps_with_vehicles; for( vehicle *this_vehicle : cache.vehicle_list ) { - tripoint pos = this_vehicle->global_pos3(); - submaps_with_vehicles.emplace( pos.x / SEEX, pos.y / SEEY, pos.z ); + tripoint_bub_ms pos = this_vehicle->pos_bub(); + submaps_with_vehicles.emplace( pos.x() / SEEX, pos.y() / SEEY, pos.z() ); } for( const tripoint &pos : submaps_with_vehicles ) { submap *const current_submap = get_submap_at_grid( tripoint_rel_sm( pos ) ); @@ -7529,7 +7529,7 @@ bool map::draw_maptile( const catacurses::window &w, const tripoint_bub_ms &p, if( !veh->forward_velocity() && !veh->player_in_control( player_character ) && !( player_character.get_grab_type() == object_type::VEHICLE && veh->get_points().count( ( player_character.pos_bub() + - player_character.grab_point ).raw() ) ) ) { + player_character.grab_point ) ) ) ) { memory_sym = sym; } } @@ -9906,25 +9906,25 @@ static void vehicle_caching_internal( level_cache &zch, const vpart_reference &v auto &floor_cache = zch.floor_cache; const size_t part = vp.part_index(); - const tripoint part_pos = v->global_part_pos3( vp.part() ); + const tripoint_bub_ms part_pos = v->bub_part_pos( vp.part() ); bool vehicle_is_opaque = vp.has_feature( VPFLAG_OPAQUE ) && !vp.part().is_broken(); if( vehicle_is_opaque ) { int dpart = v->part_with_feature( part, VPFLAG_OPENABLE, true ); if( dpart < 0 || !v->part( dpart ).open ) { - transparency_cache[part_pos.x][part_pos.y] = LIGHT_TRANSPARENCY_SOLID; + transparency_cache[part_pos.x()][part_pos.y()] = LIGHT_TRANSPARENCY_SOLID; } else { vehicle_is_opaque = false; } } if( vehicle_is_opaque || vp.is_inside() ) { - outside_cache[part_pos.x][part_pos.y] = false; + outside_cache[part_pos.x()][part_pos.y()] = false; } if( vp.has_feature( VPFLAG_BOARDABLE ) && !vp.part().is_broken() ) { - floor_cache[part_pos.x][part_pos.y] = true; + floor_cache[part_pos.x()][part_pos.y()] = true; } } @@ -9932,8 +9932,8 @@ static void vehicle_caching_internal_above( level_cache &zch_above, const vpart_ vehicle *v ) { if( vp.has_feature( VPFLAG_ROOF ) || vp.has_feature( VPFLAG_OPAQUE ) ) { - const tripoint part_pos = v->global_part_pos3( vp.part() ); - zch_above.floor_cache[part_pos.x][part_pos.y] = true; + const tripoint_bub_ms part_pos = v->bub_part_pos( vp.part() ); + zch_above.floor_cache[part_pos.x()][part_pos.y()] = true; } } @@ -10048,7 +10048,7 @@ void map::set_abs_sub( const tripoint_abs_sm &p ) { abs_sub = p; abs_ms = point_abs_ms{ project_to( abs_sub.xy() ) }; -}; +} tripoint_abs_sm map::get_abs_sub() const { diff --git a/src/map_extras.cpp b/src/map_extras.cpp index e9a137694a77c..4c3a8191beebd 100644 --- a/src/map_extras.cpp +++ b/src/map_extras.cpp @@ -445,10 +445,10 @@ static bool mx_helicopter( map &m, const tripoint &abs_sub ) break; } if( !one_in( 4 ) ) { - wreckage->smash( m, 0.8f, 1.2f, 1.0f, point( dice( 1, 8 ) - 5, dice( 1, 8 ) - 5 ), 6 + dice( 1, + wreckage->smash( m, 0.8f, 1.2f, 1.0f, { dice( 1, 8 ) - 5, dice( 1, 8 ) - 5 }, 6 + dice( 1, 10 ) ); } else { - wreckage->smash( m, 0.1f, 0.9f, 1.0f, point( dice( 1, 8 ) - 5, dice( 1, 8 ) - 5 ), 6 + dice( 1, + wreckage->smash( m, 0.1f, 0.9f, 1.0f, { dice( 1, 8 ) - 5, dice( 1, 8 ) - 5 }, 6 + dice( 1, 10 ) ); } } @@ -1360,7 +1360,7 @@ static void burned_ground_parser( map &m, const tripoint &loc ) } else { tripoint_abs_omt pos = project_to( m.getglobal( loc ) ); oter_id terrain_type = overmap_buffer.ter( pos ); - tripoint veh_origin = vehicle.v->global_pos3(); + tripoint_bub_ms veh_origin = vehicle.v->pos_bub(); debugmsg( "burned_ground_parser: Vehicle %s (origin %s; rotation (%f,%f)) has " "out of bounds part at %s in terrain_type %s\n", vehicle.v->name, veh_origin.to_string(), @@ -1505,18 +1505,18 @@ static bool mx_burned_ground( map &m, const tripoint &abs_sub ) } VehicleList vehs = m.get_vehicles(); std::vector vehicles; - std::vector points; + std::vector points; for( wrapped_vehicle vehicle : vehs ) { vehicles.push_back( vehicle.v ); - std::set occupied = vehicle.v->get_points(); - for( const tripoint &t : occupied ) { + std::set occupied = vehicle.v->get_points(); + for( const tripoint_bub_ms &t : occupied ) { points.push_back( t ); } } for( vehicle *vrem : vehicles ) { m.destroy_vehicle( vrem ); } - for( const tripoint &tri : points ) { + for( const tripoint_bub_ms &tri : points ) { m.furn_set( tri, furn_f_wreckage ); } diff --git a/src/mapdata.cpp b/src/mapdata.cpp index bad2d1b2b1c9e..719b811b8013a 100644 --- a/src/mapdata.cpp +++ b/src/mapdata.cpp @@ -507,7 +507,7 @@ ter_t null_terrain_t() template void load_season_array( const JsonObject &jo, const std::string &key, const std::string &context, - C &container, F load_func ) + const bool ignore_absent_key, C &container, F load_func ) { if( jo.has_string( key ) ) { container.fill( load_func( jo.get_string( key ) ) ); @@ -529,7 +529,7 @@ void load_season_array( const JsonObject &jo, const std::string &key, const std: } else if( jo.has_member( key ) ) { jo.throw_error_at( key, string_format( "Expected '%s' member to be string or array", key ) ); - } else { + } else if( !ignore_absent_key ) { jo.throw_error( string_format( "Expected '%s' member in %s but none was found", key, context ) ); } @@ -569,19 +569,13 @@ void map_data_common_t::examine( Character &you, const tripoint_bub_ms &examp ) examine_actor->call( you, examp ); } -void map_data_common_t::load_symbol( const JsonObject &jo, const std::string &context ) +void map_data_common_t::load_symbol_color( const JsonObject &jo, const std::string &context ) { - if( jo.has_member( "copy-from" ) && looks_like.empty() ) { - looks_like = jo.get_string( "copy-from" ); - } - jo.read( "looks_like", looks_like ); + const bool no_copy_symbol_color = jo.has_member( "copy-from" ); - load_season_array( jo, "symbol", context, symbol_, [&jo]( const std::string & str ) { - if( str == "LINE_XOXO" ) { - return LINE_XOXO; - } else if( str == "LINE_OXOX" ) { - return LINE_OXOX; - } else if( str.length() != 1 ) { + load_season_array( jo, "symbol", context, no_copy_symbol_color, + symbol_, [&jo]( const std::string_view str ) { + if( str.length() != 1 ) { jo.throw_error_at( "symbol", "Symbol string must be exactly 1 character long." ); } return static_cast( str[0] ); @@ -592,13 +586,14 @@ void map_data_common_t::load_symbol( const JsonObject &jo, const std::string &co if( has_color && has_bgcolor ) { jo.throw_error( "Found both color and bgcolor, only one of these is allowed." ); } else if( has_color ) { - load_season_array( jo, "color", context, color_, []( const std::string_view str ) { + load_season_array( jo, "color", context, no_copy_symbol_color, + color_, []( const std::string_view str ) { // has to use a lambda because of default params return color_from_string( str ); } ); } else if( has_bgcolor ) { - load_season_array( jo, "bgcolor", context, color_, bgcolor_from_string ); - } else { + load_season_array( jo, "bgcolor", context, no_copy_symbol_color, color_, bgcolor_from_string ); + } else if( !no_copy_symbol_color ) { jo.throw_error( R"(Missing member: one of: "color", "bgcolor" must exist.)" ); } } @@ -940,6 +935,10 @@ void map_data_common_t::load( const JsonObject &jo, const std::string &src ) mandatory( jo, was_loaded, "name", name_ ); mandatory( jo, was_loaded, "description", description ); + if( jo.has_member( "copy-from" ) ) { + looks_like = jo.get_string( "copy-from" ); + } + optional( jo, was_loaded, "looks_like", looks_like ); optional( jo, was_loaded, "comfort", comfort, 0 ); if( jo.has_member( "connect_groups" ) ) { @@ -1048,7 +1047,7 @@ void ter_t::load( const JsonObject &jo, const std::string &src ) optional( jo, was_loaded, "trap", trap_id_str ); optional( jo, was_loaded, "heat_radiation", heat_radiation ); - load_symbol( jo, "terrain " + id.str() ); + load_symbol_color( jo, "terrain " + id.str() ); trap = tr_null; @@ -1232,16 +1231,16 @@ void furn_t::load( const JsonObject &jo, const std::string &src ) { map_data_common_t::load( jo, src ); mandatory( jo, was_loaded, "move_cost_mod", movecost ); + mandatory( jo, was_loaded, "required_str", move_str_req ); optional( jo, was_loaded, "fall_damage_reduction", fall_damage_reduction, 0 ); int legacy_bonus_fire_warmth_feet = units::to_legacy_bodypart_temp_delta( bonus_fire_warmth_feet ); optional( jo, was_loaded, "bonus_fire_warmth_feet", legacy_bonus_fire_warmth_feet, 300 ); bonus_fire_warmth_feet = units::from_legacy_bodypart_temp_delta( legacy_bonus_fire_warmth_feet ); optional( jo, was_loaded, "keg_capacity", keg_capacity, legacy_volume_reader, 0_ml ); - mandatory( jo, was_loaded, "required_str", move_str_req ); optional( jo, was_loaded, "max_volume", max_volume, volume_reader(), DEFAULT_TILE_VOLUME ); optional( jo, was_loaded, "crafting_pseudo_item", crafting_pseudo_item, itype_id() ); optional( jo, was_loaded, "deployed_item", deployed_item ); - load_symbol( jo, "furniture " + id.str() ); + load_symbol_color( jo, "furniture " + id.str() ); optional( jo, was_loaded, "open", open, string_id_reader {}, furn_str_id::NULL_ID() ); optional( jo, was_loaded, "close", close, string_id_reader {}, furn_str_id::NULL_ID() ); diff --git a/src/mapdata.h b/src/mapdata.h index a6ed8388b775e..ce4d9c25d2fd6 100644 --- a/src/mapdata.h +++ b/src/mapdata.h @@ -540,7 +540,11 @@ struct map_data_common_t { // The color the sym will draw in on the GUI. std::array color_; - void load_symbol( const JsonObject &jo, const std::string &context ); + /** + * If "copy-from" doesn't exist, loads ASCII symbol and color + * NOTE: completely independent of "looks_like" + */ + void load_symbol_color( const JsonObject &jo, const std::string &context ); std::string looks_like; diff --git a/src/mapgen.cpp b/src/mapgen.cpp index 954121560c96f..50c4c71d820e1 100644 --- a/src/mapgen.cpp +++ b/src/mapgen.cpp @@ -6913,7 +6913,7 @@ vehicle *map::add_vehicle( const vproto_id &type, const tripoint_bub_ms &p, cons veh->turn_dir = dir; // for backwards compatibility, we always spawn with a pivot point of (0,0) so // that the mount at (0,0) is located at the spawn position. - veh->precalc_mounts( 0, dir, point() ); + veh->precalc_mounts( 0, dir, point_rel_ms_zero ); std::unique_ptr placed_vehicle_up = add_vehicle_to_map( std::move( veh ), merge_wrecks ); @@ -7006,7 +7006,7 @@ std::unique_ptr map::add_vehicle_to_map( */ std::unique_ptr handler_ptr; bool did_merge = false; - for( const tripoint &map_pos : first_veh->get_points( true ) ) { + for( const tripoint_bub_ms &map_pos : first_veh->get_points( true ) ) { std::vector parts_to_move = veh_to_add->get_parts_at( map_pos, "", part_status_flag::any ); if( !parts_to_move.empty() ) { diff --git a/src/martialarts.h b/src/martialarts.h index b82a2e7aca6cc..a8e5ee700d2c8 100644 --- a/src/martialarts.h +++ b/src/martialarts.h @@ -226,7 +226,7 @@ class ma_technique bool needs_ammo = false; // technique only works if the item is loaded with ammo // Dialogue conditions of the attack - std::function condition; + std::function condition; std::string condition_desc; bool has_condition = false; diff --git a/src/math_parser.cpp b/src/math_parser.cpp index 005131b2e5f9c..509cb14abb737 100644 --- a/src/math_parser.cpp +++ b/src/math_parser.cpp @@ -180,7 +180,7 @@ bool is_assign_target( thingie const &thing ) std::holds_alternative( thing.data ); } -std::vector _eval_params( std::vector const ¶ms, dialogue &d ) +std::vector _eval_params( std::vector const ¶ms, const_dialogue const &d ) { std::vector elems( params.size() ); std::transform( params.begin(), params.end(), elems.begin(), @@ -219,17 +219,17 @@ func_jmath::func_jmath( std::vector &¶ms_, jmath_func_id const &id_ ) : params( params_ ), id( id_ ) {} -double func::eval( dialogue &d ) const +double func::eval( const_dialogue const &d ) const { return f( _eval_params( params, d ) ); } -double func_jmath::eval( dialogue &d ) const +double func_jmath::eval( const_dialogue const &d ) const { return id->eval( d, _eval_params( params, d ) ); } -double var::eval( dialogue &d ) const +double var::eval( const_dialogue const &d ) const { std::string const str = read_var_value( varinfo, d ); if( str.empty() ) { @@ -247,7 +247,7 @@ oper::oper( thingie l_, thingie r_, binary_op::f_t op_ ): r( std::make_shared( std::move( r_ ) ) ), op( op_ ) {} -double oper::eval( dialogue &d ) const +double oper::eval( const_dialogue const &d ) const { return ( *op )( l->eval( d ), r->eval( d ) ); } @@ -261,7 +261,7 @@ ternary::ternary( thingie cond_, thingie mhs_, thingie rhs_ ) mhs( std::make_shared( std::move( mhs_ ) ) ), rhs( std::make_shared( std::move( rhs_ ) ) ) {} -double ternary::eval( dialogue &d ) const +double ternary::eval( const_dialogue const &d ) const { return cond->eval( d ) > 0 ? mhs->eval( d ) : rhs->eval( d ); } @@ -296,7 +296,7 @@ class math_exp::math_exp_impl } return true; } - double eval( dialogue &d ) const { + double eval( const_dialogue const &d ) const { return tree.eval( d ); } @@ -860,7 +860,7 @@ math_exp::~math_exp() = default; math_exp::math_exp( math_exp &&/* other */ ) noexcept = default; math_exp &math_exp::operator=( math_exp &&/* other */ ) noexcept = default; -double math_exp::eval( dialogue &d ) const +double math_exp::eval( const_dialogue const &d ) const { return impl->eval( d ); } diff --git a/src/math_parser.h b/src/math_parser.h index 33d3981e1a160..2365614acd159 100644 --- a/src/math_parser.h +++ b/src/math_parser.h @@ -6,6 +6,7 @@ #include struct dialogue; +struct const_dialogue; class math_exp { @@ -21,7 +22,7 @@ class math_exp explicit math_exp( math_exp_impl impl_ ); bool parse( std::string_view str, bool assignment = false, bool handle_errors = true ); - double eval( dialogue &d ) const; + double eval( const_dialogue const &d ) const; void assign( dialogue &d, double val ) const; private: diff --git a/src/math_parser_diag.cpp b/src/math_parser_diag.cpp index e9cc1fdfa5b9e..7824b50e74272 100644 --- a/src/math_parser_diag.cpp +++ b/src/math_parser_diag.cpp @@ -7,6 +7,7 @@ #include "calendar.h" #include "condition.h" #include "dialogue.h" +#include "enums.h" #include "field.h" #include "game.h" #include "magic.h" @@ -15,7 +16,6 @@ #include "mod_manager.h" #include "mongroup.h" #include "mtype.h" -#include "enums.h" #include "npc.h" #include "options.h" #include "string_input_popup.h" @@ -28,14 +28,14 @@ General guidelines for writing dialogue functions The typical parsing function takes the form: -std::function myfunction_eval( char scope, +math_eval_dbl_f myfunction_eval( char scope, std::vector const ¶ms, diag_kwargs const &kwargs ) { diag_value myval = kwargs.kwarg_or( "mykwarg", "default-value" ); ...parse-time code... - return[effect_id = params[0], myval, beta = is_beta( scope )]( dialogue const & d ) { + return[effect_id = params[0], myval, beta = is_beta( scope )]( const_dialogue const & d ) { ...run-time code... }; } @@ -92,86 +92,86 @@ T _read_from_string( std::string_view s, const std::vector( s, units, error ); } -std::function u_val( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f u_val( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return conditional_t::get_get_dbl( params[0].str(), scope ); } -std::function u_val_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f u_val_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return conditional_t::get_set_dbl( params[0].str(), scope ); } -std::function option_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f option_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[option = params[0]]( dialogue const & d ) { + return[option = params[0]]( const_dialogue const & d ) { return get_option( option.str( d ), true ); }; } -std::function addiction_intensity_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f addiction_intensity_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[ beta = is_beta( scope ), add_value = params[0]]( dialogue const & d ) { - return d.actor( beta )->get_addiction_intensity( addiction_id( add_value.str( d ) ) ); + return[ beta = is_beta( scope ), add_value = params[0]]( const_dialogue const & d ) { + return d.const_actor( beta )->get_addiction_intensity( addiction_id( add_value.str( d ) ) ); }; } -std::function addiction_turns_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f addiction_turns_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[ beta = is_beta( scope ), add_value = params[0]]( dialogue const & d ) { - return d.actor( beta )->get_addiction_turns( addiction_id( add_value.str( d ) ) ); + return[ beta = is_beta( scope ), add_value = params[0]]( const_dialogue const & d ) { + return d.const_actor( beta )->get_addiction_turns( addiction_id( add_value.str( d ) ) ); }; } -std::function addiction_turns_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f addiction_turns_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return[ beta = is_beta( scope ), add_value = params[0]]( dialogue const & d, double val ) { return d.actor( beta )->set_addiction_turns( addiction_id( add_value.str( d ) ), val ); }; } -std::function armor_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f armor_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[type = params[0], bpid = params[1], beta = is_beta( scope )]( dialogue const & d ) { + return[type = params[0], bpid = params[1], beta = is_beta( scope )]( const_dialogue const & d ) { damage_type_id dt( type.str( d ) ); bodypart_id bp( bpid.str( d ) ); - return d.actor( beta )->armor_at( dt, bp ); + return d.const_actor( beta )->armor_at( dt, bp ); }; } -std::function charge_count_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f charge_count_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope ), item_value = params[0]]( dialogue const & d ) { - return d.actor( beta )->charges_of( itype_id( item_value.str( d ) ) ); + return[beta = is_beta( scope ), item_value = params[0]]( const_dialogue const & d ) { + return d.const_actor( beta )->charges_of( itype_id( item_value.str( d ) ) ); }; } -std::function coverage_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f coverage_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[bpid = params[0], beta = is_beta( scope )]( dialogue const & d ) { + return[bpid = params[0], beta = is_beta( scope )]( const_dialogue const & d ) { bodypart_id bp( bpid.str( d ) ); - return d.actor( beta )->coverage_at( bp ); + return d.const_actor( beta )->coverage_at( bp ); }; } -std::function distance_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f distance_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[params, beta = is_beta( scope )]( dialogue const & d ) { + return[params, beta = is_beta( scope )]( const_dialogue const & d ) { const auto get_pos = [&d]( std::string_view str ) { if( str == "u" ) { - return d.actor( false )->global_pos(); + return d.const_actor( false )->global_pos(); } else if( str == "npc" ) { - return d.actor( true )->global_pos(); + return d.const_actor( true )->global_pos(); } return tripoint_abs_ms( tripoint::from_string( str.data() ) ); }; @@ -179,11 +179,11 @@ std::function distance_eval( char scope, }; } -std::function damage_level_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f damage_level_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[params, beta = is_beta( scope )]( dialogue const & d ) { - item_location *it = d.actor( beta )->get_item(); + return[params, beta = is_beta( scope )]( const_dialogue const & d ) { + item_location const *it = d.const_actor( beta )->get_const_item(); if( !it ) { debugmsg( "subject of damage_level() must be an item" ); return 0; @@ -192,38 +192,38 @@ std::function damage_level_eval( char scope, }; } -std::function effect_intensity_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f effect_intensity_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value bp_val = kwargs.kwarg_or( "bodypart" ); - return[effect_id = params[0], bp_val, beta = is_beta( scope )]( dialogue const & d ) { + return[effect_id = params[0], bp_val, beta = is_beta( scope )]( const_dialogue const & d ) { std::string const bp_str = bp_val.str( d ); bodypart_id const bp = bp_str.empty() ? bodypart_str_id::NULL_ID() : bodypart_id( bp_str ); - effect target = d.actor( beta )->get_effect( efftype_id( effect_id.str( d ) ), bp ); + effect target = d.const_actor( beta )->get_effect( efftype_id( effect_id.str( d ) ), bp ); return target.is_null() ? -1 : target.get_intensity(); }; } -std::function encumbrance_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f encumbrance_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[bpid = params[0], beta = is_beta( scope )]( dialogue const & d ) { + return[bpid = params[0], beta = is_beta( scope )]( const_dialogue const & d ) { bodypart_id bp( bpid.str( d ) ); - return d.actor( beta )->encumbrance_at( bp ); + return d.const_actor( beta )->encumbrance_at( bp ); }; } -std::function faction_like_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f faction_like_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [fac_val = params[0]]( dialogue & d ) { + return [fac_val = params[0]]( const_dialogue const & d ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); return fac->likes_u; }; } -std::function faction_like_ass( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f faction_like_ass( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return [fac_val = params[0]]( dialogue const & d, double val ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); @@ -231,17 +231,17 @@ std::function faction_like_ass( char /* scope */, }; } -std::function faction_respect_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f faction_respect_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [fac_val = params[0]]( dialogue & d ) { + return [fac_val = params[0]]( const_dialogue const & d ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); return fac->respects_u; }; } -std::function faction_respect_ass( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f faction_respect_ass( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return [fac_val = params[0]]( dialogue const & d, double val ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); @@ -249,17 +249,17 @@ std::function faction_respect_ass( char /* scope */, }; } -std::function faction_trust_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f faction_trust_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [fac_val = params[0]]( dialogue & d ) { + return [fac_val = params[0]]( const_dialogue const & d ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); return fac->trusts_u; }; } -std::function faction_trust_ass( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f faction_trust_ass( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return [fac_val = params[0]]( dialogue const & d, double val ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); @@ -267,16 +267,16 @@ std::function faction_trust_ass( char /* scope */, }; } -std::function faction_food_supply_eval( char /* scope */, +diag_eval_dbl_f faction_food_supply_eval( char /* scope */, std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) { - return [fac_val = params[0]]( dialogue & d ) { + return [fac_val = params[0]]( const_dialogue const & d ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); return fac->food_supply.calories; }; } -std::function faction_food_supply_ass( char /* scope */, +diag_assign_dbl_f faction_food_supply_ass( char /* scope */, std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) { return [fac_val = params[0]]( dialogue const & d, double val ) { @@ -285,17 +285,17 @@ std::function faction_food_supply_ass( char /* scope }; } -std::function faction_wealth_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f faction_wealth_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [fac_val = params[0]]( dialogue & d ) { + return [fac_val = params[0]]( const_dialogue const & d ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); return fac->wealth; }; } -std::function faction_wealth_ass( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f faction_wealth_ass( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return [fac_val = params[0]]( dialogue const & d, double val ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); @@ -303,17 +303,17 @@ std::function faction_wealth_ass( char /* scope */, }; } -std::function faction_power_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f faction_power_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [fac_val = params[0]]( dialogue & d ) { + return [fac_val = params[0]]( const_dialogue const & d ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); return fac->power; }; } -std::function faction_power_ass( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f faction_power_ass( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return [fac_val = params[0]]( dialogue const & d, double val ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); @@ -321,17 +321,17 @@ std::function faction_power_ass( char /* scope */, }; } -std::function faction_size_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f faction_size_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [fac_val = params[0]]( dialogue & d ) { + return [fac_val = params[0]]( const_dialogue const & d ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); return fac->size; }; } -std::function faction_size_ass( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f faction_size_ass( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return [fac_val = params[0]]( dialogue const & d, double val ) { faction *fac = g->faction_manager_ptr->get( faction_id( fac_val.str( d ) ) ); @@ -339,8 +339,8 @@ std::function faction_size_ass( char /* scope */, }; } -std::function field_strength_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f field_strength_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { std::optional loc_var; diag_value loc_val = kwargs.kwarg_or( "location" ); @@ -352,13 +352,13 @@ std::function field_strength_eval( char scope, R"("field_strength" needs either an actor scope (u/n) or a 'location' kwarg)" ) ); } - return [beta = is_beta( scope ), field_value = params[0], loc_var]( dialogue & d ) { + return [beta = is_beta( scope ), field_value = params[0], loc_var]( const_dialogue const & d ) { map &here = get_map(); tripoint_abs_ms loc; if( loc_var.has_value() ) { loc = get_tripoint_from_var( loc_var, d, beta ); } else { - loc = d.actor( beta )->global_pos(); + loc = d.const_actor( beta )->global_pos(); } field_type_id ft = field_type_id( field_value.str( d ) ); field_entry *fp = here.field_at( here.bub_from_abs( loc ) ).find_field( ft ); @@ -366,12 +366,12 @@ std::function field_strength_eval( char scope, }; } -std::function gun_damage_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f gun_damage_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[dt_val = params[0], beta = is_beta( scope )]( dialogue const & d )-> double { - item_location *it = d.actor( beta )->get_item(); + return[dt_val = params[0], beta = is_beta( scope )]( const_dialogue const & d )-> double { + item_location const *it = d.const_actor( beta )->get_const_item(); if( it == nullptr ) { debugmsg( "subject of gun_damage() must be an item" ); @@ -386,21 +386,21 @@ std::function gun_damage_eval( char scope, }; } -std::function has_trait_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f has_trait_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [beta = is_beta( scope ), tid = params[0] ]( dialogue const & d ) { - return d.actor( beta )->has_trait( trait_id( tid.str( d ) ) ); + return [beta = is_beta( scope ), tid = params[0] ]( const_dialogue const & d ) { + return d.const_actor( beta )->has_trait( trait_id( tid.str( d ) ) ); }; } -std::function sum_traits_of_category_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f sum_traits_of_category_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value type = kwargs.kwarg_or( "type", "ALL" ); - return [beta = is_beta( scope ), category = params[0], type]( dialogue const & d ) { + return [beta = is_beta( scope ), category = params[0], type]( const_dialogue const & d ) { mutation_category_id cat = mutation_category_id( category.str() ); std::string thing = type.str( d ); @@ -417,17 +417,17 @@ std::function sum_traits_of_category_eval( char scope, return 0; } - return d.actor( beta )->get_total_in_category( cat, count_type ); + return d.const_actor( beta )->get_total_in_category( cat, count_type ); }; } -std::function sum_traits_of_category_char_has_eval( char scope, +diag_eval_dbl_f sum_traits_of_category_char_has_eval( char scope, std::vector const ¶ms, diag_kwargs const &kwargs ) { diag_value type = kwargs.kwarg_or( "type", "ALL" ); - return [beta = is_beta( scope ), category = params[0], type]( dialogue const & d ) { + return [beta = is_beta( scope ), category = params[0], type]( const_dialogue const & d ) { mutation_category_id cat = mutation_category_id( category.str() ); std::string thing = type.str( d ); @@ -444,15 +444,15 @@ std::function sum_traits_of_category_char_has_eval( char s return 0; } - return d.actor( beta )->get_total_in_category_char_has( cat, count_type ); + return d.const_actor( beta )->get_total_in_category_char_has( cat, count_type ); }; } -std::function has_flag_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f has_flag_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [beta = is_beta( scope ), fid = params[0] ]( dialogue const & d ) -> double { - talker const *actor = d.actor( beta ); + return [beta = is_beta( scope ), fid = params[0] ]( const_dialogue const & d ) -> double { + const_talker const *actor = d.const_actor( beta ); json_character_flag jcf( fid.str( d ) ); if( jcf == json_flag_MUTATION_THRESHOLD ) { @@ -462,26 +462,26 @@ std::function has_flag_eval( char scope, }; } -std::function has_var_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f has_var_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [var = params[0].var() ]( dialogue const & d ) { + return [var = params[0].var() ]( const_dialogue const & d ) { return maybe_read_var_value( var, d ).has_value(); }; } -std::function knows_proficiency_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f knows_proficiency_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [beta = is_beta( scope ), tid = params[0] ]( dialogue const & d ) { - return d.actor( beta )->knows_proficiency( proficiency_id( tid.str( d ) ) ); + return [beta = is_beta( scope ), tid = params[0] ]( const_dialogue const & d ) { + return d.const_actor( beta )->knows_proficiency( proficiency_id( tid.str( d ) ) ); }; } -std::function hp_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f hp_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[bp_val = params[0], beta = is_beta( scope )]( dialogue const & d ) { + return[bp_val = params[0], beta = is_beta( scope )]( const_dialogue const & d ) { std::string const bp_str = bp_val.str( d ); bool const major = bp_str == "ALL_MAJOR"; bool const minor = bp_str == "ALL_MINOR"; @@ -489,18 +489,18 @@ std::function hp_eval( char scope, get_body_part_flags const parts = major ? get_body_part_flags::only_main : get_body_part_flags::only_minor; int ret{}; - for( bodypart_id const &part : d.actor( beta )->get_all_body_parts( parts ) ) { - ret += d.actor( beta )->get_cur_hp( part ); + for( bodypart_id const &part : d.const_actor( beta )->get_all_body_parts( parts ) ) { + ret += d.const_actor( beta )->get_cur_hp( part ); } return ret; } bodypart_id const bp = bp_str == "ALL" ? bodypart_str_id::NULL_ID() : bodypart_id( bp_str ); - return d.actor( beta )->get_cur_hp( bp ); + return d.const_actor( beta )->get_cur_hp( bp ); }; } -std::function hp_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f hp_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return [bp_val = params[0], beta = is_beta( scope )]( dialogue const & d, double val ) { std::string const bp_str = bp_val.str( d ); @@ -520,8 +520,8 @@ std::function hp_ass( char scope, }; } -std::function spellcasting_adjustment_ass( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_assign_dbl_f spellcasting_adjustment_ass( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { enum spell_scope { scope_all, @@ -590,40 +590,40 @@ std::function spellcasting_adjustment_ass( char scop }; } -std::function hp_max_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f hp_max_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[bpid = params[0], beta = is_beta( scope )]( dialogue const & d ) { + return[bpid = params[0], beta = is_beta( scope )]( const_dialogue const & d ) { bodypart_id bp( bpid.str( d ) ); - return d.actor( beta )->get_hp_max( bp ); + return d.const_actor( beta )->get_hp_max( bp ); }; } -std::function item_count_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f item_count_eval( char scope, + std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) { - return[beta = is_beta( scope ), item_value = params[0]]( dialogue const & d ) { - return d.actor( beta )->get_amount( itype_id( item_value.str( d ) ) ); + return[beta = is_beta( scope ), item_value = params[0]]( const_dialogue const & d ) { + return d.const_actor( beta )->get_amount( itype_id( item_value.str( d ) ) ); }; } -std::function item_rad_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f item_rad_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value agg_val = kwargs.kwarg_or( "aggregate", "min" ); - return [beta = is_beta( scope ), flag = params[0], agg_val]( dialogue const & d ) { + return [beta = is_beta( scope ), flag = params[0], agg_val]( const_dialogue const & d ) { std::optional const agg = io::string_to_enum_optional( agg_val.str( d ) ); - return d.actor( beta )->item_rads( flag_id( flag.str( d ) ), - agg.value_or( aggregate_type::MIN ) ); + return d.const_actor( beta )->item_rads( flag_id( flag.str( d ) ), + agg.value_or( aggregate_type::MIN ) ); }; } -std::function num_input_eval( char /*scope*/, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f num_input_eval( char /*scope*/, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[prompt = params[0], default_val = params[1]]( dialogue const & d ) { + return[prompt = params[0], default_val = params[1]]( const_dialogue const & d ) { string_input_popup popup; double dv = default_val.dbl( d ); int popup_val = dv; @@ -639,20 +639,20 @@ std::function num_input_eval( char /*scope*/, }; } -std::function attack_speed_eval( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f attack_speed_eval( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - return d.actor( beta )->attack_speed(); + return[beta = is_beta( scope )]( const_dialogue const & d ) { + return d.const_actor( beta )->attack_speed(); }; } -std::function melee_damage_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f melee_damage_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[dt_val = params[0], beta = is_beta( scope )]( dialogue const & d ) { - item_location *it = d.actor( beta )->get_item(); + return[dt_val = params[0], beta = is_beta( scope )]( const_dialogue const & d ) { + item_location const *it = d.const_actor( beta )->get_const_item(); if( it == nullptr ) { debugmsg( "subject of melee_damage() must be an item" ); return 0; @@ -668,10 +668,10 @@ std::function melee_damage_eval( char scope, }; } -std::function mod_order_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f mod_order_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[mod_val = params[0]]( dialogue const & d ) { + return[mod_val = params[0]]( const_dialogue const & d ) { int count = 0; mod_id our_mod_id( mod_val.str( d ) ); for( const mod_id &mod : world_generator->active_world->active_mod_order ) { @@ -720,8 +720,8 @@ bool _filter_character( Character const *beta, Character const &guy, int radius, return false; } -std::function _characters_nearby_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f _characters_nearby_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value radius_val = kwargs.kwarg_or( "radius", 1000 ); diag_value filter_val = kwargs.kwarg_or( "attitude", "any" ); @@ -737,12 +737,12 @@ std::function _characters_nearby_eval( char scope, } return [beta = is_beta( scope ), params, loc_var, filter_val, radius_val, - allow_hallucinations_val ]( dialogue & d ) { + allow_hallucinations_val ]( const_dialogue const & d ) { tripoint_abs_ms loc; if( loc_var.has_value() ) { loc = get_tripoint_from_var( loc_var, d, beta ); } else { - loc = d.actor( beta )->global_pos(); + loc = d.const_actor( beta )->global_pos(); } int const radius = static_cast( radius_val.dbl( d ) ); @@ -766,16 +766,16 @@ std::function _characters_nearby_eval( char scope, std::vector const targets = g->get_characters_if( [ &beta, &d, &radius, &loc, filter, allow_hallucinations ]( const Character & guy ) { - talker const *const tk = d.actor( beta ); - return _filter_character( tk->get_character(), guy, radius, loc, filter, + const_talker const *const tk = d.const_actor( beta ); + return _filter_character( tk->get_const_character(), guy, radius, loc, filter, allow_hallucinations ); } ); return static_cast( targets.size() ); }; } -std::function characters_nearby_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f characters_nearby_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { return _characters_nearby_eval( scope, params, kwargs ); } @@ -835,9 +835,9 @@ bool _filter_monster( Creature const &critter, std::vector const &ids, int r return false; } -template -std::function _monsters_nearby_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs, f_monster_match f ) +template +diag_eval_dbl_f _monsters_nearby_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs, f_monster_match f ) { diag_value radius_val = kwargs.kwarg_or( "radius", 1000 ); diag_value filter_val = kwargs.kwarg_or( "attitude", "hostile" ); @@ -851,12 +851,13 @@ std::function _monsters_nearby_eval( char scope, R"("monsters_nearby" needs either an actor scope (u/n) or a 'location' kwarg)" ) ); } - return [beta = is_beta( scope ), params, loc_var, radius_val, filter_val, f]( dialogue & d ) { + return [beta = is_beta( scope ), params, loc_var, radius_val, filter_val, + f]( const_dialogue const & d ) { tripoint_abs_ms loc; if( loc_var.has_value() ) { loc = get_tripoint_from_var( loc_var, d, beta ); } else { - loc = d.actor( beta )->global_pos(); + loc = d.const_actor( beta )->global_pos(); } int const radius = static_cast( radius_val.dbl( d ) ); @@ -883,43 +884,43 @@ std::function _monsters_nearby_eval( char scope, }; } -std::function monsters_nearby_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f monsters_nearby_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { return _monsters_nearby_eval( scope, params, kwargs, mon_check_id ); } -std::function monster_species_nearby_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f monster_species_nearby_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { return _monsters_nearby_eval( scope, params, kwargs, mon_check_species ); } -std::function monster_groups_nearby_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f monster_groups_nearby_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { return _monsters_nearby_eval( scope, params, kwargs, mon_check_group ); } -std::function moon_phase_eval( char /* scope */, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f moon_phase_eval( char /* scope */, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return []( dialogue const & /* d */ ) { + return []( const_dialogue const & /* d */ ) { return static_cast( get_moon_phase( calendar::turn ) ); }; } -std::function pain_eval( char scope, - std::vector const &/* params */, diag_kwargs const &kwargs ) +diag_eval_dbl_f pain_eval( char scope, std::vector const & /* params */, + diag_kwargs const &kwargs ) { diag_value format_value = kwargs.kwarg_or( "type", "raw" ); - return [format_value, beta = is_beta( scope )]( dialogue const & d ) { + return [format_value, beta = is_beta( scope )]( const_dialogue const & d ) { std::string format = format_value.str( d ); if( format == "perceived" ) { - return d.actor( beta )->perceived_pain_cur(); + return d.const_actor( beta )->perceived_pain_cur(); } else if( format == "raw" ) { - return d.actor( beta )->pain_cur(); + return d.const_actor( beta )->pain_cur(); } else { debugmsg( R"(Unknown type "%s" for pain())", format ); return 0; @@ -927,8 +928,8 @@ std::function pain_eval( char scope, }; } -std::function pain_ass( char scope, - std::vector const &/* params */, diag_kwargs const &kwargs ) +diag_assign_dbl_f pain_ass( char scope, std::vector const & /* params */, + diag_kwargs const &kwargs ) { diag_value format_value = kwargs.kwarg_or( "type", "raw" ); @@ -945,29 +946,28 @@ std::function pain_ass( char scope, }; } -std::function energy_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f energy_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - - return [val = params[0]]( dialogue const & d ) { + return [val = params[0]]( const_dialogue const & d ) { return static_cast( units::to_millijoule( _read_from_string( val.str( d ), units::energy_units ) ) ); }; } -std::function school_level_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f school_level_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope ), school_value = params[0]]( dialogue const & d ) { - return d.actor( beta )->get_spell_level( trait_id( school_value.str( d ) ) ); + return[beta = is_beta( scope ), school_value = params[0]]( const_dialogue const & d ) { + return d.const_actor( beta )->get_spell_level( trait_id( school_value.str( d ) ) ); }; } -std::function school_level_adjustment_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f school_level_adjustment_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope ), school_value = params[0]]( dialogue const & d ) { - const Character *ch = d.actor( beta )->get_character(); + return[beta = is_beta( scope ), school_value = params[0]]( const_dialogue const & d ) { + const Character *ch = d.const_actor( beta )->get_const_character(); if( ch ) { const trait_id school( school_value.str( d ) ); auto it = ch->magic->caster_level_adjustment_by_school.find( school ); @@ -981,8 +981,8 @@ std::function school_level_adjustment_eval( char scope, }; } -std::function school_level_adjustment_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f school_level_adjustment_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope ), school_value = params[0]]( dialogue const & d, double val ) { const Character *ch = d.actor( beta )->get_character(); @@ -999,13 +999,13 @@ std::function school_level_adjustment_ass( char scop }; } -std::function get_daily_calories( char scope, - std::vector const &/* params */, diag_kwargs const &kwargs ) +diag_eval_dbl_f get_daily_calories( char scope, std::vector const & /* params */, + diag_kwargs const &kwargs ) { diag_value type_val = kwargs.kwarg_or( "type", "total" ); diag_value day_val = kwargs.kwarg_or( "day" ); - return[beta = is_beta( scope ), day_val, type_val ]( dialogue const & d ) { + return[beta = is_beta( scope ), day_val, type_val ]( const_dialogue const & d ) { std::string type = type_val.str( d ); int const day = day_val.dbl( d ); if( day < 0 ) { @@ -1013,44 +1013,44 @@ std::function get_daily_calories( char scope, return 0; } - return static_cast( d.actor( beta ) )->get_daily_calories( day, type ); + return d.const_actor( beta )->get_daily_calories( day, type ); }; } -std::function skill_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f skill_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return [beta = is_beta( scope ), sid = params[0] ]( dialogue const & d ) { - return d.actor( beta )->get_skill_level( skill_id( sid.str( d ) ) ); + return [beta = is_beta( scope ), sid = params[0] ]( const_dialogue const & d ) { + return d.const_actor( beta )->get_skill_level( skill_id( sid.str( d ) ) ); }; } -std::function skill_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f skill_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return [beta = is_beta( scope ), sid = params[0] ]( dialogue const & d, double val ) { return d.actor( beta )->set_skill_level( skill_id( sid.str( d ) ), val ); }; } -std::function skill_exp_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f skill_exp_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value format_value = kwargs.kwarg_or( "format", "percentage" ); - return[skill_value = params[0], format_value, beta = is_beta( scope )]( dialogue const & d ) { + return[skill_value = params[0], format_value, beta = is_beta( scope )]( const_dialogue const & d ) { skill_id skill( skill_value.str( d ) ); std::string format = format_value.str( d ); if( format != "raw" && format != "percentage" ) { debugmsg( R"(Unknown format type "%s" for skill_exp, assumning "percentage")", format ); } bool raw = format == "raw"; - return d.actor( beta )->get_skill_exp( skill, raw ); + return d.const_actor( beta )->get_skill_exp( skill, raw ); }; } -std::function skill_exp_ass( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_assign_dbl_f skill_exp_ass( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value format_value = kwargs.kwarg_or( "format", "percentage" ); @@ -1066,71 +1066,71 @@ std::function skill_exp_ass( char scope, }; } -std::function spell_count_eval( char scope, - std::vector const &/* params */, diag_kwargs const &kwargs ) +diag_eval_dbl_f spell_count_eval( char scope, std::vector const & /* params */, + diag_kwargs const &kwargs ) { diag_value school_value = kwargs.kwarg_or( "school" ); - return[beta = is_beta( scope ), school_value]( dialogue const & d ) { + return[beta = is_beta( scope ), school_value]( const_dialogue const & d ) { std::string school_str = school_value.str( d ); const trait_id scid = school_str.empty() ? trait_id::NULL_ID() : trait_id( school_str ); - return d.actor( beta )->get_spell_count( scid ); + return d.const_actor( beta )->get_spell_count( scid ); }; } -std::function spell_sum_eval( char scope, - std::vector const &/* params */, diag_kwargs const &kwargs ) +diag_eval_dbl_f spell_sum_eval( char scope, std::vector const & /* params */, + diag_kwargs const &kwargs ) { diag_value school_value = kwargs.kwarg_or( "school" ); diag_value min_level = kwargs.kwarg_or( "level" ); - return[beta = is_beta( scope ), school_value, min_level]( dialogue const & d ) { + return[beta = is_beta( scope ), school_value, min_level]( const_dialogue const & d ) { std::string school_str = school_value.str( d ); int const min_spell_level = min_level.dbl( d ); const trait_id scid = school_str.empty() ? trait_id::NULL_ID() : trait_id( school_str ); - return d.actor( beta )->get_spell_sum( scid, min_spell_level ); + return d.const_actor( beta )->get_spell_sum( scid, min_spell_level ); }; } -std::function spell_exp_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f spell_exp_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope ), sid = params[0]]( dialogue const & d ) { - return d.actor( beta )->get_spell_exp( spell_id( sid.str( d ) ) ); + return[beta = is_beta( scope ), sid = params[0]]( const_dialogue const & d ) { + return d.const_actor( beta )->get_spell_exp( spell_id( sid.str( d ) ) ); }; } -std::function spell_exp_for_level_eval( char /* scope */, +diag_eval_dbl_f spell_exp_for_level_eval( char /* scope */, std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) { - return[level = params[0]]( dialogue const & d ) -> double { + return[level = params[0]]( const_dialogue const & d ) -> double { return spell::exp_for_level( level.dbl( d ) ); }; } -std::function spell_exp_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f spell_exp_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope ), sid = params[0]]( dialogue const & d, double val ) { return d.actor( beta )->set_spell_exp( spell_id( sid.str( d ) ), val ); }; } -std::function spell_level_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f spell_level_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope ), spell_value = params[0]]( dialogue const & d ) { + return[beta = is_beta( scope ), spell_value = params[0]]( const_dialogue const & d ) { const spell_id spell( spell_value.str( d ) ); if( spell == spell_id::NULL_ID() ) { - return d.actor( beta )->get_highest_spell_level(); + return d.const_actor( beta )->get_highest_spell_level(); } else { - return d.actor( beta )->get_spell_level( spell ); + return d.const_actor( beta )->get_spell_level( spell ); } }; } -std::function spell_level_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f spell_level_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope ), spell_value = params[0]]( dialogue const & d, double val ) { const spell_id spell( spell_value.str( d ) ); @@ -1143,11 +1143,11 @@ std::function spell_level_ass( char scope, }; } -std::function spell_level_adjustment_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f spell_level_adjustment_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope ), spell_value = params[0]]( dialogue const & d ) { - const Character *ch = d.actor( beta )->get_character(); + return[beta = is_beta( scope ), spell_value = params[0]]( const_dialogue const & d ) { + const Character *ch = d.const_actor( beta )->get_const_character(); if( ch ) { const spell_id spell( spell_value.str( d ) ); if( spell == spell_id::NULL_ID() ) { @@ -1163,8 +1163,8 @@ std::function spell_level_adjustment_eval( char scope, }; } -std::function spell_level_adjustment_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f spell_level_adjustment_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope ), spell_value = params[0]]( dialogue const & d, double val ) { const Character *ch = d.actor( beta )->get_character(); @@ -1204,12 +1204,12 @@ double _time_in_unit( double time, std::string_view unit ) return time; } -std::function time_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f time_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value unit_val = kwargs.kwarg_or( "unit" ); - return [val = params[0], unit_val]( dialogue const & d ) { + return [val = params[0], unit_val]( const_dialogue const & d ) { std::string const val_str = val.str( d ); double ret{}; if( val_str == "now" ) { @@ -1225,8 +1225,8 @@ std::function time_eval( char /* scope */, }; } -std::function time_ass( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f time_ass( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { // intentionally duplicate check for str to avoid the `Expected str, got ...` error and get the nicer one below if( params[0].is_str() && params[0] == "now" ) { @@ -1239,12 +1239,12 @@ std::function time_ass( char /* scope */, string_format( "Only time('now') is a valid time() assignment target" ) ); } -std::function time_since_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f time_since_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value unit_val = kwargs.kwarg_or( "unit" ); - return [val = params[0], unit_val]( dialogue const & d ) { + return [val = params[0], unit_val]( const_dialogue const & d ) { double ret{}; std::string const val_str = val.str( d ); if( val_str == "cataclysm" ) { @@ -1262,12 +1262,12 @@ std::function time_since_eval( char /* scope */, }; } -std::function time_until_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f time_until_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value unit_val = kwargs.kwarg_or( "unit" ); - return [val = params[0], unit_val]( dialogue const & d ) { + return [val = params[0], unit_val]( const_dialogue const & d ) { double ret{}; std::string const val_str = val.str( d ); if( val_str == "night_time" ) { @@ -1295,12 +1295,12 @@ std::function time_until_eval( char /* scope */, }; } -std::function time_until_eoc_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f time_until_eoc_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value unit_val = kwargs.kwarg_or( "unit" ); - return [eoc_val = params[0], unit_val]( dialogue const & d ) -> double { + return [eoc_val = params[0], unit_val]( const_dialogue const & d ) -> double { effect_on_condition_id eoc_id( eoc_val.str( d ) ); auto const &list = g->queued_global_effect_on_conditions.list; auto const it = std::find_if( list.cbegin(), list.cend(), [&eoc_id]( queued_eoc const & eoc ) @@ -1312,29 +1312,30 @@ std::function time_until_eoc_eval( char /* scope */, }; } -std::function effect_duration_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f effect_duration_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value bp_val = kwargs.kwarg_or( "bodypart" ); diag_value unit_val = kwargs.kwarg_or( "unit" ); - return[effect_id = params[0], bp_val, unit_val, beta = is_beta( scope )]( dialogue const & d ) { + return[effect_id = params[0], bp_val, unit_val, + beta = is_beta( scope )]( const_dialogue const & d ) { std::string const bp_str = bp_val.str( d ); bodypart_id const bp = bp_str.empty() ? bodypart_str_id::NULL_ID() : bodypart_id( bp_str ); - effect target = d.actor( beta )->get_effect( efftype_id( effect_id.str( d ) ), bp ); + effect target = d.const_actor( beta )->get_effect( efftype_id( effect_id.str( d ) ), bp ); return target.is_null() ? -1 : _time_in_unit( to_seconds( target.get_duration() ), unit_val.str( d ) ); }; } -std::function proficiency_eval( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f proficiency_eval( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value fmt_val = kwargs.kwarg_or( "format", "time_spent" ); - return [beta = is_beta( scope ), prof_value = params[0], fmt_val]( dialogue const & d ) { + return [beta = is_beta( scope ), prof_value = params[0], fmt_val]( const_dialogue const & d ) { proficiency_id prof( prof_value.str( d ) ); - time_duration raw = d.actor( beta )->proficiency_practiced_time( prof ); + time_duration raw = d.const_actor( beta )->proficiency_practiced_time( prof ); std::string const format = fmt_val.str( d ); if( format == "percent" ) { return raw * 100.0 / prof->time_to_learn(); @@ -1353,8 +1354,8 @@ std::function proficiency_eval( char scope, }; } -std::function proficiency_ass( char scope, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_assign_dbl_f proficiency_ass( char scope, std::vector const ¶ms, + diag_kwargs const &kwargs ) { diag_value fmt_val = kwargs.kwarg_or( "format", "time_spent" ); diag_value direct_val = kwargs.kwarg_or( "direct" ); @@ -1395,7 +1396,7 @@ std::function proficiency_ass( char scope, }; } -double _test_add( diag_value const &v, dialogue const &d ) +double _test_add( diag_value const &v, const_dialogue const &d ) { double ret{}; if( v.is_array() ) { @@ -1407,7 +1408,7 @@ double _test_add( diag_value const &v, dialogue const &d ) } return ret; } -double _test_len( diag_value const &v, dialogue const &d ) +double _test_len( diag_value const &v, const_dialogue const &d ) { double ret{}; for( diag_value const &w : v.array( d ) ) { @@ -1415,9 +1416,8 @@ double _test_len( diag_value const &v, dialogue const &d ) } return ret; } -std::function _test_func( std::vector const ¶ms, - diag_kwargs const &kwargs, - double ( *f )( diag_value const &v, dialogue const &d ) ) +diag_eval_dbl_f _test_func( std::vector const ¶ms, diag_kwargs const &kwargs, + double ( *f )( diag_value const &v, const_dialogue const &d ) ) { std::vector all_params( params ); for( diag_kwargs::impl_t::value_type const &v : kwargs.kwargs ) { @@ -1425,7 +1425,7 @@ std::function _test_func( std::vector const &p all_params.emplace_back( *v.second ); } } - return [all_params, f]( dialogue const & d ) { + return [all_params, f]( const_dialogue const & d ) { double ret = 0; for( diag_value const &v : all_params ) { ret += f( v, d ); @@ -1434,23 +1434,23 @@ std::function _test_func( std::vector const &p }; } -std::function test_diag( char /* scope */, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f test_diag( char /* scope */, std::vector const ¶ms, + diag_kwargs const &kwargs ) { return _test_func( params, kwargs, _test_add ); } -std::function test_str_len( char /* scope */, - std::vector const ¶ms, diag_kwargs const &kwargs ) +diag_eval_dbl_f test_str_len( char /* scope */, std::vector const ¶ms, + diag_kwargs const &kwargs ) { return _test_func( params, kwargs, _test_len ); } -std::function value_or_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f value_or_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return[var = params[0].var(), - vor = params[1]]( dialogue const & d ) -> double { + vor = params[1]]( const_dialogue const & d ) -> double { if( std::optional has = maybe_read_var_value( var, d ); has ) { return diag_value{ *has }.dbl( d ); @@ -1459,14 +1459,14 @@ std::function value_or_eval( char /* scope */, }; } -std::function vision_range_eval( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f vision_range_eval( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - talker const *const actor = d.actor( beta ); - if( Character const *const chr = actor->get_character(); chr != nullptr ) { + return[beta = is_beta( scope )]( const_dialogue const & d ) { + const_talker const *const actor = d.const_actor( beta ); + if( Character const *const chr = actor->get_const_character(); chr != nullptr ) { return chr->unimpaired_range(); - } else if( monster const *const mon = actor->get_monster(); mon != nullptr ) { + } else if( monster const *const mon = actor->get_const_monster(); mon != nullptr ) { map &here = get_map(); tripoint_bub_ms tripoint = get_map().bub_from_abs( mon->get_location() ); return mon->sight_range( here.ambient_light_at( tripoint ) ); @@ -1476,95 +1476,94 @@ std::function vision_range_eval( char scope, }; } -std::function npc_anger_eval( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f npc_anger_eval( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - if( d.actor( beta ) ) { - return d.actor( beta )->get_npc_anger(); + return[beta = is_beta( scope )]( const_dialogue const & d ) { + if( d.const_actor( beta ) ) { + return d.const_actor( beta )->get_npc_anger(); } else { return 0; } }; } -std::function npc_fear_eval( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f npc_fear_eval( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - if( d.actor( beta ) ) { - return d.actor( beta )->get_npc_fear(); + return[beta = is_beta( scope )]( const_dialogue const & d ) { + if( d.const_actor( beta ) ) { + return d.const_actor( beta )->get_npc_fear(); } else { return 0; } }; } -std::function npc_value_eval( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f npc_value_eval( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - if( d.actor( beta ) ) { - return d.actor( beta )->get_npc_value(); + return[beta = is_beta( scope )]( const_dialogue const & d ) { + if( d.const_actor( beta ) ) { + return d.const_actor( beta )->get_npc_value(); } else { return 0; } }; } -std::function npc_trust_eval( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f npc_trust_eval( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - if( d.actor( beta ) ) { - return d.actor( beta )->get_npc_trust(); + return[beta = is_beta( scope )]( const_dialogue const & d ) { + if( d.const_actor( beta ) ) { + return d.const_actor( beta )->get_npc_trust(); } else { return 0; } }; } -std::function npc_anger_ass( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f npc_anger_ass( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope )]( dialogue const & d, double val ) { return d.actor( beta )->set_npc_anger( val ); }; } -std::function npc_fear_ass( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f npc_fear_ass( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope )]( dialogue const & d, double val ) { return d.actor( beta )->set_npc_fear( val ); }; } -std::function npc_value_ass( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f npc_value_ass( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope )]( dialogue const & d, double val ) { return d.actor( beta )->set_npc_value( val ); }; } - -std::function npc_trust_ass( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f npc_trust_ass( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope )]( dialogue const & d, double val ) { return d.actor( beta )->set_npc_trust( val ); }; } -std::function calories_eval( char scope, - std::vector const &/* params */, diag_kwargs const &kwargs ) +diag_eval_dbl_f calories_eval( char scope, std::vector const & /* params */, + diag_kwargs const &kwargs ) { diag_value format_value = kwargs.kwarg_or( "format", "raw" ); // dummy kwarg, intentionally discarded! diag_value ignore_weariness_val = kwargs.kwarg_or( "dont_affect_weariness" ); - return[format_value, beta = is_beta( scope )]( dialogue const & d ) -> double { + return[format_value, beta = is_beta( scope )]( const_dialogue const & d ) -> double { std::string format = format_value.str( d ); if( format != "raw" && format != "percent" ) { @@ -1574,27 +1573,26 @@ std::function calories_eval( char scope, if( format == "percent" ) { - if( d.actor( beta )->get_character() ) { - double divisor = d.actor( beta )->get_healthy_kcal() / 100.0; + if( d.const_actor( beta )->get_const_character() ) { + double divisor = d.const_actor( beta )->get_healthy_kcal() / 100.0; //if no data, default to default height of 175cm if( divisor == 0 ) { debugmsg( "Can't get healthy amount of calories, return raw calories instead" ); - return d.actor( beta )->get_stored_kcal(); + return d.const_actor( beta )->get_stored_kcal(); } - return d.actor( beta )->get_stored_kcal() / divisor; + return d.const_actor( beta )->get_stored_kcal() / divisor; } else { debugmsg( "Percent can be used only with character" ); return 0; } } else if( format == "raw" ) { - if( d.actor( beta )->get_character() ) { - return d.actor( beta )->get_stored_kcal(); + if( d.const_actor( beta )->get_const_character() ) { + return d.const_actor( beta )->get_stored_kcal(); } - item_location const *it = static_cast( d.actor( beta ) )->get_item(); + item_location const *it = d.const_actor( beta )->get_const_item(); if( it && *it ) { - npc dummy; - return dummy.compute_effective_nutrients( *it->get_item() ).kcal(); + return default_character_compute_effective_nutrients( *it->get_item() ).kcal(); } } debugmsg( "For calories(), talker is not character nor item" ); @@ -1602,8 +1600,8 @@ std::function calories_eval( char scope, }; } -std::function calories_ass( char scope, - std::vector const &/* params */, diag_kwargs const &kwargs ) +diag_assign_dbl_f calories_ass( char scope, std::vector const & /* params */, + diag_kwargs const &kwargs ) { diag_value ignore_weariness_val = kwargs.kwarg_or( "dont_affect_weariness" ); @@ -1611,18 +1609,18 @@ std::function calories_ass( char scope, const bool ignore_weariness = is_true( ignore_weariness_val.dbl( d ) ); int current_kcal = d.actor( beta )->get_stored_kcal(); int difference = val - current_kcal; - return d.actor( beta )->mod_stored_kcal( difference, ignore_weariness ); + d.actor( beta )->mod_stored_kcal( difference, ignore_weariness ); }; } -std::function weight_eval( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f weight_eval( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - if( d.actor( beta )->get_character() || d.actor( beta )->get_monster() ) { - return d.actor( beta )->get_weight(); + return[beta = is_beta( scope )]( const_dialogue const & d ) { + if( d.const_actor( beta )->get_const_character() || d.const_actor( beta )->get_const_monster() ) { + return d.const_actor( beta )->get_weight(); } - item_location const *it = static_cast( d.actor( beta ) )->get_item(); + item_location const *it = d.const_actor( beta )->get_const_item(); if( it && *it ) { return static_cast( to_milligram( it->get_item()->weight() ) ); } @@ -1631,14 +1629,14 @@ std::function weight_eval( char scope, }; } -std::function volume_eval( char scope, - std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f volume_eval( char scope, std::vector const & /* params */, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - if( d.actor( beta )->get_character() || d.actor( beta )->get_monster() ) { - return d.actor( beta )->get_volume(); + return[beta = is_beta( scope )]( const_dialogue const & d ) { + if( d.const_actor( beta )->get_const_character() || d.const_actor( beta )->get_const_monster() ) { + return d.const_actor( beta )->get_volume(); } - item_location const *it = static_cast( d.actor( beta ) )->get_item(); + item_location const *it = d.const_actor( beta )->get_const_item(); if( it && *it ) { return to_milliliter( it->get_item()->volume() ); } @@ -1647,12 +1645,12 @@ std::function volume_eval( char scope, }; } -std::function vitamin_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f vitamin_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[beta = is_beta( scope ), id = params[0]]( dialogue const & d ) { - talker const *const actor = d.actor( beta ); - if( Character const *const chr = actor->get_character(); chr != nullptr ) { + return[beta = is_beta( scope ), id = params[0]]( const_dialogue const & d ) { + const_talker const *const actor = d.const_actor( beta ); + if( Character const *const chr = actor->get_const_character(); chr != nullptr ) { return chr->vitamin_get( vitamin_id( id.str( d ) ) ); } debugmsg( "Tried to access vitamins of a non-Character talker" ); @@ -1660,8 +1658,8 @@ std::function vitamin_eval( char scope, }; } -std::function vitamin_ass( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f vitamin_ass( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { return[beta = is_beta( scope ), id = params[0]]( dialogue const & d, double val ) { if( d.actor( beta )->get_character() ) { @@ -1670,48 +1668,48 @@ std::function vitamin_ass( char scope, }; } -std::function warmth_eval( char scope, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f warmth_eval( char scope, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { - return[bpid = params[0], beta = is_beta( scope )]( dialogue const & d ) { + return[bpid = params[0], beta = is_beta( scope )]( const_dialogue const & d ) { bodypart_id bp( bpid.str( d ) ); - return units::to_legacy_bodypart_temp( d.actor( beta )->get_cur_part_temp( bp ) ); + return units::to_legacy_bodypart_temp( d.const_actor( beta )->get_cur_part_temp( bp ) ); }; } -std::function weather_eval( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_eval_dbl_f weather_eval( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { if( params[0] == "temperature" ) { - return []( dialogue const & ) { + return []( const_dialogue const & ) { return units::to_kelvin( get_weather().weather_precise->temperature ); }; } if( params[0] == "windpower" ) { - return []( dialogue const & ) { + return []( const_dialogue const & ) { return get_weather().weather_precise->windpower; }; } if( params[0] == "humidity" ) { - return []( dialogue const & ) { + return []( const_dialogue const & ) { return get_weather().weather_precise->humidity; }; } if( params[0] == "pressure" ) { - return []( dialogue const & ) { + return []( const_dialogue const & ) { return get_weather().weather_precise->pressure; }; } if( params[0] == "precipitation" ) { - return []( dialogue const & ) { + return []( const_dialogue const & ) { return precip_mm_per_hour( get_weather().weather_id->precip ); }; } throw std::invalid_argument( string_format( "Unknown weather aspect %s", params[0].str() ) ); } -std::function weather_ass( char /* scope */, - std::vector const ¶ms, diag_kwargs const &/* kwargs */ ) +diag_assign_dbl_f weather_ass( char /* scope */, std::vector const ¶ms, + diag_kwargs const & /* kwargs */ ) { if( params[0] == "temperature" ) { return []( dialogue const &, double val ) { @@ -1741,19 +1739,19 @@ std::function weather_ass( char /* scope */, throw std::invalid_argument( string_format( "Unknown weather aspect %s", params[0].str() ) ); } -std::function climate_control_str_heat_eval( char scope, +diag_eval_dbl_f climate_control_str_heat_eval( char scope, std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) { - return [beta = is_beta( scope )]( dialogue const & d ) { - return static_cast( d.actor( beta ) )->climate_control_str_heat(); + return [beta = is_beta( scope )]( const_dialogue const & d ) { + return d.const_actor( beta )->climate_control_str_heat(); }; } -std::function climate_control_str_chill_eval( char scope, +diag_eval_dbl_f climate_control_str_chill_eval( char scope, std::vector const &/* params */, diag_kwargs const &/* kwargs */ ) { - return[beta = is_beta( scope )]( dialogue const & d ) { - return static_cast( d.actor( beta ) )->climate_control_str_chill(); + return[beta = is_beta( scope )]( const_dialogue const & d ) { + return d.const_actor( beta )->climate_control_str_chill(); }; } diff --git a/src/math_parser_diag.h b/src/math_parser_diag.h index 00c11db7c7bf4..bfb6c41c84014 100644 --- a/src/math_parser_diag.h +++ b/src/math_parser_diag.h @@ -10,6 +10,13 @@ #include "math_parser_diag_value.h" + +struct dialogue; +struct const_dialogue; + +using diag_assign_dbl_f = std::function; +using diag_eval_dbl_f = std::function; + struct diag_kwargs { using impl_t = std::map; @@ -23,8 +30,6 @@ struct diag_kwargs { return diag_value{ default_value }; } }; - -struct dialogue; struct dialogue_func { dialogue_func( std::string_view sc_, int n_ ) : scopes( sc_ ), num_params( n_ ) {} @@ -32,8 +37,8 @@ struct dialogue_func { int num_params{}; }; struct dialogue_func_eval : dialogue_func { - using f_t = std::function ( * )( char scope, - std::vector const &, diag_kwargs const & ); + using f_t = diag_eval_dbl_f( * )( char scope, std::vector const &, + diag_kwargs const & ); dialogue_func_eval( std::string_view sc_, int n_, f_t f_ ) : dialogue_func( sc_, n_ ), f( f_ ) {} @@ -42,8 +47,8 @@ struct dialogue_func_eval : dialogue_func { }; struct dialogue_func_ass : dialogue_func { - using f_t = std::function ( * )( char scope, - std::vector const &, diag_kwargs const & ); + using f_t = diag_assign_dbl_f( * )( char scope, std::vector const &, + diag_kwargs const & ); dialogue_func_ass( std::string_view sc_, int n_, f_t f_ ) : dialogue_func( sc_, n_ ), f( f_ ) {} diff --git a/src/math_parser_diag_value.cpp b/src/math_parser_diag_value.cpp index 13855be80ecd2..1148a504c0eb7 100644 --- a/src/math_parser_diag_value.cpp +++ b/src/math_parser_diag_value.cpp @@ -71,7 +71,7 @@ double diag_value::dbl() const return _diag_value_at_parse_time( data ); } -double diag_value::dbl( dialogue const &d ) const +double diag_value::dbl( const_dialogue const &d ) const { return std::visit( overloaded{ []( std::monostate const &/* std */ ) @@ -101,8 +101,7 @@ double diag_value::dbl( dialogue const &d ) const }, [&d]( math_exp const & v ) { - // FIXME: maybe re-constify eval paths? - return v.eval( const_cast( d ) ); + return v.eval( d ); }, []( diag_array const & ) { @@ -123,7 +122,7 @@ std::string_view diag_value::str() const return _diag_value_at_parse_time( data ); } -std::string diag_value::str( dialogue const &d ) const +std::string diag_value::str( const_dialogue const &d ) const { return std::visit( overloaded{ []( std::monostate const &/* std */ ) @@ -146,7 +145,7 @@ std::string diag_value::str( dialogue const &d ) const [&d]( math_exp const & v ) { // NOLINTNEXTLINE(cata-translate-string-literal) - return string_format( "%g", v.eval( const_cast( d ) ) ); + return string_format( "%g", v.eval( d ) ); }, []( diag_array const & ) { @@ -167,7 +166,7 @@ var_info diag_value::var() const return _diag_value_at_parse_time( data ); } -var_info diag_value::var( dialogue const &/* d */ ) const +var_info diag_value::var( const_dialogue const &/* d */ ) const { return _diag_value_at_parse_time( data ); } @@ -187,7 +186,7 @@ diag_array const &diag_value::array() const return _diag_value_at_parse_time( data ); } -diag_array const &diag_value::array( dialogue const &/* d */ ) const +diag_array const &diag_value::array( const_dialogue const &/* d */ ) const { return _diag_value_at_parse_time( data ); } diff --git a/src/math_parser_diag_value.h b/src/math_parser_diag_value.h index a14c8af2ab8fa..c42cb93f82a93 100644 --- a/src/math_parser_diag_value.h +++ b/src/math_parser_diag_value.h @@ -12,7 +12,7 @@ #include "math_parser.h" class math_exp; -struct dialogue; +struct const_dialogue; struct diag_value; using diag_array = std::vector; @@ -68,10 +68,10 @@ struct diag_value { // evaluate and possibly convert the parameter to this type. // These do not throw and they're meant to be used at runtime - double dbl( dialogue const &d ) const; - std::string str( dialogue const &d ) const; - var_info var( dialogue const &/* d */ ) const; - diag_array const &array( dialogue const &/* d */ ) const; + double dbl( const_dialogue const &d ) const; + std::string str( const_dialogue const &d ) const; + var_info var( const_dialogue const &/* d */ ) const; + diag_array const &array( const_dialogue const &/* d */ ) const; impl_t data; }; diff --git a/src/math_parser_impl.h b/src/math_parser_impl.h index 8d8cc63b9a44a..0e25ec97ecaea 100644 --- a/src/math_parser_impl.h +++ b/src/math_parser_impl.h @@ -60,7 +60,7 @@ struct thingie; struct oper { oper( thingie l_, thingie r_, binary_op::f_t op_ ); - double eval( dialogue &d ) const; + double eval( const_dialogue const &d ) const; std::shared_ptr l, r; binary_op::f_t op{}; @@ -68,7 +68,7 @@ struct oper { struct func { explicit func( std::vector &¶ms_, math_func::f_t f_ ); - double eval( dialogue &d ) const; + double eval( const_dialogue const &d ) const; std::vector params; math_func::f_t f{}; @@ -76,27 +76,27 @@ struct func { struct func_jmath { explicit func_jmath( std::vector &¶ms_, jmath_func_id const &id_ ); - double eval( dialogue &d ) const; + double eval( const_dialogue const &d ) const; std::vector params; jmath_func_id id; }; struct func_diag_eval { - using eval_f = std::function; + using eval_f = diag_eval_dbl_f; explicit func_diag_eval( eval_f &&f_ ) : f( f_ ) {} - double eval( dialogue &d ) const { + double eval( const_dialogue const &d ) const { return f( d ); } eval_f f; }; struct func_diag_ass { - using ass_f = std::function; + using ass_f = diag_assign_dbl_f; explicit func_diag_ass( ass_f &&f_ ) : f( f_ ) {} - static double eval( dialogue &/* d */ ) { + static double eval( const_dialogue const &/* d */ ) { debugmsg( "eval() called on assignment function" ); return 0; } @@ -111,7 +111,7 @@ struct var { template explicit var( Args &&... args ) : varinfo( std::forward( args )... ) {} - double eval( dialogue &d ) const; + double eval( const_dialogue const &d ) const; var_info varinfo; }; @@ -132,7 +132,7 @@ struct ternary { std::shared_ptr mhs; std::shared_ptr rhs; - double eval( dialogue &d ) const; + double eval( const_dialogue const &d ) const; }; struct thingie { thingie() = default; @@ -142,14 +142,14 @@ struct thingie { explicit thingie( std::in_place_type_t /*t*/, Args &&...args ) : data( std::in_place_type, std::forward( args )... ) {} - constexpr double eval( dialogue &d ) const; + constexpr double eval( const_dialogue const &d ) const; using impl_t = std::variant; impl_t data; }; -constexpr double thingie::eval( dialogue &d ) const +constexpr double thingie::eval( const_dialogue const &d ) const { return std::visit( overloaded{ []( double v ) diff --git a/src/math_parser_jmath.cpp b/src/math_parser_jmath.cpp index eb3a788b6974a..d641487fee0cb 100644 --- a/src/math_parser_jmath.cpp +++ b/src/math_parser_jmath.cpp @@ -69,16 +69,16 @@ void jmath_func::finalize() } } -double jmath_func::eval( dialogue &d ) const +double jmath_func::eval( const_dialogue const &d ) const { return _exp.eval( d ); } -double jmath_func::eval( dialogue &d, std::vector const ¶ms ) const +double jmath_func::eval( const_dialogue const &d, std::vector const ¶ms ) const { - dialogue d_next( d ); + const_dialogue d_next( d ); for( std::vector::size_type i = 0; i < params.size(); i++ ) { - write_var_value( var_type::context, "npctalk_var_" + std::to_string( i ), &d_next, params[i] ); + d_next.set_value( "npctalk_var_" + std::to_string( i ), string_format( "%g", params[i] ) ); } return eval( d_next ); diff --git a/src/math_parser_jmath.h b/src/math_parser_jmath.h index 55f8a0daccc7a..801fe8329eada 100644 --- a/src/math_parser_jmath.h +++ b/src/math_parser_jmath.h @@ -18,8 +18,8 @@ struct jmath_func { bool was_loaded = false; int num_params{}; - double eval( dialogue &d ) const; - double eval( dialogue &d, std::vector const ¶ms ) const; + double eval( const_dialogue const &d ) const; + double eval( const_dialogue const &d, std::vector const ¶ms ) const; void load( const JsonObject &jo, std::string_view src ); static void load_func( const JsonObject &jo, std::string const &src ); diff --git a/src/mattack_common.h b/src/mattack_common.h index 9656a8c597eff..ba30d821b78ef 100644 --- a/src/mattack_common.h +++ b/src/mattack_common.h @@ -31,7 +31,7 @@ class mattack_actor dbl_or_var cooldown; // Dialogue conditions of the attack - std::function condition; + std::function condition; bool has_condition = false; void load( const JsonObject &jo, const std::string &src ); diff --git a/src/melee.cpp b/src/melee.cpp index 4745541e27998..14cff849ec013 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -1381,8 +1381,8 @@ void Character::roll_damage( const damage_type_id &dt, bool crit, damage_instanc } } std::tuple Character::pick_technique( - Creature &t, const item_location &weap, bool crit, - bool dodge_counter, bool block_counter, const std::vector &blacklist ) + Creature const &t, const item_location &weap, bool crit, + bool dodge_counter, bool block_counter, const std::vector &blacklist ) const { const std::vector all = martial_arts_data->get_all_techniques( weap, *this ); @@ -1414,8 +1414,8 @@ std::tuple Character::pick_tech sub_body_part_sub_limb_debug ) ); } std::optional> - Character::evaluate_technique( const matec_id &tec_id, Creature &t, const item_location &weap, - bool crit, bool dodge_counter, bool block_counter ) + Character::evaluate_technique( const matec_id &tec_id, Creature const &t, const item_location &weap, + bool crit, bool dodge_counter, bool block_counter ) const { // this could be more robust but for now it should work fine bool is_loaded = weap && weap->is_magazine_full(); @@ -1434,7 +1434,7 @@ std::optional> // Ignore this technique if we fail the dialog conditions if( tec_id->has_condition ) { - dialogue d( get_talker_for( this ), get_talker_for( t ) ); + const_dialogue d( get_const_talker_for( *this ), get_const_talker_for( t ) ); if( !tec_id->condition( d ) ) { add_msg_debug( debugmode::DF_MELEE, "Conditionals failed, attack discarded" ); return std::nullopt; @@ -1546,14 +1546,14 @@ std::optional> return std::nullopt; } -bool Character::valid_aoe_technique( Creature &t, const ma_technique &technique ) +bool Character::valid_aoe_technique( Creature const &t, const ma_technique &technique ) const { std::vector dummy_targets; return valid_aoe_technique( t, technique, dummy_targets ); } -bool Character::valid_aoe_technique( Creature &t, const ma_technique &technique, - std::vector &targets ) +bool Character::valid_aoe_technique( Creature const &t, const ma_technique &technique, + std::vector &targets ) const { if( technique.aoe.empty() ) { return false; diff --git a/src/mission.h b/src/mission.h index 0dc7e06e51426..8e39cbc0db5b4 100644 --- a/src/mission.h +++ b/src/mission.h @@ -229,7 +229,7 @@ struct mission_type { std::map dialogue; // A dynamic goal condition invoked by MGOAL_CONDITION. - std::function goal_condition; + std::function goal_condition; mission_type() = default; diff --git a/src/monattack.cpp b/src/monattack.cpp index cfdabc0fe76b9..2e8aeffa8c7d9 100644 --- a/src/monattack.cpp +++ b/src/monattack.cpp @@ -342,12 +342,12 @@ bool mattack::eat_crop( monster *z ) //been given a stomach size yet. int consumed = 1; if( item.count_by_charges() ) { - int kcal = item.get_comestible()->default_nutrition.kcal(); + int kcal = default_character_compute_effective_nutrients( item ).kcal(); z->mod_amount_eaten( kcal ); add_msg_if_player_sees( *z, _( "The %1s eats the %2s." ), z->name(), item.display_name() ); here.use_charges( p, 1, item.type->get_id(), consumed ); } else { - int kcal = item.get_comestible()->default_nutrition.kcal(); + int kcal = default_character_compute_effective_nutrients( item ).kcal(); z->mod_amount_eaten( kcal ); add_msg_if_player_sees( *z, _( "The %1s gobbles up the %2s." ), z->name(), item.display_name() ); here.use_amount( p, 1, item.type->get_id(), consumed ); @@ -495,12 +495,12 @@ bool mattack::eat_food( monster *z ) if( z->type->baby_type.baby_egg != item.type->get_id() && ( !z->has_fully_eaten() ) ) { int consumed = 1; if( item.count_by_charges() ) { - int kcal = item.get_comestible()->default_nutrition.kcal(); + int kcal = default_character_compute_effective_nutrients( item ).kcal(); z->mod_amount_eaten( kcal ); add_msg_if_player_sees( *z, _( "The %1s eats the %2s." ), z->name(), item.display_name() ); here.use_charges( p, 1, item.type->get_id(), consumed ); } else { - int kcal = item.get_comestible()->default_nutrition.kcal(); + int kcal = default_character_compute_effective_nutrients( item ).kcal(); z->mod_amount_eaten( kcal ); add_msg_if_player_sees( *z, _( "The %1s gobbles up the %2s." ), z->name(), item.display_name() ); here.use_amount( p, 1, item.type->get_id(), consumed ); diff --git a/src/monster.cpp b/src/monster.cpp index 455ec50546e63..d999a76f6ccae 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -307,6 +307,9 @@ monster::monster( const mtype_id &id ) : monster() faction = type->default_faction; upgrades = type->upgrades && ( type->half_life || type->age_grow ); reproduces = type->reproduces && type->baby_timer && !monster::has_flag( mon_flag_NO_BREED ); + if( reproduces && type->baby_timer ) { + baby_timer.emplace( calendar::turn + *type->baby_timer ); + } biosignatures = type->biosignatures; if( monster::has_flag( mon_flag_AQUATIC ) ) { fish_population = dice( 1, 20 ); @@ -561,12 +564,6 @@ void monster::try_reproduce() return; } - if( !baby_timer && has_eaten_enough() ) { - // Assume this is a freshly spawned monster (because baby_timer is not set yet), set the point when it reproduce to somewhere in the future. - // Monsters need to have eaten eat to start their pregnancy timer, but that's all. - baby_timer.emplace( calendar::turn + *type->baby_timer ); - } - bool season_spawn = false; bool season_match = true; diff --git a/src/mutation.h b/src/mutation.h index 7d746d0b2a9ec..ce3d0bc765bdb 100644 --- a/src/mutation.h +++ b/src/mutation.h @@ -114,7 +114,7 @@ struct mut_personality_score { struct reflex_activation_data { /**What variable controls the activation*/ - std::functiontrigger; + std::functiontrigger; std::pair msg_on; std::pair msg_off; diff --git a/src/npc.cpp b/src/npc.cpp index 5a6dde4b460e5..319ea72afdb99 100644 --- a/src/npc.cpp +++ b/src/npc.cpp @@ -1768,7 +1768,7 @@ float npc::vehicle_danger( int radius ) const const wrapped_vehicle &wrapped_veh = vehicles[i]; if( wrapped_veh.v->is_moving() ) { const auto &points_to_check = wrapped_veh.v->immediate_path(); - point p( get_map().getglobal( pos_bub() ).xy().raw() ); + point_abs_ms p( get_map().getglobal( pos_bub() ).xy() ); if( points_to_check.find( p ) != points_to_check.end() ) { danger = i; } @@ -1822,7 +1822,7 @@ void npc::on_attacked( const Creature &attacker ) } } -int npc::assigned_missions_value() +int npc::assigned_missions_value() const { int ret = 0; for( ::mission *m : chatbin.missions_assigned ) { diff --git a/src/npc.h b/src/npc.h index 8ffbc0e44bf1d..fc7b11f672088 100644 --- a/src/npc.h +++ b/src/npc.h @@ -89,9 +89,10 @@ void parse_tags( std::string &phrase, const Character &u, const Character &me, const itype_id &item_type = itype_id::NULL_ID() ); void parse_tags( std::string &phrase, const Character &u, const Character &me, - const dialogue &d, const itype_id &item_type = itype_id::NULL_ID() ); + const_dialogue const &d, const itype_id &item_type = itype_id::NULL_ID() ); -void parse_tags( std::string &phrase, const talker &u, const talker &me, const dialogue &d, +void parse_tags( std::string &phrase, const_talker const &u, const_talker const &me, + const_dialogue const &d, const itype_id &item_type = itype_id::NULL_ID() ); /* @@ -882,7 +883,7 @@ class npc : public Character * towards the player. */ void on_attacked( const Creature &attacker ); - int assigned_missions_value(); + int assigned_missions_value() const; // State checks // We want to kill/mug/etc the player bool is_enemy() const; diff --git a/src/npc_attack.cpp b/src/npc_attack.cpp index b14b5e06649c9..76e2b74e6482d 100644 --- a/src/npc_attack.cpp +++ b/src/npc_attack.cpp @@ -184,7 +184,7 @@ npc_attack_rating npc_attack_spell::evaluate_tripoint( if( !critter ) { // no critter? no damage! however, we assume fields are worth something if( attack_spell_id->field ) { - dialogue d( get_talker_for( source ), nullptr ); + const_dialogue d( get_const_talker_for( source ), nullptr ); total_potential += static_cast( attack_spell.field_intensity( source ) ) / static_cast( attack_spell_id->field_chance.evaluate( d ) ) / 2.0; } diff --git a/src/npc_class.cpp b/src/npc_class.cpp index 5ad16b50be239..38956414eedeb 100644 --- a/src/npc_class.cpp +++ b/src/npc_class.cpp @@ -191,7 +191,7 @@ static distribution load_distribution( const JsonObject &jo, const std::string_v bool shopkeeper_item_group::can_sell( npc const &guy ) const { - dialogue temp( get_talker_for( get_avatar() ), get_talker_for( guy ) ); + const_dialogue temp( get_const_talker_for( get_avatar() ), get_const_talker_for( guy ) ); faction *const fac = guy.get_faction(); return ( fac == nullptr || trust <= guy.get_faction()->trusts_u ) && diff --git a/src/npc_class.h b/src/npc_class.h index 1f258651c5971..23cfb1cd41acc 100644 --- a/src/npc_class.h +++ b/src/npc_class.h @@ -15,7 +15,7 @@ class npc; class JsonObject; class Trait_group; -struct dialogue; +struct const_dialogue; struct faction_price_rule; namespace trait_group @@ -52,7 +52,7 @@ struct shopkeeper_item_group { int trust = 0; bool strict = false; translation refusal; - std::function condition; + std::function condition; // Rigid shopkeeper groups will be processed a single time. Default groups are not rigid, and will be processed until the shopkeeper has no more room or remaining value to populate goods with. bool rigid = false; diff --git a/src/npctalk.cpp b/src/npctalk.cpp index 60efb08675f2f..11ed9c3a91b33 100644 --- a/src/npctalk.cpp +++ b/src/npctalk.cpp @@ -191,7 +191,7 @@ struct item_search_data { bool wielded_only; bool held_only; - std::function condition; + std::function condition; bool has_condition = false; explicit item_search_data( const JsonObject &jo ) { @@ -264,7 +264,7 @@ struct item_search_data { held_only = jo.get_bool( "held_only", false ); } - bool check( const Character *guy, const item_location &loc, const dialogue &d ) { + bool check( const Character *guy, const item_location &loc, const_dialogue const &d ) { bool match; @@ -385,7 +385,7 @@ struct item_search_data { } if( has_condition ) { - dialogue dial( d.actor( false )->clone(), get_talker_for( loc ) ); + const_dialogue dial( d.const_actor( false )->const_clone(), get_const_talker_for( loc ) ); if( !condition( dial ) ) { return false; } @@ -1778,7 +1778,7 @@ talk_response &dialogue::add_response( const std::string &text, const std::strin { talk_response result = talk_response(); result.truetext = no_translation( text ); - result.truefalse_condition = []( const dialogue & ) { + result.truefalse_condition = []( const_dialogue const & ) { return true; }; result.success.next_topic = talk_topic( r ); @@ -2070,13 +2070,13 @@ void dialogue::gen_responses( const talk_topic &the_topic ) } } -static int parse_mod( const dialogue &d, const std::string &attribute, const int factor ) +static int parse_mod( const_dialogue const &d, const std::string &attribute, const int factor ) { - return d.actor( true )->parse_mod( attribute, factor ) + d.actor( false )->parse_mod( attribute, - factor ); + return d.const_actor( true )->parse_mod( attribute, factor ) + + d.const_actor( false )->parse_mod( attribute, factor ); } -static int total_price( const talker &seller, const itype_id &item_type ) +static int total_price( const_talker const &seller, const itype_id &item_type ) { int price = 0; item tmp( item_type ); @@ -2095,9 +2095,9 @@ static int total_price( const talker &seller, const itype_id &item_type ) return price; } -int talk_trial::calc_chance( dialogue &d ) const +int talk_trial::calc_chance( const_dialogue const &d ) const { - if( d.actor( false )->has_trait( trait_DEBUG_MIND_CONTROL ) ) { + if( d.const_actor( false )->has_trait( trait_DEBUG_MIND_CONTROL ) ) { return 100; } int chance = difficulty; @@ -2109,7 +2109,8 @@ int talk_trial::calc_chance( dialogue &d ) const chance = 100; break; case TALK_TRIAL_SKILL_CHECK: - chance = d.actor( false )->get_skill_level( skill_id( skill_required ) ) >= difficulty ? 100 : 0; + chance = d.const_actor( false )->get_skill_level( skill_id( skill_required ) ) >= difficulty ? 100 : + 0; break; case TALK_TRIAL_CONDITION: if( condition ) { @@ -2119,15 +2120,16 @@ int talk_trial::calc_chance( dialogue &d ) const } break; case TALK_TRIAL_LIE: - chance += d.actor( false )->trial_chance_mod( "lie" ) + d.actor( true )->trial_chance_mod( "lie" ); + chance += d.const_actor( false )->trial_chance_mod( "lie" ) + d.const_actor( + true )->trial_chance_mod( "lie" ); break; case TALK_TRIAL_PERSUADE: - chance += d.actor( false )->trial_chance_mod( "persuade" ) + - d.actor( true )->trial_chance_mod( "persuade" ); + chance += d.const_actor( false )->trial_chance_mod( "persuade" ) + + d.const_actor( true )->trial_chance_mod( "persuade" ); break; case TALK_TRIAL_INTIMIDATE: - chance += d.actor( false )->trial_chance_mod( "intimidate" ) + - d.actor( true )->trial_chance_mod( "intimidate" ); + chance += d.const_actor( false )->trial_chance_mod( "intimidate" ) + + d.const_actor( true )->trial_chance_mod( "intimidate" ); break; } for( const auto &this_mod : modifiers ) { @@ -2244,23 +2246,25 @@ int topic_category( const talk_topic &the_topic ) void parse_tags( std::string &phrase, const Character &u, const Character &me, const itype_id &item_type ) { - dialogue d( get_talker_for( u ), get_talker_for( me ) ); + const_dialogue d( get_const_talker_for( u ), get_const_talker_for( me ) ); parse_tags( phrase, u, me, d, item_type ); } -void parse_tags( std::string &phrase, const Character &u, const Character &me, const dialogue &d, +void parse_tags( std::string &phrase, const Character &u, const Character &me, + const_dialogue const &d, const itype_id &item_type ) { - parse_tags( phrase, *get_talker_for( u ), *get_talker_for( me ), d, item_type ); + parse_tags( phrase, *get_const_talker_for( u ), *get_const_talker_for( me ), d, item_type ); } -void parse_tags( std::string &phrase, const talker &u, const talker &me, const dialogue &d, +void parse_tags( std::string &phrase, const_talker const &u, const_talker const &me, + const_dialogue const &d, const itype_id &item_type ) { phrase = SNIPPET.expand( phrase ); - const Character *u_chr = u.get_character(); - const Character *me_chr = me.get_character(); + const Character *u_chr = u.get_const_character(); + const Character *me_chr = me.get_const_character(); size_t fa; size_t fb; size_t fa_; @@ -2533,51 +2537,51 @@ void dialogue::add_topic( const talk_topic &topic ) } } -void dialogue::set_value( const std::string &key, const std::string &value ) +void const_dialogue::set_value( const std::string &key, const std::string &value ) { context[key] = value; } -void dialogue::remove_value( const std::string &key ) +void const_dialogue::remove_value( const std::string &key ) { context->erase( key ); } -std::string dialogue::get_value( const std::string &key ) const +std::string const_dialogue::get_value( const std::string &key ) const { return maybe_get_value( key ).value_or( std::string{} ); } -std::optional dialogue::maybe_get_value( const std::string &key ) const +std::optional const_dialogue::maybe_get_value( const std::string &key ) const { auto it = context->find( key ); return it == context->end() ? std::nullopt : std::optional { it->second }; } -void dialogue::set_conditional( const std::string &key, - const std::function &value ) +void const_dialogue::set_conditional( const std::string &key, + const std::function &value ) { conditionals[key] = value; } -bool dialogue::evaluate_conditional( const std::string &key, dialogue &d ) +bool const_dialogue::evaluate_conditional( const std::string &key, const_dialogue const &d ) const { auto it = conditionals->find( key ); return ( it == conditionals->end() ) ? false : it->second( d ); } -const std::unordered_map &dialogue::get_context() const +const std::unordered_map &const_dialogue::get_context() const { return context; } -const std::unordered_map> - &dialogue::get_conditionals() const +const std::unordered_map> + &const_dialogue::get_conditionals() const { return conditionals; } -void dialogue::amend_callstack( const std::string &value ) +void const_dialogue::amend_callstack( const std::string &value ) { if( !callstack.empty() ) { callstack += " \\ " + value; @@ -2586,7 +2590,7 @@ void dialogue::amend_callstack( const std::string &value ) } } -std::string dialogue::get_callstack() const +std::string const_dialogue::get_callstack() const { if( !callstack.empty() ) { return "Callstack: " + callstack; @@ -2594,6 +2598,16 @@ std::string dialogue::get_callstack() const return ""; } +const_talker *const_dialogue::const_actor( bool is_beta ) const +{ + if( !has_beta && is_beta ) { + debugmsg( "Tried to use an invalid beta talker. %s", get_callstack() ); + } else if( !has_alpha && !is_beta ) { + debugmsg( "Tried to use an invalid alpha talker. %s", get_callstack() ); + } + return ( is_beta ? beta : alpha ).get(); +} + talker *dialogue::actor( const bool is_beta ) const { if( !has_beta && !has_alpha ) { @@ -2616,18 +2630,19 @@ talker *dialogue::actor( const bool is_beta ) const return ( is_beta ? beta : alpha ).get(); } -bool dialogue::has_actor( bool is_beta ) const +bool const_dialogue::has_actor( bool is_beta ) const { return is_beta ? has_beta : has_alpha; } -dialogue::dialogue( const dialogue &d ) : has_beta( d.has_beta ), has_alpha( d.has_alpha ) +const_dialogue::const_dialogue( const const_dialogue &d ) + : has_beta( d.has_beta ), has_alpha( d.has_alpha ) { if( has_alpha ) { - alpha = d.actor( false )->clone(); + alpha = d.const_actor( false )->const_clone(); } if( has_beta ) { - beta = d.actor( true )->clone(); + beta = d.const_actor( true )->const_clone(); } if( !has_alpha && !has_beta ) { debugmsg( "Constructed a dialogue with no actors! %s", get_callstack() ); @@ -2641,40 +2656,38 @@ dialogue::dialogue( const dialogue &d ) : has_beta( d.has_beta ), has_alpha( d.h callstack = d.callstack; } -dialogue::dialogue( std::unique_ptr alpha_in, - std::unique_ptr beta_in ) : alpha( std::move( alpha_in ) ), beta( std::move( beta_in ) ) +dialogue::dialogue( const dialogue &d ) : const_dialogue( d ) { - has_alpha = alpha != nullptr; - has_beta = beta != nullptr; - if( !has_alpha && !has_beta ) { - debugmsg( "Constructed a dialogue with no actors! %s", get_callstack() ); + if( has_alpha ) { + alpha = d.actor( false )->clone(); + } + if( has_beta ) { + beta = d.actor( true )->clone(); } } -dialogue::dialogue( std::unique_ptr alpha_in, - std::unique_ptr beta_in, - const std::unordered_map> &cond ) : alpha( std::move( - alpha_in ) ), beta( std::move( beta_in ) ), conditionals( cond ) +dialogue::dialogue( const_dialogue const &d ) : const_dialogue( d ) { - has_alpha = alpha != nullptr; - has_beta = beta != nullptr; - if( !has_alpha && !has_beta ) { - debugmsg( "Constructed a dialogue with no actors! %s", get_callstack() ); - } } -dialogue::dialogue( std::unique_ptr alpha_in, - std::unique_ptr beta_in, - const std::unordered_map> &cond, - const std::unordered_map &ctx ) : alpha( std::move( alpha_in ) ), - beta( std::move( beta_in ) ), context( ctx ), conditionals( cond ) +const_dialogue::const_dialogue( std::unique_ptr alpha_in, + std::unique_ptr beta_in, + const std::unordered_map> &cond, + const std::unordered_map &ctx ) + : alpha( std::move( alpha_in ) ), beta( std::move( beta_in ) ), context( ctx ), conditionals( cond ) { - has_alpha = alpha != nullptr; - has_beta = beta != nullptr; + has_alpha = static_cast( alpha ); + has_beta = static_cast( beta ); +} - if( !has_alpha && !has_beta ) { - debugmsg( "Constructed a dialogue with no actors! %s", get_callstack() ); - } +dialogue::dialogue( + std::unique_ptr alpha_in, std::unique_ptr beta_in, + const std::unordered_map> &cond, + const std::unordered_map &ctx ) + : const_dialogue( alpha_in ? alpha_in->const_clone() : nullptr, + beta_in ? beta_in->const_clone() : nullptr, cond, ctx ), + alpha( std::move( alpha_in ) ), beta( std::move( beta_in ) ) +{ } talk_data talk_response::create_option_line( dialogue &d, const input_event &hotkey, @@ -3249,8 +3262,8 @@ static void run_item_eocs( const dialogue &d, bool is_npc, const std::vectorclone(), get_talker_for( loc ), - d.get_conditionals(), d.get_context() ); + dialogue newDialog( d.actor( is_npc )->clone(), get_talker_for( loc ), + d.get_conditionals(), d.get_context() ); eoc->activate( newDialog ); } } @@ -4806,7 +4819,7 @@ talk_effect_fun_t::func f_message( const JsonObject &jo, std::string_view member if( global ) { target = &get_player_character(); } else { - target = static_cast( d.actor( is_npc ) )->get_character(); + target = d.actor( is_npc )->get_const_character(); } if( !target || target->is_npc() ) { return; @@ -4945,16 +4958,8 @@ talk_effect_fun_t::func f_open_dialogue( const JsonObject &jo, std::string_view } else if( !actual_topic.empty() ) { get_avatar().talk_to( get_talker_for( std::vector { actual_topic } ), false, false, true ); - } else if( d.actor( true )->get_character() != nullptr ) { - get_avatar().talk_to( get_talker_for( d.actor( true )->get_character() ) ); - } else if( d.actor( true )->get_creature() != nullptr ) { - get_avatar().talk_to( get_talker_for( d.actor( true )->get_creature() ) ); - } else if( d.actor( true )->get_monster() != nullptr ) { - get_avatar().talk_to( get_talker_for( d.actor( true )->get_monster() ) ); - } else if( d.actor( true )->get_item() != nullptr ) { - get_avatar().talk_to( get_talker_for( d.actor( true )->get_item() ) ); - } else if( d.actor( true )->get_computer() != nullptr ) { - get_avatar().talk_to( get_talker_for( d.actor( true )->get_computer() ), false, true ); + } else { + get_avatar().talk_to( d.actor( true )->clone() ); } run_eoc_vector( true_eocs, d ); }; @@ -5269,7 +5274,7 @@ talk_effect_fun_t::func f_set_condition( const JsonObject &jo, std::string_view str_or_var value; value = get_str_or_var( jo.get_member( member ), member ); - std::function cond; + std::function cond; read_condition( jo, "condition", cond, false ); return [value, cond]( dialogue & d ) { d.set_conditional( value.evaluate( d ), cond ); @@ -5673,9 +5678,9 @@ talk_effect_fun_t::func f_run_eocs( const JsonObject &jo, std::string_view membe if( jo.has_member( "iterations" ) ) { iterations = get_dbl_or_var( jo, "iterations" ); } - std::optional> cond; + std::optional> cond; if( jo.has_object( "condition" ) ) { - std::function cond_; + std::function cond_; read_condition( jo, "condition", cond_, false ); cond = { std::move( cond_ ) }; } @@ -6141,7 +6146,7 @@ talk_effect_fun_t::func f_map_run_eocs( const JsonObject &jo, std::string_view m if( jo.has_member( "target_var" ) ) { target_var = read_var_info( jo.get_object( "target_var" ) ); } - std::function cond; + std::function cond; read_condition( jo, "condition", cond, true ); dbl_or_var range = get_dbl_or_var( jo, "range", false, 1 ); @@ -6219,7 +6224,7 @@ talk_effect_fun_t::func f_weighted_list_eocs( const JsonObject &jo, talk_effect_fun_t::func f_if( const JsonObject &jo, std::string_view member, const std::string_view src ) { - std::function cond; + std::function cond; talk_effect_t then_effect; talk_effect_t else_effect; read_condition( jo, std::string( member ), cond, false ); @@ -7509,7 +7514,7 @@ void talk_effect_t::load_effect( const JsonObject &jo, const std::string &member talk_response::talk_response() { - truefalse_condition = []( const dialogue & ) { + truefalse_condition = []( const_dialogue const & ) { return true; }; mission_selected = nullptr; @@ -7532,7 +7537,7 @@ talk_response::talk_response( const JsonObject &jo, const std::string_view src ) truefalse_jo.read( "false", falsetext ); } else { jo.read( "text", truetext ); - truefalse_condition = []( const dialogue & ) { + truefalse_condition = []( const_dialogue const & ) { return true; }; } @@ -7874,7 +7879,7 @@ dynamic_line_t::dynamic_line_t( const JsonArray &ja ) json_dynamic_line_effect::json_dynamic_line_effect( const JsonObject &jo, const std::string &id, const std::string_view src ) { - std::function tmp_condition; + std::function tmp_condition; read_condition( jo, "condition", tmp_condition, true ); talk_effect_t tmp_effect = talk_effect_t( jo, "effect", src ); get_raw_debug_fields( jo, debug_info ); diff --git a/src/overmap.cpp b/src/overmap.cpp index 15a51d145adc3..84e7ace4fab89 100644 --- a/src/overmap.cpp +++ b/src/overmap.cpp @@ -4270,7 +4270,17 @@ static std::map> camp_migra void overmap::load_oter_id_migration( const JsonObject &jo ) { for( const JsonMember &kv : jo.get_object( "oter_ids" ) ) { - oter_id_migrations.emplace( kv.name(), kv.get_string() ); + const std::string old_id = kv.name(); + const std::string new_id = kv.get_string(); + // Allow overriding migrations for omts moved to mods + if( old_id == new_id ) { + if( auto it = oter_id_migrations.find( old_id ); it != oter_id_migrations.end() ) { + oter_id_migrations.erase( it ); + } + } else { + // Allow overriding migrations for mods that have better omts to use + oter_id_migrations.insert_or_assign( old_id, new_id ); + } } } diff --git a/src/projectile.cpp b/src/projectile.cpp index 87a38e5739eb5..fef70423babab 100644 --- a/src/projectile.cpp +++ b/src/projectile.cpp @@ -144,7 +144,7 @@ static void foamcrete_build( const tripoint_bub_ms &p ) } } -void apply_ammo_effects( const Creature *source, const tripoint_bub_ms &p, +void apply_ammo_effects( Creature *source, const tripoint_bub_ms &p, const std::set &effects, const int dealt_damage ) { map &here = get_map(); diff --git a/src/projectile.h b/src/projectile.h index e4acfbcee30ef..48b15c1312100 100644 --- a/src/projectile.h +++ b/src/projectile.h @@ -74,7 +74,7 @@ struct dealt_projectile_attack { double missed_by; // Accuracy of dealt attack }; -void apply_ammo_effects( const Creature *source, const tripoint_bub_ms &p, +void apply_ammo_effects( Creature *source, const tripoint_bub_ms &p, const std::set &effects, int dealt_damage ); int max_aoe_size( const std::set &tags ); diff --git a/src/ranged.cpp b/src/ranged.cpp index d7c5fc276bc67..8fddfdef1fe50 100644 --- a/src/ranged.cpp +++ b/src/ranged.cpp @@ -521,13 +521,13 @@ target_handler::trajectory target_handler::mode_turrets( avatar &you, vehicle &v int range_total = 0; for( vehicle_part *t : turrets ) { int range = veh.turret_query( *t ).range(); - tripoint pos = veh.global_part_pos3( *t ); + tripoint_bub_ms pos = veh.bub_part_pos( *t ); int res = 0; - res = std::max( res, rl_dist( you.pos(), pos + point( range, 0 ) ) ); - res = std::max( res, rl_dist( you.pos(), pos + point( -range, 0 ) ) ); - res = std::max( res, rl_dist( you.pos(), pos + point( 0, range ) ) ); - res = std::max( res, rl_dist( you.pos(), pos + point( 0, -range ) ) ); + res = std::max( res, rl_dist( you.pos_bub(), pos + point( range, 0 ) ) ); + res = std::max( res, rl_dist( you.pos_bub(), pos + point( -range, 0 ) ) ); + res = std::max( res, rl_dist( you.pos_bub(), pos + point( 0, range ) ) ); + res = std::max( res, rl_dist( you.pos_bub(), pos + point( 0, -range ) ) ); range_total = std::max( range_total, res ); } @@ -998,7 +998,7 @@ int Character::fire_gun( const tripoint_bub_ms &target, int shots, item &gun, it bool bipod = here.has_flag_ter_or_furn( ter_furn_flag::TFLAG_MOUNTABLE, pos_bub() ) || is_prone(); if( !bipod ) { if( const optional_vpart_position vp = here.veh_at( pos_bub() ) ) { - bipod = vp->vehicle().has_part( pos(), "MOUNTABLE" ); + bipod = vp->vehicle().has_part( pos_bub(), "MOUNTABLE" ); } } diff --git a/src/savegame_json.cpp b/src/savegame_json.cpp index 5cc9bd9c3673a..a2c11e559729f 100644 --- a/src/savegame_json.cpp +++ b/src/savegame_json.cpp @@ -2521,6 +2521,8 @@ void monster::load( const JsonObject &data ) data.read( "baby_timer", baby_timer ); if( baby_timer && *baby_timer == calendar::before_time_starts ) { baby_timer.reset(); + } else if( reproduces && type->baby_timer && !baby_timer ) { // Remove after 0.I + baby_timer.emplace( calendar::turn + *type->baby_timer ); } biosignatures = data.get_bool( "biosignatures", type->biosignatures ); @@ -3189,12 +3191,12 @@ void vehicle_part::deserialize( const JsonObject &data ) data.read( "items", items ); data.read( "tools", tools ); data.read( "salvageable", salvageable ); - data.read( "target_first_x", target.first.x ); - data.read( "target_first_y", target.first.y ); - data.read( "target_first_z", target.first.z ); - data.read( "target_second_x", target.second.x ); - data.read( "target_second_y", target.second.y ); - data.read( "target_second_z", target.second.z ); + data.read( "target_first_x", target.first.x() ); + data.read( "target_first_y", target.first.y() ); + data.read( "target_first_z", target.first.z() ); + data.read( "target_second_x", target.second.x() ); + data.read( "target_second_y", target.second.y() ); + data.read( "target_second_z", target.second.z() ); data.read( "ammo_pref", ammo_pref ); data.read( "locked", locked ); data.read( "last_disconnected", last_disconnected ); @@ -3240,15 +3242,15 @@ void vehicle_part::serialize( JsonOut &json ) const json.member( "items", items ); json.member( "tools", tools ); json.member( "salvageable", salvageable ); - if( target.first != tripoint_min ) { - json.member( "target_first_x", target.first.x ); - json.member( "target_first_y", target.first.y ); - json.member( "target_first_z", target.first.z ); + if( target.first != tripoint_abs_ms_min ) { + json.member( "target_first_x", target.first.x() ); + json.member( "target_first_y", target.first.y() ); + json.member( "target_first_z", target.first.z() ); } - if( target.second != tripoint_min ) { - json.member( "target_second_x", target.second.x ); - json.member( "target_second_y", target.second.y ); - json.member( "target_second_z", target.second.z ); + if( target.second != tripoint_abs_ms_min ) { + json.member( "target_second_x", target.second.x() ); + json.member( "target_second_y", target.second.y() ); + json.member( "target_second_z", target.second.z() ); } json.member( "ammo_pref", ammo_pref ); json.member( "locked", locked ); @@ -3283,16 +3285,16 @@ void vehicle_part::carried_part_data::serialize( JsonOut &json ) const void label::deserialize( const JsonObject &data ) { data.allow_omitted_members(); - data.read( "x", x ); - data.read( "y", y ); + data.read( "x", x() ); + data.read( "y", y() ); data.read( "text", text ); } void label::serialize( JsonOut &json ) const { json.start_object(); - json.member( "x", x ); - json.member( "y", y ); + json.member( "x", x() ); + json.member( "y", y() ); json.member( "text", text ); json.end_object(); } @@ -3475,11 +3477,11 @@ void vehicle::serialize( JsonOut &json ) const json.end_object(); } json.end_array(); - tripoint other_tow_temp_point; + tripoint_bub_ms other_tow_temp_point; if( is_towed() ) { vehicle *tower = tow_data.get_towed_by(); if( tower ) { - other_tow_temp_point = tower->global_part_pos3( tower->get_tow_part() ); + other_tow_temp_point = tower->bub_part_pos( tower->get_tow_part() ); } } json.member( "other_tow_point", other_tow_temp_point ); diff --git a/src/shop_cons_rate.cpp b/src/shop_cons_rate.cpp index d52d1a269cb3b..69d8e90b3614e 100644 --- a/src/shop_cons_rate.cpp +++ b/src/shop_cons_rate.cpp @@ -25,7 +25,7 @@ bool icg_entry::operator==( icg_entry const &rhs ) const bool icg_entry::matches( item const &it, npc const &beta ) const { - dialogue temp( get_talker_for( get_avatar() ), get_talker_for( beta ) ); + const_dialogue temp( get_const_talker_for( get_avatar() ), get_const_talker_for( beta ) ); return ( !condition || condition( temp ) ) && ( itype.is_empty() || it.typeId() == itype ) && ( category.is_empty() || it.get_category_shallow().id == category ) && diff --git a/src/shop_cons_rate.h b/src/shop_cons_rate.h index daa3ec9ed71e7..e5ef8acc07e39 100644 --- a/src/shop_cons_rate.h +++ b/src/shop_cons_rate.h @@ -8,7 +8,7 @@ class JsonObject; class npc; -struct dialogue; +struct const_dialogue; constexpr char const *SHOPKEEPER_CONSUMPTION_RATES = "shopkeeper_consumption_rates"; constexpr char const *SHOPKEEPER_BLACKLIST = "shopkeeper_blacklist"; @@ -19,7 +19,7 @@ struct icg_entry { item_group_id item_group; translation message; - std::function condition; + std::function condition; bool operator==( icg_entry const &rhs ) const; bool matches( item const &it, npc const &beta ) const; diff --git a/src/sounds.cpp b/src/sounds.cpp index bda94b3341216..b5b33c2d75320 100644 --- a/src/sounds.cpp +++ b/src/sounds.cpp @@ -1063,10 +1063,10 @@ void sfx::do_vehicle_exterior_engine_sfx() for( wrapped_vehicle vehicle : vehs ) { if( vehicle.v->vehicle_noise > 0 && vehicle.v->vehicle_noise - - sound_distance( player_character.pos(), vehicle.v->global_pos3() ) > noise_factor ) { + sound_distance( player_character.pos_bub().raw(), vehicle.v->pos_bub().raw() ) > noise_factor ) { - noise_factor = vehicle.v->vehicle_noise - sound_distance( player_character.pos(), - vehicle.v->global_pos3() ); + noise_factor = vehicle.v->vehicle_noise - sound_distance( player_character.pos_bub().raw(), + vehicle.v->pos_bub().raw() ); veh = vehicle.v; } } @@ -1105,7 +1105,7 @@ void sfx::do_vehicle_exterior_engine_sfx() if( is_channel_playing( ch ) ) { if( engine_external_id_and_variant == id_and_variant ) { - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->global_pos3() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "PLAYING exterior_engine_sound, vol: ex:%d true:%d", vol, Mix_Volume( ch_int, -1 ) ); @@ -1115,7 +1115,7 @@ void sfx::do_vehicle_exterior_engine_sfx() add_msg_debug( debugmode::DF_SOUND, "STOP exterior_engine_sound, change id/var" ); play_ambient_variant_sound( id_and_variant.first, id_and_variant.second, seas_str, indoors, night, 128, ch, 0 ); - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->global_pos3() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "START exterior_engine_sound %s %s vol: %d", id_and_variant.first, @@ -1126,7 +1126,7 @@ void sfx::do_vehicle_exterior_engine_sfx() play_ambient_variant_sound( id_and_variant.first, id_and_variant.second, seas_str, indoors, night, 128, ch, 0 ); add_msg_debug( debugmode::DF_SOUND, "Vol: %d %d", vol, Mix_Volume( ch_int, -1 ) ); - Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->global_pos3() ) ), 0 ); + Mix_SetPosition( ch_int, to_degrees( get_heard_angle( veh->pos_bub().raw() ) ), 0 ); add_msg_debug( debugmode::DF_SOUND, "Vol: %d %d", vol, Mix_Volume( ch_int, -1 ) ); set_channel_volume( ch, vol ); add_msg_debug( debugmode::DF_SOUND, "START exterior_engine_sound NEW %s %s vol: ex:%d true:%d", diff --git a/src/talker.h b/src/talker.h index d2181adee23e8..f8723663e7d07 100644 --- a/src/talker.h +++ b/src/talker.h @@ -37,48 +37,36 @@ using bodytype_id = std::string; * Talker is a virtual abstract class and should never really be used. Instead, * entity specific talker child classes such as character_talker should be used. */ -class talker +class const_talker { public: - virtual ~talker() = default; - virtual std::unique_ptr clone() const { - return std::make_unique(); + const_talker() = default; + const_talker( const const_talker & ) = default; + const_talker( const_talker && ) = delete; + const_talker &operator=( const const_talker & ) = default; + const_talker &operator=( const_talker && ) = delete; + virtual ~const_talker() = default; + + virtual std::unique_ptr const_clone() const { + return std::make_unique(); } // virtual member accessor functions - virtual Character *get_character() { - return nullptr; - } - virtual const Character *get_character() const { - return nullptr; - } - virtual npc *get_npc() { - return nullptr; - } - virtual npc *get_npc() const { - return nullptr; - } - virtual item_location *get_item() { - return nullptr; - } - virtual item_location const *get_item() const { - return nullptr; - } - virtual monster *get_monster() { + virtual Character const *get_const_character() const { return nullptr; } - virtual const monster *get_monster() const { + virtual npc const *get_const_npc() const { return nullptr; } - virtual Creature *get_creature() { + virtual item_location const *get_const_item() const { return nullptr; } - virtual const Creature *get_creature() const { + virtual monster const *get_const_monster() const { return nullptr; } - virtual computer *get_computer() { + virtual Creature const *get_const_creature() const { return nullptr; } - virtual const computer *get_computer() const { + virtual computer const *get_const_computer() const { return nullptr; } // identity and location @@ -115,20 +103,17 @@ class talker virtual tripoint_abs_omt global_omt_location() const { return {}; } - virtual void set_pos( tripoint ) {} virtual std::string distance_to_goal() const { return ""; } // mandatory functions for starting a dialogue - virtual bool will_talk_to_u( const Character &, bool ) { + virtual bool will_talk_to_u( const Character &, bool ) const { return false; } - virtual std::vector get_topics( bool ) { + virtual std::vector get_topics( bool ) const { return {}; } - virtual void check_missions() {} - virtual void update_missions( const std::vector & ) {} virtual bool check_hostile_response( int ) const { return false; } @@ -167,14 +152,6 @@ class talker virtual int per_cur() const { return 0; } - virtual void set_str_max( int ) {} - virtual void set_dex_max( int ) {} - virtual void set_int_max( int ) {} - virtual void set_per_max( int ) {} - virtual void set_str_bonus( int ) {} - virtual void set_dex_bonus( int ) {} - virtual void set_int_bonus( int ) {} - virtual void set_per_bonus( int ) {} virtual int get_str_max() const { return 0; } @@ -223,10 +200,6 @@ class talker virtual int get_spell_sum( const trait_id &, int ) const { return 0; } - virtual void set_spell_level( const spell_id &, int ) {} - virtual void set_spell_exp( const spell_id &, int ) {} - virtual void set_skill_level( const skill_id &, int ) {} - virtual void set_skill_exp( const skill_id &, int, bool ) {} virtual bool has_trait( const trait_id & ) const { return false; } @@ -243,20 +216,9 @@ class talker virtual bool has_recipe( const recipe_id & ) const { return false; } - virtual void learn_recipe( const recipe_id & ) {} - virtual void forget_recipe( const recipe_id & ) {} - virtual void mutate( const int &, const bool & ) {} virtual int get_daily_calories( int, std::string const & ) const { return 0; } - virtual void mutate_category( const mutation_category_id &, const bool & ) {} - virtual void mutate_towards( const trait_id &, const mutation_category_id &, const bool & ) {}; - virtual void set_mutation( const trait_id &, const mutation_variant * = nullptr ) {} - virtual void unset_mutation( const trait_id & ) {} - virtual void activate_mutation( const trait_id & ) {} - virtual void deactivate_mutation( const trait_id & ) {} - virtual void set_trait_purifiability( const trait_id &, const bool & ) {} - virtual void set_sleepiness( int ) {}; virtual bool has_flag( const json_character_flag & ) const { return false; } @@ -290,9 +252,7 @@ class talker virtual time_duration proficiency_practiced_time( const proficiency_id & ) const { return 0_seconds; } - virtual void set_proficiency_practiced_time( const proficiency_id &, int ) {} - virtual void train_proficiency_for( const proficiency_id &, int ) {} - virtual std::vector skills_offered_to( const talker & ) const { + virtual std::vector skills_offered_to( const_talker const & ) const { return {}; } virtual std::vector skills_teacheable() const { @@ -301,48 +261,46 @@ class talker virtual std::string skill_seminar_text( const skill_id & ) const { return {}; } - virtual std::string skill_training_text( const talker &, const skill_id & ) const { + virtual std::string skill_training_text( const_talker const &, const skill_id & ) const { return {}; } virtual std::vector proficiencies_teacheable() const { return {}; } - virtual std::vector proficiencies_offered_to( const talker & ) const { + virtual std::vector proficiencies_offered_to( const_talker const & ) const { return {}; } virtual std::string proficiency_seminar_text( const proficiency_id & ) const { return {}; } - virtual std::string proficiency_training_text( const talker &, const proficiency_id & ) const { + virtual std::string proficiency_training_text( const_talker const &, + const proficiency_id & ) const { return {}; } virtual std::vector styles_teacheable() const { return {}; } - virtual std::vector styles_offered_to( const talker & ) const { + virtual std::vector styles_offered_to( const_talker const & ) const { return {}; } virtual std::string style_seminar_text( const matype_id & ) const { return {}; } - virtual std::string style_training_text( const talker &, const matype_id & ) const { + virtual std::string style_training_text( const_talker const &, const matype_id & ) const { return {}; } virtual std::vector spells_teacheable() const { return {}; } - virtual std::vector spells_offered_to( talker & ) const { + virtual std::vector spells_offered_to( const_talker const & ) const { return {}; } virtual std::string spell_seminar_text( const spell_id & ) const { return {}; } - virtual std::string spell_training_text( talker &, const spell_id & ) const { + virtual std::string spell_training_text( const_talker const &, const spell_id & ) const { return {}; } - virtual void store_chosen_training( const skill_id &, const matype_id &, - const spell_id &, const proficiency_id & ) { - } // effects and values virtual bool has_effect( const efftype_id &, const bodypart_id & ) const { @@ -363,19 +321,12 @@ class talker virtual bool is_mute() const { return false; } - virtual void add_effect( const efftype_id &, const time_duration &, const std::string &, bool, bool, - int ) {} - virtual void remove_effect( const efftype_id &, const std::string & ) {} - virtual void add_bionic( const bionic_id & ) {} - virtual void remove_bionic( const bionic_id & ) {} virtual std::string get_value( const std::string &key ) const { return maybe_get_value( key ).value_or( std::string{} ); } virtual std::optional maybe_get_value( const std::string & ) const { return std::nullopt; } - virtual void set_value( const std::string &, const std::string & ) {} - virtual void remove_value( const std::string & ) {} // inventory, buying, and selling virtual bool is_wearing( const itype_id & ) const { @@ -391,22 +342,12 @@ class talker virtual bool has_charges( const itype_id &, int, bool ) const { return false; } - virtual std::list use_charges( const itype_id &, int ) { - return {}; - } - // bool = match tool containing charges of itype_id - virtual std::list use_charges( const itype_id &, int, bool ) { - return {}; - } virtual bool has_amount( const itype_id &, int ) const { return false; } virtual int get_amount( const itype_id & ) const { return 0; } - virtual std::list use_amount( const itype_id &, int ) { - return {}; - } virtual int value( const item & ) const { return 0; } @@ -416,43 +357,25 @@ class talker virtual int debt() const { return 0; } - virtual void add_debt( int ) {} virtual int sold() const { return 0; } - virtual void add_sold( int ) {} - virtual std::vector items_with( const std::function & ) const { - return {}; - } virtual std::vector const_items_with( const std::function & ) const { return {}; } - virtual void i_add( const item & ) {} - virtual void i_add_or_drop( item &, bool = false ) {} - virtual void remove_items_with( const std::function & ) {} virtual bool unarmed_attack() const { return false; } virtual bool can_stash_weapon() const { return false; } - virtual bool has_stolen_item( const talker & ) const { + virtual bool has_stolen_item( const_talker const & ) const { return false; } virtual int cash_to_favor( int ) const { return 0; } - virtual std::string give_item_to( bool ) { - return _( "Nope." ); - } - virtual bool buy_from( int ) { - return false; - } - virtual bool buy_monster( talker &, const mtype_id &, int, int, bool, - const translation & ) { - return false; - } // missions virtual std::vector available_missions() const { @@ -464,17 +387,11 @@ class talker virtual mission *selected_mission() const { return nullptr; } - virtual void select_mission( mission * ) { - } - virtual void add_mission( const mission_type_id & ) {} - virtual void set_companion_mission( const std::string & ) {} // factions and alliances virtual faction *get_faction() const { return nullptr; } - virtual void set_fac( const faction_id & ) {} - virtual void add_faction_rep( int ) {} virtual bool is_following() const { return false; } @@ -490,23 +407,17 @@ class talker virtual bool is_enemy() const { return false; } - virtual void make_angry() {} // ai rules virtual bool has_ai_rule( const std::string &, const std::string & ) const { return false; } - virtual void toggle_ai_rule( const std::string &, const std::string & ) {} - virtual void set_ai_rule( const std::string &, const std::string & ) {} - virtual void clear_ai_rule( const std::string &, const std::string & ) {} - - virtual void set_fac_relation( const Character *, npc_factions::relationship, bool ) {} // other descriptors virtual std::string get_job_description() const { return ""; } - virtual std::string evaluation_by( const talker & ) const { + virtual std::string evaluation_by( const_talker const & ) const { return ""; } virtual std::string view_personality_traits() const { @@ -524,7 +435,6 @@ class talker virtual bool is_myclass( const npc_class_id & ) const { return false; } - virtual void set_class( const npc_class_id & ) {} virtual int get_activity_level() const { return 0; } @@ -558,42 +468,22 @@ class talker virtual int get_addiction_turns( const addiction_id & ) const { return 0; } - virtual void set_addiction_turns( const addiction_id &, int ) {} - virtual void mod_stored_kcal( int, bool ) {} - virtual void set_stored_kcal( int ) {} - virtual void set_stim( int ) {} - virtual void set_thirst( int ) {} virtual bool is_in_control_of( const vehicle & ) const { return false; } - // speaking - virtual void say( const std::string & ) {} - virtual void shout( const std::string & = "", bool = false ) {} - - // miscellaneous - virtual bool enslave_mind() { - return false; - } virtual std::string opinion_text() const { return ""; } - virtual void add_opinion( const npc_opinion & ) {} - virtual void set_first_topic( const std::string & ) {} virtual bool is_safe() const { return true; } - virtual void mod_pain( int ) {} - virtual void set_pain( int ) {} virtual int pain_cur() const { return 0; } virtual int perceived_pain_cur() const { return 0; } - virtual void attack_target( Creature &, bool, const matec_id &, - bool, int ) {} - virtual int attack_speed() const { return 0; } @@ -637,61 +527,45 @@ class talker virtual units::energy power_max() const { return 0_kJ; } - virtual void set_power_cur( units::energy ) {} virtual int mana_cur() const { return 0; } virtual int mana_max() const { return 0; } - virtual void set_mana_cur( int ) {} - virtual void mod_daily_health( int, int ) {} virtual int morale_cur() const { return 0; } virtual int focus_cur() const { return 0; } - virtual void mod_focus( int ) {} virtual int get_pkill() const { return 0; } - virtual void set_pkill( int ) {} virtual int get_stamina() const { return 0; } - virtual void set_stamina( int ) {} virtual int get_sleep_deprivation() const { return 0; } - virtual void set_sleep_deprivation( int ) {} virtual int get_rad() const { return 0; } - virtual void set_rad( int ) {} virtual int get_anger() const { return 0; } - virtual void set_anger( int ) {} - virtual void set_morale( int ) {} virtual int get_friendly() const { return 0; } virtual int get_difficulty() const { return 0; } - virtual void set_friendly( int ) {} - virtual void add_morale( const morale_type &, int, int, time_duration, time_duration, bool ) {} - virtual void remove_morale( const morale_type & ) {} - virtual void set_kill_xp( int ) {} virtual int get_kill_xp() const { return 0; } - virtual void set_age( int ) {} virtual int get_age() const { return 0; } - virtual void set_height( int ) {} virtual int get_height() const { return 0; } @@ -701,19 +575,15 @@ class talker virtual int get_weight() const { return 0; } - virtual void set_npc_trust( int ) {} virtual int get_npc_trust() const { return 0; } - virtual void set_npc_fear( int ) {} virtual int get_npc_fear() const { return 0; } - virtual void set_npc_value( int ) {} virtual int get_npc_value() const { return 0; } - virtual void set_npc_anger( int ) {} virtual int get_npc_anger() const { return 0; } @@ -744,15 +614,10 @@ class talker virtual int get_part_hp_max( const bodypart_id & ) const { return 0; } - virtual void set_all_parts_hp_cur( int ) const {} - virtual void set_part_hp_cur( const bodypart_id &, int ) const {} - virtual void die() {} - virtual matec_id get_random_technique( Creature &, bool, bool, + virtual matec_id get_random_technique( Creature const &, bool, bool, bool, const std::vector & = {} ) const { return matec_id(); } - virtual void learn_martial_art( const matype_id & ) const {} - virtual void forget_martial_art( const matype_id & ) const {} virtual bool knows_martial_art( const matype_id & ) const { return false; } @@ -766,8 +631,170 @@ class talker return 0; } }; + +class talker: virtual public const_talker +{ + public: + talker() = default; + talker( const talker & ) = default; + talker( talker && ) = delete; + talker &operator=( const talker & ) = default; + talker &operator=( talker && ) = delete; + ~talker() noexcept override = default; + + virtual std::unique_ptr clone() const { + return std::make_unique(); + } + + virtual Character *get_character() { + return nullptr; + } + virtual npc *get_npc() { + return nullptr; + } + virtual item_location *get_item() { + return nullptr; + } + virtual monster *get_monster() { + return nullptr; + } + virtual Creature *get_creature() { + return nullptr; + } + virtual computer *get_computer() { + return nullptr; + } + virtual void set_pos( tripoint ) {} + virtual void update_missions( const std::vector & ) {} + virtual void set_str_max( int ) {} + virtual void set_dex_max( int ) {} + virtual void set_int_max( int ) {} + virtual void set_per_max( int ) {} + virtual void set_str_bonus( int ) {} + virtual void set_dex_bonus( int ) {} + virtual void set_int_bonus( int ) {} + virtual void set_per_bonus( int ) {} + virtual void set_spell_level( const spell_id &, int ) {} + virtual void set_spell_exp( const spell_id &, int ) {} + virtual void set_skill_level( const skill_id &, int ) {} + virtual void set_skill_exp( const skill_id &, int, bool ) {} + virtual void learn_recipe( const recipe_id & ) {} + virtual void forget_recipe( const recipe_id & ) {} + virtual void mutate( const int &, const bool & ) {} + virtual void mutate_category( const mutation_category_id &, const bool & ) {} + virtual void mutate_towards( const trait_id &, const mutation_category_id &, const bool & ) {}; + virtual void set_mutation( const trait_id &, const mutation_variant * = nullptr ) {} + virtual void unset_mutation( const trait_id & ) {} + virtual void activate_mutation( const trait_id & ) {} + virtual void deactivate_mutation( const trait_id & ) {} + virtual void set_trait_purifiability( const trait_id &, const bool & ) {} + virtual void set_sleepiness( int ) {}; + virtual void set_proficiency_practiced_time( const proficiency_id &, int ) {} + virtual void train_proficiency_for( const proficiency_id &, int ) {} + virtual void store_chosen_training( const skill_id &, const matype_id &, + const spell_id &, const proficiency_id & ) { + } + virtual void add_effect( const efftype_id &, const time_duration &, const std::string &, bool, bool, + int ) {} + virtual void remove_effect( const efftype_id &, const std::string & ) {} + virtual void add_bionic( const bionic_id & ) {} + virtual void remove_bionic( const bionic_id & ) {} + virtual void set_value( const std::string &, const std::string & ) {} + virtual void remove_value( const std::string & ) {} + virtual std::list use_charges( const itype_id &, int ) { + return {}; + } + // bool = match tool containing charges of itype_id + virtual std::list use_charges( const itype_id &, int, bool ) { + return {}; + } + virtual std::list use_amount( const itype_id &, int ) { + return {}; + } + virtual void add_debt( int ) {} + virtual void i_add( const item & ) {} + virtual void i_add_or_drop( item &, bool = false ) {} + virtual void remove_items_with( const std::function & ) {} + virtual std::string give_item_to( bool ) { + return _( "Nope." ); + } + virtual bool buy_from( int ) { + return false; + } + virtual bool buy_monster( talker &, const mtype_id &, int, int, bool, + const translation & ) { + return false; + } + virtual void select_mission( mission * ) { + } + virtual void check_missions() {} + virtual void add_mission( const mission_type_id & ) {} + virtual void set_companion_mission( const std::string & ) {} + virtual void set_fac( const faction_id & ) {} + virtual void add_faction_rep( int ) {} + virtual void make_angry() {} + virtual void add_sold( int ) {} + virtual void toggle_ai_rule( const std::string &, const std::string & ) {} + virtual void set_ai_rule( const std::string &, const std::string & ) {} + virtual void clear_ai_rule( const std::string &, const std::string & ) {} + virtual void set_class( const npc_class_id & ) {} + virtual void set_addiction_turns( const addiction_id &, int ) {} + virtual void mod_stored_kcal( int, bool ) {} + virtual void set_stored_kcal( int ) {} + virtual void set_stim( int ) {} + virtual void set_thirst( int ) {} + virtual void say( const std::string & ) {} + virtual void shout( const std::string & = "", bool = false ) {} + virtual bool enslave_mind() { + return false; + } + virtual void add_opinion( const npc_opinion & ) {} + virtual void set_first_topic( const std::string & ) {} + virtual void mod_pain( int ) {} + virtual void set_pain( int ) {} + virtual void set_power_cur( units::energy ) {} + virtual void set_part_hp_cur( const bodypart_id &, int ) {} + virtual void set_sleep_deprivation( int ) {} + virtual void set_rad( int ) {} + virtual void set_anger( int ) {} + virtual void set_morale( int ) {} + virtual void set_friendly( int ) {} + virtual void add_morale( const morale_type &, int, int, time_duration, time_duration, bool ) {} + virtual void remove_morale( const morale_type & ) {} + virtual void set_kill_xp( int ) {} + virtual void set_age( int ) {} + virtual void set_height( int ) {} + virtual void set_npc_trust( int ) {} + virtual void set_npc_fear( int ) {} + virtual void set_npc_value( int ) {} + virtual void set_npc_anger( int ) {} + virtual void set_all_parts_hp_cur( int ) {} + virtual void die() {} + virtual void set_mana_cur( int ) {} + virtual void mod_daily_health( int, int ) {} + virtual void mod_focus( int ) {} + virtual void set_pkill( int ) {} + virtual void set_stamina( int ) {} + virtual void learn_martial_art( const matype_id & ) {} + virtual void forget_martial_art( const matype_id & ) {} + virtual void attack_target( Creature &, bool, const matec_id &, bool, int ) {} + virtual void set_fac_relation( const Character *, npc_factions::relationship, bool ) {} + virtual std::vector items_with( const std::function & ) { + return {}; + } +}; + +template +class const_talker_cloner : virtual public B +{ + public: + std::unique_ptr const_clone() const override { + return std::make_unique( static_cast( *this ) ); + } +}; + template -class talker_cloner : public B +class talker_cloner : virtual public B { public: std::unique_ptr clone() const override { diff --git a/src/talker_avatar.cpp b/src/talker_avatar.cpp index 9b80d9317edcf..5ddcec5046821 100644 --- a/src/talker_avatar.cpp +++ b/src/talker_avatar.cpp @@ -11,7 +11,6 @@ #include "npc.h" #include "npctrade.h" #include "output.h" -#include "skill.h" #include "talker.h" #include "talker_avatar.h" #include "translations.h" @@ -24,23 +23,18 @@ static const itype_id itype_foodperson_mask_on( "foodperson_mask_on" ); static const trait_id trait_PROF_FOODP( "PROF_FOODP" ); -talker_avatar::talker_avatar( avatar *new_me ) -{ - me_chr = new_me; - me_chr_const = new_me; -} - -std::vector talker_avatar::get_topics( bool ) +std::vector talker_avatar_const::get_topics( bool ) const { std::vector add_topics; - if( has_trait( trait_PROF_FOODP ) && !( is_wearing( itype_foodperson_mask ) || - is_wearing( itype_foodperson_mask_on ) ) ) { + if( has_trait( trait_PROF_FOODP ) && + !( is_wearing( itype_foodperson_mask ) || + is_wearing( itype_foodperson_mask_on ) ) ) { add_topics.emplace_back( "TALK_NOFACE" ); } return add_topics; } -int talker_avatar::parse_mod( const std::string &attribute, const int factor ) const +int talker_avatar_const::parse_mod( const std::string &attribute, const int factor ) const { int modifier = 0; if( attribute == "U_INTIMIDATE" ) { @@ -50,7 +44,7 @@ int talker_avatar::parse_mod( const std::string &attribute, const int factor ) c return modifier; } -int talker_avatar::trial_chance_mod( const std::string &trial_type ) const +int talker_avatar_const::trial_chance_mod( const std::string &trial_type ) const { int chance = 0; const social_modifiers &me_mods = me_chr->get_mutation_bionic_social_mods(); @@ -64,9 +58,9 @@ int talker_avatar::trial_chance_mod( const std::string &trial_type ) const return chance; } -int talker_avatar::get_daily_calories( int day, std::string const &type ) const +int talker_avatar_const::get_daily_calories( int day, std::string const &type ) const { - return me_chr_const->as_avatar()->get_daily_calories( day, type ); + return me_chr->get_daily_calories( day, type ); } bool talker_avatar::buy_monster( talker &seller, const mtype_id &mtype, int cost, diff --git a/src/talker_avatar.h b/src/talker_avatar.h index ab15dd4fd55e1..e36f73c13f915 100644 --- a/src/talker_avatar.h +++ b/src/talker_avatar.h @@ -2,9 +2,9 @@ #ifndef CATA_SRC_TALKER_AVATAR_H #define CATA_SRC_TALKER_AVATAR_H -#include #include +#include "avatar.h" #include "talker_character.h" #include "type_id.h" @@ -15,21 +15,45 @@ class translation; /* * Talker wrapper class for avatar. */ -class talker_avatar: public talker_cloner +class talker_avatar_const: public const_talker_cloner { public: - explicit talker_avatar( avatar *new_me ); - ~talker_avatar() override = default; + talker_avatar_const( const talker_avatar_const & ) = default; + talker_avatar_const( talker_avatar_const && ) = delete; + talker_avatar_const &operator=( const talker_avatar_const & ) = default; + talker_avatar_const &operator=( talker_avatar_const && ) = delete; + explicit talker_avatar_const( avatar const *new_me ) + : talker_character_const{ new_me }, me_chr( new_me ) {}; + ~talker_avatar_const() override = default; // mandatory functions for starting a dialogue - std::vector get_topics( bool ) override; + std::vector get_topics( bool ) const override; int parse_mod( const std::string &attribute, int factor ) const override; int trial_chance_mod( const std::string &trial_type ) const override; int get_daily_calories( int, std::string const & ) const override; - // inventory and such + private: + avatar const *me_chr{}; +}; + +class talker_avatar: virtual public talker_avatar_const, + public talker_cloner +{ + public: + talker_avatar( const talker_avatar & ) = default; + talker_avatar( talker_avatar && ) = delete; + talker_avatar &operator=( const talker_avatar & ) = default; + talker_avatar &operator=( talker_avatar && ) = delete; + explicit talker_avatar( avatar *new_me ) + : talker_character_const( new_me ), talker_avatar_const( new_me ), + talker_character( new_me ), me_chr( new_me ) {}; + ~talker_avatar() override = default; + bool buy_monster( talker &seller, const mtype_id &mtype, int cost, int count, bool pacified, const translation &name ) override; + + private: + avatar *me_chr{}; }; #endif // CATA_SRC_TALKER_AVATAR_H diff --git a/src/talker_character.cpp b/src/talker_character.cpp index b48a572eff10a..2eaf1aa222e28 100644 --- a/src/talker_character.cpp +++ b/src/talker_character.cpp @@ -22,12 +22,6 @@ class time_duration; static const flag_id json_flag_FIT( "FIT" ); static const json_character_flag json_flag_SEESLEEP( "SEESLEEP" ); -talker_character::talker_character( Character *new_me ) -{ - me_chr = new_me; - me_chr_const = new_me; -} - std::string talker_character_const::disp_name() const { return me_chr_const->disp_name(); @@ -594,7 +588,7 @@ std::vector talker_character_const::const_items_with( const } std::vector talker_character::items_with( const std::function - &filter ) const + &filter ) { return me_chr->items_with( filter ); } @@ -641,9 +635,9 @@ bool talker_character_const::can_stash_weapon() const return me_chr_const->can_pickVolume( *me_chr_const->get_wielded_item() ); } -bool talker_character_const::has_stolen_item( const talker &guy ) const +bool talker_character_const::has_stolen_item( const_talker const &guy ) const { - const Character *owner = guy.get_character(); + const Character *owner = guy.get_const_character(); if( owner ) { for( const item *&elem : me_chr_const->inv_dump() ) { if( elem->is_old_owner( *owner, true ) ) { @@ -1130,19 +1124,19 @@ std::vector talker_character_const::spells_teacheable() const return me_chr_const->spells_offered_to( nullptr ); } -std::vector talker_character_const::skills_offered_to( const talker &student ) const +std::vector talker_character_const::skills_offered_to( const_talker const &student ) const { - if( student.get_character() ) { - return me_chr_const->skills_offered_to( student.get_character() ); + if( student.get_const_character() ) { + return me_chr_const->skills_offered_to( student.get_const_character() ); } else { return {}; } } -std::string talker_character_const::skill_training_text( const talker &student, +std::string talker_character_const::skill_training_text( const_talker const &student, const skill_id &skill ) const { - const Character *pupil = student.get_character(); + Character const *pupil = student.get_const_character(); if( !pupil ) { return ""; } @@ -1163,19 +1157,19 @@ std::string talker_character_const::skill_training_text( const talker &student, } std::vector talker_character_const::proficiencies_offered_to( - const talker &student ) const + const_talker const &student ) const { - if( student.get_character() ) { - return me_chr_const->proficiencies_offered_to( student.get_character() ); + if( student.get_const_character() ) { + return me_chr_const->proficiencies_offered_to( student.get_const_character() ); } else { return {}; } } -std::string talker_character_const::proficiency_training_text( const talker &student, +std::string talker_character_const::proficiency_training_text( const_talker const &student, const proficiency_id &proficiency ) const { - const Character *pupil = student.get_character(); + Character const *pupil = student.get_const_character(); if( !pupil ) { return ""; } @@ -1198,40 +1192,42 @@ std::string talker_character_const::proficiency_training_text( const talker &stu return string_format( _( "%s: (%2.0f%%) -> (%s)" ), name, pct_before, after_str ); } -std::vector talker_character_const::styles_offered_to( const talker &student ) const +std::vector talker_character_const::styles_offered_to( const_talker const &student ) +const { - if( student.get_character() ) { - return me_chr_const->styles_offered_to( student.get_character() ); + if( student.get_const_character() ) { + return me_chr_const->styles_offered_to( student.get_const_character() ); } else { return {}; } } -std::string talker_character_const::style_training_text( const talker &student, +std::string talker_character_const::style_training_text( const_talker const &student, const matype_id &style ) const { - if( !student.get_character() ) { + if( !student.get_const_character() ) { return ""; } else if( !me_chr_const->is_npc() || - me_chr_const->as_npc()->is_ally( *student.get_character() ) ) { + me_chr_const->as_npc()->is_ally( *student.get_const_character() ) ) { return string_format( "%s", style.obj().name ); } else { return string_format( _( "%s ( cost $%d )" ), style.obj().name, 8 ); } } -std::vector talker_character_const::spells_offered_to( talker &student ) const +std::vector talker_character_const::spells_offered_to( const_talker const &student ) const { - if( student.get_character() ) { - return me_chr_const->spells_offered_to( student.get_character() ); + if( student.get_const_character() ) { + return me_chr_const->spells_offered_to( student.get_const_character() ); } else { return {}; } } -std::string talker_character_const::spell_training_text( talker &student, const spell_id &sp ) const +std::string talker_character_const::spell_training_text( const_talker const &student, + const spell_id &sp ) const { - Character *pupil = student.get_character(); + Character const *pupil = student.get_const_character(); if( !pupil ) { return ""; } @@ -1273,34 +1269,35 @@ std::string talker_character_const::spell_seminar_text( const spell_id &s ) cons return s->name.translated(); } -std::vector talker_character::get_all_body_parts( get_body_part_flags flags ) const +std::vector talker_character_const::get_all_body_parts( get_body_part_flags flags ) +const { - return me_chr->get_all_body_parts( flags ); + return me_chr_const->get_all_body_parts( flags ); } -int talker_character::get_part_hp_cur( const bodypart_id &id ) const +int talker_character_const::get_part_hp_cur( const bodypart_id &id ) const { - return me_chr->get_part_hp_cur( id ); + return me_chr_const->get_part_hp_cur( id ); } -int talker_character::get_part_hp_max( const bodypart_id &id ) const +int talker_character_const::get_part_hp_max( const bodypart_id &id ) const { - return me_chr->get_part_hp_max( id ); + return me_chr_const->get_part_hp_max( id ); } -void talker_character::set_part_hp_cur( const bodypart_id &id, int set ) const +void talker_character::set_part_hp_cur( const bodypart_id &id, int set ) { me_chr->set_part_hp_cur( id, set ); } -void talker_character::set_all_parts_hp_cur( int set ) const +void talker_character::set_all_parts_hp_cur( int set ) { me_chr->set_all_parts_hp_cur( set ); } -bool talker_character::get_is_alive() const +bool talker_character_const::get_is_alive() const { - return !me_chr->is_dead_state(); + return !me_chr_const->is_dead_state(); } void talker_character::die() @@ -1308,10 +1305,11 @@ void talker_character::die() me_chr->die( nullptr ); } -matec_id talker_character::get_random_technique( Creature &t, bool crit, +matec_id talker_character_const::get_random_technique( Creature const &t, bool crit, bool dodge_counter, bool block_counter, const std::vector &blacklist ) const { - return std::get<0>( me_chr->pick_technique( t, me_chr->used_weapon(), crit, dodge_counter, + return std::get<0>( me_chr_const->pick_technique( t, me_chr_const->used_weapon(), crit, + dodge_counter, block_counter, blacklist ) ); } @@ -1322,12 +1320,12 @@ void talker_character::attack_target( Creature &t, bool allow_special, me_chr->melee_attack( t, allow_special, force_technique, allow_unarmed, forced_movecost ); } -void talker_character::learn_martial_art( const matype_id &id ) const +void talker_character::learn_martial_art( const matype_id &id ) { me_chr->martial_arts_data->add_martialart( id ); } -void talker_character::forget_martial_art( const matype_id &id ) const +void talker_character::forget_martial_art( const matype_id &id ) { me_chr->martial_arts_data->clear_style( id ); } diff --git a/src/talker_character.h b/src/talker_character.h index f1373968ca817..6609bc501ab44 100644 --- a/src/talker_character.h +++ b/src/talker_character.h @@ -32,24 +32,20 @@ enum class relationship : int; * Talker wrapper class for const Character access. * Should never be invoked directly. Only talker_avatar and talker_npc are really valid. */ -class talker_character_const: public talker_cloner +class talker_character_const: virtual public const_talker { public: - explicit talker_character_const( const Character *new_me ): me_chr_const( new_me ) { - } + talker_character_const( const talker_character_const & ) = default; + talker_character_const( talker_character_const && ) = delete; + talker_character_const &operator=( const talker_character_const & ) = default; + talker_character_const &operator=( talker_character_const && ) = delete; + explicit talker_character_const( const Character *new_me ) : me_chr_const( new_me ) {}; ~talker_character_const() override = default; - // underlying element accessor functions - Character *get_character() override { - return nullptr; - } - const Character *get_character() const override { + Character const *get_const_character() const override { return me_chr_const; } - Creature *get_creature() override { - return nullptr; - } - const Creature *get_creature() const override { + Creature const *get_const_creature() const override { return me_chr_const; } @@ -129,22 +125,22 @@ class talker_character_const: public talker_cloner // stats, skills, traits, bionics, magic, and proficiencies std::vector skills_teacheable() const override; - std::vector skills_offered_to( const talker &student ) const override; + std::vector skills_offered_to( const_talker const &student ) const override; std::string skill_seminar_text( const skill_id &s ) const override; - std::string skill_training_text( const talker &, const skill_id & ) const override; + std::string skill_training_text( const_talker const &, const skill_id & ) const override; std::vector proficiencies_teacheable() const override; - std::vector proficiencies_offered_to( const talker &student ) const override; + std::vector proficiencies_offered_to( const_talker const &student ) const override; std::string proficiency_seminar_text( const proficiency_id & ) const override; - std::string proficiency_training_text( const talker &student, + std::string proficiency_training_text( const_talker const &student, const proficiency_id &proficiency ) const override; std::vector styles_teacheable() const override; - std::vector styles_offered_to( const talker &student ) const override; + std::vector styles_offered_to( const_talker const &student ) const override; std::string style_seminar_text( const matype_id & ) const override; - std::string style_training_text( const talker &, const matype_id & ) const override; + std::string style_training_text( const_talker const &, const matype_id & ) const override; std::vector spells_teacheable() const override; - std::vector spells_offered_to( talker &student ) const override; + std::vector spells_offered_to( const_talker const &student ) const override; std::string spell_seminar_text( const spell_id & ) const override; - std::string spell_training_text( talker &, const spell_id & ) const override; + std::string spell_training_text( const_talker const &, const spell_id & ) const override; // inventory, buying, and selling bool is_wearing( const itype_id &item_id ) const override; @@ -158,7 +154,7 @@ class talker_character_const: public talker_cloner const override; bool unarmed_attack() const override; bool can_stash_weapon() const override; - bool has_stolen_item( const talker &guy ) const override; + bool has_stolen_item( const_talker const &guy ) const override; // factions and alliances faction *get_faction() const override; @@ -185,6 +181,11 @@ class talker_character_const: public talker_cloner bool has_item_with_flag( const flag_id &flag ) const override; int item_rads( const flag_id &flag, aggregate_type agg_func ) const override; + std::vector get_all_body_parts( get_body_part_flags flags ) const override; + int get_part_hp_cur( const bodypart_id &id ) const override; + int get_part_hp_max( const bodypart_id &id ) const override; + bool get_is_alive() const override; + bool can_see() const override; bool can_see_location( const tripoint &pos ) const override; int morale_cur() const override; @@ -211,34 +212,37 @@ class talker_character_const: public talker_cloner bool using_martial_art( const matype_id &id ) const override; int climate_control_str_heat() const override; int climate_control_str_chill() const override; + matec_id get_random_technique( Creature const &t, bool crit, bool dodge_counter, + bool block_counter, + const std::vector &blacklist = {} ) const override; + + private: + const Character *me_chr_const{}; protected: talker_character_const() = default; - const Character *me_chr_const; }; /* * Talker wrapper class for mutable Character access. * Should never be invoked directly. Only talker_avatar and talker_npc are really valid. */ -class talker_character: public talker_cloner +class talker_character: virtual public talker { public: - explicit talker_character( Character *new_me ); + talker_character( const talker_character & ) = default; + talker_character( talker_character && ) = delete; + talker_character &operator=( const talker_character & ) = default; + talker_character &operator=( talker_character && ) = delete; + explicit talker_character( Character *new_me ) : me_chr( new_me ) {}; ~talker_character() override = default; - // underlying element accessor functions Character *get_character() override { return me_chr; } - const Character *get_character() const override { - return me_chr_const; - } Creature *get_creature() override { return me_chr; } - const Creature *get_creature() const override { - return me_chr_const; - } + void set_pos( tripoint new_pos ) override; // stats, skills, traits, bionics, and magic @@ -277,7 +281,6 @@ class talker_character: public talker_cloner items_with( const std::function &filter ) const override; std::list use_charges( const itype_id &item_name, int count ) override; std::list use_charges( const itype_id &item_name, int count, bool in_tools ) override; std::list use_amount( const itype_id &item_name, int count ) override; @@ -313,22 +316,18 @@ class talker_character: public talker_cloner get_all_body_parts( get_body_part_flags flags ) const override; - int get_part_hp_cur( const bodypart_id &id ) const override; - int get_part_hp_max( const bodypart_id &id ) const override; - void set_all_parts_hp_cur( int ) const override; - void set_part_hp_cur( const bodypart_id &id, int set ) const override; - bool get_is_alive() const override; + void set_all_parts_hp_cur( int ) override; + void set_part_hp_cur( const bodypart_id &id, int set ) override; void die() override; void attack_target( Creature &t, bool allow_special, const matec_id &force_technique, bool allow_unarmed, int forced_movecost ) override; - matec_id get_random_technique( Creature &t, bool crit, bool dodge_counter, bool block_counter, - const std::vector &blacklist = {} ) - const override; - void learn_martial_art( const matype_id &id ) const override; - void forget_martial_art( const matype_id &id ) const override; + void learn_martial_art( const matype_id &id ) override; + void forget_martial_art( const matype_id &id ) override; + std::vector items_with( const std::function &filter ) override; + + private: + Character *me_chr{}; protected: talker_character() = default; - Character *me_chr; }; #endif // CATA_SRC_TALKER_CHARACTER_H diff --git a/src/talker_furniture.cpp b/src/talker_furniture.cpp index 9faeae68ac779..030ac0d289c38 100644 --- a/src/talker_furniture.cpp +++ b/src/talker_furniture.cpp @@ -1,52 +1,50 @@ -#include +#include "talker_furniture.h" -#include "character_id.h" +#include "character.h" #include "computer.h" #include "item.h" #include "itype.h" #include "magic.h" -#include "npc.h" -#include "pimpl.h" #include "point.h" -#include "talker_furniture.h" #include "vehicle.h" -std::string talker_furniture::disp_name() const +std::string talker_furniture_const::disp_name() const { return me_comp->name; } -int talker_furniture::posx() const +int talker_furniture_const::posx() const { return me_comp->loc.x; } -int talker_furniture::posy() const +int talker_furniture_const::posy() const { return me_comp->loc.y; } -int talker_furniture::posz() const +int talker_furniture_const::posz() const { return me_comp->loc.z; } -tripoint talker_furniture::pos() const +tripoint talker_furniture_const::pos() const { return me_comp->loc; } -tripoint_abs_ms talker_furniture::global_pos() const +tripoint_abs_ms talker_furniture_const::global_pos() const { return get_map().getglobal( me_comp->loc ); } -tripoint_abs_omt talker_furniture::global_omt_location() const +tripoint_abs_omt talker_furniture_const::global_omt_location() const { return get_player_character().global_omt_location(); } -std::optional talker_furniture::maybe_get_value( const std::string &var_name ) const +std::optional talker_furniture_const::maybe_get_value( const std::string &var_name ) +const { return me_comp->maybe_get_value( var_name ); } @@ -61,12 +59,12 @@ void talker_furniture::remove_value( const std::string &var_name ) me_comp->remove_value( var_name ); } -std::vector talker_furniture::get_topics( bool ) +std::vector talker_furniture_const::get_topics( bool ) const { return me_comp->chat_topics; } -bool talker_furniture::will_talk_to_u( const Character &you, bool ) +bool talker_furniture_const::will_talk_to_u( const Character &you, bool ) const { return !you.is_dead_state(); } diff --git a/src/talker_furniture.h b/src/talker_furniture.h index 745bced0d0a2d..b4abe44321658 100644 --- a/src/talker_furniture.h +++ b/src/talker_furniture.h @@ -2,14 +2,10 @@ #ifndef CATA_SRC_TALKER_FURNITURE_H #define CATA_SRC_TALKER_FURNITURE_H -#include -#include -#include #include #include "coords_fwd.h" #include "talker.h" -#include "type_id.h" class computer; struct tripoint; @@ -17,17 +13,18 @@ struct tripoint; /* * Talker wrapper class for furniture */ -class talker_furniture: public talker_cloner +class talker_furniture_const: public const_talker_cloner { public: - explicit talker_furniture( computer *new_me ): me_comp( new_me ) { - } - ~talker_furniture() override = default; + explicit talker_furniture_const( computer *new_me ): me_comp( new_me ) {}; + talker_furniture_const() = default; + talker_furniture_const( const talker_furniture_const & ) = default; + talker_furniture_const( talker_furniture_const && ) = delete; + talker_furniture_const &operator=( const talker_furniture_const & ) = default; + talker_furniture_const &operator=( talker_furniture_const && ) = delete; + ~talker_furniture_const() override = default; - computer *get_computer() override { - return me_comp; - } - computer *get_computer() const override { + computer const *get_const_computer() const override { return me_comp; } // identity and location @@ -40,14 +37,33 @@ class talker_furniture: public talker_cloner tripoint_abs_omt global_omt_location() const override; std::optional maybe_get_value( const std::string &var_name ) const override; - void set_value( const std::string &var_name, const std::string &value ) override; - void remove_value( const std::string & ) override; - std::vector get_topics( bool radio_contact ) override; - bool will_talk_to_u( const Character &you, bool force ) override; + std::vector get_topics( bool radio_contact ) const override; + bool will_talk_to_u( const Character &you, bool force ) const override; - protected: + private: + computer *me_comp{}; +}; +class talker_furniture: public talker_furniture_const, public talker_cloner +{ + public: + explicit talker_furniture( computer *new_me ): talker_furniture_const( new_me ), + me_comp( new_me ) {}; talker_furniture() = default; - computer *me_comp; + talker_furniture( const talker_furniture & ) = default; + talker_furniture( talker_furniture && ) = delete; + talker_furniture &operator=( const talker_furniture & ) = default; + talker_furniture &operator=( talker_furniture && ) = delete; + ~talker_furniture() override = default; + + computer *get_computer() override { + return me_comp; + } + + void set_value( const std::string &var_name, const std::string &value ) override; + void remove_value( const std::string & ) override; + + private: + computer *me_comp{}; }; #endif // CATA_SRC_TALKER_FURNITURE_H diff --git a/src/talker_item.cpp b/src/talker_item.cpp index 810dcbca57764..fb4dea54cc134 100644 --- a/src/talker_item.cpp +++ b/src/talker_item.cpp @@ -1,25 +1,16 @@ -#include +#include "talker_item.h" -#include "character_id.h" +#include "character.h" #include "item.h" #include "itype.h" #include "magic.h" -#include "npc.h" -#include "pimpl.h" #include "point.h" -#include "talker_item.h" #include "vehicle.h" static const ammotype ammo_battery( "battery" ); static const itype_id itype_battery( "battery" ); -talker_item::talker_item( item_location *new_me ) -{ - me_it = new_me; - me_it_const = new_me; -} - std::string talker_item_const::disp_name() const { return me_it_const->get_item()->display_name(); @@ -73,12 +64,12 @@ bool talker_item_const::has_flag( const flag_id &f ) const return me_it_const->get_item()->has_flag( f ); } -std::vector talker_item_const::get_topics( bool ) +std::vector talker_item_const::get_topics( bool ) const { return me_it_const->get_item()->typeId()->chat_topics; } -bool talker_item_const::will_talk_to_u( const Character &you, bool ) +bool talker_item_const::will_talk_to_u( const Character &you, bool ) const { return !you.is_dead_state(); } @@ -143,10 +134,10 @@ void talker_item::remove_value( const std::string &var_name ) void talker_item::set_power_cur( units::energy value ) { me_it->get_item()->ammo_set( itype_battery, clamp( static_cast( value.value() ), 0, - me_it_const->get_item()->ammo_capacity( ammo_battery ) ) ); + me_it->get_item()->ammo_capacity( ammo_battery ) ) ); } -void talker_item::set_all_parts_hp_cur( int set ) const +void talker_item::set_all_parts_hp_cur( int set ) { me_it->get_item()->set_damage( me_it->get_item()->max_damage() - set ); } diff --git a/src/talker_item.h b/src/talker_item.h index 9d2afb4efc73c..78dd7b5fc77fe 100644 --- a/src/talker_item.h +++ b/src/talker_item.h @@ -2,13 +2,9 @@ #ifndef CATA_SRC_TALKER_ITEM_H #define CATA_SRC_TALKER_ITEM_H -#include -#include -#include #include #include "coords_fwd.h" -#include "npc.h" #include "talker.h" #include "type_id.h" @@ -19,13 +15,21 @@ struct tripoint; /* * Talker wrapper class for item. */ -class talker_item_const: public talker_cloner +class talker_item_const: public const_talker_cloner { public: - explicit talker_item_const( const item_location *new_me ): me_it_const( new_me ) { - } + explicit talker_item_const( const item_location *new_me ): me_it_const( new_me ) {} + talker_item_const() = default; + talker_item_const( const talker_item_const & ) = default; + talker_item_const( talker_item_const && ) = delete; + talker_item_const &operator=( const talker_item_const & ) = default; + talker_item_const &operator=( talker_item_const && ) = delete; ~talker_item_const() override = default; + item_location const *get_const_item() const override { + return me_it_const; + } + // identity and location std::string disp_name() const override; std::string get_name() const override; @@ -40,8 +44,8 @@ class talker_item_const: public talker_cloner bool has_flag( const flag_id &f ) const override; - std::vector get_topics( bool radio_contact ) override; - bool will_talk_to_u( const Character &you, bool force ) override; + std::vector get_topics( bool radio_contact ) const override; + bool will_talk_to_u( const Character &you, bool force ) const override; int get_cur_hp( const bodypart_id & ) const override; int get_hp_max( const bodypart_id & ) const override; @@ -53,42 +57,35 @@ class talker_item_const: public talker_cloner int encumbrance_at( bodypart_id & ) const override; int get_volume() const override; int get_weight() const override; - item_location *get_item() override { - return nullptr; - } - item_location const *get_item() const override { - return me_it_const; - - } - protected: - talker_item_const() = default; - const item_location *me_it_const; + private: + const item_location *me_it_const{}; }; -class talker_item: public talker_cloner +class talker_item: public talker_item_const, public talker_cloner { public: - explicit talker_item( item_location *new_me ); + explicit talker_item( item_location *new_me ) : talker_item_const( new_me ), me_it( new_me ) {}; + talker_item() = default; + talker_item( const talker_item & ) = default; + talker_item( talker_item && ) = delete; + talker_item &operator=( const talker_item & ) = default; + talker_item &operator=( talker_item && ) = delete; ~talker_item() override = default; // underlying element accessor functions item_location *get_item() override { return me_it; } - item_location const *get_item() const override { - return me_it; - } void set_value( const std::string &var_name, const std::string &value ) override; void remove_value( const std::string & ) override; void set_power_cur( units::energy value ) override; - void set_all_parts_hp_cur( int ) const override; + void set_all_parts_hp_cur( int ) override; void die() override; - protected: - talker_item() = default; - item_location *me_it; + private: + item_location *me_it{}; }; #endif // CATA_SRC_TALKER_ITEM_H diff --git a/src/talker_monster.cpp b/src/talker_monster.cpp index 2f22aab4de421..b4d1094656459 100644 --- a/src/talker_monster.cpp +++ b/src/talker_monster.cpp @@ -1,23 +1,16 @@ -#include +#include "talker_monster.h" + #include "character.h" #include "effect.h" #include "item.h" #include "magic.h" #include "monster.h" #include "mtype.h" -#include "pimpl.h" #include "point.h" -#include "talker_monster.h" #include "vehicle.h" class time_duration; -talker_monster::talker_monster( monster *new_me ) -{ - me_mon = new_me; - me_mon_const = new_me; -} - std::string talker_monster_const::disp_name() const { return me_mon_const->disp_name(); @@ -217,7 +210,7 @@ void talker_monster::die() me_mon->die( nullptr ); } -void talker_monster::set_all_parts_hp_cur( int set ) const +void talker_monster::set_all_parts_hp_cur( int set ) { me_mon->set_hp( set ); } @@ -228,7 +221,7 @@ dealt_damage_instance talker_monster::deal_damage( Creature *source, bodypart_id return source->deal_damage( source, bp, dam ); } -std::vector talker_monster_const::get_topics( bool ) +std::vector talker_monster_const::get_topics( bool ) const { return me_mon_const->type->chat_topics; } @@ -248,7 +241,7 @@ double talker_monster_const::armor_at( damage_type_id &dt, bodypart_id &bp ) con return me_mon_const->get_armor_type( dt, bp ); } -bool talker_monster_const::will_talk_to_u( const Character &you, bool ) +bool talker_monster_const::will_talk_to_u( const Character &you, bool ) const { return !you.is_dead_state(); } diff --git a/src/talker_monster.h b/src/talker_monster.h index baba58cd51e24..00c270238b1d0 100644 --- a/src/talker_monster.h +++ b/src/talker_monster.h @@ -23,13 +23,24 @@ struct tripoint; /* * Talker wrapper class for monster. */ -class talker_monster_const: public talker_cloner +class talker_monster_const: public const_talker_cloner { public: - explicit talker_monster_const( const monster *new_me ): me_mon_const( new_me ) { - } + explicit talker_monster_const( const monster *new_me ): me_mon_const( new_me ) {} + talker_monster_const() = default; + talker_monster_const( const talker_monster_const & ) = default; + talker_monster_const( talker_monster_const && ) = delete; + talker_monster_const &operator=( const talker_monster_const & ) = default; + talker_monster_const &operator=( talker_monster_const && ) = delete; ~talker_monster_const() override = default; + monster const *get_const_monster() const override { + return me_mon_const; + } + Creature const *get_const_creature() const override { + return me_mon_const; + } + // identity and location std::string disp_name() const override; std::string get_name() const override; @@ -62,8 +73,8 @@ class talker_monster_const: public talker_cloner int get_friendly() const override; int get_size() const override; int get_grab_strength() const override; - bool will_talk_to_u( const Character &u, bool force ) override; - std::vector get_topics( bool radio_contact ) override; + std::vector get_topics( bool radio_contact ) const override; + bool will_talk_to_u( const Character &u, bool force ) const override; int get_cur_hp( const bodypart_id & ) const override; int get_hp_max( const bodypart_id & ) const override; double armor_at( damage_type_id &dt, bodypart_id &bp ) const override; @@ -71,30 +82,28 @@ class talker_monster_const: public talker_cloner bool can_see_location( const tripoint &pos ) const override; int get_volume() const override; int get_weight() const override; - protected: - talker_monster_const() = default; - const monster *me_mon_const; + + private: + const monster *me_mon_const{}; }; -class talker_monster: public talker_cloner +class talker_monster: public talker_monster_const, public talker_cloner { public: - explicit talker_monster( monster *new_me ); + explicit talker_monster( monster *new_me ): talker_monster_const( new_me ), me_mon( new_me ) {}; + talker_monster() = default; + talker_monster( const talker_monster & ) = default; + talker_monster( talker_monster && ) = delete; + talker_monster &operator=( const talker_monster & ) = default; + talker_monster &operator=( talker_monster && ) = delete; ~talker_monster() override = default; - // underlying element accessor functions monster *get_monster() override { return me_mon; } - const monster *get_monster() const override { - return me_mon_const; - } Creature *get_creature() override { return me_mon; } - const Creature *get_creature() const override { - return me_mon_const; - } // effects and values void add_effect( const efftype_id &new_effect, const time_duration &dur, @@ -112,11 +121,11 @@ class talker_monster: public talker_cloner bool get_is_alive() const override; void die() override; - void set_all_parts_hp_cur( int ) const override; + void set_all_parts_hp_cur( int ) override; dealt_damage_instance deal_damage( Creature *source, bodypart_id bp, const damage_instance &dam ) const override; - protected: - talker_monster() = default; - monster *me_mon; + + private: + monster *me_mon{}; }; #endif // CATA_SRC_TALKER_MONSTER_H diff --git a/src/talker_npc.cpp b/src/talker_npc.cpp index 7841477aa671d..9ff75f8758984 100644 --- a/src/talker_npc.cpp +++ b/src/talker_npc.cpp @@ -30,7 +30,6 @@ #include "npctrade.h" #include "output.h" #include "overmapbuffer.h" -#include "pimpl.h" #include "player_activity.h" #include "proficiency.h" #include "ret_val.h" @@ -41,7 +40,6 @@ #include "translations.h" #include "units.h" #include "units_utility.h" -#include "value_ptr.h" static const efftype_id effect_lying_down( "lying_down" ); static const efftype_id effect_narcosis( "narcosis" ); @@ -56,14 +54,7 @@ static const trait_id trait_PROF_CHURL( "PROF_CHURL" ); static const trait_id trait_PROF_FOODP( "PROF_FOODP" ); static const trait_id trait_SAPROVORE( "SAPROVORE" ); -talker_npc::talker_npc( npc *new_me ) -{ - me_npc = new_me; - me_chr = new_me; - me_chr_const = new_me; -} - -std::string talker_npc::distance_to_goal() const +std::string talker_npc_const::distance_to_goal() const { // TODO: this ignores the z-component int dist = rl_dist( me_npc->global_omt_location(), me_npc->goal ); @@ -83,7 +74,7 @@ std::string talker_npc::distance_to_goal() const return response; } -bool talker_npc::will_talk_to_u( const Character &you, bool force ) +bool talker_npc::will_talk_to_u( const Character &you, bool force ) const { if( you.is_dead_state() ) { me_npc->set_attitude( NPCATT_NULL ); @@ -109,7 +100,7 @@ bool talker_npc::will_talk_to_u( const Character &you, bool force ) return true; } -std::vector talker_npc::get_topics( bool radio_contact ) +std::vector talker_npc::get_topics( bool radio_contact ) const { avatar &player_character = get_avatar(); std::vector add_topics; @@ -229,14 +220,14 @@ void talker_npc::update_missions( const std::vector &missions_assigne } } -bool talker_npc::check_hostile_response( const int anger ) const +bool talker_npc_const::check_hostile_response( const int anger ) const { return me_npc->op_of_u.anger + anger > me_npc->hostile_anger_level(); } // Every OWED_VAL that the NPC owes you counts as +1 towards convincing static constexpr int OWED_VAL = 1000; -int talker_npc::parse_mod( const std::string &attribute, const int factor ) const +int talker_npc_const::parse_mod( const std::string &attribute, const int factor ) const { int modifier = 0; if( attribute == "ANGER" ) { @@ -270,7 +261,7 @@ int talker_npc::parse_mod( const std::string &attribute, const int factor ) cons return modifier; } -int talker_npc::trial_chance_mod( const std::string &trial_type ) const +int talker_npc_const::trial_chance_mod( const std::string &trial_type ) const { int chance = 0; if( trial_type == "lie" ) { @@ -291,7 +282,7 @@ void talker_npc::store_chosen_training( const skill_id &c_skill, const matype_id me_npc->chatbin.store_chosen_training( c_skill, c_style, c_spell, c_proficiency ); } -int talker_npc::debt() const +int talker_npc_const::debt() const { return me_npc->op_of_u.owed; } @@ -301,7 +292,7 @@ void talker_npc::add_debt( const int cost ) me_npc->op_of_u.owed += cost; } -int talker_npc::sold() const +int talker_npc_const::sold() const { return me_npc->op_of_u.sold; } @@ -311,12 +302,12 @@ void talker_npc::add_sold( const int value ) me_npc->op_of_u.sold += value; } -int talker_npc::cash_to_favor( const int value ) const +int talker_npc_const::cash_to_favor( const int value ) const { return npc_trading::cash_to_favor( *me_npc, value ); } -int talker_npc::value( const item &it ) const +int talker_npc_const::value( const item &it ) const { return me_npc->value( it ); } @@ -520,17 +511,17 @@ bool talker_npc::buy_from( const int amount ) return npc_trading::pay_npc( *me_npc, amount ); } -std::vector talker_npc::available_missions() const +std::vector talker_npc_const::available_missions() const { return me_npc->chatbin.missions; } -std::vector talker_npc::assigned_missions() const +std::vector talker_npc_const::assigned_missions() const { return me_npc->chatbin.missions_assigned; } -mission *talker_npc::selected_mission() const +mission *talker_npc_const::selected_mission() const { return me_npc->chatbin.mission_selected; } @@ -567,27 +558,27 @@ void talker_npc::add_faction_rep( const int rep_change ) } } -bool talker_npc::is_following() const +bool talker_npc_const::is_following() const { return me_npc->is_following(); } -bool talker_npc::is_friendly( const Character &guy ) const +bool talker_npc_const::is_friendly( const Character &guy ) const { return me_npc->is_friendly( guy ); } -bool talker_npc::is_enemy() const +bool talker_npc_const::is_enemy() const { return me_npc->is_enemy(); } -bool talker_npc::is_player_ally() const +bool talker_npc_const::is_player_ally() const { return me_npc->is_player_ally(); } -bool talker_npc::turned_hostile() const +bool talker_npc_const::turned_hostile() const { return me_npc->turned_hostile(); } @@ -597,8 +588,8 @@ void talker_npc::make_angry() me_npc->make_angry(); } -bool talker_npc::has_ai_rule( const std::string &type, - const std::string &rule ) const +bool talker_npc_const::has_ai_rule( const std::string &type, + const std::string &rule ) const { if( type == "aim_rule" ) { auto rule_val = aim_rule_strs.find( rule ); @@ -697,12 +688,12 @@ void talker_npc::clear_ai_rule( const std::string &, const std::string &rule ) me_npc->wield_better_weapon(); } -std::string talker_npc::get_job_description() const +std::string talker_npc_const::get_job_description() const { return me_npc->describe_mission(); } -std::string talker_npc::view_personality_traits() const +std::string talker_npc_const::view_personality_traits() const { // Special starting char so it doesn't appear as though the NPC is talking to us std::string assessment = "&"; @@ -730,7 +721,7 @@ std::string talker_npc::view_personality_traits() const return assessment; } -std::string talker_npc::evaluation_by( const talker &alpha ) const +std::string talker_npc_const::evaluation_by( const_talker const &alpha ) const { if( !alpha.can_see() ) { return _( "&You're blind and can't make anything out." ); @@ -811,12 +802,12 @@ std::string talker_npc::evaluation_by( const talker &alpha ) const } -bool talker_npc::has_activity() const +bool talker_npc_const::has_activity() const { return !me_npc->activity.is_null(); } -bool talker_npc::is_myclass( const npc_class_id &class_to_check ) const +bool talker_npc_const::is_myclass( const npc_class_id &class_to_check ) const { return me_npc->myclass == class_to_check; } @@ -831,7 +822,7 @@ void talker_npc::say( const std::string &speech ) me_npc->say( speech ); } -std::string talker_npc::opinion_text() const +std::string talker_npc_const::opinion_text() const { return me_npc->opinion_text(); } @@ -854,7 +845,7 @@ void talker_npc::set_first_topic( const std::string &chat_topic ) me_npc->chatbin.first_topic = chat_topic; } -bool talker_npc::is_safe() const +bool talker_npc_const::is_safe() const { return me_npc->is_safe(); } @@ -873,7 +864,7 @@ void talker_npc::set_npc_trust( const int trust ) me_npc->op_of_u.trust = trust; } -int talker_npc::get_npc_trust() const +int talker_npc_const::get_npc_trust() const { return me_npc->op_of_u.trust; } @@ -883,7 +874,7 @@ void talker_npc::set_npc_fear( const int fear ) me_npc->op_of_u.fear = fear; } -int talker_npc::get_npc_fear() const +int talker_npc_const::get_npc_fear() const { return me_npc->op_of_u.fear; } @@ -893,7 +884,7 @@ void talker_npc::set_npc_value( const int value ) me_npc->op_of_u.value = value; } -int talker_npc::get_npc_value() const +int talker_npc_const::get_npc_value() const { return me_npc->op_of_u.value; } @@ -903,7 +894,7 @@ void talker_npc::set_npc_anger( const int anger ) me_npc->op_of_u.anger = anger; } -int talker_npc::get_npc_anger() const +int talker_npc_const::get_npc_anger() const { return me_npc->op_of_u.anger; } diff --git a/src/talker_npc.h b/src/talker_npc.h index fad25392934f9..78bf65f327382 100644 --- a/src/talker_npc.h +++ b/src/talker_npc.h @@ -2,7 +2,6 @@ #ifndef CATA_SRC_TALKER_NPC_H #define CATA_SRC_TALKER_NPC_H -#include #include #include "faction.h" @@ -17,16 +16,18 @@ class talker; /* */ -class talker_npc : public talker_cloner +class talker_npc_const : public const_talker_cloner { public: - explicit talker_npc( npc *new_me ); - ~talker_npc() override = default; - - npc *get_npc() override { - return me_npc; - } - npc *get_npc() const override { + talker_npc_const( const talker_npc_const & ) = default; + talker_npc_const( talker_npc_const && ) = delete; + talker_npc_const &operator=( const talker_npc_const & ) = default; + talker_npc_const &operator=( talker_npc_const && ) = delete; + explicit talker_npc_const( npc const *new_me ) : talker_character_const( new_me ), + me_npc( new_me ) {}; + ~talker_npc_const() override = default; + + npc const *get_const_npc() const override { return me_npc; } @@ -34,80 +35,99 @@ class talker_npc : public talker_cloner std::string distance_to_goal() const override; // mandatory functions for starting a dialogue - bool will_talk_to_u( const Character &you, bool force ) override; - std::vector get_topics( bool radio_contact ) override; - void check_missions() override; - void update_missions( const std::vector &missions_assigned ) override; bool check_hostile_response( int anger ) const override; int parse_mod( const std::string &attribute, int factor ) const override; int trial_chance_mod( const std::string &trial_type ) const override; - void store_chosen_training( const skill_id &c_skill, const matype_id &c_style, - const spell_id &c_spell, const proficiency_id &c_proficiency ) override; // inventory, buying, and selling int debt() const override; - void add_debt( int cost ) override; int sold() const override; - void add_sold( int value ) override; int cash_to_favor( int value ) const override; - std::string give_item_to( bool to_use ) override; - bool buy_from( int amount ) override; int value( const item &it ) const override; // missions std::vector available_missions() const override; std::vector assigned_missions() const override; mission *selected_mission() const override; - void select_mission( mission *selected ) override; - void add_mission( const mission_type_id &mission_id ) override; - void set_companion_mission( const std::string &role_id ) override; // factions and alliances - void set_fac( const faction_id &new_fac_name ) override; - void add_faction_rep( int rep_change ) override; bool is_following() const override; bool is_friendly( const Character &guy ) const override; bool is_enemy() const override; bool is_player_ally() const override; bool turned_hostile() const override; - void make_angry() override; // ai rules bool has_ai_rule( const std::string &type, const std::string &rule ) const override; - void toggle_ai_rule( const std::string &type, const std::string &rule ) override; - void set_ai_rule( const std::string &type, const std::string &rule ) override; - void clear_ai_rule( const std::string &type, const std::string &rule ) override; // other descriptors std::string get_job_description() const override; std::string view_personality_traits() const override; - std::string evaluation_by( const talker &alpha ) const override; + std::string evaluation_by( const_talker const &alpha ) const override; bool has_activity() const override; bool is_myclass( const npc_class_id &class_to_check ) const override; - void set_class( const npc_class_id &new_class ) override; - - // speaking - void say( const std::string &speech ) override; // miscellaneous std::string opinion_text() const override; + bool is_safe() const override; + + // opinions + int get_npc_fear() const override; + int get_npc_trust() const override; + int get_npc_value() const override; + int get_npc_anger() const override; + + private: + npc const *me_npc{}; +}; + +class talker_npc : virtual public talker_npc_const, + public talker_cloner +{ + public: + talker_npc( const talker_npc & ) = default; + talker_npc( talker_npc && ) = delete; + talker_npc &operator=( const talker_npc & ) = default; + talker_npc &operator=( talker_npc && ) = delete; + explicit talker_npc( npc *new_me ) : talker_character_const( new_me ), talker_npc_const( new_me ), + talker_character( new_me ), me_npc( new_me ) {}; + ~talker_npc() override = default; + + npc *get_npc() override { + return me_npc; + } + + void update_missions( const std::vector &missions_assigned ) override; + void store_chosen_training( const skill_id &c_skill, const matype_id &c_style, + const spell_id &c_spell, const proficiency_id &c_proficiency ) override; + void add_debt( int cost ) override; + std::string give_item_to( bool to_use ) override; + bool buy_from( int amount ) override; + void select_mission( mission *selected ) override; + void check_missions() override; + void add_mission( const mission_type_id &mission_id ) override; + void set_companion_mission( const std::string &role_id ) override; + void set_fac( const faction_id &new_fac_name ) override; + void add_faction_rep( int rep_change ) override; + void make_angry() override; + void toggle_ai_rule( const std::string &type, const std::string &rule ) override; + void set_ai_rule( const std::string &type, const std::string &rule ) override; + void clear_ai_rule( const std::string &type, const std::string &rule ) override; + void set_class( const npc_class_id &new_class ) override; + void say( const std::string &speech ) override; + void add_sold( int value ) override; void add_opinion( const npc_opinion &op ) override; bool enslave_mind() override; void set_first_topic( const std::string &chat_topic ) override; - bool is_safe() const override; void die() override; - - // opinions void set_npc_trust( int trust ) override; - int get_npc_trust() const override; void set_npc_fear( int fear ) override; - int get_npc_fear() const override; void set_npc_value( int value ) override; - int get_npc_value() const override; void set_npc_anger( int anger ) override; - int get_npc_anger() const override; + std::vector get_topics( bool radio_contact ) const override; + bool will_talk_to_u( const Character &you, bool force ) const override; - protected: - npc *me_npc; + private: + npc *me_npc{}; }; #endif // CATA_SRC_TALKER_NPC_H diff --git a/src/talker_topic.cpp b/src/talker_topic.cpp index 0774e3eda142b..6afa56c0364a8 100644 --- a/src/talker_topic.cpp +++ b/src/talker_topic.cpp @@ -1,77 +1,13 @@ #include -#include "character_id.h" -#include "item.h" -#include "itype.h" -#include "magic.h" #include "npc.h" -#include "pimpl.h" -#include "point.h" #include "talker_topic.h" -#include "vehicle.h" -std::string talker_topic::disp_name() const -{ - debugmsg( "This talker doesn't have a name." ); - return ""; -} - -int talker_topic::posx() const -{ - debugmsg( "This talker doesn't have a posx." ); - return 0; -} - -int talker_topic::posy() const -{ - debugmsg( "This talker doesn't have a posy." ); - return 0; -} - -int talker_topic::posz() const -{ - debugmsg( "This talker doesn't have a posz." ); - return 0; -} - -tripoint talker_topic::pos() const -{ - debugmsg( "This talker doesn't have a pos." ); - return tripoint_zero; -} - -tripoint_abs_ms talker_topic::global_pos() const -{ - debugmsg( "This talker doesn't have a global_pos." ); - return tripoint_abs_ms( tripoint_zero ); -} - -tripoint_abs_omt talker_topic::global_omt_location() const -{ - debugmsg( "This talker doesn't have a global_omt_location." ); - return tripoint_abs_omt( tripoint_zero ); -} - -void talker_topic::set_value( const std::string &, const std::string & ) -{ - debugmsg( "This talker doesn't have values to set." ); -} - -void talker_topic::remove_value( const std::string & ) -{ - debugmsg( "This talker doesn't have values to remove." ); -} - -std::vector talker_topic::get_topics( bool ) +std::vector talker_topic_const::get_topics( bool ) const { return topics; } -bool talker_topic::will_talk_to_u( const Character &, bool ) -{ - return true; -} - std::unique_ptr get_talker_for( const std::vector &topics ) { return std::make_unique( topics ); diff --git a/src/talker_topic.h b/src/talker_topic.h index d3e00efe94bca..22fe6ba94832a 100644 --- a/src/talker_topic.h +++ b/src/talker_topic.h @@ -2,46 +2,50 @@ #ifndef CATA_SRC_TALKER_TOPIC_H #define CATA_SRC_TALKER_TOPIC_H -#include -#include -#include +#include #include -#include "coords_fwd.h" #include "talker.h" -#include "type_id.h" struct tripoint; /* * Talker wrapper class for an empty talker thats just topics */ -class talker_topic: public talker_cloner +class talker_topic_const: public const_talker_cloner { public: - explicit talker_topic( std::vector new_topics ) { - topics = std::move( new_topics ); + explicit talker_topic_const( std::vector new_topics ) + : topics( std::move( new_topics ) ) {} + talker_topic_const() = default; + talker_topic_const( const talker_topic_const & ) = default; + talker_topic_const( talker_topic_const && ) = delete; + talker_topic_const &operator=( const talker_topic_const & ) = default; + talker_topic_const &operator=( talker_topic_const && ) = delete; + ~talker_topic_const() override = default; + + std::vector get_topics( bool radio_contact ) const override; + bool will_talk_to_u( const Character &/* you */, bool /* force */ ) const override { + return true; } - ~talker_topic() override = default; - - // identity and location - std::string disp_name() const override; - int posx() const override; - int posy() const override; - int posz() const override; - tripoint pos() const override; - tripoint_abs_ms global_pos() const override; - tripoint_abs_omt global_omt_location() const override; - - void set_value( const std::string &var_name, const std::string &value ) override; - void remove_value( const std::string & ) override; - std::vector get_topics( bool radio_contact ) override; - bool will_talk_to_u( const Character &you, bool force ) override; + private: + std::vector topics; +}; - protected: +class talker_topic: virtual public talker_topic_const, public talker_cloner +{ + public: + explicit talker_topic( std::vector new_topics ) + : talker_topic_const( std::move( new_topics ) ) {} talker_topic() = default; - std::vector topics; + talker_topic( const talker_topic & ) = default; + talker_topic( talker_topic && ) = delete; + talker_topic &operator=( const talker_topic & ) = default; + talker_topic &operator=( talker_topic && ) = delete; + ~talker_topic() override = default; }; + std::unique_ptr get_talker_for( const std::vector &topics ); + #endif // CATA_SRC_TALKER_TOPIC_H diff --git a/src/text.cpp b/src/text.cpp index 4bc72b8c8c9de..8f6ee1e3d496a 100644 --- a/src/text.cpp +++ b/src/text.cpp @@ -1,6 +1,6 @@ #define IMGUI_DEFINE_MATH_OPERATORS -#include "third-party/imgui/imgui.h" -#include "third-party/imgui/imgui_internal.h" +#include "imgui/imgui.h" +#include "imgui/imgui_internal.h" #undef IMGUI_DEFINE_MATH_OPERATORS #include "color.h" diff --git a/src/third-party/imgui/imgui.h b/src/third-party/imgui/imgui.h index ce18083d740ef..4f9dcc79f4740 100644 --- a/src/third-party/imgui/imgui.h +++ b/src/third-party/imgui/imgui.h @@ -47,9 +47,6 @@ Index of this file: */ #pragma once -// NOLINTBEGIN -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" // Configuration file with compile-time options // (edit imconfig.h or '#define IMGUI_USER_CONFIG "myfilename.h" from your build system') @@ -3174,5 +3171,3 @@ enum ImGuiModFlags_ { ImGuiModFlags_None = 0, ImGuiModFlags_Ctrl = ImGuiMod_Ctrl #endif #endif // #ifndef IMGUI_DISABLE -#pragma GCC diagnostic pop -// NOLINTEND diff --git a/src/third-party/imgui/imgui_impl_sdl2.h b/src/third-party/imgui/imgui_impl_sdl2.h index 38f20e586118b..8dcabac103f09 100644 --- a/src/third-party/imgui/imgui_impl_sdl2.h +++ b/src/third-party/imgui/imgui_impl_sdl2.h @@ -18,10 +18,6 @@ #pragma once #include "imgui.h" // IMGUI_IMPL_API -// NOLINTBEGIN -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" - struct SDL_Window; struct SDL_Renderer; typedef union SDL_Event SDL_Event; @@ -38,6 +34,3 @@ IMGUI_IMPL_API bool ImGui_ImplSDL2_ProcessEvent(const SDL_Event* event); #ifndef IMGUI_DISABLE_OBSOLETE_FUNCTIONS static inline void ImGui_ImplSDL2_NewFrame(SDL_Window*) { ImGui_ImplSDL2_NewFrame(); } // 1.84: removed unnecessary parameter #endif - -#pragma GCC diagnostic pop -// NOLINTEND diff --git a/src/third-party/imgui/imgui_impl_sdlrenderer2.h b/src/third-party/imgui/imgui_impl_sdlrenderer2.h index d4ef432e690e6..643c87a45cf46 100644 --- a/src/third-party/imgui/imgui_impl_sdlrenderer2.h +++ b/src/third-party/imgui/imgui_impl_sdlrenderer2.h @@ -15,10 +15,6 @@ #include #include "imgui.h" // IMGUI_IMPL_API -// NOLINTBEGIN -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" - struct SDL_Renderer; IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_Init(SDL_Renderer* renderer); @@ -32,6 +28,3 @@ IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateFontsTexture(); IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyFontsTexture(); IMGUI_IMPL_API bool ImGui_ImplSDLRenderer2_CreateDeviceObjects(); IMGUI_IMPL_API void ImGui_ImplSDLRenderer2_DestroyDeviceObjects(); - -#pragma GCC diagnostic pop -// NOLINTEND diff --git a/src/third-party/imgui/imgui_internal.h b/src/third-party/imgui/imgui_internal.h index 417c216fac629..ab350d422eee4 100644 --- a/src/third-party/imgui/imgui_internal.h +++ b/src/third-party/imgui/imgui_internal.h @@ -42,9 +42,6 @@ Index of this file: */ #pragma once -// NOLINTBEGIN -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" #ifndef IMGUI_DISABLE @@ -3312,5 +3309,3 @@ extern const char* ImGuiTestEngine_FindItemDebugLabel(ImGuiContext* ctx, ImGuiI #endif #endif // #ifndef IMGUI_DISABLE -#pragma GCC diagnostic pop -// NOLINTEND diff --git a/src/third-party/imgui/imstb_rectpack.h b/src/third-party/imgui/imstb_rectpack.h index 4cad696d81edf..f6917e7a6e56a 100644 --- a/src/third-party/imgui/imstb_rectpack.h +++ b/src/third-party/imgui/imstb_rectpack.h @@ -70,10 +70,6 @@ #ifndef STB_INCLUDE_STB_RECT_PACK_H #define STB_INCLUDE_STB_RECT_PACK_H -// NOLINTBEGIN -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" - #define STB_RECT_PACK_VERSION 1 #ifdef STBRP_STATIC @@ -629,6 +625,3 @@ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ - -#pragma GCC diagnostic pop -// NOLINTEND diff --git a/src/third-party/imgui/imstb_textedit.h b/src/third-party/imgui/imstb_textedit.h index f36be35b6b34e..a8a823110b0df 100644 --- a/src/third-party/imgui/imstb_textedit.h +++ b/src/third-party/imgui/imstb_textedit.h @@ -277,10 +277,6 @@ #ifndef INCLUDE_STB_TEXTEDIT_H #define INCLUDE_STB_TEXTEDIT_H -// NOLINTBEGIN -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" - //////////////////////////////////////////////////////////////////////// // // STB_TexteditState @@ -1439,6 +1435,3 @@ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ - -#pragma GCC diagnostic pop -// NOLINTEND diff --git a/src/third-party/imgui/imstb_truetype.h b/src/third-party/imgui/imstb_truetype.h index babdce3540256..35c827e6b9ee5 100644 --- a/src/third-party/imgui/imstb_truetype.h +++ b/src/third-party/imgui/imstb_truetype.h @@ -271,10 +271,6 @@ // Inline sort : 6.54 s 5.65 s // New rasterizer : 5.63 s 5.00 s -// NOLINTBEGIN -#pragma GCC diagnostic push -#pragma GCC diagnostic ignored "-Wold-style-cast" - ////////////////////////////////////////////////////////////////////////////// ////////////////////////////////////////////////////////////////////////////// //// @@ -5087,6 +5083,3 @@ ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. ------------------------------------------------------------------------------ */ - -#pragma GCC diagnostic pop -// NOLINTEND diff --git a/src/turret.cpp b/src/turret.cpp index 6cd40f456138a..da3f36186cbad 100644 --- a/src/turret.cpp +++ b/src/turret.cpp @@ -48,13 +48,13 @@ std::vector vehicle::turrets() return res; } -std::vector vehicle::turrets( const tripoint &target ) +std::vector vehicle::turrets( const tripoint_bub_ms &target ) { std::vector res = turrets(); // exclude turrets not ready to fire or where target is out of range res.erase( std::remove_if( res.begin(), res.end(), [&]( vehicle_part * e ) { return turret_query( *e ).query() != turret_data::status::ready || - rl_dist( global_part_pos3( *e ), target ) > e->base.gun_range(); + rl_dist( bub_part_pos( *e ), target ) > e->base.gun_range(); } ), res.end() ); return res; } @@ -67,7 +67,7 @@ turret_data vehicle::turret_query( vehicle_part &pt ) return turret_data( this, &pt ); } -turret_data vehicle::turret_query( const tripoint &pos ) +turret_data vehicle::turret_query( const tripoint_bub_ms &pos ) { auto res = get_parts_at( pos, "TURRET", part_status_flag::any ); return !res.empty() ? turret_query( *res.front() ) : turret_data(); @@ -392,7 +392,7 @@ int vehicle::turrets_aim_and_fire( std::vector &turrets ) if( has_target ) { turret_data turret = turret_query( *t ); npc &cpu = t->get_targeting_npc( *this ); - shots += turret.fire( cpu, tripoint_bub_ms( t->target.second ) ); + shots += turret.fire( cpu, get_map().bub_from_abs( t->target.second ) ); t->reset_target( bub_part_pos( *t ) ); } } @@ -433,7 +433,7 @@ bool vehicle::turrets_aim( std::vector &turrets ) // Set target for any turret in range for( vehicle_part *t : turrets ) { if( turret_query( *t ).in_range( target ) ) { - t->target.second = target.raw(); + t->target.second = get_map().getglobal( target ); } } @@ -465,7 +465,7 @@ void vehicle::turrets_set_targeting() for( vehicle_part &p : parts ) { if( p.is_turret() ) { turrets.push_back( &p ); - locations.push_back( global_part_pos3( p ) ); + locations.push_back( bub_part_pos( p ).raw() ); } } @@ -480,9 +480,9 @@ void vehicle::turrets_set_targeting() menu.fselected = sel; for( vehicle_part *&p : turrets ) { - menu.addentry( -1, has_part( global_part_pos3( *p ), "TURRET_CONTROLS" ), MENU_AUTOASSIGN, + menu.addentry( -1, has_part( bub_part_pos( *p ), "TURRET_CONTROLS" ), MENU_AUTOASSIGN, "%s [%s]", p->name(), p->enabled ? - _( "auto -> manual" ) : has_part( global_part_pos3( *p ), "TURRET_CONTROLS" ) ? + _( "auto -> manual" ) : has_part( bub_part_pos( *p ), "TURRET_CONTROLS" ) ? _( "manual -> auto" ) : _( "manual (turret control unit required for auto mode)" ) ); } @@ -520,7 +520,7 @@ void vehicle::turrets_set_mode() for( vehicle_part &p : parts ) { if( p.base.is_gun() ) { turrets.push_back( &p ); - locations.push_back( global_part_pos3( p ) ); + locations.push_back( bub_part_pos( p ).raw() ); } } @@ -570,7 +570,7 @@ npc &vehicle_part::get_targeting_npc( vehicle &veh ) brain.name = string_format( _( "The %s turret" ), get_base().tname( 1 ) ); brain.set_skill_level( get_base().gun_skill(), 8 ); } - cpu.brain->setpos( veh.global_part_pos3( *this ) ); + cpu.brain->setpos( veh.bub_part_pos( *this ) ); cpu.brain->recalc_sight_limits(); return *cpu.brain; } @@ -649,11 +649,11 @@ int vehicle::automatic_fire_turret( vehicle_part &pt ) return shots; } - target.second = auto_target->pos(); + target.second = auto_target->get_location(); } else { // Target is already set, make sure we didn't move after aiming (it's a bug if we did). - if( pos.raw() != target.first ) { + if( pos != get_map().bub_from_abs( target.first ) ) { target.second = target.first; debugmsg( "%s moved after aiming but before it could fire.", cpu.get_name() ); return shots; @@ -661,7 +661,7 @@ int vehicle::automatic_fire_turret( vehicle_part &pt ) } // Get the turret's target and reset it - tripoint_bub_ms targ( target.second ); + tripoint_bub_ms targ( get_map().bub_from_abs( target.second ) ); pt.reset_target( pos ); shots = gun.fire( cpu, targ ); diff --git a/src/veh_appliance.cpp b/src/veh_appliance.cpp index 97ffc2aecb94f..65991912862e9 100644 --- a/src/veh_appliance.cpp +++ b/src/veh_appliance.cpp @@ -76,9 +76,9 @@ bool place_appliance( const tripoint_bub_ms &p, const vpart_id &vpart, // transform the deploying item into what it *should* be before storing it copied.convert( vpinfo.base_item ); } - partnum = veh->install_part( point_zero, vpart, std::move( copied ) ); + partnum = veh->install_part( point_rel_ms_zero, vpart, std::move( copied ) ); } else { - partnum = veh->install_part( point_zero, vpart ); + partnum = veh->install_part( point_rel_ms_zero, vpart ); } if( partnum == -1 ) { // unrecoverable, failed to be installed somehow @@ -112,7 +112,7 @@ bool place_appliance( const tripoint_bub_ms &p, const vpart_id &vpart, continue; } if( connected_vehicles.find( &veh_target ) == connected_vehicles.end() ) { - veh->connect( p.raw(), trip.raw() ); + veh->connect( p, trip ); connected_vehicles.insert( &veh_target ); } } @@ -403,7 +403,7 @@ void veh_app_interact::refill() act.str_values.push_back( pt->info().id.str() ); const point_rel_ms q = veh->coord_translate( pt->mount ); map &here = get_map(); - for( const tripoint &p : veh->get_points( true ) ) { + for( const tripoint_bub_ms &p : veh->get_points( true ) ) { act.coord_set.insert( here.getglobal( p ).raw() ); } act.values.push_back( here.getglobal( veh->pos_bub() ).x() + q.x() ); @@ -492,7 +492,7 @@ void veh_app_interact::remove() } else if( query_yn( _( "Are you sure you want to take down the %s?" ), veh->name ) ) { act = player_activity( ACT_VEHICLE, to_moves( time ), static_cast( 'O' ) ); act.str_values.push_back( vpinfo.id.str() ); - for( const tripoint &p : veh->get_points( true ) ) { + for( const tripoint_bub_ms &p : veh->get_points( true ) ) { act.coord_set.insert( here.getglobal( p ).raw() ); } const tripoint a_point_abs( here.getglobal( a_point_bub ).raw() ); @@ -526,7 +526,7 @@ void veh_app_interact::disconnect() void veh_app_interact::plug() { const int part = veh->part_at( veh->coord_translate( a_point ) ); - const tripoint pos = veh->global_part_pos3( part ); + const tripoint_bub_ms pos = veh->bub_part_pos( part ); item cord( "power_cord" ); cord.link_to( *veh, a_point, link_state::automatic ); if( cord.get_use( "link_up" ) ) { diff --git a/src/veh_interact.cpp b/src/veh_interact.cpp index 44a4b8844fbed..f3c841423f0bb 100644 --- a/src/veh_interact.cpp +++ b/src/veh_interact.cpp @@ -177,7 +177,7 @@ player_activity veh_interact::serialize_activity() const point_rel_ms q = veh->coord_translate( pt ? pt->mount : veh->part( 0 ).mount ); const vehicle_part *vpt = pt ? pt : &veh->part( 0 ); map &here = get_map(); - for( const tripoint &p : veh->get_points( true ) ) { + for( const tripoint_bub_ms &p : veh->get_points( true ) ) { res.coord_set.insert( here.getglobal( p ).raw() ); } res.values.push_back( here.getglobal( veh->pos_bub() ).x() + q.x() ); // values[0] @@ -2316,15 +2316,15 @@ void veh_interact::display_veh() if( debug_mode ) { // show CoM, pivot in debug mode - const point &pivot = veh->pivot_point(); - const point &com = veh->local_center_of_mass(); + const point_rel_ms &pivot = veh->pivot_point(); + const point_rel_ms &com = veh->local_center_of_mass(); - mvwprintz( w_disp, point_zero, c_green, "CoM %d,%d", com.x, com.y ); + mvwprintz( w_disp, point_zero, c_green, "CoM %d,%d", com.x(), com.y() ); // NOLINTNEXTLINE(cata-use-named-point-constants) - mvwprintz( w_disp, point( 0, 1 ), c_red, "Pivot %d,%d", pivot.x, pivot.y ); + mvwprintz( w_disp, point( 0, 1 ), c_red, "Pivot %d,%d", pivot.x(), pivot.y() ); - const point com_s = ( com + dd ).rotate( 3 ) + h_size; - const point pivot_s = ( pivot + dd ).rotate( 3 ) + h_size; + const point com_s = ( com.raw() + dd ).rotate( 3 ) + h_size; + const point pivot_s = ( pivot.raw() + dd ).rotate( 3 ) + h_size; for( int x = 0; x < getmaxx( w_disp ); ++x ) { if( x <= com_s.x ) { @@ -3088,7 +3088,7 @@ void veh_interact::complete_vehicle( Character &you ) } vehicle &veh = ovp->vehicle(); - const point d( you.activity.values[4], you.activity.values[5] ); + const point_rel_ms d( you.activity.values[4], you.activity.values[5] ); const vpart_id part_id( you.activity.str_values[0] ); const vpart_info &vpinfo = part_id.obj(); @@ -3136,7 +3136,7 @@ void veh_interact::complete_vehicle( Character &you ) const int partnum = veh.install_part( d, part_id, std::move( base ), installed_with ); if( partnum < 0 ) { debugmsg( "complete_vehicle install part fails dx=%d dy=%d id=%s", - d.x, d.y, part_id.c_str() ); + d.x(), d.y(), part_id.c_str() ); break; } ::vehicle_part &vp_new = veh.part( partnum ); @@ -3146,15 +3146,15 @@ void veh_interact::complete_vehicle( Character &you ) // Need map-relative coordinates to compare to output of look_around. // Need to call coord_translate() directly since it's a new part. - const point q = veh.coord_translate( d ); + const point_rel_ms q = veh.coord_translate( d ); if( vpinfo.has_flag( VPFLAG_CONE_LIGHT ) || vpinfo.has_flag( VPFLAG_WIDE_CONE_LIGHT ) || vpinfo.has_flag( VPFLAG_HALF_CIRCLE_LIGHT ) ) { - orient_part( &veh, vpinfo, partnum, q ); + orient_part( &veh, vpinfo, partnum, q.raw() ); } - const tripoint_bub_ms vehp = veh.pos_bub() + tripoint( q, 0 ); + const tripoint_bub_ms vehp = veh.pos_bub() + tripoint_rel_ms( q, 0 ); // TODO: allow boarding for non-players as well. Character *const pl = get_creature_tracker().creature_at( vehp ); if( vpinfo.has_flag( VPFLAG_BOARDABLE ) && pl ) { @@ -3341,7 +3341,7 @@ void veh_interact::complete_vehicle( Character &you ) veh.part_removal_cleanup(); // Ensure the position, pivot, and precalc points are up-to-date veh.pos -= veh.pivot_anchor[0]; - veh.precalc_mounts( 0, veh.turn_dir, point() ); + veh.precalc_mounts( 0, veh.turn_dir, point_rel_ms_zero ); here.rebuild_vehicle_level_caches(); if( auto newpart = here.veh_at( act_pos ).part_with_feature( VPFLAG_APPLIANCE, false ) ) { diff --git a/src/veh_shape.cpp b/src/veh_shape.cpp index 3849c9a083204..2ed598abd7cfb 100644 --- a/src/veh_shape.cpp +++ b/src/veh_shape.cpp @@ -28,7 +28,7 @@ player_activity veh_shape::start( const tripoint_bub_ms &pos ) if( !set_cursor_pos( pos ) ) { debugmsg( "failed to set cursor at given part" ); - set_cursor_pos( tripoint_bub_ms( veh.global_part_pos3( 0 ) ) ); + set_cursor_pos( veh.bub_part_pos( 0 ) ); } const auto target_ui_cb = make_shared_fast( @@ -141,7 +141,7 @@ void veh_shape::change_part_shape( vpart_reference vpr ) const .keep_menu_open() .skip_locked_check() .skip_theft_check() - .location( veh.global_part_pos3( part ) ) + .location( veh.bub_part_pos( part ).raw() ) .select( part.variant == vvid ) .desc( _( "Confirm to save or exit to revert" ) ) .symbol( vv.get_symbol_curses( 0_degrees, false ) ) diff --git a/src/veh_type.cpp b/src/veh_type.cpp index 19c744a8277ec..b3a0c3823ba98 100644 --- a/src/veh_type.cpp +++ b/src/veh_type.cpp @@ -1420,11 +1420,11 @@ void vehicle_prototype::save_vehicle_as_prototype( const vehicle &veh, JsonOut & for( int x = mount_max_x; x >= mount_min_x; x-- ) { std::string row; for( int y = mount_min_y; y <= mount_max_y; y++ ) { - if( veh.part_displayed_at( point( x, y ), false, true, true ) == -1 ) { + if( veh.part_displayed_at( point_rel_ms( x, y ), false, true, true ) == -1 ) { row += " "; continue; } - const vpart_display &c = veh.get_display_of_tile( point( x, y ), false, false, true, true ); + const vpart_display &c = veh.get_display_of_tile( point_rel_ms( x, y ), false, false, true, true ); row += utf32_to_utf8( c.symbol ); } json.write( row ); diff --git a/src/vehicle.cpp b/src/vehicle.cpp index 993d680e45e28..4c57be1ff074e 100644 --- a/src/vehicle.cpp +++ b/src/vehicle.cpp @@ -649,13 +649,13 @@ void vehicle::autopilot_patrol() */ map &here = get_map(); // if we are close to a waypoint, then return to come back to this function next turn. - if( autodrive_local_target != tripoint_zero ) { - if( rl_dist( global_square_location().raw(), autodrive_local_target ) <= 3 ) { - autodrive_local_target = tripoint_zero; + if( autodrive_local_target != tripoint_abs_ms_zero ) { + if( rl_dist( global_square_location(), autodrive_local_target ) <= 3 ) { + autodrive_local_target = tripoint_abs_ms_zero; return; } - if( !here.inbounds( here.bub_from_abs( tripoint_abs_ms( autodrive_local_target ) ) ) ) { - autodrive_local_target = tripoint_zero; + if( !here.inbounds( here.bub_from_abs( autodrive_local_target ) ) ) { + autodrive_local_target = tripoint_abs_ms_zero; is_patrolling = false; return; } @@ -697,13 +697,13 @@ void vehicle::autopilot_patrol() chosen_tri = max_tri; } // TODO: fix point types - autodrive_local_target = chosen_tri.raw(); + autodrive_local_target = chosen_tri; drive_to_local_target( autodrive_local_target, false ); } -std::set vehicle::immediate_path( const units::angle &rotate ) +std::set vehicle::immediate_path( const units::angle &rotate ) { - std::set points_to_check; + std::set points_to_check; const int distance_to_check = 10 + ( velocity / 800 ); units::angle adjusted_angle = normalize( face.dir() + rotate ); // clamp to multiples of 15. @@ -719,7 +719,7 @@ std::set vehicle::immediate_path( const units::angle &rotate ) for( int i = 0; i < distance_to_check; ++i ) { collision_vector.advance( i ); point_abs_ms point_to_add = elem + point( collision_vector.dx(), collision_vector.dy() ); - points_to_check.emplace( point_to_add.raw() ); + points_to_check.emplace( point_to_add ); } } collision_check_points = points_to_check; @@ -749,11 +749,11 @@ static int get_turn_from_angle( const units::angle &angle, const tripoint &vehpo return 0; } -void vehicle::drive_to_local_target( const tripoint &target, bool follow_protocol ) +void vehicle::drive_to_local_target( const tripoint_abs_ms &target, bool follow_protocol ) { Character &player_character = get_player_character(); if( follow_protocol && player_character.in_vehicle ) { - sounds::sound( global_pos3(), 30, sounds::sound_t::alert, + sounds::sound( pos_bub(), 30, sounds::sound_t::alert, string_format( _( "the %s emitting a beep and saying \"Autonomous driving protocols suspended!\"" ), name ) ); stop_autodriving(); @@ -767,14 +767,14 @@ void vehicle::drive_to_local_target( const tripoint &target, bool follow_protoco bool stop = precollision_check( angle, here, follow_protocol ); if( stop ) { if( autopilot_on ) { - sounds::sound( global_pos3(), 30, sounds::sound_t::alert, + sounds::sound( pos_bub(), 30, sounds::sound_t::alert, string_format( _( "the %s emitting a beep and saying \"Obstacle detected!\"" ), name ) ); } stop_autodriving(); return; } - int turn_x = get_turn_from_angle( angle, vehpos.raw(), target ); + int turn_x = get_turn_from_angle( angle, vehpos.raw(), target.raw() ); int accel_y = 0; // best to cruise around at a safe velocity or 40mph, whichever is lowest // accelerate when it doesn't need to turn. @@ -808,7 +808,7 @@ void vehicle::drive_to_local_target( const tripoint &target, bool follow_protoco accel_y = 1; } } - selfdrive( point( turn_x, accel_y ) ); + selfdrive( turn_x, accel_y ); } bool vehicle::precollision_check( units::angle &angle, map &here, bool follow_protocol ) @@ -819,10 +819,10 @@ bool vehicle::precollision_check( units::angle &angle, map &here, bool follow_pr Character &player_character = get_player_character(); // now we got the angle to the target, we can work out when we are heading towards disaster. // Check the tileray in the direction we need to head towards. - std::set points_to_check = immediate_path( angle ); + std::set points_to_check = immediate_path( angle ); bool stop = false; creature_tracker &creatures = get_creature_tracker(); - for( const point &pt_elem : points_to_check ) { + for( const point_abs_ms &pt_elem : points_to_check ) { point_bub_ms elem = here.bub_from_abs( point_abs_ms( pt_elem ) ); if( stop ) { break; @@ -864,12 +864,12 @@ bool vehicle::precollision_check( units::angle &angle, map &here, bool follow_pr return stop; } -units::angle vehicle::get_angle_from_targ( const tripoint &targ ) const +units::angle vehicle::get_angle_from_targ( const tripoint_abs_ms &targ ) const { - tripoint vehpos = global_square_location().raw(); + tripoint_abs_ms vehpos = global_square_location(); rl_vec2d facevec = face_vec(); - point rel_pos_target = targ.xy() - vehpos.xy(); - rl_vec2d targetvec = rl_vec2d( rel_pos_target.x, rel_pos_target.y ); + point_rel_ms rel_pos_target = targ.xy() - vehpos.xy(); + rl_vec2d targetvec = rl_vec2d( rel_pos_target.x(), rel_pos_target.y() ); // cross product double crossy = ( facevec.x * targetvec.y ) - ( targetvec.x * facevec.y ); // dot product. @@ -885,7 +885,7 @@ units::angle vehicle::get_angle_from_targ( const tripoint &targ ) const * was the collision point. */ void vehicle::smash( map &m, float hp_percent_loss_min, float hp_percent_loss_max, - float percent_of_parts_to_affect, point damage_origin, float damage_size ) + float percent_of_parts_to_affect, point_rel_ms damage_origin, float damage_size ) { for( vehicle_part &part : parts ) { //Skip any parts already mashed up or removed. @@ -915,9 +915,9 @@ void vehicle::smash( map &m, float hp_percent_loss_min, float hp_percent_loss_ma int roll = dice( 1, 1000 ); int pct_af = ( percent_of_parts_to_affect * 1000.0f ); if( roll < pct_af ) { - double dist = damage_size == 0.0f ? 1.0f : - clamp( 1.0f - trig_dist( damage_origin, part.precalc[0].xy().raw() ) / - damage_size, 0.0f, 1.0f ); + double dist = damage_size == 0.0f ? 1.0f : + clamp( 1.0f - trig_dist( damage_origin, part.precalc[0].xy() ) / + damage_size, 0.0f, 1.0f ); //Everywhere else, drop by 10-120% of max HP (anything over 100 = broken) const float roll = rng_float( hp_percent_loss_min * dist, hp_percent_loss_max * dist ); if( mod_hp( part, -part.info().durability * roll ) ) { @@ -929,13 +929,13 @@ void vehicle::smash( map &m, float hp_percent_loss_min, float hp_percent_loss_ma std::unique_ptr handler_ptr; // clear out any duplicated locations for( int p = static_cast( parts.size() ) - 1; p >= 0; p-- ) { - vehicle_part &part = parts[ p ]; + vehicle_part &part = parts[p]; if( part.removed ) { continue; } std::vector parts_here = parts_at_relative( part.mount, true ); - for( int other_i = static_cast( parts_here.size() ) - 1; other_i >= 0; other_i -- ) { - int other_p = parts_here[ other_i ]; + for( int other_i = static_cast( parts_here.size() ) - 1; other_i >= 0; other_i-- ) { + int other_p = parts_here[other_i]; if( p == other_p ) { continue; } @@ -1090,7 +1090,7 @@ void vehicle::backfire( const vehicle_part &vp ) const // single space after the exclamation mark because it does not end the sentence //~ backfire sound const std::string text = _( "a loud BANG! from the %s" ); // NOLINT(cata-text-style); - const tripoint pos = global_part_pos3( vp ); + const tripoint_bub_ms pos = bub_part_pos( vp ); const int volume = 40 + units::to_watt( part_vpower_w( vp, true ) ) / 10000; sounds::sound( pos, volume, sounds::sound_t::movement, string_format( text, vp.name() ), true, "vehicle", "engine_backfire" ); @@ -1483,12 +1483,12 @@ bool vehicle::is_appliance() const int vehicle::install_part( const point &dp, const vpart_id &type ) { - return install_part( dp, type, item( type.obj().base_item ) ); + return install_part( point_rel_ms( dp ), type, item( type.obj().base_item ) ); } -int vehicle::install_part( const point &dp, const vpart_id &type, item &&base ) +int vehicle::install_part( const point_rel_ms &dp, const vpart_id &type ) { - return install_part( dp, vehicle_part( type, std::move( base ) ) ); + return install_part( dp, type, item( type.obj().base_item ) ); } int vehicle::install_part( const point_rel_ms &dp, const vpart_id &type, item &&base ) @@ -1496,7 +1496,7 @@ int vehicle::install_part( const point_rel_ms &dp, const vpart_id &type, item && return install_part( dp, vehicle_part( type, std::move( base ) ) ); } -int vehicle::install_part( const point &dp, const vpart_id &type, item &&base, +int vehicle::install_part( const point_rel_ms &dp, const vpart_id &type, item &&base, std::vector &installed_with ) { return install_part( dp, vehicle_part( type, std::move( base ), installed_with ) ); @@ -2023,6 +2023,11 @@ bool vehicle::merge_appliance_into_grid( vehicle &veh_target ) } void vehicle::separate_from_grid( const point mount ) +{ + vehicle::separate_from_grid( point_rel_ms( mount ) ); +} + +void vehicle::separate_from_grid( const point_rel_ms mount ) { // Disconnect items and power cords unlink_cables( mount, get_player_character(), true, true, true ); @@ -2042,7 +2047,7 @@ void vehicle::separate_from_grid( const point mount ) const std::string part_name = part( idx ).name(); std::vector> split_indices( { { idx } } ); const std::vector null_vehicles( 2, nullptr ); - const std::vector> null_mounts( 2, std::vector() ); + const std::vector> null_mounts( 2, std::vector() ); if( !split_vehicles( here, split_indices, null_vehicles, null_mounts ) ) { debugmsg( "unable to split %s from power grid", part( idx ).name( false ) ); return; @@ -2054,7 +2059,7 @@ void vehicle::separate_from_grid( const point mount ) // Ensure the position, pivot, and precalc points are up-to-date. shift_if_needed( get_map() ); pos -= pivot_anchor[0]; - precalc_mounts( 0, turn_dir, point() ); + precalc_mounts( 0, turn_dir, point_rel_ms_zero ); add_msg( _( "You separate the %s from the power grid" ), part_name ); @@ -2192,7 +2197,7 @@ bool vehicle::remove_part( vehicle_part &vp, RemovePartHandler &handler ) handler.removed( *this, vp_idx ); const point_rel_ms &vp_mount = vp.mount; - const auto iter = labels.find( label( vp_mount.raw() ) ); + const auto iter = labels.find( label( vp_mount ) ); if( iter != labels.end() && parts_at_relative( vp_mount, false ).empty() ) { labels.erase( iter ); } @@ -2307,7 +2312,7 @@ bool vehicle::remove_carried_vehicle( const std::vector &carried_parts, return false; } - std::vector new_mounts; + std::vector new_mounts; new_vehicle->name = carried_pivot->veh_name; new_vehicle->owner = owner; new_vehicle->old_owner = old_owner; @@ -2333,7 +2338,7 @@ bool vehicle::remove_carried_vehicle( const std::vector &carried_parts, } } } - new_mounts.push_back( mount.xy().raw() ); + new_mounts.push_back( mount.xy() ); } for( const int &rack_part : racks ) { @@ -2458,7 +2463,8 @@ bool vehicle::find_and_split_vehicles( map &here, std::set exclude ) if( !all_vehicles.empty() ) { const std::vector null_vehicles( all_vehicles.size(), nullptr ); - const std::vector> null_mounts( all_vehicles.size(), std::vector() ); + const std::vector> null_mounts( all_vehicles.size(), + std::vector() ); std::vector mark_wreckage { this }; if( split_vehicles( here, all_vehicles, null_vehicles, null_mounts, &mark_wreckage ) ) { for( vehicle *veh : mark_wreckage ) { @@ -2466,7 +2472,7 @@ bool vehicle::find_and_split_vehicles( map &here, std::set exclude ) veh->add_tag( "wreckage" ); // wreckages don't get fake parts added } } - shift_parts( here, point_zero ); // update the active cache + shift_parts( here, point_rel_ms_zero ); // update the active cache return true; } } @@ -2485,26 +2491,6 @@ void vehicle::relocate_passengers( const std::vector &passengers ) } } -bool vehicle::split_vehicles( map &here, - const std::vector> &new_vehs, - const std::vector &new_vehicles, - const std::vector> &new_mounts, - std::vector *added_vehicles ) -{ - std::vector> temp; - for( const std::vector &sub : new_mounts ) { - std::vector temp2; - temp2.reserve( sub.size() ); - for( const point pt : sub ) { - const point_rel_ms temp3{pt}; - temp2.emplace_back( temp3 ); - } - temp.emplace_back( temp2 ); - } - - return vehicle::split_vehicles( here, new_vehs, new_vehicles, temp, added_vehicles ); -} - bool vehicle::split_vehicles( map &here, const std::vector> &new_vehs, const std::vector &new_vehicles, @@ -2616,11 +2602,11 @@ bool vehicle::split_vehicles( map &here, new_vehicle->parts.back().mount = new_mount; // remove labels associated with the mov_part - const auto iter = labels.find( label( cur_mount.raw() ) ); + const auto iter = labels.find( label( cur_mount ) ); if( iter != labels.end() ) { std::string label_str = iter->text; labels.erase( iter ); - new_labels.insert( label( new_mount.raw(), label_str ) ); + new_labels.insert( label( new_mount, label_str ) ); } // Prepare the zones to be moved to the new vehicle const std::pair::iterator, std::unordered_multimap::iterator> @@ -2672,7 +2658,7 @@ bool vehicle::split_vehicles( map &here, } // update the precalc points - new_vehicle->precalc_mounts( 0, new_vehicle->turn_dir, point() ); + new_vehicle->precalc_mounts( 0, new_vehicle->turn_dir, point_rel_ms_zero ); new_vehicle->precalc_mounts( 1, new_vehicle->skidding ? new_vehicle->turn_dir : new_vehicle->face.dir(), new_vehicle->pivot_point() ); @@ -2949,12 +2935,6 @@ int vehicle::part_with_feature( int part, vpart_bitflags flag, bool unbroken, return -1; } -int vehicle::part_with_feature( const point &pt, vpart_bitflags f, bool unbroken, - bool include_fake ) const -{ - return vehicle::part_with_feature( point_rel_ms( pt ), f, unbroken, include_fake ); -} - int vehicle::part_with_feature( const point_rel_ms &pt, vpart_bitflags f, bool unbroken, bool include_fake ) const { @@ -2995,6 +2975,11 @@ int vehicle::avail_part_with_feature( int part, vpart_bitflags flag ) const } int vehicle::avail_part_with_feature( const point &pt, const std::string &flag ) const +{ + return vehicle::avail_part_with_feature( point_rel_ms( pt ), flag ); +} + +int vehicle::avail_part_with_feature( const point_rel_ms &pt, const std::string &flag ) const { const int part_a = part_with_feature( pt, flag, true ); if( ( part_a >= 0 ) && this->part( part_a ).is_available() ) { @@ -3034,10 +3019,15 @@ bool vehicle::has_part( const std::string &flag, bool enabled ) const bool vehicle::has_part( const tripoint &pos, const std::string &flag, bool enabled ) const { - const tripoint relative_pos = pos - global_pos3(); + return vehicle::has_part( tripoint_bub_ms( pos ), flag, enabled ); +} + +bool vehicle::has_part( const tripoint_bub_ms &pos, const std::string &flag, bool enabled ) const +{ + const tripoint_rel_ms relative_pos = pos - pos_bub(); for( const vpart_reference &vpr : get_all_parts() ) { - if( vpr.part().precalc[0].raw() != relative_pos ) { + if( vpr.part().precalc[0] != relative_pos ) { continue; } if( !vpr.part().removed && ( !enabled || vpr.part().enabled ) && !vpr.part().is_broken() && @@ -3051,12 +3041,20 @@ bool vehicle::has_part( const tripoint &pos, const std::string &flag, bool enabl // NOLINTNEXTLINE(readability-make-member-function-const) std::vector vehicle::get_parts_at( const tripoint &pos, const std::string &flag, const part_status_flag condition ) +{ + return vehicle::get_parts_at( tripoint_bub_ms( pos ), flag, condition ); +} + +// NOLINTNEXTLINE(readability-make-member-function-const) +std::vector vehicle::get_parts_at( const tripoint_bub_ms &pos, + const std::string &flag, + const part_status_flag condition ) { // TODO: provide access to fake parts via argument ? - const tripoint relative_pos = pos - global_pos3(); + const tripoint_rel_ms relative_pos = pos - pos_bub(); std::vector res; for( const vpart_reference &vpr : get_all_parts() ) { - if( vpr.part().precalc[ 0 ].raw() != relative_pos ) { + if( vpr.part().precalc[0] != relative_pos ) { continue; } if( !vpr.part().removed && @@ -3069,21 +3067,14 @@ std::vector vehicle::get_parts_at( const tripoint &pos, const st return res; } -std::vector vehicle::get_parts_at( const tripoint_bub_ms &pos, - const std::string &flag, - const part_status_flag condition ) -{ - return vehicle::get_parts_at( pos.raw(), flag, condition ); -} - -std::vector vehicle::get_parts_at( const tripoint &pos, +std::vector vehicle::get_parts_at( const tripoint_bub_ms &pos, const std::string &flag, const part_status_flag condition ) const { - const tripoint relative_pos = pos - global_pos3(); + const tripoint_rel_ms relative_pos = pos - pos_bub(); std::vector res; for( const vpart_reference &vpr : get_all_parts() ) { - if( vpr.part().precalc[ 0 ].raw() != relative_pos ) { + if( vpr.part().precalc[ 0 ] != relative_pos ) { continue; } if( !vpr.part().removed && @@ -3098,7 +3089,7 @@ std::vector vehicle::get_parts_at( const tripoint &pos, std::optional vpart_position::get_label() const { - const auto it = vehicle().labels.find( label( mount() ) ); + const auto it = vehicle().labels.find( label( mount_pos() ) ); if( it == vehicle().labels.end() ) { return std::nullopt; } @@ -3112,13 +3103,13 @@ std::optional vpart_position::get_label() const void vpart_position::set_label( const std::string &text ) const { std::set