forked from Mineclonia/Mineclonia
Fishing & Mineshaft loot
This commit is contained in:
parent
b91b587876
commit
d820c35937
|
@ -11,12 +11,15 @@ Parameters:
|
||||||
stacks_max = 3, -- Maximum number of item stacks to get. Default: 1
|
stacks_max = 3, -- Maximum number of item stacks to get. Default: 1
|
||||||
items = { -- Table of possible loot items. This function selects between stacks_min and stacks_max of these.
|
items = { -- Table of possible loot items. This function selects between stacks_min and stacks_max of these.
|
||||||
{
|
{
|
||||||
|
weight = 5, -- Likelihood of this item being selected (see below). Optional (default: 1)
|
||||||
|
|
||||||
|
itemstack = ItemStack("example:item1"), -- Itemstack to select
|
||||||
|
-- OR
|
||||||
itemstring = "example:item1", -- Which item to select
|
itemstring = "example:item1", -- Which item to select
|
||||||
amount_min = 1, -- Minimum size of itemstack. Must not be larger than 6553. Optional (default: 1)
|
amount_min = 1, -- Minimum size of itemstack. Must not be larger than 6553. Optional (default: 1)
|
||||||
amount_max = 10, -- Maximum size of item stack. Must not be larger than item definition's stack_max or 6553. Optional (default: 1)
|
amount_max = 10, -- Maximum size of item stack. Must not be larger than item definition's stack_max or 6553. Optional (default: 1)
|
||||||
wear_min = 1, -- Minimum wear value. Must be at least 1. Optional (default: no wear)
|
wear_min = 1, -- Minimum wear value. Must be at least 1. Optional (default: no wear)
|
||||||
wear_max = 1, -- Maxiumum wear value. Must be at least 1. Optional (default: no wear)
|
wear_max = 1, -- Maxiumum wear value. Must be at least 1. Optional (default: no wear)
|
||||||
weight = 5, -- Likelihood of this item being selected (see below). Optional (default: 1)
|
|
||||||
},
|
},
|
||||||
{ -- more tables like above, one table per item stack }
|
{ -- more tables like above, one table per item stack }
|
||||||
}
|
}
|
||||||
|
@ -56,24 +59,29 @@ function mcl_loot.get_loot(loot_definitions, pr)
|
||||||
end
|
end
|
||||||
if item then
|
if item then
|
||||||
local itemstring = item.itemstring
|
local itemstring = item.itemstring
|
||||||
if item.amount_min and item.amount_max then
|
local itemstack = item.itemstack
|
||||||
itemstring = itemstring .. " " .. pr:next(item.amount_min, item.amount_max)
|
if itemstring then
|
||||||
end
|
if item.amount_min and item.amount_max then
|
||||||
if item.wear_min and item.wear_max then
|
itemstring = itemstring .. " " .. pr:next(item.amount_min, item.amount_max)
|
||||||
-- Sadly, PseudoRandom only allows very narrow ranges, so we set wear in steps of 10
|
|
||||||
local wear_min = math.floor(item.wear_min / 10)
|
|
||||||
local wear_max = math.floor(item.wear_max / 10)
|
|
||||||
local wear = pr:next(wear_min, wear_max) * 10
|
|
||||||
|
|
||||||
if not item.amount_min and not item.amount_max then
|
|
||||||
itemstring = itemstring .. " 1"
|
|
||||||
end
|
end
|
||||||
|
if item.wear_min and item.wear_max then
|
||||||
|
-- Sadly, PseudoRandom only allows very narrow ranges, so we set wear in steps of 10
|
||||||
|
local wear_min = math.floor(item.wear_min / 10)
|
||||||
|
local wear_max = math.floor(item.wear_max / 10)
|
||||||
|
local wear = pr:next(wear_min, wear_max) * 10
|
||||||
|
|
||||||
|
if not item.amount_min and not item.amount_max then
|
||||||
|
itemstring = itemstring .. " 1"
|
||||||
|
end
|
||||||
|
|
||||||
itemstring = itemstring .. " " .. tostring(wear)
|
itemstring = itemstring .. " " .. tostring(wear)
|
||||||
|
end
|
||||||
|
table.insert(items, itemstring)
|
||||||
|
elseif itemstack then
|
||||||
|
table.insert(items, itemstack)
|
||||||
|
else
|
||||||
|
minetest.log("error", "[mcl_loot] INTERNAL ERROR! Failed to select random loot item!")
|
||||||
end
|
end
|
||||||
table.insert(items, itemstring)
|
|
||||||
else
|
|
||||||
minetest.log("error", "[mcl_loot] INTERNAL ERROR! Failed to select random loot item!")
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -320,6 +320,23 @@ function mcl_enchanting.get_randomly_enchanted_book(enchantment_level, treasure,
|
||||||
return mcl_enchanting.enchant_randomly(enchantment_level, treasure, no_reduced_bonus_chance)
|
return mcl_enchanting.enchant_randomly(enchantment_level, treasure, no_reduced_bonus_chance)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
function mcl_enchanting.get_uniform_randomly_enchanted_book(except)
|
||||||
|
except = except or except
|
||||||
|
local stack = ItemStack("mcl_enchanting:book_enchanted")
|
||||||
|
local list = {}
|
||||||
|
for enchantment in pairs(mcl_enchanting.enchantments) do
|
||||||
|
if table.indexof(except, enchantment) == -1 then
|
||||||
|
table.insert(list, enchantment)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
local index = math.random(#list)
|
||||||
|
local enchantment = list[index]
|
||||||
|
local enchantment_def = mcl_enchanting.enchantments[enchantment]
|
||||||
|
local level = math.random(enchantment_def.max_level)
|
||||||
|
mcl_enchanting.enchant(stack, enchantment, level)
|
||||||
|
return stack
|
||||||
|
end
|
||||||
|
|
||||||
function mcl_enchanting.get_random_glyph_row()
|
function mcl_enchanting.get_random_glyph_row()
|
||||||
local glyphs = ""
|
local glyphs = ""
|
||||||
local x = 1.3
|
local x = 1.3
|
||||||
|
|
|
@ -88,8 +88,7 @@ local fish = function(itemstack, player)
|
||||||
items = {
|
items = {
|
||||||
-- TODO: Enchanted Bow
|
-- TODO: Enchanted Bow
|
||||||
{ itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage
|
{ itemstring = "mcl_bows:bow", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage
|
||||||
-- TODO: Enchanted Book
|
{ itemstack = mcl_enchanting.get_randomly_enchanted_book(30, true, true)},
|
||||||
{ itemstring = "mcl_books:book" },
|
|
||||||
-- TODO: Enchanted Fishing Rod
|
-- TODO: Enchanted Fishing Rod
|
||||||
{ itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage
|
{ itemstring = "mcl_fishing:fishing_rod", wear_min = 49144, wear_max = 65535 }, -- 75%-100% damage
|
||||||
{ itemstring = "mcl_mobs:nametag", },
|
{ itemstring = "mcl_mobs:nametag", },
|
||||||
|
|
|
@ -21,8 +21,7 @@ local get_loot = function()
|
||||||
{ itemstring = "mcl_jukebox:record_4", weight = 15 },
|
{ itemstring = "mcl_jukebox:record_4", weight = 15 },
|
||||||
{ itemstring = "mobs_mc:iron_horse_armor", weight = 15 },
|
{ itemstring = "mobs_mc:iron_horse_armor", weight = 15 },
|
||||||
{ itemstring = "mcl_core:apple_gold", weight = 15 },
|
{ itemstring = "mcl_core:apple_gold", weight = 15 },
|
||||||
-- TODO: Enchanted Book
|
{ itemstack = mcl_enchanting.get_uniform_randomly_enchanted_book({"soul_speed"}), weight = 10 },
|
||||||
{ itemstring = "mcl_books:book", weight = 10 },
|
|
||||||
{ itemstring = "mobs_mc:gold_horse_armor", weight = 10 },
|
{ itemstring = "mobs_mc:gold_horse_armor", weight = 10 },
|
||||||
{ itemstring = "mobs_mc:diamond_horse_armor", weight = 5 },
|
{ itemstring = "mobs_mc:diamond_horse_armor", weight = 5 },
|
||||||
-- TODO: Enchanted Golden Apple
|
-- TODO: Enchanted Golden Apple
|
||||||
|
|
Loading…
Reference in New Issue