def blastcap_explode(blastcap, context): blastcap.fighter = None main.current_map.fighters.remove(blastcap) ui.render_explosion(blastcap.x, blastcap.y, 1, libtcod.gold, libtcod.white, distance_h='manhattan') ui.message('The blastcap explodes with a BANG, stunning nearby creatures!', libtcod.gold) for obj in main.current_map.fighters: if main.is_adjacent_orthogonal(blastcap.x, blastcap.y, obj.x, obj.y): if obj.fighter.apply_status_effect( effects.stunned(duration=context['duration'])): ui.message( '%s %s stunned!' % (syntax.name(obj).capitalize(), syntax.conjugate(obj is player.instance, ('are', 'is'))), libtcod.gold) if ui.selected_monster is blastcap: main.changed_tiles.append((blastcap.x, blastcap.y)) ui.selected_monster = None ui.auto_target_monster() blastcap.destroy() return
def smite(actor, target, context): import monsters dc = context['save_dc'] + actor.fighter.spell_power(elements=['radiance']) combat.attack_magical(actor.fighter, target, 'ability_smite') if target.fighter is not None: target.fighter.apply_status_effect( effects.judgement(main.roll_dice('2d8')), dc, actor) if target.fighter.has_flag(monsters.EVIL): target.fighter.apply_status_effect(effects.stunned()) return 'success'
def knock_back(actor, target): # check for resistance if 'displacement' in target.fighter.immunities: if fov.player_can_see(target.x, target.y): ui.message( '%s %s.' % (syntax.name(target).capitalize(), syntax.conjugate(target is player.instance, ('resist', 'resists'))), libtcod.gray) return 'resisted' # knock the target back one space. Stun it if it cannot move. direction = target.x - actor.x, target.y - actor.y # assumes the instance is adjacent stun = False against = '' against_tile = main.current_map.tiles[target.x + direction[0]][target.y + direction[1]] if against_tile.blocks and not against_tile.is_pit: stun = True against = main.current_map.tiles[target.x + direction[0]][target.y + direction[1]].name elif against_tile.elevation != target.elevation and against_tile.tile_type != 'ramp' and \ main.current_map.tiles[target.x][target.y] != 'ramp': stun = True against = 'cliff' else: for obj in main.current_map.objects: if obj.x == target.x + direction[ 0] and obj.y == target.y + direction[1] and obj.blocks: stun = True against = obj.name break if stun: # stun the target if target.fighter.apply_status_effect(effects.stunned(duration=2)): ui.message( '%s %s with the %s, stunning %s!' % (syntax.name(target).capitalize(), syntax.conjugate(target is actor, ('collide', 'collides')), against, syntax.pronoun(target, objective=True)), libtcod.gold) else: ui.message( '%s %s knocked backwards.' % (syntax.name(target).capitalize(), syntax.conjugate(target is actor, ('are', 'is'))), libtcod.gray) target.set_position(target.x + direction[0], target.y + direction[1]) main.render_map() libtcod.console_flush()
def holy_water(actor, target, context): import monsters if not target.fighter.has_flag(monsters.EVIL): if actor is player.instance: ui.message('That target is not vulnerable to holy water.', libtcod.gray) return 'cancelled' ui.render_projectile((actor.x, actor.y), (target.x, target.y), color=spells.essence_colors['water'], character=libtcod.CHAR_BLOCK2) combat.attack_magical(actor.fighter, target, 'ability_holy_water') if target.fighter is not None: target.fighter.apply_status_effect( effects.stunned(duration=(3 + main.roll_dice('1d6')))) return 'success'
def mace_stun(attacker, target, damage): scaling_factor = 1 stun_duration = 1 if target.fighter is None: return if (attacker is player.instance): scaling_factor = attacker.player_stats.str / 10 if main.has_skill('ringing_blows'): scaling_factor *= 1.5 stun_duration = 2 if libtcod.random_get_float(0, 0.0, 1.0) * scaling_factor > 0.85: if attacker == player.instance: ui.message( "Your " + main.get_equipped_in_slot(player.instance.fighter.inventory, 'right hand').owner.name.title() + " rings out!", libtcod.blue) target.fighter.apply_status_effect(effects.stunned(stun_duration))
def on_death_summon(obj, context): ui.message('%s is dead!' % syntax.name(obj).capitalize(), libtcod.red) obj.fighter = None main.current_map.fighters.remove(obj) obj.destroy() if context.get('require_tile') is not None: tile_at_location = main.current_map.tiles[obj.x][obj.y] if context['require_tile'] != tile_at_location.tile_type: return if 'message' in context.keys(): ui.message(context['message']) monster = main.spawn_monster(context['monster'], obj.x, obj.y) monster.fighter.apply_status_effect( effects.stunned(1)) #summoning sickness if 'duration' in context: monster.summon_time = context['duration'] if ui.selected_monster is obj: main.changed_tiles.append((obj.x, obj.y)) ui.selected_monster = None ui.auto_target_monster()
def healing_trance(actor, target, context): actor.fighter.apply_status_effect(effects.stunned(duration=15)) actor.fighter.apply_status_effect(effects.regeneration(duration=15))