def handlemessage(self, m):
        #self._handlemessageSanityCheck()
        if isinstance(m, ba.OutOfBoundsMessage): self.handlemessage(ba.DieMessage())
        elif isinstance(m, ba.DieMessage):
            if hasattr(self,"light") and self.light is not None:self.light.delete()
            if hasattr(self,"smokeTimer"):self.smokeTimer = None
            if hasattr(self,"surround"):self.surround = None
            if hasattr(self,"sparkTimer"):self.sparkTimer = None
            if hasattr(self,"snowTimer"):self.snowTimer = None
            if hasattr(self,"metalTimer"):self.metalTimer = None
            if hasattr(self,"DistortionTimer"):self.DistortionTimer = None
            if hasattr(self,"slimeTimer"):self.slimeTimer = None
            if hasattr(self,"KamikazeCheck"):self.KamikazeCheck = None
            if hasattr(self,"neroLightTimer"):self.neroLightTimer = None
            if hasattr(self,"checkDeadTimer"):self.checkDeadTimer = None
            if hasattr(self,"HealTimer"):self.HealTimer = None
            if hasattr(self,"scorchTimer"):self.scorchTimer = None
            if hasattr(self,"scorchNode"):self.scorchNode = None
            if not self._hasDead:
                spaz = self.spazRef()
                #print str(spaz) + "Spaz"
                if spaz is not None and spaz.is_alive() and spaz.node.exists(): spaz.node.color = self.spazNormalColor
                killer = spaz.last_player_attacked_by if spaz is not None else None
                try:
                    if killer in (None,ba.Player(None)) or killer.actor is None or not killer.actor.exists() or killer.actor.hitPoints <= 0:killer = None
                except:
                    killer = None
                    #if hasattr(self,"hasDead") and not self.hasDead:
                self._hasDead = True

        ba.Actor.handlemessage(self, m)
    def emitIce(self):
        spaz = self.spazRef()

        if spaz is None or not spaz.is_alive() or not spaz.node.exists():
            self.handlemessage(ba.DieMessage())
            return
        ba.emitfx(position=spaz.node.position , velocity=spaz.node.velocity, count=random.randint(2,8), scale=0.4, spread=0.2, chunk_type="ice")
 def emitDistortion(self):
     spaz = self.spazRef()
     if spaz is None or not spaz.is_alive() or not spaz.node.exists():
         self.handlemessage(ba.DieMessage())
         return
     ba.emitfx(position=spaz.node.position,emit_type="distortion",spread=1.0)
     ba.emitfx(position=spaz.node.position, velocity=spaz.node.velocity,count=random.randint(1,5),emit_type="tendrils",tendril_type="smoke")
 def circleMove(self):
     spaz = self.spazRef()
     if spaz is None or not spaz.is_alive() or not spaz.node.exists():
         self.handlemessage(ba.DieMessage())
         return
     p = spaz.node.position
     pt = self.getTargetPosition(p)
     pn = self.node.position
     d = [pt[0] - pn[0], pt[1] - pn[1], pt[2] - pn[2]]
     speed = self.getMaxSpeedByDir(d)
     self.node.velocity = speed
 def update_Scorch(self):
     spaz = self.spazRef()
     if spaz is not None and spaz.is_alive() and spaz.node.exists():
         color = (random.random(),random.random(),random.random())
         if not hasattr(self,"scorchNode") or self.scorchNode == None:
             self.scorchNode = None
             self.scorchNode = ba.newnode("scorch",attrs={"position":(spaz.node.position),"size":1.17,"big":True})
             spaz.node.connectattr("position",self.scorchNode,"position")
         ba.animate_array(self.scorchNode,"color",3,{0:self.scorchNode.color,500:color}, timetype=tt, timeformat=tf)
     else:
         self.scorchTimer = None
         self.scorchNode.delete()
         self.handlemessage(ba.DieMessage())
 def neonLightSwitch(self,shine,Highlight,NameColor):
     spaz = self.spazRef()
     if spaz is not None and spaz.is_alive() and spaz.node.exists():
         color = (random.random(),random.random(),random.random())
         if NameColor: ba.animate_array(spaz.node,"nameColor",3,{0:spaz.node.nameColor,500:ba.safecolor(color)}, timetype=tt, timeformat=tf)
         if shine:color = tuple([min(10., 10 * x) for x in color])
         ba.animate_array(spaz.node,"color",3,{0:spaz.node.color,500:color}, timetype=tt, timeformat=tf)
         if Highlight:
             #print spaz.node.highlight
             color = (random.random(),random.random(),random.random())
             if shine:color = tuple([min(10., 10 * x) for x in color])
             ba.animate_array(spaz.node,"highlight",3,{0:spaz.node.highlight,500:color}, timetype=tt, timeformat=tf)
     else:
         self.neroLightTimer = None
         self.handlemessage(ba.DieMessage())
 def checkPlayerifDead(self):
     spaz = self.spazRef()
     if spaz is None or not spaz.is_alive() or not spaz.node.exists():
         self.checkDeadTimer = None
         self.handlemessage(ba.DieMessage())
         return