sorcery  Diff

Differences From Artifact [e0cdcfa7d5]:

To Artifact [dfbf2cd360]:


    60     60   			-- can't mutate table while we're iterating it
    61     61   			if not minetest.registered_nodes[g] then bad[#bad+1] = g end
    62     62   		end
    63     63   		for _, g in ipairs(bad) do god.gifts[g] = nil end
    64     64   	end
    65     65   end)
    66     66   
    67         -local std_god_interval = 70
           67  +local std_god_interval = 40
    68     68   
    69     69   for name, god in pairs(sorcery.data.gods) do
    70     70   	local hitbox = {
    71     71   		0-(god.idol.width / 2.0), 0-(god.idol.height / 2.0), -0.15,
    72     72   		   god.idol.width / 2.0,     god.idol.height / 2.0,   0.15
    73     73   	} -- {xmin, ymin, zmin,
    74     74   	  -- xmax, ymax, zmax} in nodes from node center.
................................................................................
    76     76   	if god.idol.craft then
    77     77   		minetest.register_craft {
    78     78   			output = 'sorcery:idol_' .. name;
    79     79   			recipe = god.idol.craft;
    80     80   		};
    81     81   	end
    82     82   	local god_interval = std_god_interval * (god.freq or 1)
           83  +	local add_sparkles = function(pos,divine_favor)
           84  +		divine_favor = divine_favor or minetest.get_meta(pos):get_int('favor')
           85  +		if divine_favor > 5 then
           86  +			local ct = divine_favor / 5
           87  +			minetest.add_particlespawner {
           88  +				texture = L.image('sorcery_glitter.png'):glow(L.color(god.color)):render();
           89  +				glow = 14;
           90  +				amount = ct / (1 / god_interval), time = god_interval;
           91  +				minpos = pos:offset(-0.4, -0.5, -0.4);
           92  +				maxpos = pos:offset( 0.4,god.idol.height-0.5,0.4);
           93  +				minvel = vector.new(0, 0.05, 0);
           94  +				minvel = vector.new(0, 0.1, 0);
           95  +				minacc = vector.new(0, 0.1, 0);
           96  +				maxacc = vector.new(0, 0.2, 0);
           97  +				minexptime = 4, maxexptime = 4;
           98  +				minsize = 0.3, maxsize = 1;
           99  +				animation = {
          100  +					type = 'vertical_frames';
          101  +					length = 0.1;
          102  +					aspect_w = 16, aspect_h = 16;
          103  +				}
          104  +			}
          105  +		end
          106  +	end
    83    107   	sorcery.lib.node.reg_autopreserve('sorcery:idol_' .. name, {
    84    108   		description = god.idol.desc;
    85    109   		drawtype = "mesh";
    86    110   		mesh = 'sorcery-idol-' .. name .. '.obj';
    87    111   		paramtype = 'light';
    88    112   		paramtype2 = 'facedir';
    89    113   		sunlight_propagates = true;
    90    114   		stack_max = 1;
    91    115   		tiles = god.idol.tex;
    92    116   		selection_box = { type = "fixed"; fixed = {hitbox}; };
    93    117   		collision_box = { type = "fixed"; fixed = {hitbox}; };
    94         -		groups = { cracky = 2, sorcery_idol = 1, heavy = 1, sorcery_worship = 1};
          118  +		groups = { cracky = 2, sorcery_idol = 1, heavy = 1, sorcery_worship = 1, sorcery_instantiate = 1};
          119  +		_sorcery = {
          120  +			idol_god = name;
          121  +			on_load = function(pos) add_sparkles(pos) end;
          122  +		};
    95    123   
    96    124   		on_construct = function(pos)
    97    125   			minetest.get_node_timer(pos):start(god_interval)
          126  +			add_sparkles(pos)
    98    127   		end;
    99    128   
   100    129   		on_timer = function(pos, elapsed)
   101    130   			local altar = minetest.find_node_near(pos, 3, "sorcery:altar")
   102    131   			-- TODO even without an altar, an idol with high favor could still be the source of miracles
   103    132   			-- refills nearby partly empty troughs at cost to favor?
   104    133   			if not altar then return true end
   105    134   
   106    135   			local altarmeta = minetest.get_meta(altar)
   107    136   			local inv = altarmeta:get_inventory()
   108    137   			local idolmeta = minetest.get_meta(pos)
   109    138   			local divine_favor = idolmeta:get_int('favor')
   110         -			if divine_favor > 5 then
   111         -				local ct = divine_favor / 5
   112         -				minetest.add_particlespawner {
   113         -					texture = L.image('sorcery_glitter.png'):glow(L.color(god.color)):render();
   114         -					glow = 14;
   115         -					amount = ct / (1 / god_interval), time = god_interval;
   116         -					minpos = pos:offset(-0.4, -0.5, -0.4);
   117         -					maxpos = pos:offset( 0.4,god.idol.height-0.5,0.4);
   118         -					minvel = vector.new(0, 0.05, 0);
   119         -					minvel = vector.new(0, 0.1, 0);
   120         -					minacc = vector.new(0, 0.1, 0);
   121         -					maxacc = vector.new(0, 0.2, 0);
   122         -					minexptime = 4, maxexptime = 4;
   123         -					minsize = 0.3, maxsize = 1;
   124         -					animation = {
   125         -						type = 'vertical_frames';
   126         -						length = 0.1;
   127         -						aspect_w = 16, aspect_h = 16;
   128         -					}
   129         -				}
   130         -			end
          139  +			add_sparkles(pos,divine_favor)
   131    140   			local bestow = function(item,color)
   132    141   				if type(item) == 'string' then
   133    142   					item = ItemStack(item)
   134    143   				end
   135    144   				if color == nil then
   136    145   					color = sorcery.lib.color(god.color)
   137    146   				end
................................................................................
   193    202   					-- we pick a random gift and roll against its rarity
   194    203   					-- to determine if the god is feeling generous
   195    204   					local gift = sorcery.lib.tbl.pick(god.gifts)
   196    205   					local data = god.gifts[gift]
   197    206   					local value, rarity = data[1], data[2]
   198    207   					if value <= divine_favor and math.random(rarity) == 1 then
   199    208   						bestow(gift)
   200         -						log.act(god.name .. ' has produced ' .. gift .. ' upon an altar as a gift')
          209  +						log.act(god.name,'has produced',gift,'upon an altar as a gift')
   201    210   						if math.random(god.generosity) == 1 then
   202    211   							-- unappreciated gifts may incur divine
   203    212   							-- irritation
   204    213   							divine_favor = divine_favor - 1
   205    214   						end
   206    215   					end
   207    216   				end
................................................................................
   231    240   								-- the gods are getting bored
   232    241   								value = math.floor(value / 2)
   233    242   							end
   234    243   							bestow(nil)
   235    244   						end
   236    245   						divine_favor = divine_favor + value
   237    246   						
   238         -						print(god.name.." has accepted a sacrifice of "..s..", raising divine favor by "..value.." points to "..divine_favor)
          247  +						log.actf("%s has accepted a sacrifice of %s, raising divine favor by %u points to %u at altar %s", god.name, s, value, divine_favor, minetest.pos_to_string(pos))
          248  +
   239    249   						idolmeta:set_string('last_sacrifice', s)
   240    250   
   241    251   						goto refresh
   242    252   					end
   243    253   				end
   244    254   
   245    255   				-- loop through the list of things this god will consecrate and