def generatePhysicalAttackEffect(self, attacker, criticity=None): """Called for animate a character hit by a physical blow. Character will innaturally move away in a direction opposite to blow origin. """ damage = cbrandom.throwDices(attacker.attackDamage) critic = "" if criticity and criticity==module_th0.TH0_SURPRISE_HIT: critic = "BACKSTAB! " damage*=cbrandom.randint(3,4) elif criticity and criticity==module_th0.TH0_HIT_CRITICAL: if cbrandom.randint(1,2)==1: self.shout(_("Ouch!")) damage = int(damage * 1.5) critic = "CRITICAL! " elif criticity and criticity==module_th0.TH0_HIT_SURPRISE_CRITICAL: damage*=cbrandom.randint(4,6) critic = "DEADLY! " self.hitPointsLeft-= damage print " %s%s wounded for %s points. %s left" % (critic, self.name, damage, self.hitPointsLeft) # Below I use lastAttackHeading because may be that attackHeading is now None (enemy ends the attack) self.damageHeading = attacker.lastAttackHeading if self.brain: self.brain.setState("hitten") if not self.checkAliveState(): print "%s is dead." % self.name elif attacker.stealth and not self.canSeeHiddenCharacter(attacker): # The attacker was hidden in shadows and unseen, but the character (the target) is not dead! Now the character can see it! self.noticeForHiddenCharacter(attacker) # however the character has been hit, so I need to reset it's stealth state if self.stealth: self.stealth = False
def roll(self): """Service method to roll 1d20""" return cbrandom.throwDices("1d20")