-- Ground slam: heavy AoE attack around the combatant 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 = 0.7 self.damageDealt = false self.range = 80 self.multiplier = 2.5 combatant.skillAnimation = "skill" return self end function Skill:update(dt) self.timer = self.timer + dt if not self.damageDealt and self.timer >= 0.3 then self.damageDealt = true local ex = self.combatant.x + self.combatant.width / 2 local ey = self.combatant.y + self.combatant.height / 2 local opponents = self:getOpponents() for _, target in ipairs(opponents) do local tx = target.x + target.width / 2 local ty = target.y + target.height / 2 local dist = math.sqrt((tx - ex) ^ 2 + (ty - ey) ^ 2) if dist <= self.range then local damage = self:calcDamage(self.combatant, target) if damage > 0 then target:damage(damage) local dir = (tx - ex) > 0 and 1 or -1 target:knockback(dir, 250) end end end end if self.timer >= self.duration then self.finished = true self.combatant.skillAnimation = nil return true end return false end function Skill:calcDamage(source, target) return BaseSkill.calcDamage(self, source, target) end function Skill:draw() local alpha = 1 - (self.timer / self.duration) local ex = self.combatant.x + self.combatant.width / 2 local ey = self.combatant.y + self.combatant.height / 2 love.graphics.setColor(0.6, 0.4, 0.2, alpha * 0.5) love.graphics.circle("fill", ex, ey, self.range * (self.timer / 0.3 > 1 and 1 or self.timer / 0.3)) love.graphics.setColor(1, 1, 1, 1) end return Skill