feat: make aerial ennemies able to avoir attacks
This commit is contained in:
parent
b9d324fa57
commit
487d14dece
1 changed files with 24 additions and 7 deletions
|
@ -2,6 +2,8 @@ local FighterParent = Object:extend()
|
|||
|
||||
local counter = 0
|
||||
|
||||
local AERIAL_ACCURACY_FACTOR = 0
|
||||
|
||||
function FighterParent:new(owner, isHero, id)
|
||||
self.owner = owner
|
||||
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)
|
||||
|
||||
target:receiveDamage(value, accuracy, isSpecial, isAerial, self)
|
||||
return target:receiveDamage(value, accuracy, isSpecial, isAerial, self)
|
||||
end
|
||||
|
||||
function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromWho)
|
||||
local stats = self:getStats()
|
||||
local isSuccess = true
|
||||
|
||||
if (isSpecial) then
|
||||
value = value / stats.mind
|
||||
|
@ -94,6 +97,15 @@ function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromW
|
|||
value = value / stats.defense
|
||||
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" )
|
||||
if (self.isDefending) then
|
||||
self:setHP(value * -0.66, true)
|
||||
|
@ -101,6 +113,11 @@ function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromW
|
|||
self:setHP(value * -1, true)
|
||||
self.actor:getHurt()
|
||||
end
|
||||
else
|
||||
self.actor:avoidedAttack()
|
||||
end
|
||||
|
||||
return isSuccess
|
||||
end
|
||||
|
||||
function FighterParent:getAbstract()
|
||||
|
|
Loading…
Reference in a new issue