Multiple deaths and Eidolon stacking
Posted: Sun Feb 10, 2013 2:15 am
There have been several reports of people dying and ending up on the Eidolon plane twice, with permanent invulnerability when leaving the second plane. I was bored, so I went bug hunting. I think I've got a fix.Sorry if you were looking forward to my usual involved explanation, but the interactions of this one meander from function to function through several files. The basic gist is that the takeHit() function kills an Actor on every hit that lands after its health is low enough and going to the Eidolon plane is scheduled for the end of the next game tick every time that happens. Multiple deaths before that game tick means multiple scheduled trips. This patch prevents any Actor from dying more than once. The dead still take damage when hit, but aren't killed again.
Edit: Rearranged checks for efficiency.
Code: Select all
Index: game/engines/default/engine/interface/ActorLife.lua
===================================================================
--- game/engines/default/engine/interface/ActorLife.lua (revision 6387)
+++ game/engines/default/engine/interface/ActorLife.lua (working copy)
@@ -66,7 +66,7 @@
if self.onTakeHit then value = self:onTakeHit(value, src) end
self.life = self.life - value
self.changed = true
- if self.life <= self.die_at then
+ if self.life <= self.die_at and not self.dead then
if src.on_kill and src:on_kill(self) then return false, value end
game.logSeen(self, "#{bold}#%s killed %s!#{normal}#", src.name:capitalize(), self.name)
return self:die(src, death_note), value
Index: game/modules/tome/class/interface/ActorLife.lua
===================================================================
--- game/modules/tome/class/interface/ActorLife.lua (revision 6387)
+++ game/modules/tome/class/interface/ActorLife.lua (working copy)
@@ -31,7 +31,7 @@
if self.onTakeHit then value = self:onTakeHit(value, src) end
self.life = self.life - value
self.changed = true
- if self.life <= self.die_at then
+ if self.life <= self.die_at and not self.dead then
if self:hasEffect(self.EFF_PRECOGNITION) then
game.log("%s dies during precognition, ending the effect!", self.name:capitalize())
self:removeEffect(self.EFF_PRECOGNITION)
Edit: Rearranged checks for efficiency.