feat: make aerial ennemies able to avoir attacks

This commit is contained in:
Kazhnuz 2021-05-09 15:08:46 +02:00
parent b9d324fa57
commit 487d14dece

View file

@ -2,6 +2,8 @@ local FighterParent = Object:extend()
local counter = 0 local counter = 0
local AERIAL_ACCURACY_FACTOR = 0
function FighterParent:new(owner, isHero, id) function FighterParent:new(owner, isHero, id)
self.owner = owner self.owner = owner
self.turnSystem = owner.turnSystem self.turnSystem = owner.turnSystem
@ -82,11 +84,12 @@ function FighterParent:sendDamage(target, value, accuracy, isSpecial, isAerial)
core.debug:print("cbs/battler", "Sending " .. value .." damage at " .. target.name) core.debug:print("cbs/battler", "Sending " .. value .." damage at " .. target.name)
target:receiveDamage(value, accuracy, isSpecial, isAerial, self) return target:receiveDamage(value, accuracy, isSpecial, isAerial, self)
end end
function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho) function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho)
local stats = self:getStats() local stats = self:getStats()
local isSuccess = true
if (isSpecial) then if (isSpecial) then
value = value / stats.mind value = value / stats.mind
@ -94,6 +97,15 @@ function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromW
value = value / stats.defense value = value / stats.defense
end end
print(self.abstract.data.isArieal)
if (self.abstract.data.isAerial and not isAerial) then
accuracy = accuracy * AERIAL_ACCURACY_FACTOR
end
isSuccess = (math.random(100) <= accuracy)
if (isSuccess) then
core.debug:print("cbs/fighter", "Taken " .. value .. " damage" ) core.debug:print("cbs/fighter", "Taken " .. value .. " damage" )
if (self.isDefending) then if (self.isDefending) then
self:setHP(value * -0.66, true) self:setHP(value * -0.66, true)
@ -101,6 +113,11 @@ function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromW
self:setHP(value * -1, true) self:setHP(value * -1, true)
self.actor:getHurt() self.actor:getHurt()
end end
else
self.actor:avoidedAttack()
end
return isSuccess
end end
function FighterParent:getAbstract() function FighterParent:getAbstract()