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 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,13 +97,27 @@ function FighterParent:receiveDamage(value, accuracy, isSpecial, isAerial, fromW
|
||||||
value = value / stats.defense
|
value = value / stats.defense
|
||||||
end
|
end
|
||||||
|
|
||||||
core.debug:print("cbs/fighter", "Taken " .. value .. " damage" )
|
print(self.abstract.data.isArieal)
|
||||||
if (self.isDefending) then
|
|
||||||
self:setHP(value * -0.66, true)
|
if (self.abstract.data.isAerial and not isAerial) then
|
||||||
else
|
accuracy = accuracy * AERIAL_ACCURACY_FACTOR
|
||||||
self:setHP(value * -1, true)
|
|
||||||
self.actor:getHurt()
|
|
||||||
end
|
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)
|
||||||
|
else
|
||||||
|
self:setHP(value * -1, true)
|
||||||
|
self.actor:getHurt()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
self.actor:avoidedAttack()
|
||||||
|
end
|
||||||
|
|
||||||
|
return isSuccess
|
||||||
end
|
end
|
||||||
|
|
||||||
function FighterParent:getAbstract()
|
function FighterParent:getAbstract()
|
||||||
|
|
Loading…
Reference in a new issue