@@ -18,8 +18,16 @@ local enchantment_sparkle = function(ctx,color) sorcery.vfx.enchantment_sparkle(ctx.target,color) end +local tblroll = function(bonus,tbl) --> string + local r = {} + for _,v in ipairs(tbl) do + local chance = math.max(1,v.value - bonus) + if math.random(chance) == 1 then r[#r+1] = v.item end + end + return r[math.random(#r)] +end local anchorwand = function(aff,uses,recipe) local affcolor = sorcery.lib.color(sorcery.data.affinities[aff].color) return { name = aff .. ' anchor'; @@ -56,13 +64,13 @@ or #material.data.slots == 0 then return false end -- determine the properties the enchantment will have - local power = 10 + local pbonus = ctx.stats.power or 1 + local power = math.floor(10 + (pbonus*5 - 5)) local energy = material.data.maxenergy - local reliability = 100 - if ctx.base.gem == 'sapphire' then power = power + 5 - elseif ctx.base.gem == 'amethyst' then + local reliability = math.floor(100 * (ctx.stats.reliability or 1)) + if ctx.base.gem == 'amethyst' then energy = energy * (math.random() * 0.7) elseif ctx.base.gem == 'diamond' then if math.random(5) == 1 then power = power * 2 @@ -173,22 +181,15 @@ leytype = 'praxic'; desc = 'Conjure a gout of fire to scorch your foes with a flick of this wand'; cast = function(ctx) local speed = 30 -- TODO maybe amethyst tip increases speed? - local radius - if ctx.base.gem == 'sapphire' - then radius = math.random(2,3) - else radius = math.random(1,2) - end + 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)) + print('!! radius',radius) local heading = ctx.heading heading.pos.y = heading.pos.y + heading.eyeheight*0.9 - local bolt = minetest.add_entity(heading.pos,'sorcery:spell_projectile_flamebolt') + local vel = vector.multiply(heading.yaw,speed) + local bolt = minetest.add_entity(vector.add(heading.pos,vector.multiply(heading.yaw,2.5)),'sorcery:spell_projectile_flamebolt') bolt:set_rotation(heading.yaw) - local vel = { - x = heading.yaw.x * speed; - y = heading.yaw.y * speed; - z = heading.yaw.z * speed; - }; bolt:get_luaentity()._blastradius = radius bolt:set_velocity(vel) end; }; @@ -408,12 +409,13 @@ end end local res + local bonus = math.floor(ctx.stats.power or 1) if type(m.results) == 'function' then res = m.results(ctx) elseif type(m.results) == 'table' and m.results[1] then -- haaaack - res = select(2,sorcery.lib.tbl.pick(m.results)) + res = tblroll(bonus,m.results) else res = m.results end @@ -450,13 +452,14 @@ return false end local dst + local bonus = math.floor(ctx.stats.power or 1) if div.mode == 'any' then local lst = sorcery.lib.tbl.cshuf(div.give) dst = function(i) return lst[i] end elseif div.mode == 'random' then - dst = function() return sorcery.lib.tbl.pick(div.give) end + dst = function() return tblroll(bonus,div.give) end elseif div.mode == 'set' then dst = function(i) return div.give[i] end elseif div.mode == 'all' then dst = function() return div.give end @@ -680,9 +683,10 @@ leytype = 'cognic'; cast = function(ctx) local center = ctx.heading.pos local maxpower = 20 - local power = (ctx.base.gem == 'sapphire' and maxpower) or maxpower/2 + local power = math.min(maxpower,(maxpower/2) + ((ctx.stats.power or 1)*(maxpower/2) - (maxpower/2))) + -- (ctx.base.gem == 'sapphire' and maxpower) or maxpower/2 local range = (ctx.base.gem == 'emerald' and 6) or 3 local duration = (ctx.base.gem == 'amethyst' and 60) or 30 if ctx.base.gem == 'diamond' then power = power * (math.random()*2)