From 410972c0c1003fa257924814eb476cd0552071f7 Mon Sep 17 00:00:00 2001 From: dg <dg@51575b47-30f0-44d4-a5cc-537603b46e54> Date: Mon, 4 Oct 2010 14:51:10 +0000 Subject: [PATCH] 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 --- game/modules/tome/class/Actor.lua | 34 ++++++++++++++++--------------- 1 file changed, 18 insertions(+), 16 deletions(-) diff --git a/game/modules/tome/class/Actor.lua b/game/modules/tome/class/Actor.lua index fda1e5c5a6..e7e9c2aae2 100644 --- a/game/modules/tome/class/Actor.lua +++ b/game/modules/tome/class/Actor.lua @@ -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 -- GitLab