Skip to content
Snippets Groups Projects
Commit 410972c0 authored by dg's avatar dg
Browse files

NPCs splitting on damage: each copy will take half the damage of the blow. If...

NPCs splitting on damage: each copy will take half the damage of the blow. If half damage is sufficient to kill it the clone will still pop but with just 1 HP


git-svn-id: http://svn.net-core.org/repos/t-engine4@1398 51575b47-30f0-44d4-a5cc-537603b46e54
parent e373dbde
No related branches found
No related tags found
No related merge requests found
......@@ -645,22 +645,6 @@ function _M:onTakeHit(value, src)
game.logSeen(self, "%s shatters into pieces!", self.name:capitalize())
end
-- Split ?
if self.clone_on_hit and value >= self.clone_on_hit.min_dam_pct * self.max_life / 100 and rng.percent(self.clone_on_hit.chance) then
-- Find space
local x, y = util.findFreeGrid(self.x, self.y, 1, true, {[Map.ACTOR]=true})
if x then
-- Find a place around to clone
local a = self:clone()
a.energy.val = 0
a.exp_worth = 0.1
a.inven = {}
a.x, a.y = nil, nil
game.zone:addEntity(game.level, a, "actor", x, y)
game.logSeen(self, "%s is split in two!", self.name:capitalize())
end
end
-- Adds hate
if self:knowTalent(self.T_HATE_POOL) then
local hateGain = 0
......@@ -717,6 +701,24 @@ function _M:onTakeHit(value, src)
if value > self.life then value = self.life - 1 end
end
-- Split ?
if self.clone_on_hit and value >= self.clone_on_hit.min_dam_pct * self.max_life / 100 and rng.percent(self.clone_on_hit.chance) then
-- Find space
local x, y = util.findFreeGrid(self.x, self.y, 1, true, {[Map.ACTOR]=true})
if x then
-- Find a place around to clone
local a = self:clone()
a.life = math.max(1, a.life - value / 2)
a.energy.val = 0
a.exp_worth = 0.1
a.inven = {}
a.x, a.y = nil, nil
game.zone:addEntity(game.level, a, "actor", x, y)
game.logSeen(self, "%s is split in two!", self.name:capitalize())
value = value / 2
end
end
return value
end
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment