2021-08-15 16:50:53 +02:00
|
|
|
local ActionParent = require "scenes.battlesystem.fighters.character.actions.parent"
|
2020-07-19 22:38:59 +02:00
|
|
|
local FleeAction = ActionParent:extend()
|
2021-07-03 11:17:57 +02:00
|
|
|
local STATS = require "datas.consts.stats"
|
2020-07-19 22:38:59 +02:00
|
|
|
|
|
|
|
function FleeAction:new(fighter)
|
|
|
|
FleeAction.super.new(self, fighter)
|
|
|
|
end
|
|
|
|
|
|
|
|
function FleeAction:needTarget()
|
|
|
|
return false, false
|
|
|
|
end
|
|
|
|
|
|
|
|
function FleeAction:startAction()
|
|
|
|
core.debug:print("cbs/action", "Starting flee action")
|
2021-07-03 09:51:19 +02:00
|
|
|
local stats = self.fighter.abstract.stats
|
|
|
|
|
2021-03-13 18:00:39 +01:00
|
|
|
if (self.fighter.abstract.name == "shadow") then
|
2021-09-16 21:51:32 +02:00
|
|
|
self.fighter.turnSystem.scene:showMessage("You won't flee the battle")
|
2021-03-13 18:00:39 +01:00
|
|
|
self:finishAction()
|
|
|
|
return
|
|
|
|
end
|
|
|
|
|
2021-07-03 11:17:57 +02:00
|
|
|
local chanceToFlee = self.fighter.turnSystem:getChanceTooFlee(self.fighter:getStat(STATS.SPEED))
|
2021-03-13 18:00:39 +01:00
|
|
|
if (math.random(100) < chanceToFlee) then
|
2021-09-16 21:51:32 +02:00
|
|
|
self.fighter.turnSystem.scene:showMessage("You flee the battle")
|
2021-03-13 18:00:39 +01:00
|
|
|
self.fighter.turnSystem:fleeBattle()
|
|
|
|
else
|
2021-09-16 21:51:32 +02:00
|
|
|
self.fighter.turnSystem.scene:showMessage("You failed to flee the battle")
|
2021-03-13 18:00:39 +01:00
|
|
|
self:finishAction()
|
|
|
|
end
|
|
|
|
|
2020-07-19 22:38:59 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
return FleeAction
|