-- Whirlwind: spinning attack hitting all nearby opponents 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.5 self.damageDealt = false self.range = 64 self.angle = 0 self.multiplier = 1.5 combatant.skillAnimation = "skill" Sound.play("whirlwind") return self end function Skill:update(dt) self.timer = self.timer + dt self.angle = self.angle + dt * 8 self.combatant.moveX = 0 if not self.damageDealt and self.timer >= 0.15 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) target:damage(damage) local dir = (tx - ex) > 0 and 1 or -1 target:knockback(dir, 200) end end end self:updateWeaponSprite(dt) if self.timer >= self.duration then self.finished = true self.combatant.skillAnimation = nil return true end return false 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.8, 0.8, 1, alpha * 0.4) love.graphics.arc("fill", ex, ey, self.range, self.angle, self.angle + 4) love.graphics.setColor(1, 1, 1, 1) self:drawWeaponSpriteAnimation(ex, ey, { scale = { self.combatant.facing, 1 }, angle = self.timer * 15, origin = { -self.combatant.width / 2 + (self.config.weaponSpriteOffsetX or 0), self.config.weaponSpriteOffsetY or 0 } }) end return Skill