From e02c221e3116bf84a30e6eaa0a91a13def644712 Mon Sep 17 00:00:00 2001 From: PeaAshMeter Date: Fri, 30 Jan 2026 00:55:08 +0300 Subject: [PATCH] make all 3 demo spells work with tasks --- lib/spellbook.lua | 43 +++++++++++-------------------------------- 1 file changed, 11 insertions(+), 32 deletions(-) diff --git a/lib/spellbook.lua b/lib/spellbook.lua index 34af175..8be53ac 100644 --- a/lib/spellbook.lua +++ b/lib/spellbook.lua @@ -22,7 +22,7 @@ function spell:update(caster, dt) end function spell:draw() end -function spell:cast(caster, target) return true end +function spell:cast(caster, target) return end local walk = setmetatable({ --- @type Deque @@ -55,32 +55,9 @@ function walk:cast(caster, target) return end - local testChar = Tree.level.characters[1]; - - - return function(callback) -- <- вызовется после всех анимаций - local counter = require 'lib.utils.counter' (callback) - counter.push() + return function(callback) return caster:has(Tree.behaviors.tiled):followPath(path)( - function() - do - counter.push() - local initialPos2 = caster:has(Tree.behaviors.positioned).position:floor() - local path2 = require "lib.pathfinder" (initialPos2, Vec3 { 10, math.random(1, 10) }) - path:pop_front() - caster:has(Tree.behaviors.tiled):followPath(path2)(counter.pop) - end - - do - counter.push() - local testInitialPos = testChar:has(Tree.behaviors.positioned).position:floor() - local testPath = require "lib.pathfinder" (testInitialPos, Vec3 { 10, math.random(20, 5) }) - path:pop_front() - testChar:has(Tree.behaviors.tiled):followPath(testPath)(counter.pop) - end - - counter.pop() - end + callback ) -- <- callback вызовется после followPath end end @@ -114,9 +91,10 @@ function regenerateMana:cast(caster, target) stats.mana = 10 stats.initiative = stats.initiative + 10 end) - print(caster.id, "has regenerated mana and gained initiative") + local sprite = caster:has(Tree.behaviors.sprite) if not sprite then return nil end + print(caster.id, "has regenerated mana and gained initiative") local light = require "lib/character/character".spawn("Light Effect") light:addBehavior { @@ -126,11 +104,12 @@ function regenerateMana:cast(caster, target) } return function(callback) - print(light:has(Tree.behaviors.light).animateColor) - light:has(Tree.behaviors.light):animateColor(Vec3 {})(function() - light:die() - callback() - end) + light:has(Tree.behaviors.light):animateColor(Vec3 {})( + function() + light:die() + end + ) + sprite:animate("hurt")(callback) end end