Differences From
Artifact [5ad2e81269]:
- File
enchanter.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: 16338)
[annotate]
[blame]
[check-ins using]
170 170 end
171 171 sorcery.enchant.strength = function(stack,id)
172 172 -- this functions should be used whenever you need to
173 173 -- determine the power of a particular enchantment on
174 174 -- an enchanted item.
175 175 local e = sorcery.enchant.get(stack)
176 176 local p = 0.0
177 + local ct = 0
177 178 local slots = sorcery.matreg.lookup[stack:get_name()].data.slots
178 179 -- TODO handle strength-boosting spells!
179 180 for _,s in pairs(e.spells) do
180 - if s.id == id then p = p + ((s.boost * slots[s.slot].confluence)/10) end
181 + if s.id == id then
182 + p = p + ((s.boost * slots[s.slot].confluence)/10)
183 + ct = ct + 1
184 + end
181 185 end
182 - return p
186 + return p, ct
183 187 end
184 188 sorcery.enchant.stackup = function(stack)
185 189 -- stack update function. this should be called whenever
186 190 -- the enchantment status of a stack changes; it will
187 191 -- alter/reset tool capabilities and tooltip as necessary
188 192 local e = sorcery.enchant.get(stack)
189 193 local meta = stack:get_meta()
................................................................................
423 427 local material = sorcery.enchant.getsubj(tool)
424 428 local totalcost = 0
425 429 do local done = {} for _,sp in pairs(ench.spells) do
426 430 if done[sp.id] then goto skip end
427 431 done[sp.id] = true
428 432
429 433 local data = sorcery.data.enchants[sp.id]
430 - local strength = sorcery.enchant.strength(tool,sp.id)
434 + local strength, nsp = sorcery.enchant.strength(tool,sp.id)
431 435 local ch = math.random(1,100)
432 436 local props = {
433 437 fail = ch > sp.reliability;
434 438 user = puncher;
435 439 pos = pos;
436 440 node = node;
437 441 tool = tool;
................................................................................
439 443 enchantment = ench;
440 444 power = strength;
441 445 spell = sp;
442 446 sparks = sparks;
443 447 cost = data.cost;
444 448 }
445 449 if data.on_dig then data.on_dig(props) end
446 - if props.cost ~= 0 then totalcost = totalcost + math.max(1,math.floor(props.cost * strength)) end
450 + if props.cost ~= 0 then totalcost = totalcost + math.max(1,props.cost * nsp) --[[math.max(1,math.floor(props.cost * strength))]] end
451 + -- strength does not increase cost but number of spell slots occupied does -- incentive for the player to be more clever, less brute-force-y
447 452
448 453 if ch > sp.reliability then goto skip end
449 454 sparks[#sparks + 1] = {
450 455 color = sorcery.lib.color(data.tone):brighten(1.1);
451 - count = strength * 7;
456 + count = strength * 8;
452 457 }
453 458 ::skip::end end
454 459 if totalcost > 0 then
455 460 local conservation = math.floor(sorcery.enchant.strength(tool,'conserve') * 6)
456 461 -- totalcost = totalcost - (totalcost * conservation)
457 462 if conservation == 0 or math.random(conservation) == 1 then
458 463 ench.energy = math.max(0,ench.energy - (totalcost - (material.data.energysource or 0)))
................................................................................
483 488 };
484 489 velocity = {
485 490 x = range(-1.3,1.3);
486 491 z = range(-1.3,1.3);
487 492 y = range( 0.3,0.9);
488 493 };
489 494 expirationtime = life;
490 - size = range(0.5,1.5);
495 + size = range(0.2,1.5);
491 496 texture = sorcery.lib.image('sorcery_spark.png'):multiply(s.color):render();
492 497 glow = 14;
493 498 animation = {
494 499 type = "vertical_frames";
495 500 aspect_w = 16;
496 501 aspect_h = 16;
497 502 length = life + 0.1;