def bow_shot(actor, target, context): weapon = main.get_equipped_in_slot(actor.fighter.inventory, 'right hand') ui.render_projectile((actor.x, actor.y), (target.x, target.y), libtcod.white) combat.attack_ex(actor.fighter, target, 0, verb=("shoot", "shoots"), weapon=weapon, ranged=True)
def dragonweed_pull(actor, target, context): if target.fighter.hp > 0: ui.message( "The dragonweed's stem lashes out at %s!" % syntax.name(target), libtcod.dark_green) result = combat.attack_ex(actor.fighter, target, 0, accuracy_modifier=1.5, damage_multiplier=0.75, verb=('pull', 'pulls')) if result == 'hit' and target.fighter is not None: 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 'success' beam = main.beam(actor.x, actor.y, target.x, target.y) pull_to = beam[max(len(beam) - 3, 0)] target.set_position(pull_to[0], pull_to[1]) if main.roll_dice('1d10') <= 5: target.fighter.apply_status_effect( effects.immobilized(duration=2), context['save_dc'], actor)
def ranged_attack(actor, target, context): spent = actor.fighter.adjust_ammo(-1) if spent != 0 and actor.fighter is not None: weapon = main.get_equipped_in_slot(actor.fighter.inventory, 'right hand') ui.render_projectile((actor.x, actor.y), (target.x, target.y), libtcod.white) result = combat.attack_ex(actor.fighter, target, 0, verb=("shoot", "shoots"), weapon=weapon, ranged=True) if result == 'failed': actor.fighter.adjust_ammo(-spent, False) # Refund ammo return 'didnt-take-turn' if result == 'miss' or target.fighter is None: # ammo lands on the ground main.drop_ammo(target.x, target.y, -spent) else: # target was hit, ammo sticks in them if hasattr(target, 'recoverable_ammo'): target.recoverable_ammo += -spent else: target.recoverable_ammo = -spent else: return 'didnt-take-turn'
def great_dive(actor, target, context): ui.message("{} {} into the ground!".format( syntax.name(actor).capitalize(), syntax.conjugate(actor is player.instance, ['slam', 'slams']))) for obj in main.current_map.fighters: if (obj.x, obj.y) in target: combat.attack_ex(actor.fighter, obj, 0) x, y = context['origin'] if not main.is_blocked(x, y): actor.set_position(x, y) else: for t in target: if not main.is_blocked(t[0], t[1]): actor.set_position(t[0], t[1]) break
def sweep_attack(actor, target, context): weapon = main.get_equipped_in_slot(actor.fighter.inventory, 'right hand') if weapon is None or weapon.subtype != 'polearm': ui.message('You need a polearm to use this ability') return 'didnt-take-turn' targets = main.get_objects(actor.x,actor.y,distance=2, condition=lambda o: o.fighter is not None and o.fighter.team != 'ally') targets = [t for t in targets if (abs(t.x - actor.x) == 2 or abs(t.y - actor.y) == 2)] if len(targets) > 0: for enemy in targets: combat.attack_ex(actor.fighter,enemy,0, verb=('sweep','sweeps')) actor.fighter.adjust_stamina(-(weapon.stamina_cost * context['stamina_multiplier'])) return True else: ui.message('There are no targets in range') return 'didnt-take-turn'
def essence_fist(actor, target, context): ops = player.instance.essence choice = ui.menu('Which essence?',ops) if choice is not None: essence = ops[choice] else: return "didnt-take-turn" result = combat.attack_ex(player.instance.fighter,target,context['stamina_cost'],damage_multiplier=context['damage_multiplier']) if result != 'failed': player.instance.essence.remove(essence) return result
def frog_tongue(actor, target, context): if target.fighter.hp > 0: ui.message("The frog's tongue lashes out at %s!" % syntax.name(target), libtcod.dark_green) result = combat.attack_ex(actor.fighter, target, 0, accuracy_modifier=1.5, damage_multiplier=1.5, verb=('pull', 'pulls')) if result == 'hit': 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 'success' beam = main.beam(actor.x, actor.y, target.x, target.y) pull_to = beam[max(len(beam) - 3, 0)] target.set_position(pull_to[0], pull_to[1])
def crush(actor, target, context): combat.attack_ex(actor.fighter, target, int(actor.fighter.calculate_attack_stamina_cost() * 1.5), damage_multiplier=1.5 + ((target.fighter.armor + 1) / 20) * 2.5, shred_modifier=1 + int(target.fighter.armor / 2))
def skullsplitter(actor, target, context): combat.attack_ex(actor.fighter, target, int(actor.fighter.calculate_attack_stamina_cost() * 1.5), damage_multiplier=1.5 * (2 - target.fighter.hp / target.fighter.max_hp))
def pommel_strike(actor, target, context): combat.attack_ex(actor.fighter, target, int(actor.fighter.calculate_attack_stamina_cost() * 1.5), verb=('pommel-strike', 'pommel-strikes'), shred_modifier=2) actor.fighter.apply_status_effect(effects.exhausted(5))