sorcery  Diff

Differences From Artifact [5335f5f5e0]:

To Artifact [f718356661]:


     1      1   local altar_item_offset = {
     2      2   	x = 0, y = -0.3, z = 0
     3      3   }
            4  +
            5  +local range = function(min, max)
            6  +	local span = max - min
            7  +	local val = math.random() * span
            8  +	return val + min
            9  +end
     4     10   
     5     11   local get_altar_ent = function(pos)
     6     12   	for _, obj in pairs(minetest.get_objects_inside_radius(pos,0.9)) do
     7     13   		if not obj then goto nextloop end
     8     14   		local ent = obj:get_luaentity()
     9     15   		if not ent then goto nextloop end
    10     16   
................................................................................
    98    104   			local bestow = function(item,color)
    99    105   				if type(item) == 'string' then
   100    106   					item = ItemStack(item)
   101    107   				end
   102    108   				if color == nil then
   103    109   					color = sorcery.lib.color(god.color)
   104    110   				end
   105         -				local range = function(min, max)
   106         -					local span = max - min
   107         -					local val = math.random() * span
   108         -					return val + min
   109         -				end
   110    111   				for i=0,32 do
   111    112   					minetest.add_particle{
   112    113   						pos = {
   113    114   							x = altar.x + range(-0.4,0.4);
   114    115   							z = altar.z + range(-0.4,0.4);
   115    116   							y = altar.y + range(-0.2,0.3);
   116    117   						};
................................................................................
   217    218   				-- loop through the list of things this god will consecrate and
   218    219   				-- check whether the item on the altar is any of them
   219    220   				for s, cons in pairs(god.consecrate) do
   220    221   					local cost, tx = cons[1], cons[2]
   221    222   					if type(tx) == "table" then
   222    223   						tx = tx[math.random(#tx)]
   223    224   					end
          225  +					-- preserve wear
   224    226   					local gift = ItemStack(tx)
   225    227   					local wear = stack:get_wear()
   226    228   					if wear > 0 then
   227    229   						gift:set_wear(wear)
   228    230   					end
          231  +					-- preserve meta
          232  +					gift:get_meta():from_table(stack:get_meta():to_table())
          233  +					-- reflash enchantments to ensure label is accurate
          234  +					local ench = sorcery.enchant.get(gift)
          235  +					if #ench.spells > 0 then
          236  +						-- add a bit of energy as a gift?
          237  +						if math.random(math.ceil(god.stinginess * 0.5)) == 1 then
          238  +							local max = 0.05 * god.generosity
          239  +							ench.energy = ench.energy * range(0.7*max,max)
          240  +						end
          241  +						sorcery.enchant.set(gift,ench)
          242  +					end
   229    243   					if itemname == s then
   230    244   						if divine_favor >= cost then
   231    245   							bestow(gift)
   232    246   							divine_favor = divine_favor - cost
   233    247   							print(god.name..'has consecrated ' ..s.. ' into ' ..tx.. ', for the cost of ' ..cost.. ' points of divine favor')
   234    248   							goto refresh
   235    249   						end