diff --git a/DEV_GROUPS.md b/DEV_GROUPS.md index eefbc8c0..557dc67c 100644 --- a/DEV_GROUPS.md +++ b/DEV_GROUPS.md @@ -92,6 +92,25 @@ any of the other digging groups, make sure dig times of the weakest tool are still faster than with the hand (test this in-game to make sure). Also, never use `handy` and `oddly_breakable_by_hand` at the same time. +### Pathfinder groups + +These groups very roughly categorize nodes for pathfinding. Specifically, +the cost function in the `rp_pathfinder` mod. The groups +are based on how the node would "feel" when you're barefoot. +The pathfinder can use the groups to use preferences for paths. +It’s not restricted to these groups, however, as the groups are intentionally +very broad. + +It is recommended that every walkable node has at least one pathfinder +group. Non-walkable nodes don't need this. + +* `pathfinder_crumbly`: Floor gives in (dirt, etc.) +* `pathfinder_fibrous`: Fiber- or plant-based floor (grass, leaves, ...) +* `pathfinder_spiky`: Somewhat spiky floor with sharp edges (cactus, gravel, ...) +* `pathfinder_thin`: Block has a very thin walking surface (door, ...) +* `pathfinder_hard`: Generic hard floor (stone, wood, ...) +* `pathfinder_soft`: Generic soft floor (sand, cotton, ...) + ### Interactive node groups: * `soil`: For blocks that allow several plants to grow * `leafdecay`: Node decays if not close to a `tree` group node (max. distance = rating). @@ -162,11 +181,13 @@ Unlike `attached_node`, they also work if the node is not `walkable`. Use these * `dry_leaves`: Dry leaves * `lush_leaves`: Any non-dry leaves -* `spikes`: Spikes +* `furniture`: Any piece of furniture, including workstations (e.g.: bed, chest, furnace, jeweller's workbench) * `item_showcase`: Item showcase * `chest`: Chest (1=not locked, 2=with lock) * `furnace`: Furnace (1=inactive, 2=active) +* `spikes`: Spikes + * `plantable_dry`: You can plant farming plants on it and this node is considered to be dry * `plantable_wet`: You can plant farming plants on it and this node is considered to be wet * `plantable_sandy`: You can plant farming plants on it and this node is considered to be made out of sand diff --git a/mods/rp_bed/init.lua b/mods/rp_bed/init.lua index b636e9da..0301c0fc 100644 --- a/mods/rp_bed/init.lua +++ b/mods/rp_bed/init.lua @@ -606,7 +606,7 @@ minetest.register_node( {name="bed_back_overlay.png",color="white"}, }, use_texture_alpha = "clip", - groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1, fall_damage_add_percent = -15, creative_decoblock = 1, interactive_node = 1, paintable = 1 }, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1, fall_damage_add_percent = -15, creative_decoblock = 1, interactive_node = 1, paintable = 1, furniture = 1, pathfinder_soft = 1}, is_ground_content = false, sounds = sounds, node_box = { @@ -778,7 +778,7 @@ minetest.register_node( {name="bed_inside_overlay.png",color="white"}, }, use_texture_alpha = "clip", - groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1, fall_damage_add_percent = -15, not_in_creative_inventory = 1, paintable = 1 }, + groups = {choppy = 2, oddly_breakable_by_hand = 2, flammable = 3, bed = 1, fall_damage_add_percent = -15, not_in_creative_inventory = 1, paintable = 1, furniture = 1, pathfinder_soft = 1 }, sounds = sounds, node_box = { type = "fixed", diff --git a/mods/rp_book/bookshelf.lua b/mods/rp_book/bookshelf.lua index 8cec50bb..2d20c12c 100644 --- a/mods/rp_book/bookshelf.lua +++ b/mods/rp_book/bookshelf.lua @@ -85,7 +85,7 @@ local bookshelf_def = { _tt_help = S("Provides 8 inventory slots"), tiles = {"rp_book_bookshelf_base.png", "rp_book_bookshelf_base.png", "rp_book_bookshelf_base_side.png^rp_book_bookshelf_overlay.png"}, paramtype2 = "4dir", - groups = {choppy = 3,oddly_breakable_by_hand = 2,container=1,paintable=2}, + groups = {choppy = 3,oddly_breakable_by_hand = 2,container=1,paintable=2,furniture=1,pathfinder_hard=1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), on_construct = function(pos) diff --git a/mods/rp_decor/init.lua b/mods/rp_decor/init.lua index f25768db..7fd096dd 100644 --- a/mods/rp_decor/init.lua +++ b/mods/rp_decor/init.lua @@ -5,7 +5,7 @@ minetest.register_node("rp_decor:barrel", { tiles = {"rp_decor_barrel_top.png", "rp_decor_barrel_top.png", "rp_decor_barrel_sides.png"}, paramtype2 = "facedir", on_place = minetest.rotate_node, - groups = { choppy = 2, level = -1, creative_decoblock = 1, flammable = 2 }, + groups = { choppy = 2, level = -1, creative_decoblock = 1, flammable = 2, furniture = 1, pathfinder_hard = 1 }, sounds = rp_sounds.node_sound_planks_defaults(), _rp_blast_resistance = 1, }) diff --git a/mods/rp_default/chest.lua b/mods/rp_default/chest.lua index 8395a5de..083264af 100644 --- a/mods/rp_default/chest.lua +++ b/mods/rp_default/chest.lua @@ -50,7 +50,7 @@ minetest.register_node( tiles = {"default_chest_top.png", "default_chest_top.png", "default_chest_sides.png", "default_chest_sides.png", "default_chest_sides.png", "default_chest_front.png"}, paramtype2 = "4dir", - groups = {choppy = 2, oddly_breakable_by_hand = 2, level = -1, chest = 1, container = 1, paintable = 2}, + groups = {choppy = 2, oddly_breakable_by_hand = 2, level = -1, chest = 1, container = 1, paintable = 2, furniture = 1, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), on_construct = function(pos) @@ -86,7 +86,7 @@ minetest.register_node( -- Actual legit overlay {name="default_chest_front_painted_overlay.png",color="white"}}, paramtype2 = "color4dir", - groups = {choppy = 2, oddly_breakable_by_hand = 2, level = -1, chest = 1, container = 1, paintable = 1, not_in_creative_inventory = 1}, + groups = {choppy = 2, oddly_breakable_by_hand = 2, level = -1, chest = 1, container = 1, paintable = 1, not_in_creative_inventory = 1, furniture = 1, pathfinder_hard = 1}, palette = "rp_paint_palette_64d.png", is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), diff --git a/mods/rp_default/fertilizer.lua b/mods/rp_default/fertilizer.lua index 9aeafa33..2a725dde 100644 --- a/mods/rp_default/fertilizer.lua +++ b/mods/rp_default/fertilizer.lua @@ -20,6 +20,7 @@ minetest.register_node( plantable_soil = 1, plantable_fertilizer = 1, fall_damage_add_percent = -5, + pathfinder_crumbly = 1, }, drop = "rp_default:dirt", sounds = rp_sounds.node_sound_dirt_defaults(), @@ -42,6 +43,7 @@ minetest.register_node( plantable_dry = 1, plantable_fertilizer = 1, fall_damage_add_percent = -10, + pathfinder_crumbly = 1, }, drop = "rp_default:dry_dirt", sounds = rp_sounds.node_sound_dry_dirt_defaults(), @@ -64,6 +66,7 @@ minetest.register_node( plantable_wet = 1, plantable_fertilizer = 1, fall_damage_add_percent = -10, + pathfinder_crumbly = 1, }, drop = "rp_default:swamp_dirt", sounds = rp_sounds.node_sound_swamp_dirt_defaults(), @@ -82,6 +85,7 @@ minetest.register_node( plantable_sandy = 1, plantable_fertilizer = 1, fall_damage_add_percent = -10, + pathfinder_soft = 1, }, drop = "rp_default:sand", sounds = rp_sounds.node_sound_sand_defaults(), diff --git a/mods/rp_default/furnace.lua b/mods/rp_default/furnace.lua index 3b1678f7..94fb795d 100644 --- a/mods/rp_default/furnace.lua +++ b/mods/rp_default/furnace.lua @@ -171,7 +171,7 @@ minetest.register_node( tiles ={"rp_default_furnace_top.png", "rp_default_furnace_top.png", "rp_default_furnace_sides.png", "rp_default_furnace_sides.png", "rp_default_furnace_sides.png", "rp_default_furnace_front.png"}, paramtype2 = "4dir", - groups = {cracky = 2,container=1,interactive_node=1,furnace=1}, + groups = {cracky = 2,container=1,interactive_node=1,furnace=1,furniture=1,pathfinder_hard=1}, is_ground_content = false, sounds = rp_sounds.node_sound_stone_defaults(), on_construct = function(pos) @@ -207,7 +207,7 @@ minetest.register_node( paramtype2 = "4dir", light_source = 8, drop = "rp_default:furnace", - groups = {cracky = 2, container=1,interactive_node=1, furnace=2,not_in_creative_inventory=1}, + groups = {cracky = 2, container=1,interactive_node=1, furnace=2,not_in_creative_inventory=1,furniture=1,pathfinder_hard=1}, is_ground_content = false, sounds = rp_sounds.node_sound_stone_defaults(), on_construct = function(pos) diff --git a/mods/rp_default/nodes_base.lua b/mods/rp_default/nodes_base.lua index db7d17b4..fb5dba36 100644 --- a/mods/rp_default/nodes_base.lua +++ b/mods/rp_default/nodes_base.lua @@ -12,7 +12,7 @@ minetest.register_node( { description = S("Stone with Sulfur"), tiles = {"default_stone.png^default_mineral_sulfur.png"}, - groups = {cracky = 2, stone = 1, ore = 1}, + groups = {cracky = 2, stone = 1, ore = 1, pathfinder_hard = 1}, drop = "rp_default:lump_sulfur", sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 1, @@ -23,7 +23,7 @@ minetest.register_node( { description = S("Stone with Graphite"), tiles = {"default_stone.png^default_mineral_graphite.png"}, - groups = {cracky = 2, stone = 1, ore = 1}, + groups = {cracky = 2, stone = 1, ore = 1, pathfinder_hard = 1}, drop = "rp_default:sheet_graphite", sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 1, @@ -34,7 +34,7 @@ minetest.register_node( { description = S("Stone with Coal"), tiles = {"default_stone.png^default_mineral_coal.png"}, - groups = {cracky = 2, stone = 1, ore = 1}, + groups = {cracky = 2, stone = 1, ore = 1, pathfinder_hard = 1}, drop = "rp_default:lump_coal", sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 1, @@ -45,7 +45,7 @@ minetest.register_node( { description = S("Stone with Iron"), tiles = {"default_stone.png^default_mineral_iron.png"}, - groups = {cracky = 2, stone = 1, magnetic = 1, ore = 1}, + groups = {cracky = 2, stone = 1, magnetic = 1, ore = 1, pathfinder_hard = 1}, drop = "rp_default:lump_iron", sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 1, @@ -56,7 +56,7 @@ minetest.register_node( { description = S("Stone with Tin"), tiles = {"default_stone.png^default_mineral_tin.png"}, - groups = {cracky = 1, stone = 1, ore = 1}, + groups = {cracky = 1, stone = 1, ore = 1, pathfinder_hard = 1}, drop = "rp_default:lump_tin", sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 1, @@ -67,7 +67,7 @@ minetest.register_node( { description = S("Stone with Copper"), tiles = {"default_stone.png^default_mineral_copper.png"}, - groups = {cracky = 1, stone = 1, ore = 1}, + groups = {cracky = 1, stone = 1, ore = 1, pathfinder_hard = 1}, drop = "rp_default:lump_copper", sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 1, @@ -80,7 +80,7 @@ minetest.register_node( { description = S("Stone"), tiles = {"default_stone.png"}, - groups = {cracky = 2, stone = 1}, + groups = {cracky = 2, stone = 1, pathfinder_hard = 1}, drop = "rp_default:cobble", sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 1, @@ -92,7 +92,7 @@ minetest.register_node( description = S("Cobble"), tiles = {"default_cobbles.png"}, stack_max = 240, - groups = {cracky = 3, stone = 1}, + groups = {cracky = 3, stone = 1, pathfinder_hard = 1}, sounds = rp_sounds.node_sound_stone_defaults(), is_ground_content = false, _rp_blast_resistance = 2, @@ -104,7 +104,7 @@ minetest.register_node( description = S("Reinforced Cobble"), tiles = {"default_reinforced_cobbles.png"}, is_ground_content = false, - groups = {cracky = 1, stone = 1}, + groups = {cracky = 1, stone = 1, pathfinder_hard = 1}, sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 6, }) @@ -114,7 +114,7 @@ minetest.register_node( { description = S("Gravel"), tiles = {"default_gravel.png"}, - groups = {crumbly = 2, falling_node = 1, gravel = 1}, + groups = {crumbly = 2, falling_node = 1, gravel = 1, pathfinder_spiky = 1}, sounds = rp_sounds.node_sound_gravel_defaults(), }) @@ -125,7 +125,7 @@ minetest.register_node( { description = S("Coal Block"), tiles = {"default_block_coal.png"}, - groups = {cracky = 3}, + groups = {cracky = 3, pathfinder_spiky = 1}, sounds = rp_sounds.node_sound_coal_defaults(), _rp_blast_resistance = 1, }) @@ -152,7 +152,7 @@ minetest.register_node( { description = S("Wrought Iron Block"), tiles = {"default_block_wrought_iron.png"}, - groups = {cracky = 2, magnetic = 1}, + groups = {cracky = 2, magnetic = 1, pathfinder_hard = 1}, sounds = make_metal_sounds(default.METAL_PITCH_WROUGHT_IRON), is_ground_content = false, _rp_blast_resistance = 8, @@ -163,7 +163,7 @@ minetest.register_node( { description = S("Steel Block"), tiles = {"default_block_steel.png"}, - groups = {cracky = 2}, + groups = {cracky = 2, pathfinder_hard = 1}, sounds = make_metal_sounds(default.METAL_PITCH_STEEL), is_ground_content = false, _rp_blast_resistance = 9, @@ -174,7 +174,7 @@ minetest.register_node( { description = S("Carbon Steel Block"), tiles = {"default_block_carbon_steel.png"}, - groups = {cracky = 1}, + groups = {cracky = 1, pathfinder_hard = 1}, sounds = make_metal_sounds(default.METAL_PITCH_CARBON_STEEL), is_ground_content = false, _rp_blast_resistance = 9.25, @@ -185,7 +185,7 @@ minetest.register_node( { description = S("Bronze Block"), tiles = {"default_block_bronze.png"}, - groups = {cracky = 1}, + groups = {cracky = 1, pathfinder_hard = 1}, sounds = make_metal_sounds(default.METAL_PITCH_BRONZE), is_ground_content = false, _rp_blast_resistance = 9.5, @@ -196,7 +196,7 @@ minetest.register_node( { description = S("Copper Block"), tiles = {"default_block_copper.png"}, - groups = {cracky = 2}, + groups = {cracky = 2, pathfinder_hard = 1}, sounds = make_metal_sounds(default.METAL_PITCH_COPPER), is_ground_content = false, _rp_blast_resistance = 7, @@ -207,7 +207,7 @@ minetest.register_node( { description = S("Tin Block"), tiles = {"default_block_tin.png"}, - groups = {cracky = 2}, + groups = {cracky = 2, pathfinder_hard = 1}, sounds = make_metal_sounds(default.METAL_PITCH_TIN), is_ground_content = false, _rp_blast_resistance = 8.5, @@ -221,7 +221,7 @@ minetest.register_node( description = S("Dirt"), tiles = {"default_dirt.png"}, stack_max = 240, - groups = {crumbly = 3, soil = 1, dirt = 1, normal_dirt = 1, plantable_soil = 1, fall_damage_add_percent = -5}, + groups = {crumbly = 3, soil = 1, dirt = 1, normal_dirt = 1, plantable_soil = 1, fall_damage_add_percent = -5, pathfinder_crumbly = 1}, sounds = rp_sounds.node_sound_dirt_defaults(), _fertilized_node = "rp_default:fertilized_dirt", @@ -252,7 +252,7 @@ minetest.register_node( description = S("Dry Dirt"), tiles = { "default_dry_dirt.png" }, stack_max = 240, - groups = {crumbly = 3, soil = 1, dirt = 1, dry_dirt = 1, plantable_dry = 1, fall_damage_add_percent = -10}, + groups = {crumbly = 3, soil = 1, dirt = 1, dry_dirt = 1, plantable_dry = 1, fall_damage_add_percent = -10, pathfinder_crumbly = 1}, sounds = rp_sounds.node_sound_dry_dirt_defaults(), _fertilized_node = "rp_default:fertilized_dry_dirt", }) @@ -263,7 +263,7 @@ minetest.register_node( description = S("Swamp Dirt"), tiles = { "default_swamp_dirt.png" }, stack_max = 240, - groups = {crumbly = 3, soil = 1, dirt = 1, swamp_dirt = 1, plantable_wet = 1, fall_damage_add_percent = -10}, + groups = {crumbly = 3, soil = 1, dirt = 1, swamp_dirt = 1, plantable_wet = 1, fall_damage_add_percent = -10, pathfinder_crumbly = 1}, sounds = rp_sounds.node_sound_swamp_dirt_defaults(), _fertilized_node = "rp_default:fertilized_swamp_dirt", @@ -298,7 +298,7 @@ minetest.register_node( "default_dirt.png", "default_dirt.png^default_dry_grass_side.png" }, - groups = {crumbly = 3, soil = 1, dirt = 1, normal_dirt = 1, plantable_soil = 1, grass_cover = 1, + groups = {crumbly = 3, soil = 1, dirt = 1, normal_dirt = 1, plantable_soil = 1, grass_cover = 1, pathfinder_fibrous = 1, fall_damage_add_percent = -5}, drop = { max_items = 3, @@ -329,7 +329,7 @@ minetest.register_node( "default_swamp_dirt.png^default_swamp_grass_side.png" }, groups = {crumbly = 3, soil = 1, dirt = 1, swamp_dirt = 1, plantable_wet = 1, grass_cover = 1, - fall_damage_add_percent = -10}, + fall_damage_add_percent = -10, pathfinder_fibrous = 1}, drop = { max_items = 3, items = { @@ -359,7 +359,7 @@ minetest.register_node( "default_dirt.png^default_grass_side.png", }, groups = {crumbly = 3, soil = 1, dirt = 1, normal_dirt = 1, plantable_soil = 1, grass_cover = 1, - fall_damage_add_percent = -5}, + fall_damage_add_percent = -5, pathfinder_fibrous = 1}, drop = { max_items = 3, items = { @@ -393,7 +393,7 @@ minetest.register_node( fixed = {-0.5, -0.5, -0.5, 0.5, 0.5-2/16, 0.5} }, tiles = { "default_dirt.png" }, - groups = {crumbly = 3, path = 1, fall_damage_add_percent = -10}, + groups = {crumbly = 3, path = 1, fall_damage_add_percent = -10, pathfinder_crumbly = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_dirt_defaults(), }) @@ -409,7 +409,7 @@ minetest.register_node( fixed = {-0.5, -0.5, -0.5, 0.5, -2/16, 0.5} }, tiles = { "default_dirt.png" }, - groups = {crumbly = 3, level = -1, path = 2, slab = 2, creative_decoblock = 1, fall_damage_add_percent = -10}, + groups = {crumbly = 3, level = -1, path = 2, slab = 2, creative_decoblock = 1, fall_damage_add_percent = -10, pathfinder_crumbly = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_dirt_defaults(), on_place = function(itemstack, placer, pointed_thing) @@ -451,7 +451,7 @@ minetest.register_node( fixed = {-0.5, -0.5, -0.5, 0.5, 0.5-2/16, 0.5} }, tiles = { "default_dirt.png" }, - groups = {crumbly = 3, path = 1, creative_decoblock = 1, fall_damage_add_percent = -10}, + groups = {crumbly = 3, path = 1, creative_decoblock = 1, fall_damage_add_percent = -10, pathfinder_crumbly = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_dirt_defaults(), }) @@ -464,7 +464,7 @@ minetest.register_node( description = S("Brick Block"), tiles = {"default_brick.png"}, is_ground_content = false, - groups = {cracky = 2, paintable = 2}, + groups = {cracky = 2, paintable = 2, pathfinder_hard = 1}, sounds = rp_sounds.node_sound_stone_defaults(), _rp_blast_resistance = 2, }) @@ -476,7 +476,7 @@ minetest.register_node( overlay_tiles = {{name="rp_default_brick_paintable_overlay.png",color="white"}}, use_texture_alpha = "blend", is_ground_content = false, - groups = {cracky = 2, paintable = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {cracky = 2, paintable = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1, pathfinder_hard = 1}, sounds = rp_sounds.node_sound_stone_defaults(), paramtype2 = "color", palette = "rp_paint_palette_256.png", @@ -491,7 +491,7 @@ minetest.register_node( { description = S("Sand"), tiles = {"default_sand.png"}, - groups = {crumbly = 3, falling_node = 1, sand = 1, plantable_sandy = 1, fall_damage_add_percent = -10}, + groups = {crumbly = 3, falling_node = 1, sand = 1, plantable_sandy = 1, fall_damage_add_percent = -10, pathfinder_soft = 1}, sounds = rp_sounds.node_sound_sand_defaults(), _fertilized_node = "rp_default:fertilized_sand", }) @@ -501,7 +501,7 @@ minetest.register_node( { description = S("Sandstone"), tiles = {"default_sandstone.png"}, - groups = {crumbly = 2, cracky = 3, sandstone = 1}, + groups = {crumbly = 2, cracky = 3, sandstone = 1, pathfinder_hard = 1}, drop = "rp_default:sand 2", sounds = rp_sounds.node_sound_stone_defaults({ dug = {name="rp_sounds_dug_stone", gain=0.9, pitch=1.4}, @@ -515,7 +515,7 @@ minetest.register_node( { description = S("Compressed Sandstone"), tiles = {"default_compressed_sandstone_top.png", "default_compressed_sandstone_top.png", "default_compressed_sandstone.png"}, - groups = {cracky = 2, sandstone = 1}, + groups = {cracky = 2, sandstone = 1, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_stone_defaults({ dug = {name="rp_sounds_dug_stone", gain=0.9, pitch=1.2}, @@ -529,7 +529,7 @@ minetest.register_node( { description = S("Reinforced Compressed Sandstone"), tiles = {"rp_default_reinforced_compressed_sandstone.png"}, - groups = {cracky = 2, sandstone = 1}, + groups = {cracky = 2, sandstone = 1, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_stone_defaults({ dug = {name="rp_sounds_dug_stone", gain=0.9, pitch=1.2}, @@ -549,7 +549,7 @@ minetest.register_node( use_texture_alpha = "clip", paramtype = "light", sunlight_propagates = true, - groups = {cracky = 3,oddly_breakable_by_hand = 2, glass=1, paintable=2}, + groups = {cracky = 3,oddly_breakable_by_hand = 2, glass=1, paintable=2, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_glass_defaults(), drop = "rp_default:glass", @@ -568,7 +568,7 @@ minetest.register_node( use_texture_alpha = "blend", paramtype = "light", sunlight_propagates = true, - groups = {cracky = 3,oddly_breakable_by_hand = 2, glass=1, paintable=1, not_in_creative_inventory=1, not_in_craft_guide = 1}, + groups = {cracky = 3,oddly_breakable_by_hand = 2, glass=1, paintable=1, not_in_creative_inventory=1, not_in_craft_guide = 1, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_glass_defaults(), drop = "rp_default:glass", @@ -598,7 +598,7 @@ for p=1, #planks do { description = desc, tiles = {tex}, - groups = {planks = 1, wood = 1, choppy = 3, oddly_breakable_by_hand = 3, paintable = 2}, + groups = {planks = 1, wood = 1, choppy = 3, oddly_breakable_by_hand = 3, paintable = 2, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), _rp_blast_resistance = 0.5, @@ -610,7 +610,7 @@ for p=1, #planks do tiles = {tex_paint}, -- HACK: This is a workaround to fix the coloring of the crack overlay overlay_tiles = {{name="rp_textures_blank_paintable_overlay.png",color="white"}}, - groups = {planks = 1, wood = 1, choppy = 3, oddly_breakable_by_hand = 3, paintable = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {planks = 1, wood = 1, choppy = 3, oddly_breakable_by_hand = 3, paintable = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), @@ -628,7 +628,7 @@ minetest.register_node( { description = S("Frame"), tiles = {"default_frame.png"}, - groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, paintable = 2}, + groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, paintable = 2, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), _rp_blast_resistance = 0.75, @@ -642,7 +642,7 @@ minetest.register_node( overlay_tiles = {{name="rp_textures_blank_paintable_overlay.png",color="white"}}, paramtype2 = "color", palette = "rp_paint_palette_256.png", - groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, paintable = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {wood = 1, choppy = 2, oddly_breakable_by_hand = 1, paintable = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), drop = "rp_default:frame", @@ -654,7 +654,7 @@ minetest.register_node( { description = S("Reinforced Frame"), tiles = {"default_reinforced_frame.png"}, - groups = {wood = 1, choppy = 1, paintable = 2}, + groups = {wood = 1, choppy = 1, paintable = 2, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), _rp_blast_resistance = 5, @@ -667,7 +667,7 @@ minetest.register_node( overlay_tiles = {{name="rp_default_reinforced_frame_overlay.png",color="white"}}, paramtype2 = "color", palette = "rp_paint_palette_256.png", - groups = {wood = 1, choppy = 1, paintable = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1}, + groups = {wood = 1, choppy = 1, paintable = 1, not_in_creative_inventory = 1, not_in_craft_guide = 1, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), drop = "rp_default:reinforced_frame", @@ -685,7 +685,7 @@ minetest.register_node( "rp_default_reed_block_top.png", "rp_default_reed_block_side.png", }, - groups = {snappy=2, fall_damage_add_percent=-10}, + groups = {snappy=2, fall_damage_add_percent=-10, pathfinder_soft=1}, is_ground_content = false, sounds = rp_sounds.node_sound_grass_defaults(), _rp_blast_resistance = 0.5, @@ -699,7 +699,7 @@ minetest.register_node( "rp_default_dried_reed_block_top.png", "rp_default_dried_reed_block_side.png", }, - groups = {snappy=2, fall_damage_add_percent=-15}, + groups = {snappy=2, fall_damage_add_percent=-15, pathfinder_soft=1}, is_ground_content = false, sounds = rp_sounds.node_sound_straw_defaults(), _rp_blast_resistance = 0.5, @@ -713,7 +713,7 @@ minetest.register_node( tiles = { "rp_default_hay.png", }, - groups = {snappy=3, fall_damage_add_percent=-30}, + groups = {snappy=3, fall_damage_add_percent=-30, pathfinder_soft = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_grass_defaults({ footstep = { name = "rp_default_footstep_hay", gain = 1.0 }, diff --git a/mods/rp_default/nodes_plants.lua b/mods/rp_default/nodes_plants.lua index 7abe97e3..ec42c4a2 100644 --- a/mods/rp_default/nodes_plants.lua +++ b/mods/rp_default/nodes_plants.lua @@ -64,7 +64,7 @@ minetest.register_node( }, tiles = {"default_cactus_top.png", "default_cactus_top.png", "default_cactus_sides.png"}, -- damage_per_second = 1, - groups = {snappy = 2, choppy = 2, fall_damage_add_percent = 20, plant = 1, food = 2}, + groups = {snappy = 2, choppy = 2, fall_damage_add_percent = 20, plant = 1, food = 2, pathfinder_spiky = 1}, sounds = rp_sounds.node_sound_defaults({ footstep = { name = "rp_default_footstep_cactus", gain = 1.0 }, dig = { name = "rp_default_dig_cactus", gain = 0.5 }, diff --git a/mods/rp_default/nodes_trees.lua b/mods/rp_default/nodes_trees.lua index 2aa1bb12..c7a5957b 100644 --- a/mods/rp_default/nodes_trees.lua +++ b/mods/rp_default/nodes_trees.lua @@ -198,7 +198,7 @@ minetest.register_node( { description = S("Tree"), tiles = {"default_tree_top.png", "default_tree_top.png", "default_tree.png"}, - groups = {choppy = 2,tree = 1,oddly_breakable_by_hand = 1}, + groups = {choppy = 2,tree = 1,oddly_breakable_by_hand = 1, pathfinder_hard = 1}, sounds = snd_tree, _rp_blast_resistance = 1, }) @@ -208,7 +208,7 @@ minetest.register_node( { description = S("Oak Tree"), tiles = {"default_tree_oak_top.png", "default_tree_oak_top.png", "default_tree_oak.png"}, - groups = {choppy = 2, tree = 1, oddly_breakable_by_hand = 1}, + groups = {choppy = 2, tree = 1, oddly_breakable_by_hand = 1, pathfinder_hard = 1}, sounds = snd_tree, _rp_blast_resistance = 1, }) @@ -218,7 +218,7 @@ minetest.register_node( { description = S("Birch Tree"), tiles = {"default_tree_birch_top.png", "default_tree_birch_top.png", "default_tree_birch.png"}, - groups = {choppy = 2, tree = 1, oddly_breakable_by_hand = 1}, + groups = {choppy = 2, tree = 1, oddly_breakable_by_hand = 1, pathfinder_hard = 1}, sounds = snd_tree, _rp_blast_resistance = 1, }) @@ -244,7 +244,7 @@ minetest.register_node( tiles = {"default_leaves.png"}, paramtype = "light", waving = 1, - groups = {snappy = 3, leafdecay = 3, fall_damage_add_percent = -10, leaves = 1, lush_leaves = 1}, + groups = {snappy = 3, leafdecay = 3, fall_damage_add_percent = -10, leaves = 1, lush_leaves = 1, pathfinder_fibrous = 1}, drop = { max_items = 1, items = { @@ -269,7 +269,7 @@ minetest.register_node( tiles = {"default_leaves_oak.png"}, paramtype = "light", waving = 1, - groups = {snappy = 3, leafdecay = 4, fall_damage_add_percent = -5, leaves = 1, lush_leaves = 1}, + groups = {snappy = 3, leafdecay = 4, fall_damage_add_percent = -5, leaves = 1, lush_leaves = 1, pathfinder_fibrous = 1}, drop = { max_items = 1, items = { @@ -294,7 +294,7 @@ minetest.register_node( tiles = {"default_leaves_birch.png"}, paramtype = "light", waving = 1, - groups = {snappy = 3, leafdecay = 6, fall_damage_add_percent = -5, leaves = 1, lush_leaves = 1}, + groups = {snappy = 3, leafdecay = 6, fall_damage_add_percent = -5, leaves = 1, lush_leaves = 1, pathfinder_fibrous = 1}, drop = { max_items = 1, items = { @@ -344,7 +344,7 @@ minetest.register_node( tiles = {"default_dry_leaves.png"}, paramtype = "light", waving = 1, - groups = {snappy = 3, leafdecay = 3, fall_damage_add_percent = -20, leaves = 1, dry_leaves = 1}, + groups = {snappy = 3, leafdecay = 3, fall_damage_add_percent = -20, leaves = 1, dry_leaves = 1, pathfinder_fibrous = 1}, drop = { max_items = 1, items = { diff --git a/mods/rp_door/init.lua b/mods/rp_door/init.lua index 7d785489..78f73cec 100644 --- a/mods/rp_door/init.lua +++ b/mods/rp_door/init.lua @@ -332,6 +332,7 @@ function door.register_door(name, def) local groups_node = table.copy(def.groups) groups_node.not_in_creative_inventory = 1 + groups_node.pathfinder_thin = 1 local groups_node_b_1 = table.copy(groups_node) -- door position: 1 = bottom, 2 = top diff --git a/mods/rp_farming/nodes.lua b/mods/rp_farming/nodes.lua index acaf793c..3b7cc905 100644 --- a/mods/rp_farming/nodes.lua +++ b/mods/rp_farming/nodes.lua @@ -270,7 +270,7 @@ minetest.register_node( is_ground_content = false, groups = {snappy = 2, oddly_breakable_by_hand = 3, fall_damage_add_percent = -15, fuzzy = 1, - unmagnetic = 1, paintable = 1}, + unmagnetic = 1, paintable = 1, pathfinder_soft=1}, sounds = rp_sounds.node_sound_fuzzy_defaults({ footstep = { name = "rp_sounds_footstep_fuzzy", gain = 0.7, pitch = 1.3 }, dig = {name="rp_sounds_dig_fuzzy", gain=0.5, pitch = 1.3 }, @@ -290,7 +290,7 @@ minetest.register_node( description = S("Straw"), tiles = {"rp_farming_straw.png"}, is_ground_content = false, - groups = {snappy = 3, fall_damage_add_percent = -15}, + groups = {snappy = 3, fall_damage_add_percent = -15, pathfinder_fibrous=1}, sounds = rp_sounds.node_sound_straw_defaults(), } ) diff --git a/mods/rp_gold/init.lua b/mods/rp_gold/init.lua index c942d421..7529ec49 100644 --- a/mods/rp_gold/init.lua +++ b/mods/rp_gold/init.lua @@ -402,7 +402,7 @@ minetest.register_node( { description = S("Stone with Gold"), tiles ={"default_stone.png^gold_mineral_gold.png"}, - groups = {cracky=1, stone=1, ore=1}, + groups = {cracky=1, stone=1, ore=1, pathfinder_hard=1}, drop = "rp_gold:lump_gold", is_ground_content = true, sounds = rp_sounds.node_sound_stone_defaults(), @@ -431,7 +431,7 @@ minetest.register_node( { description = S("Gold Block"), tiles = {"gold_block.png"}, - groups = {cracky = 2}, + groups = {cracky = 2, pathfinder_hard=1}, sounds = make_metal_sounds(gold.PITCH), is_ground_content = false, _rp_blast_resistance = 8, diff --git a/mods/rp_itemshow/init.lua b/mods/rp_itemshow/init.lua index 65e1b113..6b870375 100644 --- a/mods/rp_itemshow/init.lua +++ b/mods/rp_itemshow/init.lua @@ -267,6 +267,7 @@ minetest.register_node("rp_itemshow:frame",{ sunlight_propagates = true, groups = { choppy = 2, dig_immediate = 2, creative_decoblock = 1, paintable = 1, + pathfinder_thin = 1, -- So that placing a magnocompass on it will point -- the needle to the correct direction special_magnocompass_place_handling = 1}, @@ -347,7 +348,7 @@ minetest.register_node("rp_itemshow:showcase", { tiles = {"rp_itemshow_showcase.png"}, use_texture_alpha = "clip", paramtype = "light", - groups = { item_showcase = 1, cracky = 3, oddly_breakable_by_hand = 2, uses_canonical_compass = 1, creative_decoblock = 1 }, + groups = { item_showcase = 1, cracky = 3, oddly_breakable_by_hand = 2, uses_canonical_compass = 1, creative_decoblock = 1, furniture = 1, pathfinder_hard = 1 }, sounds = rp_sounds.node_sound_glass_defaults(), is_ground_content = false, diff --git a/mods/rp_jewels/init.lua b/mods/rp_jewels/init.lua index 2ae5e085..d7065511 100644 --- a/mods/rp_jewels/init.lua +++ b/mods/rp_jewels/init.lua @@ -313,7 +313,7 @@ minetest.register_node( _tt_help = S("Tools can be upgraded with jewels here"), tiles ={"jewels_bench_top.png", "jewels_bench_bottom.png", "jewels_bench_sides.png"}, paramtype2 = "4dir", - groups = {choppy=2,oddly_breakable_by_hand=2,interactive_node=1}, + groups = {choppy=2,oddly_breakable_by_hand=2,interactive_node=1,furniture=1,pathfinder_hard=1}, is_ground_content = false, sounds = rp_sounds.node_sound_wood_defaults(), diff --git a/mods/rp_locks/init.lua b/mods/rp_locks/init.lua index d50ca044..25eb53e0 100644 --- a/mods/rp_locks/init.lua +++ b/mods/rp_locks/init.lua @@ -297,7 +297,7 @@ local chest_def = { }, use_texture_alpha = "blend", paramtype2 = "4dir", - groups = {choppy = 2, oddly_breakable_by_hand = 2, level = -1, locked = 1, chest = 2, container = 1, paintable = 2}, + groups = {choppy = 2, oddly_breakable_by_hand = 2, level = -1, locked = 1, chest = 2, container = 1, paintable = 2, furniture = 1, pathfinder_hard = 1}, is_ground_content = false, sounds = rp_sounds.node_sound_planks_defaults(), on_construct = function(pos) diff --git a/mods/rp_lumien/init.lua b/mods/rp_lumien/init.lua index 744bff7f..d234dee5 100644 --- a/mods/rp_lumien/init.lua +++ b/mods/rp_lumien/init.lua @@ -101,7 +101,7 @@ minetest.register_node( end end, - groups = {crumbly = 3, not_in_creative_inventory = 1}, + groups = {crumbly = 3, not_in_creative_inventory = 1, furniture = 1, pathfinder_hard = 1}, light_source = LUMIEN_CRYSTAL_LIGHT_MAX, _rp_itemshow_offset = vector.new(-0.2, 0, -0.2), drop = "rp_lumien:crystal_off", @@ -143,7 +143,7 @@ minetest.register_node( end end, - groups = {crumbly = 3, creative_decoblock = 1}, + groups = {crumbly = 3, creative_decoblock = 1, furniture = 1, pathfinder_hard = 1}, light_source = LUMIEN_CRYSTAL_LIGHT_MIN, _tt_light_source_max = LUMIEN_CRYSTAL_LIGHT_MAX, _rp_itemshow_offset = vector.new(-0.2, 0, -0.2), @@ -155,7 +155,7 @@ minetest.register_node( { description = S("Lumien Block"), tiles = {"lumien_block.png"}, - groups = {cracky = 1, mineral_natural=1}, + groups = {cracky = 1, mineral_natural=1, pathfinder_hard = 1}, light_source = LUMIEN_BLOCK_LIGHT, sounds = get_sounds(), _rp_blast_resistance = 3, diff --git a/mods/rp_mobs_mobs/crafts.lua b/mods/rp_mobs_mobs/crafts.lua index 2b447f87..08722568 100644 --- a/mods/rp_mobs_mobs/crafts.lua +++ b/mods/rp_mobs_mobs/crafts.lua @@ -15,7 +15,7 @@ minetest.register_node( -- HACK: This is a workaround to fix the coloring of the crack overlay overlay_tiles = {{name="rp_textures_blank_paintable_overlay.png",color="white"}}, is_ground_content = false, - groups = {snappy = 2, oddly_breakable_by_hand = 3, fall_damage_add_percent = -25, fuzzy = 1, unmagnetic = 1, paintable = 1}, + groups = {snappy = 2, oddly_breakable_by_hand = 3, fall_damage_add_percent = -25, fuzzy = 1, unmagnetic = 1, paintable = 1, pathfinder_soft = 1}, sounds = rp_sounds.node_sound_fuzzy_defaults(), paramtype2 = "color", palette = "rp_paint_palette_256.png", diff --git a/mods/rp_mobs_mobs/mobs/villager.lua b/mods/rp_mobs_mobs/mobs/villager.lua index 562f22d9..dd0a2c1b 100644 --- a/mods/rp_mobs_mobs/mobs/villager.lua +++ b/mods/rp_mobs_mobs/mobs/villager.lua @@ -66,11 +66,8 @@ local is_node_walkable = function(node) if not def then -- Unknown nodes are walkable return true - elseif node.name == "rp_itemshow:frame" then - -- Item frames are to thin to walk *on* - return false - elseif minetest.get_item_group(node.name, "door") ~= 0 then - -- Same for doors + elseif minetest.get_item_group(node.name, "pathfinder_thin") ~= 0 then + -- Refuse to walk on very thin nodes like item frames to avoid fall-through return false elseif minetest.get_item_group(node.name, "fence") ~= 0 or minetest.get_item_group(node.name, "fence_gate") ~= 0 then -- We refuse to walk on fences and fence gates (although we could) @@ -161,6 +158,26 @@ local is_node_swimmable = function(node) end end +-- Cost function for rp_pathfinder. Returns the cost of walking +-- *on* a node. +local function get_floor_cost(node) + local nn = node.name + if nn == "rp_default:heated_dirt_path" then + return 1 + elseif nn == "rp_default:cactus" or nn == "rp_tnt:tnt" or nn == "rp_tnt:tnt_burning" then + return 100 + elseif minetest.get_item_group(nn, "furniture") ~= 0 then + return 50 + elseif minetest.get_item_group(nn, "path") ~= 0 then + return 2 + elseif minetest.get_item_group(nn, "pathfinder_hard") ~= 0 then + return 4 + else + return 6 + end +end + + local PATHFINDER_SEARCHDISTANCE = 30 local PATHFINDER_TIMEOUT = 1.0 local PATHFINDER_OPTIONS = { @@ -172,6 +189,7 @@ local PATHFINDER_OPTIONS = { respect_disable_jump = true, handler_walkable = is_node_walkable, handler_blocking = is_node_blocking, + get_floor_cost = get_floor_cost, use_vmanip = true, } diff --git a/mods/rp_music/init.lua b/mods/rp_music/init.lua index c7ccb288..66d28d6b 100644 --- a/mods/rp_music/init.lua +++ b/mods/rp_music/init.lua @@ -294,7 +294,7 @@ if minetest.settings:get_bool("music_enable") then rp_music.toggle(pos) end, - groups = {handy = 3, attached_node = 1, interactive_node = 1, paintable = 1}, + groups = {handy = 3, attached_node = 1, interactive_node = 1, paintable = 1, furniture = 1, pathfinder_hard = 1}, drop = "rp_music:player", }) @@ -369,7 +369,7 @@ else note_particle(pos, "rp_music_no_music.png") end, - groups = {handy = 3, attached_node = 1, interactive_node = 1} + groups = {handy = 3, attached_node = 1, interactive_node = 1, furniture = 1, pathfinder_hard = 1} }) end diff --git a/mods/rp_partialblocks/register.lua b/mods/rp_partialblocks/register.lua index 3e1e8ac6..8923fb7d 100644 --- a/mods/rp_partialblocks/register.lua +++ b/mods/rp_partialblocks/register.lua @@ -11,35 +11,35 @@ local empty_overlay = {{name="rp_textures_blank_paintable_overlay.png",color="wh -- Stonelike materials partialblocks.register_material( - "cobble", S("Cobble Slab"), S("Cobble Stair"), "rp_default:cobble", {cracky=3}, false, nil, "w") + "cobble", S("Cobble Slab"), S("Cobble Stair"), "rp_default:cobble", {cracky=3, pathfinder_hard=1}, false, nil, "w") partialblocks.register_material( - "stone", S("Stone Slab"), S("Stone Stair"), "rp_default:stone", {cracky=2}, false, nil, "w") + "stone", S("Stone Slab"), S("Stone Stair"), "rp_default:stone", {cracky=2, pathfinder_hard=1}, false, nil, "w") partialblocks.register_material( - "sandstone", S("Sandstone Slab"), S("Sandstone Stair"), "rp_default:sandstone", {crumbly=2, cracky=3}, false, nil, "w") + "sandstone", S("Sandstone Slab"), S("Sandstone Stair"), "rp_default:sandstone", {crumbly=2, cracky=3, pathfinder_hard=1}, false, nil, "w") partialblocks.register_material( - "brick", S("Brick Slab"), S("Brick Stair"), "rp_default:brick", {cracky=2, paintable=2}, false, nil, "w") + "brick", S("Brick Slab"), S("Brick Stair"), "rp_default:brick", {cracky=2, paintable=2, pathfinder_hard=1}, false, nil, "w") partialblocks.register_material( - "brick_painted", S("Painted Brick Slab"), S("Painted Brick Stair"), "rp_default:brick_painted", {cracky=2, paintable=1, not_in_creative_inventory=1}, false, nil, "w", nil, "w", false) + "brick_painted", S("Painted Brick Slab"), S("Painted Brick Stair"), "rp_default:brick_painted", {cracky=2, paintable=1, pathfinder_hard=1, not_in_creative_inventory=1}, false, nil, "w", nil, "w", false) -- Woodlike partialblocks.register_material( - "wood", S("Wooden Slab"), S("Wooden Stair"), "rp_default:planks", {choppy = 3, oddly_breakable_by_hand = 3, paintable = 2}, true, nil, "w") + "wood", S("Wooden Slab"), S("Wooden Stair"), "rp_default:planks", {choppy = 3, oddly_breakable_by_hand = 3, paintable = 2, pathfinder_hard=1}, true, nil, "w") partialblocks.register_material( - "wood_painted", S("Painted Wooden Slab"), S("Painted Wooden Stair"), "rp_default:planks_painted", {choppy = 3, oddly_breakable_by_hand = 3, not_in_creative_inventory=1, paintable = 1}, true, nil, "w", empty_overlay, "w", false) + "wood_painted", S("Painted Wooden Slab"), S("Painted Wooden Stair"), "rp_default:planks_painted", {choppy = 3, oddly_breakable_by_hand = 3, not_in_creative_inventory=1, paintable = 1, pathfinder_hard=1}, true, nil, "w", empty_overlay, "w", false) partialblocks.register_material( - "oak", S("Oak Slab"), S("Oak Stair"), "rp_default:planks_oak", {choppy = 3, oddly_breakable_by_hand = 3, paintable = 2}, true, nil, "w") + "oak", S("Oak Slab"), S("Oak Stair"), "rp_default:planks_oak", {choppy = 3, oddly_breakable_by_hand = 3, paintable = 2, pathfinder_hard=1}, true, nil, "w") partialblocks.register_material( - "oak_painted", S("Painted Oak Slab"), S("Painted Oak Stair"), "rp_default:planks_oak_painted", {choppy = 3, oddly_breakable_by_hand = 3, not_in_creative_inventory=1, paintable = 1}, true, nil, "w", empty_overlay, "w", false) + "oak_painted", S("Painted Oak Slab"), S("Painted Oak Stair"), "rp_default:planks_oak_painted", {choppy = 3, oddly_breakable_by_hand = 3, not_in_creative_inventory=1, paintable = 1, pathfinder_hard=1}, true, nil, "w", empty_overlay, "w", false) partialblocks.register_material( - "birch", S("Birch Slab"), S("Birch Stair"), "rp_default:planks_birch", {choppy = 3, oddly_breakable_by_hand = 3, paintable = 2}, true, nil, "w") + "birch", S("Birch Slab"), S("Birch Stair"), "rp_default:planks_birch", {choppy = 3, oddly_breakable_by_hand = 3, paintable = 2, pathfinder_hard=1}, true, nil, "w") partialblocks.register_material( - "birch_painted", S("Painted Birch Slab"), S("Painted Birch Stair"), "rp_default:planks_birch_painted", {choppy = 3, oddly_breakable_by_hand = 3, not_in_creative_inventory=1, paintable = 1}, true, nil, "w", empty_overlay, "w", false) + "birch_painted", S("Painted Birch Slab"), S("Painted Birch Stair"), "rp_default:planks_birch_painted", {choppy = 3, oddly_breakable_by_hand = 3, not_in_creative_inventory=1, paintable = 1, pathfinder_hard=1}, true, nil, "w", empty_overlay, "w", false) partialblocks.register_material( "fir", S("Fir Slab"), S("Fir Stair"), "rp_default:planks_fir", {choppy = 3, oddly_breakable_by_hand = 3, paintable = 2}, true, nil, "w") @@ -49,60 +49,60 @@ partialblocks.register_material( -- Reed partialblocks.register_material( - "reed", S("Reed Slab"), S("Reed Stair"), "rp_default:reed_block", {snappy = 2, fall_damage_add_percent=-10}, true, nil, "w") + "reed", S("Reed Slab"), S("Reed Stair"), "rp_default:reed_block", {snappy = 2, fall_damage_add_percent=-10, pathfinder_soft=1}, true, nil, "w") partialblocks.register_material( - "dried_reed", S("Dried Reed Slab"), S("Dried Reed Stair"), "rp_default:dried_reed_block", {snappy = 2, fall_damage_add_percent=-15}, true, nil, "w") + "dried_reed", S("Dried Reed Slab"), S("Dried Reed Stair"), "rp_default:dried_reed_block", {snappy = 2, fall_damage_add_percent=-15, pathfinder_soft=1}, true, nil, "w") partialblocks.register_material( - "straw", S("Straw Slab"), S("Straw Stair"), "rp_farming:straw", {snappy = 3, fall_damage_add_percent=-15}, true, nil, "w") + "straw", S("Straw Slab"), S("Straw Stair"), "rp_farming:straw", {snappy = 3, fall_damage_add_percent=-15, pathfinder_soft=1}, true, nil, "w") partialblocks.register_material( - "hay", S("Hay Slab"), S("Hay Stair"), "rp_default:hay", {snappy = 3, fall_damage_add_percent=-30}, true, nil, "w") + "hay", S("Hay Slab"), S("Hay Stair"), "rp_default:hay", {snappy = 3, fall_damage_add_percent=-30, pathfinder_soft=1}, true, nil, "w") -- Frames partialblocks.register_material( - "frame", S("Frame Slab"), S("Frame Stair"), "rp_default:frame", {choppy = 2, oddly_breakable_by_hand = 1, paintable = 2}, true, "a|"..pbp.."frame", "a|"..pbp.."frame") + "frame", S("Frame Slab"), S("Frame Stair"), "rp_default:frame", {choppy = 2, oddly_breakable_by_hand = 1, paintable = 2, pathfinder_hard=1}, true, "a|"..pbp.."frame", "a|"..pbp.."frame") partialblocks.register_material( - "frame_painted", S("Painted Frame Slab"), S("Painted Frame Stair"), "rp_default:frame_painted", {choppy = 2, oddly_breakable_by_hand = 1, not_in_creative_inventory=1, paintable = 1}, true, "a|"..pbp.."frame_painted", "a|"..pbp.."frame_painted", nil, nil, false) + "frame_painted", S("Painted Frame Slab"), S("Painted Frame Stair"), "rp_default:frame_painted", {choppy = 2, oddly_breakable_by_hand = 1, not_in_creative_inventory=1, paintable = 1, pathfinder_hard=1}, true, "a|"..pbp.."frame_painted", "a|"..pbp.."frame_painted", nil, nil, false) -- The reinforced partialblocks have their level forced to 0, so are as hard to dig as the basenode. They're reinforced, after all. partialblocks.register_material( - "reinforced_frame", S("Reinforced Frame Slab"), S("Reinforced Frame Stair"), "rp_default:reinforced_frame", {choppy = 1, level = 0, paintable = 2}, true, "a|"..pbp.."reinforced_frame", "a|"..pbp.."reinforced_frame") + "reinforced_frame", S("Reinforced Frame Slab"), S("Reinforced Frame Stair"), "rp_default:reinforced_frame", {choppy = 1, level = 0, paintable = 2, pathfinder_hard=1}, true, "a|"..pbp.."reinforced_frame", "a|"..pbp.."reinforced_frame") partialblocks.register_material( - "reinforced_frame_painted", S("Painted Reinforced Frame Slab"), S("Painted Reinforced Frame Stair"), "rp_default:reinforced_frame_painted", {choppy = 1, level = 0, not_in_creative_inventory=1, paintable = 1}, true, "a|"..pbp.."reinforced_frame_painted", "a|"..pbp.."reinforced_frame_painted", "A|"..pbp.."reinforced_frame_painted_overlay", "A|"..pbp.."reinforced_frame_painted_overlay", false) + "reinforced_frame_painted", S("Painted Reinforced Frame Slab"), S("Painted Reinforced Frame Stair"), "rp_default:reinforced_frame_painted", {choppy = 1, level = 0, not_in_creative_inventory=1, paintable = 1, pathfinder_hard=1}, true, "a|"..pbp.."reinforced_frame_painted", "a|"..pbp.."reinforced_frame_painted", "A|"..pbp.."reinforced_frame_painted_overlay", "A|"..pbp.."reinforced_frame_painted_overlay", false) partialblocks.register_material( - "reinforced_cobble", S("Reinforced Cobble Slab"), S("Reinforced Cobble Stair"), "rp_default:reinforced_cobble", {cracky = 1, level = 0}, false, "A|"..pbp.."reinforced_cobbles", "A|"..pbp.."reinforced_cobbles") + "reinforced_cobble", S("Reinforced Cobble Slab"), S("Reinforced Cobble Stair"), "rp_default:reinforced_cobble", {cracky = 1, level = 0, pathfinder_hard=1}, false, "A|"..pbp.."reinforced_cobbles", "A|"..pbp.."reinforced_cobbles") -- Coal partialblocks.register_material( - "coal", S("Coal Slab"), S("Coal Stair"), "rp_default:block_coal", { cracky = 3 }, true, "a|"..pbp.."block_coal", "a|"..pbp.."block_coal") + "coal", S("Coal Slab"), S("Coal Stair"), "rp_default:block_coal", { cracky = 3, pathfinder_spiky = 1 }, true, "a|"..pbp.."block_coal", "a|"..pbp.."block_coal") -- Metal partialblocks.register_material( - "steel", S("Steel Slab"), S("Steel Stair"), "rp_default:block_steel", { cracky = 2, level = 0 }, false, "a|"..pbp.."block_steel", "a|"..pbp.."block_steel") + "steel", S("Steel Slab"), S("Steel Stair"), "rp_default:block_steel", { cracky = 2, level = 0, pathfinder_hard=1 }, false, "a|"..pbp.."block_steel", "a|"..pbp.."block_steel") partialblocks.register_material( - "carbon_steel", S("Carbon Steel Slab"), S("Carbon Steel Stair"), "rp_default:block_carbon_steel", { cracky = 1, level = 0 }, false, "a|"..pbp.."block_carbon_steel", "a|"..pbp.."block_carbon_steel") + "carbon_steel", S("Carbon Steel Slab"), S("Carbon Steel Stair"), "rp_default:block_carbon_steel", { cracky = 1, level = 0, pathfinder_hard=1 }, false, "a|"..pbp.."block_carbon_steel", "a|"..pbp.."block_carbon_steel") partialblocks.register_material( - "wrought_iron", S("Wrought Iron Slab"), S("Wrought Iron Stair"), "rp_default:block_wrought_iron", { cracky = 2, magnetic = 1 }, false, "a|"..pbp.."block_wrought_iron", "a|"..pbp.."block_wrought_iron") + "wrought_iron", S("Wrought Iron Slab"), S("Wrought Iron Stair"), "rp_default:block_wrought_iron", { cracky = 2, magnetic = 1, pathfinder_hard=1 }, false, "a|"..pbp.."block_wrought_iron", "a|"..pbp.."block_wrought_iron") partialblocks.register_material( - "bronze", S("Bronze Slab"), S("Bronze Stair"), "rp_default:block_bronze", { cracky = 1, level = 0 }, false, "a|"..pbp.."block_bronze", "a|"..pbp.."block_bronze") + "bronze", S("Bronze Slab"), S("Bronze Stair"), "rp_default:block_bronze", { cracky = 1, level = 0, pathfinder_hard=1 }, false, "a|"..pbp.."block_bronze", "a|"..pbp.."block_bronze") partialblocks.register_material( - "copper", S("Copper Slab"), S("Copper Stair"), "rp_default:block_copper", { cracky = 2 }, false, "a|"..pbp.."block_copper", "a|"..pbp.."block_copper") + "copper", S("Copper Slab"), S("Copper Stair"), "rp_default:block_copper", { cracky = 2, pathfinder_hard=1 }, false, "a|"..pbp.."block_copper", "a|"..pbp.."block_copper") partialblocks.register_material( - "tin", S("Tin Slab"), S("Tin Stair"), "rp_default:block_tin", { cracky = 2, level = 0 }, false, "a|"..pbp.."block_tin", "a|"..pbp.."block_tin") + "tin", S("Tin Slab"), S("Tin Stair"), "rp_default:block_tin", { cracky = 2, level = 0, pathfinder_hard=1 }, false, "a|"..pbp.."block_tin", "a|"..pbp.."block_tin") partialblocks.register_material( - "gold", S("Gold Slab"), S("Gold Stair"), "rp_gold:block_gold", { cracky = 2 }, false, "a|"..pbp.."block_gold", "a|"..pbp.."block_gold") + "gold", S("Gold Slab"), S("Gold Stair"), "rp_gold:block_gold", { cracky = 2, pathfinder_hard=1 }, false, "a|"..pbp.."block_gold", "a|"..pbp.."block_gold") -- Compressed sandstone local cs_stair_tiles = { @@ -113,7 +113,7 @@ local cs_stair_tiles = { "default_compressed_sandstone.png", "default_compressed_sandstone.png" } partialblocks.register_material( - "compressed_sandstone", S("Compressed Sandstone Slab"), S("Compressed Sandstone Stair"), "rp_default:compressed_sandstone", { cracky = 2 }, false, nil, cs_stair_tiles) + "compressed_sandstone", S("Compressed Sandstone Slab"), S("Compressed Sandstone Stair"), "rp_default:compressed_sandstone", { cracky = 2, pathfinder_hard=1 }, false, nil, cs_stair_tiles) partialblocks.register_material( - "reinforced_compressed_sandstone", S("Reinforced Compressed Sandstone Slab"), S("Reinforced Compressed Sandstone Stair"), "rp_default:reinforced_compressed_sandstone", { cracky = 2 }, false, "a|"..pbp.."reinforced_compressed_sandstone", "a|"..pbp.."reinforced_compressed_sandstone") + "reinforced_compressed_sandstone", S("Reinforced Compressed Sandstone Slab"), S("Reinforced Compressed Sandstone Stair"), "rp_default:reinforced_compressed_sandstone", { cracky = 2, pathfinder_hard=1 }, false, "a|"..pbp.."reinforced_compressed_sandstone", "a|"..pbp.."reinforced_compressed_sandstone") diff --git a/mods/rp_pathfinder/API.md b/mods/rp_pathfinder/API.md index 29d9bd83..59986607 100644 --- a/mods/rp_pathfinder/API.md +++ b/mods/rp_pathfinder/API.md @@ -44,6 +44,13 @@ restrictions and does not cut corners. * `handler_climbable`: A function that takes a node table and returns true if the node is considered climable (default: if `climbing` field of node is true) + * `get_floor_cost`: Function that takes a node table and returns + the cost (a number) of walking _on_ the given node. The villager searches + for the path with the lowest total cost. By default, the cost is 1 + for all nodes. The function _MUST NOT_ return a negative cost! + It’s recommended this function utilizes pathfinder node groups + as laid out in `DEV_GROUPS.md` in the root Repixture directory. + But it’s not mandatory to only rely on these groups. * `use_vmanip`: If true, nodes will be queried using a LuaVoxelManip; otherwise, `minetest.get_node` will be used. Required for async usage. diff --git a/mods/rp_pathfinder/init.lua b/mods/rp_pathfinder/init.lua index b866a401..5bfcaf61 100644 --- a/mods/rp_pathfinder/init.lua +++ b/mods/rp_pathfinder/init.lua @@ -104,14 +104,19 @@ local function get_distance_2d(pos1, pos2) return distX + distZ end --- 3D distance heuristic between pos1 and pos2 -local function get_distance_3d(pos1, pos2) - local distX = math.abs(pos1.x - pos2.x) - local distY = math.abs(pos1.y - pos2.y) - local distZ = math.abs(pos1.z - pos2.z) - - -- Manhattan distance - return distX + distY + distZ +-- Get actual cost to walk from pos1 to pos2 (which must be a neighbor) +-- * pos1: Origin position +-- * pos2: Target position (neighbor of pos1) +-- * get_node: get_node function +-- * get_floor_cost(node): Function that, given a node table, returns the +-- cost of walking *on* this node (default cost is 1) +local function get_neighbor_cost(pos1, pos2, get_node, get_floor_cost) + if not get_floor_cost then + return 1 + end + local floor = vector.offset(pos2, 0, -1, 0) + local floornode = get_node(floor) + return get_floor_cost(floornode) end -- Checks nodes above pos to be non-blocking. @@ -364,6 +369,7 @@ function rp_pathfinder.find_path(pos1, pos2, searchdistance, options, timeout) local max_jump = options.max_jump or 0 local respect_disable_jump = options.respect_disable_jump or false local respect_climb_restrictions = options.respect_climb_restrictions + local get_floor_cost = options.get_floor_cost if respect_climb_restrictions == nil then respect_climb_restrictions = true end @@ -446,7 +452,7 @@ function rp_pathfinder.find_path(pos1, pos2, searchdistance, options, timeout) -- Add the first search node to open set at the start - local h_first = get_distance_3d(pos1, pos2) + local h_first = get_neighbor_cost(pos1, pos2, get_node, get_floor_cost) set_search_node(open_set, start_hash, { pos = pos1, parent = nil, @@ -577,7 +583,7 @@ function rp_pathfinder.find_path(pos1, pos2, searchdistance, options, timeout) local g = 0 -- cost from start local h -- estimated cost from search node to finish local f -- g+h - local neighbor_cost = current_data.g + get_distance_3d(current_data.pos, neighbor.pos) + local neighbor_cost = current_data.g + get_neighbor_cost(current_data.pos, neighbor.pos, get_node, get_floor_cost) local neighbor_data = get_search_node(open_set, neighbor.hash) local neighbor_exists if neighbor_data then @@ -587,7 +593,7 @@ function rp_pathfinder.find_path(pos1, pos2, searchdistance, options, timeout) neighbor_exists = false end if not neighbor_exists or neighbor_cost < g then - h = get_distance_3d(neighbor.pos, pos2) + h = get_neighbor_cost(neighbor.pos, pos2, get_node, get_floor_cost) g = neighbor_cost f = g + h set_search_node(open_set, neighbor.hash, { diff --git a/mods/rp_tnt/init.lua b/mods/rp_tnt/init.lua index a584404d..4d5b69c1 100644 --- a/mods/rp_tnt/init.lua +++ b/mods/rp_tnt/init.lua @@ -198,7 +198,7 @@ minetest.register_node( _rp_tt_has_ignitible_text = true, -- prevent rp_tt mod from adding automatic tooltip tiles = {top_tex, "tnt_bottom.png", "tnt_sides.png"}, is_ground_content = false, - groups = {handy = 2, interactive_node=1}, + groups = {handy = 2, interactive_node=1, pathfinder_hard=1}, sounds = rp_sounds.node_sound_wood_defaults(), on_blast = function(pos, intensity) @@ -243,7 +243,7 @@ minetest.register_node( light_source = 5, drop = "", is_ground_content = false, - groups = {handy = 2, not_in_creative_inventory=1}, + groups = {handy = 2, not_in_creative_inventory=1, pathfinder_hard=1}, sounds = rp_sounds.node_sound_wood_defaults(), on_timer = tnt_burning_on_timer, on_construct = function(pos)