sorcery  Diff

Differences From Artifact [c8e0c3ac03]:

To Artifact [f2cf52d41a]:

  • File runeforge.lua — part of check-in [147592b8e9] at 2020-10-26 03:58:08 on branch trunk — add over-time spellcasting abstraction to enable metamagic and in particular disjunction, add more animations and sound effects, add excavation spell, possibly some others, forget when the last commit was, edit a bunch of magitech to make it subject to the disjunction mechanism (throw up a disjunction aura and waltz right through those force fields bby, wheee), also illumination spells, tweak runeforge and rune frequence to better the balance and also limit player frustration, move some math functions into their own library category, various tweaks and bugfixes, probably other shit i don't remember (user: lexi, size: 16843) [annotate] [blame] [check-ins using]

47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
...
226
227
228
229
230
231
232
233
234
235
236
237

238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256










257

258
259
260
261
262
263
264
265
266
...
284
285
286
287
288
289
290
291

292
293
294
295
296
297
298
299
...
446
447
448
449
450
451
452

453
454
455
456

457
458
459
460
461
462
463
...
474
475
476
477
478
479
480

481
482
483
484
485
486
487
		};
		_proto = { id = name, data = rune; };
	})
end)

for name,p in pairs(constants.phial_kinds) do
	local f = string.format
	local color = sorcery.lib.color(204,38,235)
	local fac = p.grade / 6
	local id = f('phial_%s', name);
	sorcery.register_potion_tbl {
		name = id;
		label = f('%s Phial',p.name);
		desc = "A powerful liquid consumed in the operation of a rune forge. Its quality determines how fast new runes can be constructed and how much energy is required by the process.";
		color = color:brighten(1 + fac*0.5);
................................................................................
		frame = proto.frame;
		framestats = proto.frame and sorcery.data.metals[proto.frame].amulet;
		tone = sorcery.lib.color(rd.tone);
		base_spell = base_spell;
	}
end


local runeforge_update = function(pos,time)
	local m = minetest.get_meta(pos)
	local i = m:get_inventory()
	local l = sorcery.ley.netcaps(pos,time or 1)


	local pow_min = l.self.powerdraw >= l.self.minpower
	local pow_max = l.self.powerdraw >= l.self.maxpower
	local has_phial = function() return not i:is_empty('phial') end

	if time and has_phial() and pow_min then -- roll for runes
		local int, powerfac = calc_phial_props(i:get_stack('phial',1))
		local rolls = math.floor(time/int)
		local newrunes = {}
		for _=1,rolls do
			local choices = {}
			for name,rune in pairs(sorcery.data.runes) do
				print('considering',name)
				print('-- power',rune.minpower,(rune.minpower*powerfac)*time,'//',l.self.powerdraw,l.self.powerdraw/time,'free',l.freepower,'max',l.maxpower)
				if (rune.minpower*powerfac)*time <= l.self.powerdraw and math.random(rune.rarity) == 1 then
					local n = ItemStack(rune.item)
					choices[#choices + 1] = n
				end
			end










			if #choices > 0 then newrunes[#newrunes + 1] = choices[math.random(#choices)] end

			print('rune choices:',dump(choices))
			print('me',dump(l.self))
		end

		for _,r in pairs(newrunes) do
			if i:room_for_item('cache',r) and has_phial() then
				local qual = math.random(#constants.rune_grades)
				rune_set(r,{grade = qual})
				i:add_item('cache',r)
................................................................................
		list[context;phial;7.25,1.75;1,1;]
		list[context;refuse;8.50,1.75;1,1;]

		list[current_player;main;0.25,3;8,4;]

		image[0.25,0.50;1,1;sorcery_statlamp_%s.png]
	]], (10.5 - constants.rune_cache_max*1.25)/2, constants.rune_cache_max,
	    ((has_phial and pow_max) and 'green' ) or

		((has_phial and pow_min) and 'yellow') or 'off')

	local ghost = function(slot,x,y,img)
		if i:is_empty(slot) then spec = spec .. string.format([[
			image[%f,%f;1,1;%s.png]
		]], x,y,img) end
	end

................................................................................
	allow_metadata_inventory_take = function(pos,list,idx,stack,user)
		if list == 'amulet' or list == 'wrench' then return 1 end
		if list == 'phial' or list == 'refuse' then return stack:get_count() end
		return 0
	end;
	allow_metadata_inventory_move = function(pos, fl,fi, tl,ti, count, user)
		local inv = minetest.get_meta(pos):get_inventory()

		local wrench if not inv:is_empty('wrench') then
			wrench = inv:get_stack('wrench',1):get_definition()._proto
		end
		if fl == 'cache' then

			if tl == 'cache' then return 1 end
			if tl == 'active' and inv:is_empty('active') then
				print(dump(wrench))
				if wrench and wrench.powers.imbue and not inv:is_empty('amulet') then
					local amulet = inv:get_stack('amulet',1)
					local rune = inv:get_stack(fl,fi)
					local runeid = rune:get_definition()._proto.id
................................................................................
							return 1
						end
					end
				end
			end
		end
		if fl == 'active' then

			if tl == 'cache' and wrench and (wrench.powers.extract or wrench.powers.purge) then return 1 end
		end
		return 0
	end;
})

do local m = sorcery.data.metals







|







 







<




>





|






|
|

<
|


>
>
>
>
>
>
>
>
>
>
|
>
|
|







 







|
>
|







 







>




>







 







>







47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
...
226
227
228
229
230
231
232

233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252

253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
...
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
...
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
...
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
		};
		_proto = { id = name, data = rune; };
	})
end)

for name,p in pairs(constants.phial_kinds) do
	local f = string.format
	local color = sorcery.lib.color(142,232,0)
	local fac = p.grade / 6
	local id = f('phial_%s', name);
	sorcery.register_potion_tbl {
		name = id;
		label = f('%s Phial',p.name);
		desc = "A powerful liquid consumed in the operation of a rune forge. Its quality determines how fast new runes can be constructed and how much energy is required by the process.";
		color = color:brighten(1 + fac*0.5);
................................................................................
		frame = proto.frame;
		framestats = proto.frame and sorcery.data.metals[proto.frame].amulet;
		tone = sorcery.lib.color(rd.tone);
		base_spell = base_spell;
	}
end


local runeforge_update = function(pos,time)
	local m = minetest.get_meta(pos)
	local i = m:get_inventory()
	local l = sorcery.ley.netcaps(pos,time or 1)
	local probe = sorcery.spell.probe(pos)

	local pow_min = l.self.powerdraw >= l.self.minpower
	local pow_max = l.self.powerdraw >= l.self.maxpower
	local has_phial = function() return not i:is_empty('phial') end

	if time and has_phial() and pow_min and not probe.disjunction then -- roll for runes
		local int, powerfac = calc_phial_props(i:get_stack('phial',1))
		local rolls = math.floor(time/int)
		local newrunes = {}
		for _=1,rolls do
			local choices = {}
			for name,rune in pairs(sorcery.data.runes) do
				-- print('considering',name)
				-- print('-- power',rune.minpower,(rune.minpower*powerfac)*time,'//',l.self.powerdraw,l.self.powerdraw/time,'free',l.freepower,'max',l.maxpower)
				if (rune.minpower*powerfac)*time <= l.self.powerdraw and math.random(rune.rarity) == 1 then

					choices[#choices + 1] = rune
				end
			end
			if #choices > 0 then
				-- if multiple runes were rolled up, be nice to the player
				-- and pick the rarest one to give them
				local rare, choice = 0
				for i,c in pairs(choices) do
					if c.rarity > rare then
						rare = c.rarity
						choice = c
					end
				end
				newrunes[#newrunes + 1] = ItemStack(choice.item)
			end
			-- print('rune choices:',dump(choices))
			-- print('me',dump(l.self))
		end

		for _,r in pairs(newrunes) do
			if i:room_for_item('cache',r) and has_phial() then
				local qual = math.random(#constants.rune_grades)
				rune_set(r,{grade = qual})
				i:add_item('cache',r)
................................................................................
		list[context;phial;7.25,1.75;1,1;]
		list[context;refuse;8.50,1.75;1,1;]

		list[current_player;main;0.25,3;8,4;]

		image[0.25,0.50;1,1;sorcery_statlamp_%s.png]
	]], (10.5 - constants.rune_cache_max*1.25)/2, constants.rune_cache_max,
		((not (has_phial and pow_min)) and 'off'  ) or
		( probe.disjunction            and 'blue' ) or
	    ((has_phial and pow_max)       and 'green') or 'yellow')

	local ghost = function(slot,x,y,img)
		if i:is_empty(slot) then spec = spec .. string.format([[
			image[%f,%f;1,1;%s.png]
		]], x,y,img) end
	end

................................................................................
	allow_metadata_inventory_take = function(pos,list,idx,stack,user)
		if list == 'amulet' or list == 'wrench' then return 1 end
		if list == 'phial' or list == 'refuse' then return stack:get_count() end
		return 0
	end;
	allow_metadata_inventory_move = function(pos, fl,fi, tl,ti, count, user)
		local inv = minetest.get_meta(pos):get_inventory()
		local probe = sorcery.spell.probe(pos)
		local wrench if not inv:is_empty('wrench') then
			wrench = inv:get_stack('wrench',1):get_definition()._proto
		end
		if fl == 'cache' then
			if probe.disjunction then return 0 end
			if tl == 'cache' then return 1 end
			if tl == 'active' and inv:is_empty('active') then
				print(dump(wrench))
				if wrench and wrench.powers.imbue and not inv:is_empty('amulet') then
					local amulet = inv:get_stack('amulet',1)
					local rune = inv:get_stack(fl,fi)
					local runeid = rune:get_definition()._proto.id
................................................................................
							return 1
						end
					end
				end
			end
		end
		if fl == 'active' then
			if probe.disjunction then return 0 end
			if tl == 'cache' and wrench and (wrench.powers.extract or wrench.powers.purge) then return 1 end
		end
		return 0
	end;
})

do local m = sorcery.data.metals