def handle_effect(self, camp, originator, pos, anims, delay=0):
        """Apply some hurting to whoever is in the indicated tile."""
        # Damage effects can clear fields, enchantments as a side effect.
        # Do that first.
        if self.element:
            TidyEnchantments.tidy(camp, pos, self.element)

        target = camp.scene.get_character_at_spot(pos)
        if target:
            dmg = sum(
                random.randint(1, self.att_dice[1])
                for x in range(self.att_dice[0])) + self.att_dice[2]
            if self.stat_bonus and originator:
                # Calculate base stat bonus
                bstatb = (originator.get_stat(self.stat_bonus) - 11) // 2
                stat = int(bstatb * self.stat_mod)
                if self.stat_mod > 1:
                    stat = max(stat, bstatb + 1)
                dmg = max(dmg + stat, 1)
            if self.element:
                resist = target.get_stat(self.element)
                dmg = (dmg * (100 - resist)) // 100
                if dmg < 1 and resist < 150:
                    dmg = 1
                elif dmg < 1:
                    dmg = 0

            # If the target is asleep, damage doubled but they wake up.
            if camp.fight and camp.fight.cstat[target].asleep:
                dmg = dmg * 2
                camp.fight.cstat[target].asleep = False

            target.hp_damage += dmg
            target.most_recent_wound = dmg

            anims.append(animobs.Caption(str(dmg), pos, delay=delay))

            # A damaged monster gets activated, and automatically loses hiding.
            camp.activate_monster(target)
            target.hidden = False

            # Check to see if this model mitoses.
            if hasattr(target, "mitose") and target.mitose(self.element):
                target.mitose_me = True

            if target.is_alright():
                if dmg > 0:
                    return self.on_success
                else:
                    return self.on_failure
            else:
                return self.on_death
        else:
            return self.on_failure
Esempio n. 2
0
 def attempt_awareness( self, explo, chara ):
     """Try to spot any hidden models taking part in combat."""
     awareness = chara.get_stat( stats.AWARENESS ) + chara.get_stat_bonus( stats.INTELLIGENCE ) + 55
     anims = list()
     for m in self.active:
         if m.is_alright() and m.is_enemy( self.camp, chara ) and m.hidden:
             spot_chance = max( awareness - m.get_stat( stats.STEALTH ) - chara.get_stat_bonus( stats.REFLEXES ), 10)
             if random.randint(1,100) <= spot_chance:
                 m.hidden = False
                 anims.append( animobs.PurpleSparkle( pos=m.pos ) )
     if not anims:
         anims.append( animobs.Caption( "Fail!", pos=chara.pos ) )
     animobs.handle_anim_sequence( explo.screen, explo.view, anims )
     self.end_turn( chara )
Esempio n. 3
0
 def handle_effect(self, camp, originator, pos, anims, delay=0):
     """Apply some hurting to whoever is in the indicated tile."""
     target = camp.scene.get_character_at_spot(pos)
     if target:
         if self.amount > 1:
             amount = random.randint(1, self.amount)
         else:
             amount = 1
         target.stat_damage[self.stat_to_damage] += amount
         anims.append(
             animobs.Caption(str(amount),
                             pos,
                             delay=delay,
                             color=(250, 200, 50)))
     return self.children
Esempio n. 4
0
 def handle_effect(self, camp, originator, pos, anims, delay=0):
     """Apply some mana damage to whoever is in the indicated tile."""
     target = camp.scene.get_character_at_spot(pos)
     if target:
         dmg = sum(
             random.randint(1, self.dice[1])
             for x in range(self.dice[0])) + self.dice[2]
         if self.stat_bonus and originator:
             dmg = max(
                 dmg + (originator.get_stat(self.stat_bonus) - 11) // 2, 1)
         dmg = min(dmg, target.mp_damage)
         target.mp_damage -= dmg
         anims.append(
             animobs.Caption(str(dmg),
                             pos,
                             delay=delay,
                             color=(100, 200, 250)))
     return self.children
Esempio n. 5
0
 def handle_effect(self, camp, originator, pos, anims, delay=0):
     """Apply some mana damage to whoever is in the indicated tile."""
     target = camp.scene.get_character_at_spot(pos)
     if target:
         dmg = sum(
             random.randint(1, self.att_dice[1])
             for x in range(self.att_dice[0])) + self.att_dice[2]
         if self.stat_bonus and originator:
             stat = (originator.get_stat(self.stat_bonus) - 11) // 2
             dmg = max(dmg + stat, 1)
         # Mana damage cannot take the mana score below 0.
         dmg = min(dmg, target.current_mp())
         target.mp_damage += dmg
         anims.append(
             animobs.Caption(str(dmg),
                             pos,
                             delay=delay,
                             color=(250, 0, 250)))
     return self.children
Esempio n. 6
0
    def attempt_stealth( self, explo, chara ):
        """Make a stealth roll for chara vs best enemy awareness roll."""
        # Determine the highest awareness of all enemies.
        hi = 0
        for m in self.active:
            if m.is_alright() and m.is_enemy( self.camp, chara ):
                awareness = m.get_stat( stats.AWARENESS ) + m.get_stat_bonus( stats.INTELLIGENCE )
                hi = max( hi, awareness )
        # The target number is clamped between 5 and 96- always 5% chance of success or failure.
        hi = min( max( hi - chara.get_stat( stats.STEALTH ) - chara.get_stat_bonus( stats.REFLEXES ) + 45 , 5 ), 96 )
        anims = list()
        if random.randint(1,100) >= hi:
            chara.hidden = True
            anims.append( animobs.Smoke( pos=chara.pos ) )
        else:
            anims.append( animobs.Smoke( pos=chara.pos ) )
            anims.append( animobs.Caption( "Fail!", pos=chara.pos ) )
        animobs.handle_anim_sequence( explo.screen, explo.view, anims )

        self.end_turn( chara )