def on_hit(self, attack_action): if attack_action.dmg_done and engine.roll_chance(self.poison_chance): if 'undead' or 'zombie' not in attack_action.target.types: if engine.roll_chance(50): statuses.Poison(attack_action.unit.target) attack_action.to_emotes(emoji_utils.emote_dict['poisoned_em']) else: statuses.Bleeding(attack_action.unit.target) attack_action.to_emotes(emoji_utils.emote_dict['bleeding_em'])
def on_hit(self, action): if engine.roll_chance((self.heat - 4) * 5): if engine.roll_chance(50): if action.dmg_done: action.dmg_done = action.dmg_done * 2 statuses.Burning(action.target) action.str = 'special' else: action.dmg_done = 0 self.unit.dmg_received += 1 statuses.Stun(action.actor) action.str = 'special_1' self.heat = 0 self.heat += self.heating
def find_target(self): if self.unit.weapon.targets(): self.unit.target = get_lowest_hp(self.unit.weapon.targets()) if engine.roll_chance(20): self.unit.target = random.choice(self.unit.weapon.targets()) else: self.unit.target = None
def generate_location(self, x, y): map_tuple = self.map_tuples[(x, y)] del self.map_tuples[(x, y)] if x == 0 and y == 0: return self.entrance_location(0, 0, self.dungeon, map_tuple) if engine.roll_chance(self.neutral_chance): self.neutral_chance -= self.neutral_scarceness self.neutral_chance = 0 if self.neutral_chance < 0 else self.neutral_chance impact = 'neutral' current_modifier = 0 else: self.neutral_chance += self.neutral_probability impact_integer = random.randint(*self.impact_integer_range) + self.balance_integer if impact_integer < 0: impact = 'negative' current_modifier = self.negative_modifier else: impact = 'positive' current_modifier = self.positive_modifier self.statistics[impact] += 1 locations_pool = [location_weight for location_weight in self.location_dict[map_tuple.types] if location_weight[0].impact == impact and location_weight[0].available_for_pool(self.map_tuples)] if not locations_pool: locations_pool = [location_weight for location_weight in self.location_dict[map_tuple.types] if location_weight[0].available_for_pool(self.map_tuples)] return self.create_location(x, y, map_tuple, current_modifier, locations_pool)
def on_hit(self, attack_action): if not self.melee: if attack_action.dmg_done and engine.roll_chance( self.bleed_chance ) and 'alive' in attack_action.target.types: statuses.Bleeding(attack_action.unit.target) attack_action.to_emotes(emoji_utils.emote_dict['bleeding_em']) self.melee = True
def generate_loot(self): if self.lost_weapon: self.weapon = self.lost_weapon[0] elif self.weapon_to_member: self.weapon = self.weapon_to_member[0] loot = engine.Container() for item in self.loot: if engine.roll_chance(item[1][1]): loot.put(item[0], value=item[1][0]) if engine.roll_chance( self.loot_chances['weapon']) and not self.weapon.natural: loot.put(self.weapon.name) for piece in self.armor: if engine.roll_chance(self.loot_chances['armor']): loot.put(piece.name) for item in self.items: if engine.roll_chance(self.loot_chances['items']): loot.put(item.name) return loot
def handler(self, call): bot_methods.err(call.data) data = call.data.split('_') action = data[3] if action == 'map': bot_methods.bot.edit_message_reply_markup( chat_id=call.from_user.id, message_id=call.message.message_id) for member in self.dungeon.party.members: member.occupied = False self.dungeon.update_map(new=True) elif action == 'sneak': if engine.roll_chance(50): self.state = 'sneaked' for member in self.dungeon.party.members: member.delete_message() self.dungeon.party.send_message( self.get_lang_tuple('text_1'), image=self.image, reply_markup=self.get_action_keyboard()) else: self.state = 'attacked' for member in self.dungeon.party.members: member.delete_message() image = create_dungeon_image( './files/images/backgrounds/dark_forest.jpg', self.mobs.get_image_tuples()) self.fight(first_turn='mobs') elif action == 'leave': for member in self.dungeon.party.members: member.delete_message() member.occupied = False self.dungeon.party.send_message(self.get_lang_tuple('text_3'), image=self.image) self.dungeon.update_map(new=True) elif action == 'attack': self.state = 'attacked' for member in self.dungeon.party.members: member.delete_message() image = create_dungeon_image( 'D:\YandexDisk\Veganwars\Veganwars\\files\images\\backgrounds\dark_forest.jpg', self.mobs.get_image_tuples()) self.dungeon.party.send_message(self.get_lang_tuple('text_2'), image=image) self.fight() elif action == 'sneak_attack': self.state = 'attacked' for member in self.dungeon.party.members: member.delete_message() image = create_dungeon_image( 'D:\YandexDisk\Veganwars\Veganwars\\files\images\\backgrounds\dark_forest.jpg', self.mobs.get_image_tuples()) self.dungeon.party.send_message(self.get_lang_tuple('text_2'), image=image) self.fight(first_turn='party')
def on_hit(self, attack_action): if engine.roll_chance(self.get_effect_chance()): if attack_action.dmg_done: if 'alive' in attack_action.target.types: statuses.Crippled(attack_action.target) attack_action.to_emotes( emoji_utils.emote_dict['crippled_em']) else: attack_action.dmg_done += 1 elif attack_action.dmg_blocked > 0: attack_action.armored.armor -= 1
def activate_armor(self, dmg_done): if not self.armor: return 0, None armor = list(self.armor) armor.sort(key=lambda x: x.rating) blocked_damage = 0 acted_piece = None for piece in armor: chance = piece.coverage if engine.roll_chance(chance): blocked_damage = piece.block(dmg_done) acted_piece = piece break return blocked_damage, acted_piece
def activate_armor(self, action): if not self.armor or self.rooted or self.disabled: return 0, None armor = list(armor for armor in self.armor if armor.armor > 0 and armor.rating >= action.dmg_done) armor.sort(key=lambda x: x.rating) blocked_damage = 0 acted_piece = None for piece in armor: chance = piece.current_coverage if engine.roll_chance(chance): blocked_damage = piece.block(action.dmg_done) acted_piece = piece break return blocked_damage, acted_piece
def second_stage(self): self.use() damage = random.randint(4, 6) + self.spell_damage targets = self.unit.targets() self.string('use', format_dict={'actor': self.unit.name}) damage_spread = engine.aoe_split(damage, len(targets)) damage_index = 0 for target in targets: damage = damage_spread[damage_index] damage_index += 1 if not damage: pass elif 'dodge' not in target.action: self.dmg_done = damage self.target = target target.receive_spell(self) if self.dmg_done: self.string('use_1', format_dict={'target': target.name, 'damage': self.dmg_done}) if engine.roll_chance(50): statuses.Burning(self.target, stacks=2 + int(self.spell_damage/2)) else: self.string('use_2', format_dict={'target': target.name})
def act(self, action): if engine.roll_chance(60) and action.weapon.melee: self.unit.damage += 1 self.string('use', format_dict={'actor': self.unit.name}, order=21)
def on_hit(self, attack_action): if self.effect_applicable(attack_action) and engine.roll_chance( self.get_effect_chance()): self.effect_resolve(attack_action)
def effect_applicable(self, attack_action): if attack_action.dmg_blocked or attack_action.dmg_done > 0: self.effect_chance += 10 * attack_action.dmg_blocked if engine.roll_chance(self.effect_chance): return True return False
def on_hit(self, attack_action): if attack_action.dmg_done and engine.roll_chance(self.stun_chance): statuses.Stun(attack_action.target) attack_action.to_emotes(emoji_utils.emote_dict['stun_em'])
def on_hit(self, action): if action.dmg_done and engine.roll_chance(self.confuse_chance): statuses.Confused(action.target) action.to_emotes(emoji_utils.emote_dict['confused_em'])
def on_hit(self, attack_action): if attack_action.dmg_done and engine.roll_chance( self.get_cripple_chance()) and 'alive' in attack_action.target.types: statuses.Crippled(attack_action.unit.target) attack_action.to_emotes(emoji_utils.emote_dict['crippled_em'])
def act(self, action): if engine.roll_chance(25) and action.weapon.melee: action.dmg_done *= 2 action.to_emotes(emoji_utils.emote_dict['exclaim_em'])
def check_combust(self): Overloaded(self.unit) overload = self.unit.statuses['overloaded'] if engine.roll_chance(self.get_combustion_chance(overload.strength)): self.combust()
def on_attack(new): standart_actions.BaseAttack.on_attack(new) if engine.roll_chance(self.stun_chance) and new.dmg_done: new.to_emotes(emoji_utils.emote_dict['stun_em']) statuses.Stun(new.target)
def on_hit(self, attack_action): if attack_action.dmg_done and engine.roll_chance( self.get_bleed_chance()) and 'alive' in attack_action.target.types: statuses.Bleeding(attack_action.unit.target) attack_action.to_emotes(emoji_utils.emote_dict['bleeding_em']) self.bleed_applied_turn = self.unit.fight.turn