-- Shoot: fires a projectile from 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.15 self.shootTimer = 0.1 combatant.skillAnimation = "skill" self:createProjectile() return self end function Skill:createProjectile() local ex = self.combatant.x + self.combatant.width / 2 local ey = self.combatant.y + self.combatant.height / 2 local speed = 300 local power = self.power local weaponSprite = self:getWeaponSprite() if weaponSprite then local config = Utils.mergeTables({}, weaponSprite.config) config.animations = { default = { 2 } } local sprite = Sprite:new(weaponSprite.image, config) sprite:setAnimation("default") table.insert(self.context.projectiles or {}, Projectile:new(sprite, self.combatant, { x = ex + (self.combatant.facing * 8), y = ey - (Config.WEAPON_SPRITE_SIZE[2] / 2), dirX = self.combatant.facing, speed = speed, power = power })) Sound.play("shoot") --ParticlePlayer:play("sparkle", ex + self.combatant.facing * 12, ey, { duration = 0.3 }) end end function Skill:update(dt) self.timer = self.timer + dt self.combatant.moveX = 0 self:updateWeaponSprite(dt) if self.timer >= self.duration then 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) love.graphics.setColor(0.9, 0.9, 0.3, alpha) local ex = self.combatant.x + self.combatant.width / 2 local ey = self.combatant.y + self.combatant.height / 2 love.graphics.circle("fill", ex + self.combatant.facing * 12, ey, 4 * alpha) love.graphics.setColor(1, 1, 1, 1) local weapon = self:getWeapon() local wX = self.combatant.x + (self.combatant.facing * (weapon.config.offset and weapon.config.offset[1] or 0)) local wY = self.combatant.y + self.combatant.visualOffsetY + (weapon.config.offset and weapon.config.offset[2] or 0) if self.combatant.facing == -1 then wX = wX + self.combatant.width end self:drawWeaponSpriteAnimation(wX, wY, { scale = { self.combatant.facing, 1 } }) end return Skill