local Parent = require("scenes.battlesystem.actors.parent") local Battler = Parent:extend() function Battler:new(world, x, y, z) Battler.super.new(self, world, x, y, z) self.isBattler = true self.speed = 3 self.isActive = false self.debugActiveTimer = 0 end function Battler:setActive() core.debug:print("cbs/actor","actor " .. self.id .. " is active") self.isActive = true self.debugActiveTimer = 0 end function Battler:update(dt) if (self.isActive) then self.debugActiveTimer = self.debugActiveTimer + dt core.debug:print("cbs/battler", "debug timer is " .. math.floor(self.debugActiveTimer*100) .. " for battler " .. self.id) if self.debugActiveTimer >= 0.5 then core.debug:print("cbs/battler", "counter ended, switching active battler") self.world:switchActiveBattler() self.isActive = false end end end function Battler:validateAction() end function Battler:sendDamage(x, y, value, accuracy, isSpecial, isAerial) local stats = self:getStats() local value = value / 10 if (isSpecial) then value = value * stats.power else value = value * stats.attack end core.debug:print("battler", "sending " .. value .." damage at position <" .. x .. ";" .. y .. ">") local fromEnnemy = self.isEnnemy local other = self.world:getActorInCase(x, y) if (other ~= nil) then core.debug:print("battler", "sending damage to actor at position <" .. x .. ";" .. y .. ">") other:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho) end end function Battler:receiveDamage(value, accuracy, isSpecial, isAerial) local stats = self:getStats() if (fromEnnemy ~= self.isEnnemy) then if (isSpecial) then value = value / stats.mind else value = value / stats.defense end core.debug:print("battler", "taken " .. value .. " damage" ) self:setHP(value * -1, true) end end return Battler