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,
speed = 15,
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,
speed = 15,
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,
speed = 15,
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.owner = owner
self.isDefending = false
end
function Battler:destroy()

View file

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

View file

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

View file

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