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     47   		};
    48     48   		_proto = { id = name, data = rune; };
    49     49   	})
    50     50   end)
    51     51   
    52     52   for name,p in pairs(constants.phial_kinds) do
    53     53   	local f = string.format
    54         -	local color = sorcery.lib.color(204,38,235)
           54  +	local color = sorcery.lib.color(142,232,0)
    55     55   	local fac = p.grade / 6
    56     56   	local id = f('phial_%s', name);
    57     57   	sorcery.register_potion_tbl {
    58     58   		name = id;
    59     59   		label = f('%s Phial',p.name);
    60     60   		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.";
    61     61   		color = color:brighten(1 + fac*0.5);
................................................................................
   226    226   		frame = proto.frame;
   227    227   		framestats = proto.frame and sorcery.data.metals[proto.frame].amulet;
   228    228   		tone = sorcery.lib.color(rd.tone);
   229    229   		base_spell = base_spell;
   230    230   	}
   231    231   end
   232    232   
   233         -
   234    233   local runeforge_update = function(pos,time)
   235    234   	local m = minetest.get_meta(pos)
   236    235   	local i = m:get_inventory()
   237    236   	local l = sorcery.ley.netcaps(pos,time or 1)
          237  +	local probe = sorcery.spell.probe(pos)
   238    238   
   239    239   	local pow_min = l.self.powerdraw >= l.self.minpower
   240    240   	local pow_max = l.self.powerdraw >= l.self.maxpower
   241    241   	local has_phial = function() return not i:is_empty('phial') end
   242    242   
   243         -	if time and has_phial() and pow_min then -- roll for runes
          243  +	if time and has_phial() and pow_min and not probe.disjunction then -- roll for runes
   244    244   		local int, powerfac = calc_phial_props(i:get_stack('phial',1))
   245    245   		local rolls = math.floor(time/int)
   246    246   		local newrunes = {}
   247    247   		for _=1,rolls do
   248    248   			local choices = {}
   249    249   			for name,rune in pairs(sorcery.data.runes) do
   250         -				print('considering',name)
   251         -				print('-- power',rune.minpower,(rune.minpower*powerfac)*time,'//',l.self.powerdraw,l.self.powerdraw/time,'free',l.freepower,'max',l.maxpower)
          250  +				-- print('considering',name)
          251  +				-- print('-- power',rune.minpower,(rune.minpower*powerfac)*time,'//',l.self.powerdraw,l.self.powerdraw/time,'free',l.freepower,'max',l.maxpower)
   252    252   				if (rune.minpower*powerfac)*time <= l.self.powerdraw and math.random(rune.rarity) == 1 then
   253         -					local n = ItemStack(rune.item)
   254         -					choices[#choices + 1] = n
          253  +					choices[#choices + 1] = rune
          254  +				end
          255  +			end
          256  +			if #choices > 0 then
          257  +				-- if multiple runes were rolled up, be nice to the player
          258  +				-- and pick the rarest one to give them
          259  +				local rare, choice = 0
          260  +				for i,c in pairs(choices) do
          261  +					if c.rarity > rare then
          262  +						rare = c.rarity
          263  +						choice = c
          264  +					end
   255    265   				end
          266  +				newrunes[#newrunes + 1] = ItemStack(choice.item)
   256    267   			end
   257         -			if #choices > 0 then newrunes[#newrunes + 1] = choices[math.random(#choices)] end
   258         -			print('rune choices:',dump(choices))
   259         -			print('me',dump(l.self))
          268  +			-- print('rune choices:',dump(choices))
          269  +			-- print('me',dump(l.self))
   260    270   		end
   261    271   
   262    272   		for _,r in pairs(newrunes) do
   263    273   			if i:room_for_item('cache',r) and has_phial() then
   264    274   				local qual = math.random(#constants.rune_grades)
   265    275   				rune_set(r,{grade = qual})
   266    276   				i:add_item('cache',r)
................................................................................
   284    294   		list[context;phial;7.25,1.75;1,1;]
   285    295   		list[context;refuse;8.50,1.75;1,1;]
   286    296   
   287    297   		list[current_player;main;0.25,3;8,4;]
   288    298   
   289    299   		image[0.25,0.50;1,1;sorcery_statlamp_%s.png]
   290    300   	]], (10.5 - constants.rune_cache_max*1.25)/2, constants.rune_cache_max,
   291         -	    ((has_phial and pow_max) and 'green' ) or
   292         -		((has_phial and pow_min) and 'yellow') or 'off')
          301  +		((not (has_phial and pow_min)) and 'off'  ) or
          302  +		( probe.disjunction            and 'blue' ) or
          303  +	    ((has_phial and pow_max)       and 'green') or 'yellow')
   293    304   
   294    305   	local ghost = function(slot,x,y,img)
   295    306   		if i:is_empty(slot) then spec = spec .. string.format([[
   296    307   			image[%f,%f;1,1;%s.png]
   297    308   		]], x,y,img) end
   298    309   	end
   299    310   
................................................................................
   446    457   	allow_metadata_inventory_take = function(pos,list,idx,stack,user)
   447    458   		if list == 'amulet' or list == 'wrench' then return 1 end
   448    459   		if list == 'phial' or list == 'refuse' then return stack:get_count() end
   449    460   		return 0
   450    461   	end;
   451    462   	allow_metadata_inventory_move = function(pos, fl,fi, tl,ti, count, user)
   452    463   		local inv = minetest.get_meta(pos):get_inventory()
          464  +		local probe = sorcery.spell.probe(pos)
   453    465   		local wrench if not inv:is_empty('wrench') then
   454    466   			wrench = inv:get_stack('wrench',1):get_definition()._proto
   455    467   		end
   456    468   		if fl == 'cache' then
          469  +			if probe.disjunction then return 0 end
   457    470   			if tl == 'cache' then return 1 end
   458    471   			if tl == 'active' and inv:is_empty('active') then
   459    472   				print(dump(wrench))
   460    473   				if wrench and wrench.powers.imbue and not inv:is_empty('amulet') then
   461    474   					local amulet = inv:get_stack('amulet',1)
   462    475   					local rune = inv:get_stack(fl,fi)
   463    476   					local runeid = rune:get_definition()._proto.id
................................................................................
   474    487   							return 1
   475    488   						end
   476    489   					end
   477    490   				end
   478    491   			end
   479    492   		end
   480    493   		if fl == 'active' then
          494  +			if probe.disjunction then return 0 end
   481    495   			if tl == 'cache' and wrench and (wrench.powers.extract or wrench.powers.purge) then return 1 end
   482    496   		end
   483    497   		return 0
   484    498   	end;
   485    499   })
   486    500   
   487    501   do local m = sorcery.data.metals