sorcery  Diff

Differences From Artifact [7e265da854]:

To Artifact [235fbb7fc6]:


1
2
3
4

5
6
7
8
9
10
11
..
58
59
60
61
62
63
64


65
66
67
68
69
70
71
72






73
74
75
76
77
78
79
..
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99





















100
101
102
103
104
105
106
...
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
local altar_item_offset = {
	x = 0, y = -0.3, z = 0
}
local log = sorcery.logger('altar')


local range = function(min, max)
	local span = max - min
	local val = math.random() * span
	return val + min
end

................................................................................
		for g in pairs(god.gifts) do
			-- can't mutate table while we're iterating it
			if not minetest.registered_nodes[g] then bad[#bad+1] = g end
		end
		for _, g in ipairs(bad) do god.gifts[g] = nil end
	end
end)



for name, god in pairs(sorcery.data.gods) do
	local hitbox = {
		0-(god.idol.width / 2.0), 0-(god.idol.height / 2.0), -0.15,
		   god.idol.width / 2.0,     god.idol.height / 2.0,   0.15
	} -- {xmin, ymin, zmin,
	  -- xmax, ymax, zmax} in nodes from node center.
	paramtype = "light";






	sorcery.lib.node.reg_autopreserve('sorcery:idol_' .. name, {
		description = god.idol.desc;
		drawtype = "mesh";
		mesh = 'sorcery-idol-' .. name .. '.obj';
		paramtype = 'light';
		paramtype2 = 'facedir';
		sunlight_propagates = true;
................................................................................
		stack_max = 1;
		tiles = god.idol.tex;
		selection_box = { type = "fixed"; fixed = {hitbox}; };
		collision_box = { type = "fixed"; fixed = {hitbox}; };
		groups = { cracky = 2, sorcery_idol = 1, heavy = 1, sorcery_worship = 1};

		on_construct = function(pos)
			minetest.get_node_timer(pos):start(1)
		end;

		on_timer = function(pos, elapsed)
			local altar = minetest.find_node_near(pos, 3, "sorcery:altar")
			-- TODO even without an altar, an idol with high favor could still be the source of miracles
			-- refills nearby partly empty troughs at cost to favor?
			if not altar then return true end

			local altarmeta = minetest.get_meta(altar)
			local inv = altarmeta:get_inventory()
			local idolmeta = minetest.get_meta(pos)
			local divine_favor = idolmeta:get_int('favor')





















			local bestow = function(item,color)
				if type(item) == 'string' then
					item = ItemStack(item)
				end
				if color == nil then
					color = sorcery.lib.color(god.color)
				end
................................................................................
					}
				end
				inv:set_stack('item',1,item)
			end
			if inv:is_empty('item') then 
				-- nothing on the altar. decide if we're going to do a
				-- gift cycle by rolling against the god's stinginess
				if math.random(god.stinginess) == 1 then
					-- we've beat the odds and started a gift cycle. now
					-- we pick a random gift and roll against its rarity
					-- to determine if the god is feeling generous
					local gift = sorcery.lib.tbl.pick(god.gifts)
					local data = god.gifts[gift]
					local value, rarity = data[1], data[2]
					if value <= divine_favor and math.random(rarity) == 1 then




>







 







>
>








>
>
>
>
>
>







 







|












>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







 







|







1
2
3
4
5
6
7
8
9
10
11
12
..
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
..
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
...
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
local altar_item_offset = {
	x = 0, y = -0.3, z = 0
}
local log = sorcery.logger('altar')
local L = sorcery.lib

local range = function(min, max)
	local span = max - min
	local val = math.random() * span
	return val + min
end

................................................................................
		for g in pairs(god.gifts) do
			-- can't mutate table while we're iterating it
			if not minetest.registered_nodes[g] then bad[#bad+1] = g end
		end
		for _, g in ipairs(bad) do god.gifts[g] = nil end
	end
end)

local god_interval = 1

for name, god in pairs(sorcery.data.gods) do
	local hitbox = {
		0-(god.idol.width / 2.0), 0-(god.idol.height / 2.0), -0.15,
		   god.idol.width / 2.0,     god.idol.height / 2.0,   0.15
	} -- {xmin, ymin, zmin,
	  -- xmax, ymax, zmax} in nodes from node center.
	paramtype = "light";
	if god.idol.craft then
		minetest.register_craft {
			output = 'sorcery:idol_' .. name;
			recipe = god.idol.craft;
		};
	end
	sorcery.lib.node.reg_autopreserve('sorcery:idol_' .. name, {
		description = god.idol.desc;
		drawtype = "mesh";
		mesh = 'sorcery-idol-' .. name .. '.obj';
		paramtype = 'light';
		paramtype2 = 'facedir';
		sunlight_propagates = true;
................................................................................
		stack_max = 1;
		tiles = god.idol.tex;
		selection_box = { type = "fixed"; fixed = {hitbox}; };
		collision_box = { type = "fixed"; fixed = {hitbox}; };
		groups = { cracky = 2, sorcery_idol = 1, heavy = 1, sorcery_worship = 1};

		on_construct = function(pos)
			minetest.get_node_timer(pos):start(god_interval)
		end;

		on_timer = function(pos, elapsed)
			local altar = minetest.find_node_near(pos, 3, "sorcery:altar")
			-- TODO even without an altar, an idol with high favor could still be the source of miracles
			-- refills nearby partly empty troughs at cost to favor?
			if not altar then return true end

			local altarmeta = minetest.get_meta(altar)
			local inv = altarmeta:get_inventory()
			local idolmeta = minetest.get_meta(pos)
			local divine_favor = idolmeta:get_int('favor')
			if divine_favor > 5 then
				local ct = divine_favor / 5
				minetest.add_particlespawner {
					texture = L.image('sorcery_glitter.png'):glow(L.color(god.color)):render();
					glow = 14;
					amount = ct / (1 / god_interval), time = god_interval;
					minpos = pos:offset(-0.4, -0.5, -0.4);
					maxpos = pos:offset( 0.4,god.idol.height-0.5,0.4);
					minvel = vector.new(0, 0.05, 0);
					minvel = vector.new(0, 0.1, 0);
					minacc = vector.new(0, 0.1, 0);
					maxacc = vector.new(0, 0.2, 0);
					minexptime = 4, maxexptime = 4;
					minsize = 0.3, maxsize = 1;
					animation = {
						type = 'vertical_frames';
						length = 0.1;
						aspect_w = 16, aspect_h = 16;
					}
				}
			end
			local bestow = function(item,color)
				if type(item) == 'string' then
					item = ItemStack(item)
				end
				if color == nil then
					color = sorcery.lib.color(god.color)
				end
................................................................................
					}
				end
				inv:set_stack('item',1,item)
			end
			if inv:is_empty('item') then 
				-- nothing on the altar. decide if we're going to do a
				-- gift cycle by rolling against the god's stinginess
				if god.gifts and next(god.gifts) and math.random(god.stinginess) == 1 then
					-- we've beat the odds and started a gift cycle. now
					-- we pick a random gift and roll against its rarity
					-- to determine if the god is feeling generous
					local gift = sorcery.lib.tbl.pick(god.gifts)
					local data = god.gifts[gift]
					local value, rarity = data[1], data[2]
					if value <= divine_favor and math.random(rarity) == 1 then