@@ -1,7 +1,13 @@ local altar_item_offset = { x = 0, y = -0.3, z = 0 } + +local range = function(min, max) + local span = max - min + local val = math.random() * span + return val + min +end local get_altar_ent = function(pos) for _, obj in pairs(minetest.get_objects_inside_radius(pos,0.9)) do if not obj then goto nextloop end @@ -101,13 +107,8 @@ end if color == nil then color = sorcery.lib.color(god.color) end - local range = function(min, max) - local span = max - min - local val = math.random() * span - return val + min - end for i=0,32 do minetest.add_particle{ pos = { x = altar.x + range(-0.4,0.4); @@ -220,13 +221,26 @@ local cost, tx = cons[1], cons[2] if type(tx) == "table" then tx = tx[math.random(#tx)] end + -- preserve wear local gift = ItemStack(tx) local wear = stack:get_wear() if wear > 0 then gift:set_wear(wear) end + -- preserve meta + gift:get_meta():from_table(stack:get_meta():to_table()) + -- reflash enchantments to ensure label is accurate + local ench = sorcery.enchant.get(gift) + if #ench.spells > 0 then + -- add a bit of energy as a gift? + if math.random(math.ceil(god.stinginess * 0.5)) == 1 then + local max = 0.05 * god.generosity + ench.energy = ench.energy * range(0.7*max,max) + end + sorcery.enchant.set(gift,ench) + end if itemname == s then if divine_favor >= cost then bestow(gift) divine_favor = divine_favor - cost