-- Heal: restore health in small area around caster local BaseSkill = require("skills.base") local Skill = {} Skill.__index = Skill setmetatable(Skill, { __index = BaseSkill }) function Skill:new(asset, combatant) self = setmetatable(BaseSkill:new(asset, combatant), Skill) self.duration = 1.0 self.range = asset.config.range or 32.0 ParticlePlayer:play("cast_spell", self.combatant.x + (self.combatant.width / 2), self.combatant.y + (self.combatant.height / 2), { duration = self.duration }) self.startPos = { self.combatant.x, self.combatant.y } Sound.play("casting") return self end function Skill:update(dt) self.timer = self.timer + dt self.combatant.velX = self.combatant.velX / 5 self.combatant.skillAnimation = "skill" if math.abs(self.combatant.x - self.startPos[1]) > 2 or math.abs(self.combatant.y - self.startPos[2]) > 2 then return true end if self.timer >= self.duration then Sound.play("potion") self:applyHeal() return true end return false end function Skill:draw() end function Skill:applyHeal() local allies = self:getAllies() local targets = self:getCombatantsInRange(allies, self.range) local healPotency = (self.combatant.stats.mag or 1) * (self.power or 1) for _, target in ipairs(targets) do local healAmount = math.min(healPotency, target.maxHealth - target.health) target:heal(healAmount) end end return Skill