2020-07-19 13:13:54 +02:00
|
|
|
local AbstractMobParent = Object:extend()
|
|
|
|
|
|
|
|
function AbstractMobParent:new()
|
|
|
|
self:initBasicElements()
|
|
|
|
self.stats = self:createStats()
|
|
|
|
self.skills = self:createSkills()
|
|
|
|
self:initLife()
|
|
|
|
end
|
|
|
|
|
|
|
|
function AbstractMobParent:initBasicElements()
|
|
|
|
self.name = "PlaceHolder"
|
|
|
|
self.fullname = "PlaceHolder"
|
|
|
|
self.turns = 2
|
|
|
|
end
|
|
|
|
|
|
|
|
function AbstractMobParent:createStats()
|
|
|
|
local stats = {}
|
|
|
|
|
|
|
|
stats.hpmax = 0
|
|
|
|
stats.ppmax = 0
|
|
|
|
stats.attack = 0
|
|
|
|
stats.power = 0
|
|
|
|
stats.defense = 0
|
|
|
|
stats.technic = 0
|
|
|
|
stats.mind = 0
|
|
|
|
stats.speed = 0
|
|
|
|
|
|
|
|
return stats
|
|
|
|
end
|
|
|
|
|
|
|
|
function AbstractMobParent:createSkills()
|
|
|
|
return {}
|
|
|
|
end
|
|
|
|
|
2020-07-24 19:49:24 +02:00
|
|
|
-- LIFE FUNCTIONS
|
|
|
|
-- Handle HP and stuff like that
|
|
|
|
|
2020-07-19 13:13:54 +02:00
|
|
|
function AbstractMobParent:initLife()
|
|
|
|
self.hp = self.stats.hpmax
|
2020-07-19 16:06:35 +02:00
|
|
|
self.pp = self.stats.ppmax
|
2020-07-19 13:13:54 +02:00
|
|
|
self.status = 0
|
|
|
|
end
|
|
|
|
|
2020-07-24 19:49:24 +02:00
|
|
|
function AbstractMobParent:setHP(newHP, relative)
|
|
|
|
if (relative) then
|
|
|
|
self.hp = self.hp + newHP
|
|
|
|
else
|
|
|
|
self.hp = newHP
|
|
|
|
end
|
2020-08-07 07:32:16 +02:00
|
|
|
self.hp = math.floor(math.max(0, self.hp))
|
2020-07-24 19:49:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function AbstractMobParent:setPP(newPP, relative)
|
|
|
|
if (relative) then
|
|
|
|
self.pp = self.pp + newPP
|
|
|
|
else
|
|
|
|
self.pp = newPP
|
|
|
|
end
|
2020-08-07 07:32:16 +02:00
|
|
|
self.pp = math.floor(math.max(0, self.pp))
|
2020-07-24 19:49:24 +02:00
|
|
|
end
|
|
|
|
|
|
|
|
function AbstractMobParent:isAlive()
|
|
|
|
return (self.hp > 0)
|
|
|
|
end
|
|
|
|
|
2020-07-19 13:13:54 +02:00
|
|
|
function AbstractMobParent:getStats()
|
|
|
|
return self.stats
|
|
|
|
end
|
|
|
|
|
2020-08-04 17:50:03 +02:00
|
|
|
-- Bonus stuff
|
|
|
|
|
|
|
|
function AbstractMobParent:setBonus(pvFactor, statFactor)
|
|
|
|
self.stats.hpmax = self.stats.hpmax * pvFactor
|
|
|
|
self.hp = self.stats.hpmax
|
|
|
|
|
|
|
|
self.stats.attack = self.stats.attack * statFactor
|
|
|
|
self.stats.power = self.stats.power * statFactor
|
|
|
|
self.stats.defense = self.stats.defense * statFactor
|
|
|
|
self.stats.mind = self.stats.mind * statFactor
|
|
|
|
self.stats.technic = self.stats.technic * statFactor
|
|
|
|
self.stats.speed = self.stats.speed * statFactor
|
|
|
|
end
|
|
|
|
|
2020-07-19 13:13:54 +02:00
|
|
|
return AbstractMobParent
|