@@ -4,9 +4,9 @@ -- i think amulets are a little overpowered for something that just -- passively consumes ley-current local constants = { - rune_mine_interval = 250; + rune_mine_interval = 240; -- how often a powered forge rolls for new runes rune_cache_max = 4; -- how many runes a runeforge can hold at a time @@ -26,9 +26,9 @@ supreme = {grade = 6; name = 'Supreme'; infusion = 'sorcery:essence_force'}; }; } local calc_phial_props = function(phial) --> mine interval: float, time factor: float - local g = phial:get_definition()._proto.grade + local g = phial:get_definition()._proto.data.grade local i = constants.rune_mine_interval local fac = (g-1) / 5 return i - ((i*0.5) * fac), 0.5 * fac end @@ -50,15 +50,15 @@ end) for name,p in pairs(constants.phial_kinds) do local f = string.format - local color = sorcery.lib.color(255,27,188) + 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."; + 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); imgvariant = (fac >= 5) and 'sparkle' or 'dull'; glow = 5+p.grade; extra = { @@ -68,9 +68,9 @@ } sorcery.register.infusions.link { infuse = p.infusion; into = 'sorcery:potion_subtle'; - output = id; + output = 'sorcery:'..id; } end local register_rune_wrench = function(w) @@ -92,9 +92,9 @@ output = w.name; recipe = { {'', mp.fragment,''}; {'', mp.ingot, mp.fragment}; - {'sorcery:vidrium_fragment','', ''}; + {'sorcery:fragment_vidrium','', ''}; }; } end @@ -135,10 +135,14 @@ m:set_string('amulet_rune', rp.id) m:set_int('amulet_rune_grade', rg) local spell = sorcery.amulet.getspell(stack) if not spell then return nil end - - local name = string.format('Amulet of %s %s', constants.amulet_grades[rg], spell.name) + local name + if spell.minrune then -- indicating quality makes less sense if it's restricted + name = string.format('Amulet of %s', spell.name) + else + name = string.format('Amulet of %s %s', constants.amulet_grades[rg], spell.name) + end m:set_string('description', sorcery.lib.ui.tooltip { title = name; color = spell.tone; desc = spell.desc; @@ -199,9 +203,9 @@ local rg = m:get_string('amulet_rune_grade') local rd = sorcery.data.runes[rune] local spell = rd.amulets[proto.base] if not spell then return nil end - local title,desc,cast,apply,remove = spell.name, spell.desc, spell.cast, spell.apply, spell.remove -- FIXME in serious need of refactoring + local title,desc,cast,apply,remove,mingrade = spell.name, spell.desc, spell.cast, spell.apply, spell.remove, spell.mingrade -- FIXME in serious need of refactoring local base_spell = true if proto.frame and spell.frame and spell.frame[proto.frame] then local sp = spell.frame[proto.frame] @@ -209,15 +213,15 @@ desc = sp.desc or desc cast = sp.desc or cast apply = sp.apply or apply remove = sp.remove or remove + mingrade = sp.mingrade or remove base_spell = false end return { - rune = rune; - grade = rg; - spell = spell; + rune = rune, grade = rg; + spell = spell, mingrade = mingrade; name = title, desc = desc; cast = cast, apply = apply, remove = remove; frame = proto.frame; framestats = proto.frame and sorcery.data.metals[proto.frame].amulet; @@ -236,19 +240,24 @@ 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 rolls = math.floor(time/calc_phial_props(i:get_stack('phial',1))) + 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 - if rune.minpower*time <= l.self.powerdraw and math.random(rune.rarity) == 1 then + 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 @@ -445,15 +454,26 @@ wrench = inv:get_stack('wrench',1):get_definition()._proto end if fl == 'cache' then if tl == 'cache' then return 1 end - if tl == 'active' then + 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) - if sorcery.data.runes[rune:get_definition()._proto.id].amulets[amulet:get_definition()._sorcery.amulet.base] then - return 1 + local runeid = rune:get_definition()._proto.id + local runegrade = rune:get_meta():get_int('rune_grade') + if sorcery.data.runes[runeid].amulets[amulet:get_definition()._sorcery.amulet.base] then + local spell do -- haaaack + local i=ItemStack(amulet:get_name()) + local im = i:get_meta() + im:set_string('amulet_rune',runeid) + im:set_int('amulet_rune_grade',runegrade) + spell = sorcery.amulet.getspell(i) + end + if not spell.mingrade or runegrade >= spell.mingrade then + return 1 + end end end end end