feat: add defend action

Fixes #51
This commit is contained in:
Kazhnuz 2021-03-13 15:49:21 +01:00
parent 58989e974d
commit db1c3005cb
10 changed files with 40 additions and 2 deletions

View file

@ -132,6 +132,13 @@ return {
loop = 52, loop = 52,
speed = 15, speed = 15,
pauseAtEnd = true, pauseAtEnd = true,
},
["defend"] = {
startAt = 53,
endAt = 54,
loop = 54,
speed = 15,
pauseAtEnd = true,
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 50 KiB

After

Width:  |  Height:  |  Size: 43 KiB

View file

@ -132,6 +132,13 @@ return {
loop = 62, loop = 62,
speed = 15, speed = 15,
pauseAtEnd = true, pauseAtEnd = true,
},
["defend"] = {
startAt = 63,
endAt = 64,
loop = 64,
speed = 15,
pauseAtEnd = true,
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 47 KiB

After

Width:  |  Height:  |  Size: 48 KiB

View file

@ -132,6 +132,13 @@ return {
loop = 59, loop = 59,
speed = 15, speed = 15,
pauseAtEnd = true, pauseAtEnd = true,
},
["defend"] = {
startAt = 60,
endAt = 61,
loop = 61,
speed = 15,
pauseAtEnd = true,
} }
} }
} }

Binary file not shown.

Before

Width:  |  Height:  |  Size: 59 KiB

After

Width:  |  Height:  |  Size: 58 KiB

View file

@ -34,6 +34,8 @@ function Battler:new(world, x, y, z, owner)
self.isSelected = false self.isSelected = false
self.owner = owner self.owner = owner
self.isDefending = false
end end
function Battler:destroy() function Battler:destroy()

View file

@ -35,6 +35,7 @@ function Hero:revive()
if (self.isKo) then if (self.isKo) then
self:changeAnimation("idle") self:changeAnimation("idle")
self.isKo = false self.isKo = false
self.isDefending = false
end end
end end

View file

@ -19,6 +19,8 @@ function FighterParent:new(owner, isHero, id)
self.isActive = false self.isActive = false
self.isAlive = true self.isAlive = true
self.isDefending = false
self.action = nil self.action = nil
end end
@ -51,6 +53,7 @@ end
function FighterParent:revive() function FighterParent:revive()
self.isAlive = true self.isAlive = true
self.isDefending = false
self.actor:revive() self.actor:revive()
end end
@ -92,9 +95,13 @@ function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromW
end end
core.debug:print("cbs/fighter", "Taken " .. value .. " damage" ) core.debug:print("cbs/fighter", "Taken " .. value .. " damage" )
if (self.isDefending) then
self:setHP(value * -0.66, true)
else
self:setHP(value * -1, true) self:setHP(value * -1, true)
self.actor:getHurt() self.actor:getHurt()
end end
end
function FighterParent:getAbstract() function FighterParent:getAbstract()
return {} return {}
@ -119,6 +126,10 @@ end
function FighterParent:setActive() function FighterParent:setActive()
counter = 0 counter = 0
self.isActive = true self.isActive = true
if (self.isDefending) then
self.actor:changeAnimation("idle")
self.actor.isDefending = false
end
self:startAction() self:startAction()
end end

View file

@ -11,6 +11,9 @@ end
function DefendAction:startAction() function DefendAction:startAction()
core.debug:print("cbs/action", "Starting defend action") core.debug:print("cbs/action", "Starting defend action")
self.fighter.isDefending = true
self.fighter.actor:changeAnimation("defend")
self.fighter.actor.isDefending = true
self:finishAction() self:finishAction()
end end