randomly enchant treasure

This commit is contained in:
cora 2022-06-02 12:30:51 +02:00
parent 4af1094eed
commit b7419dc207
2 changed files with 47 additions and 39 deletions

View file

@ -14,45 +14,53 @@ local schems = {
"shipwreck_half_back", "shipwreck_half_back",
} }
local loottable_supply = { local function get_supply_loot()
stacks_min = 3, return {
stacks_max = 10, stacks_min = 3,
items = { stacks_max = 10,
--{ itemstring = "TODO:sus_stew", weight = 10, amount_min = 1, amount_max = 1 }, items = {
{ itemstring = "mcl_core:paper", weight = 8, amount_min = 1, amount_max = 12 }, --{ itemstring = "TODO:sus_stew", weight = 10, amount_min = 1, amount_max = 1 },
{ itemstring = "mcl_farming:wheat_item", weight = 7, amount_min = 8, amount_max = 21 }, { itemstring = "mcl_core:paper", weight = 8, amount_min = 1, amount_max = 12 },
{ itemstring = "mcl_farming:carrot_item", weight = 7, amount_min = 4, amount_max = 8 }, { itemstring = "mcl_farming:wheat_item", weight = 7, amount_min = 8, amount_max = 21 },
{ itemstring = "mcl_farming:potato_item_poison", weight = 7, amount_min = 2, amount_max = 6 }, { itemstring = "mcl_farming:carrot_item", weight = 7, amount_min = 4, amount_max = 8 },
{ itemstring = "mcl_farming:potato_item", weight = 7, amount_min = 2, amount_max = 6 }, { itemstring = "mcl_farming:potato_item_poison", weight = 7, amount_min = 2, amount_max = 6 },
--{ itemstring = "TODO:moss_block", weight = 7, amount_min = 1, amount_max = 4 }, { itemstring = "mcl_farming:potato_item", weight = 7, amount_min = 2, amount_max = 6 },
{ itemstring = "mcl_core:coal_lump", weight = 6, amount_min = 2, amount_max = 8 }, --{ itemstring = "TODO:moss_block", weight = 7, amount_min = 1, amount_max = 4 },
{ itemstring = "mcl_mobitems:rotten_flesh", weight = 5, amount_min = 5, amount_max = 24 }, { itemstring = "mcl_core:coal_lump", weight = 6, amount_min = 2, amount_max = 8 },
{ itemstring = "mcl_farming:potato_item", weight = 3, amount_min = 1, amount_max = 5 }, { itemstring = "mcl_mobitems:rotten_flesh", weight = 5, amount_min = 5, amount_max = 24 },
{ itemstring = "mcl_armor:helmet_leather_enchanted", weight = 3 }, { itemstring = "mcl_farming:potato_item", weight = 3, amount_min = 1, amount_max = 5 },
{ itemstring = "mcl_armor:chestplate_leather_enchanted", weight = 3 }, { itemstring = "mcl_armor:helmet_leather_enchanted", weight = 3, func = function(stack, pr)
{ itemstring = "mcl_armor:leggings_leather_enchanted", weight = 3 }, mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end },
{ itemstring = "mcl_armor:boots_leather_enchanted", weight = 3 }, { itemstring = "mcl_armor:chestplate_leather_enchanted", weight = 3, func = function(stack, pr)
--{ itemstring = "TODO:bamboo", weight = 2, amount_min = 1, amount_max = 3 }, mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end },
{ itemstring = "mcl_farming:pumpkin", weight = 2, amount_min = 1, amount_max = 3 }, { itemstring = "mcl_armor:leggings_leather_enchanted", weight = 3, func = function(stack, pr)
{ itemstring = "mcl_tnt:tnt", weight = 1, amount_min = 1, amount_max = 2 }, mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end },
{ itemstring = "mcl_armor:boots_leather_enchanted", weight = 3, func = function(stack, pr)
mcl_enchanting.enchant_uniform_randomly(stack, {"soul_speed"}) end },
--{ itemstring = "TODO:bamboo", weight = 2, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_farming:pumpkin", weight = 2, amount_min = 1, amount_max = 3 },
{ itemstring = "mcl_tnt:tnt", weight = 1, amount_min = 1, amount_max = 2 },
}
} }
} end
local loottable_treasure = { local function get_treasure_loot()
stacks_min = 3, return {
stacks_max = 10, stacks_min = 3,
items = { stacks_max = 10,
{ itemstring = "mcl_core:iron_ingot", weight = 8, amount_min = 1, amount_max = 5 }, items = {
{ itemstring = "mcl_core:iron_nugget", weight = 8, amount_min = 1, amount_max = 10 }, { itemstring = "mcl_core:iron_ingot", weight = 8, amount_min = 1, amount_max = 5 },
{ itemstring = "mcl_core:emerald", weight = 8, amount_min = 1, amount_max = 12 }, { itemstring = "mcl_core:iron_nugget", weight = 8, amount_min = 1, amount_max = 10 },
{ itemstring = "mcl_dye:blue", weight = 8, amount_min = 1, amount_max = 12 }, { itemstring = "mcl_core:emerald", weight = 8, amount_min = 1, amount_max = 12 },
{ itemstring = "mcl_core:gold_ingot", weight = 8, amount_min = 1, amount_max = 5 }, { itemstring = "mcl_dye:blue", weight = 8, amount_min = 1, amount_max = 12 },
{ itemstring = "mcl_core:gold_nugget", weight = 8, amount_min = 1, amount_max = 10 }, { itemstring = "mcl_core:gold_ingot", weight = 8, amount_min = 1, amount_max = 5 },
{ itemstring = "mcl_experience:bottle", weight = 8, amount_min = 1, amount_max = 10 }, { itemstring = "mcl_core:gold_nugget", weight = 8, amount_min = 1, amount_max = 10 },
{ itemstring = "mcl_core:diamond", weight = 8, amount_min = 1, amount_max = 10 }, { itemstring = "mcl_experience:bottle", weight = 8, amount_min = 1, amount_max = 10 },
{ itemstring = "mcl_core:diamond", weight = 8, amount_min = 1, amount_max = 10 },
}
} }
} end
local function fill_chests(p1,p2) local function fill_chests(p1,p2)
for _,p in pairs(minetest.find_nodes_in_area(p1,p2,{"mcl_chests:chest_small"})) do for _,p in pairs(minetest.find_nodes_in_area(p1,p2,{"mcl_chests:chest_small"})) do
@ -60,8 +68,8 @@ local function fill_chests(p1,p2)
minetest.registered_nodes["mcl_chests:chest_small"].on_construct(p) minetest.registered_nodes["mcl_chests:chest_small"].on_construct(p)
end end
local inv = minetest.get_inventory( {type="node", pos=p} ) local inv = minetest.get_inventory( {type="node", pos=p} )
local loot = loottable_supply local loot = get_supply_loot()
if pr:next(1,10) == 1 then loot = loottable_treasure end if pr:next(1,10) == 1 then loot = get_treasure_loot() end
mcl_loot.fill_inventory(inv, "main", mcl_loot.get_multi_loot({loot}, pr), pr) mcl_loot.fill_inventory(inv, "main", mcl_loot.get_multi_loot({loot}, pr), pr)
end end
end end

View file

@ -1,3 +1,3 @@
name = mcl_shipwrecks name = mcl_shipwrecks
author = cora author = cora
depends = mcl_loot, mcl_structures depends = mcl_loot, mcl_structures, mcl_enchanting