sorcery  Diff

Differences From Artifact [807df7a655]:

  • File data/spells.lua — part of check-in [ea6e475e44] at 2020-10-19 09:52:11 on branch trunk — continue dev on celestial mechanics, add melding+division spells (resonance), refine itemclasses, add keypunch and punchcards, add paper pulp, add a shitload of visuals, add convenience scripts for working with the wiki, make the flamebolt spell actually useful instead of just a pretty lightshow, add essences, inferno crystal, and other goodies; iterate on wands, lots of shit i can't remember, various bugfixes (user: lexi, size: 25710) [annotate] [blame] [check-ins using]

To Artifact [bdb226347b]:


    15     15   	sorcery.vfx.cast_sparkle(ctx.caster,color,strength,duration)
    16     16   end
    17     17   
    18     18   local enchantment_sparkle = function(ctx,color)
    19     19   	sorcery.vfx.enchantment_sparkle(ctx.target,color)
    20     20   end
    21     21   
           22  +local tblroll = function(bonus,tbl) --> string
           23  +	local r = {}
           24  +	for _,v in ipairs(tbl) do
           25  +		local chance = math.max(1,v.value - bonus)
           26  +		if math.random(chance) == 1 then r[#r+1] = v.item end
           27  +	end
           28  +	return r[math.random(#r)]
           29  +end
    22     30   local anchorwand = function(aff,uses,recipe)
    23     31   	local affcolor = sorcery.lib.color(sorcery.data.affinities[aff].color)
    24     32   	return {
    25     33   		name = aff .. ' anchor';
    26     34   		desc = 'With an enchanter, anchor ' .. aff .. ' spells into an object to enable it to produce preternatural effects';
    27     35   		uses = uses;
    28     36   		affinity = recipe;
................................................................................
    53     61   			   or #eligible_spells == 0
    54     62   			   or  material == nil
    55     63   			   or  material.data.slots == nil
    56     64   			   or #material.data.slots == 0
    57     65   				   then return false end
    58     66   
    59     67   			-- determine the properties the enchantment will have
    60         -			local power = 10
           68  +			local pbonus = ctx.stats.power or 1
           69  +			local power = math.floor(10 + (pbonus*5 - 5))
    61     70   			local energy = material.data.maxenergy
    62         -			local reliability = 100
    63         -			if ctx.base.gem == 'sapphire' then power = power + 5
    64         -			elseif ctx.base.gem == 'amethyst' then
           71  +			local reliability = math.floor(100 * (ctx.stats.reliability or 1))
           72  +			if ctx.base.gem == 'amethyst' then
    65     73   				energy = energy * (math.random() * 0.7)
    66     74   			elseif ctx.base.gem == 'diamond' then
    67     75   				if math.random(5) == 1 then
    68     76   					power = power * 2
    69     77   					reliability = reliability - (reliability / 4)
    70     78   				else
    71     79   					power = power + 5
................................................................................
   170    178   		color = {255,89,16};
   171    179   		uses = 32;
   172    180   		affinity = {'acacia','blazing'};
   173    181   		leytype = 'praxic';
   174    182   		desc = 'Conjure a gout of fire to scorch your foes with a flick of this wand';
   175    183   		cast = function(ctx)
   176    184   			local speed = 30 -- TODO maybe amethyst tip increases speed?
   177         -			local radius 
   178         -			if ctx.base.gem == 'sapphire'
   179         -				then radius = math.random(2,3)
   180         -				else radius = math.random(1,2)
   181         -			end
          185  +			local radius = math.random(math.max(1,math.floor((ctx.stats.power or 1) - 0.5)), math.ceil((ctx.stats.power or 1)+0.5))
          186  +			print('!! radius',radius)
   182    187   			local heading = ctx.heading
   183    188   			heading.pos.y = heading.pos.y + heading.eyeheight*0.9
   184         -			local bolt = minetest.add_entity(heading.pos,'sorcery:spell_projectile_flamebolt')
          189  +			local vel = vector.multiply(heading.yaw,speed)
          190  +			local bolt = minetest.add_entity(vector.add(heading.pos,vector.multiply(heading.yaw,2.5)),'sorcery:spell_projectile_flamebolt')
   185    191   			bolt:set_rotation(heading.yaw)
   186         -			local vel = {
   187         -				x = heading.yaw.x * speed;
   188         -				y = heading.yaw.y * speed;
   189         -				z = heading.yaw.z * speed;
   190         -			};
   191    192   			bolt:get_luaentity()._blastradius = radius
   192    193   			bolt:set_velocity(vel)
   193    194   		end;
   194    195   	};
   195    196   	seal = {
   196    197   		name = 'sealing';
   197    198   		color = {255,238,16};
................................................................................
   405    406   						end
   406    407   					else
   407    408   						e:set_stack('foci',t.slot,ItemStack(t.replacement))
   408    409   					end
   409    410   				end
   410    411   				
   411    412   				local res
          413  +				local bonus = math.floor(ctx.stats.power or 1) 
   412    414   				if type(m.results) == 'function' then
   413    415   					res = m.results(ctx)
   414    416   				elseif type(m.results) == 'table' and m.results[1] then -- haaaack
   415         -					res = select(2,sorcery.lib.tbl.pick(m.results))
          417  +					res = tblroll(bonus,m.results)
   416    418   				else
   417    419   					res = m.results
   418    420   				end
   419    421   
   420    422   				e:set_stack('item',1,ItemStack(res))
   421    423   				enchantment_sparkle(ctx,sorcery.lib.color(228,4,201))
   422    424   			::next_meld::end
................................................................................
   447    449   			end
   448    450   			
   449    451   			if div.restrict and not div.restrict(ctx) then
   450    452   				return false
   451    453   			end
   452    454   
   453    455   			local dst
          456  +			local bonus = math.floor(ctx.stats.power or 1) 
   454    457   			if div.mode == 'any' then
   455    458   				local lst = sorcery.lib.tbl.cshuf(div.give)
   456    459   				dst = function(i) return lst[i] end
   457    460   			elseif div.mode == 'random' then
   458         -				dst = function() return sorcery.lib.tbl.pick(div.give) end
          461  +				dst = function() return tblroll(bonus,div.give) end
   459    462   			elseif div.mode == 'set' then
   460    463   				dst = function(i) return div.give[i] end
   461    464   			elseif div.mode == 'all' then
   462    465   				dst = function() return div.give end
   463    466   			elseif div.mode == 'fn' then
   464    467   				dst = function(i) return div.give(i,ctx) end
   465    468   			else return bitch('invalid division mode') end
................................................................................
   677    680   		uses = 40;
   678    681   		color = {244,255,157};
   679    682   		affinity = {'acacia','shimmering','blazing'};
   680    683   		leytype = 'cognic';
   681    684   		cast = function(ctx)
   682    685   			local center = ctx.heading.pos
   683    686   			local maxpower = 20
   684         -			local power = (ctx.base.gem == 'sapphire' and maxpower) or maxpower/2
          687  +			local power = math.min(maxpower,(maxpower/2) + ((ctx.stats.power or 1)*(maxpower/2) - (maxpower/2)))
          688  +			-- (ctx.base.gem == 'sapphire' and maxpower) or maxpower/2
   685    689   			local range = (ctx.base.gem == 'emerald' and 6) or 3
   686    690   			local duration = (ctx.base.gem == 'amethyst' and 60) or 30
   687    691   			if ctx.base.gem == 'diamond' then
   688    692   				power = power * (math.random()*2)
   689    693   				range = range * (math.random()*2)
   690    694   				duration = duration * (math.random()*2)
   691    695   			end