def _handle_hit(self, msg: ba.HitMessage) -> None: ispunch = (msg.srcnode and msg.srcnode.getnodetype() == 'spaz') # Normal bombs are triggered by non-punch impacts; # impact-bombs by all impacts. if (not self._exploded and not ispunch or self.bomb_type in ['impact', 'land_mine']): # Also lets change the owner of the bomb to whoever is setting # us off. (this way points for big chain reactions go to the # person causing them). source_player = msg.get_source_player(ba.Player) if source_player is not None: self.source_player = source_player # Also inherit the hit type (if a landmine sets off by a bomb, # the credit should go to the mine) # the exception is TNT. TNT always gets credit. if self.bomb_type != 'tnt': self.hit_type = msg.hit_type self.hit_subtype = msg.hit_subtype ba.timer(100 + int(random.random() * 100), ba.WeakCall(self.handlemessage, ExplodeMessage()), timeformat=ba.TimeFormat.MILLISECONDS) assert self.node self.node.handlemessage('impulse', msg.pos[0], msg.pos[1], msg.pos[2], msg.velocity[0], msg.velocity[1], msg.velocity[2], msg.magnitude, msg.velocity_magnitude, msg.radius, 0, msg.velocity[0], msg.velocity[1], msg.velocity[2]) if msg.srcnode: pass
def _handle_hit(self, msg: ba.HitMessage) -> None: ispunched = (msg.srcnode and msg.srcnode.getnodetype() == 'spaz') # Normal bombs are triggered by non-punch impacts; # impact-bombs by all impacts. if (not self._exploded and (not ispunched or self.bomb_type in ['impact', 'land_mine'])): # Also lets change the owner of the bomb to whoever is setting # us off. (this way points for big chain reactions go to the # person causing them). source_player = msg.get_source_player(ba.Player) if source_player is not None: self._source_player = source_player # Also inherit the hit type (if a landmine sets off by a bomb, # the credit should go to the mine) # the exception is TNT. TNT always gets credit. # UPDATE (July 2020): not doing this anymore. Causes too much # weird logic such as bombs acting like punches. Holler if # anything is noticeably broken due to this. # if self.bomb_type != 'tnt': # self.hit_type = msg.hit_type # self.hit_subtype = msg.hit_subtype ba.timer(0.1 + random.random() * 0.1, ba.WeakCall(self.handlemessage, ExplodeMessage())) assert self.node self.node.handlemessage('impulse', msg.pos[0], msg.pos[1], msg.pos[2], msg.velocity[0], msg.velocity[1], msg.velocity[2], msg.magnitude, msg.velocity_magnitude, msg.radius, 0, msg.velocity[0], msg.velocity[1], msg.velocity[2]) if msg.srcnode: pass