def end_turn(self): """ Reroll save against paralysis """ if self.is_paralyzed: dc = self.paralyzed["dc"] ability = self.paralyzed['save'] if R.roll_save(self, ability, dc) or self.paralyzed['duration'] == 0: self.set_paralysis(state=False, dc=0, save=None, duration=-1) if self.is_frightened: dc = self.frightened["dc"] ability = self.frightened['save'] if R.roll_save(self, ability, dc) or self.frightened['duration'] == 0: self.set_fear(state=False, dc=0, save=None, duration=-1, by=None) """ Decrease paralysis duration counter """ self.paralyzed['duration'] -= 1 self.frightened['duration'] -= 1 """ Set first attack flag in case creature can make attacks of opportunity """ self.first_attack = True
def begin_turn(self): """ At the beginning of each turn, perform a list of actions such as standing up, recharging abilities etc. Return True if creature did not use its action """ self.distance = 0 # reset traveled distance self.speed = self.max_speed.copy() # reset movement speed self.first_attack = True # reset first attack flag if self.poisoned['duration'] == 0: self.set_poison(state=False, dc=0, save='con', duration=-1) if self.is_poisoned: self.poisoned['duration'] -= 1 """ If swallowed creatures, do damage and check conditions """ if self.stomach is not None: if self.stomach.contents: self.stomach.check_status(self) """ Recharge abilities """ if self.actions: for action in self.actions: action.check_and_recharge() """ Stand up if prone """ if self.is_proned: self.set_prone(state=False) self.speed['fly'] = math.floor(self.speed['fly'] / 2) self.speed['ground'] = math.floor(self.speed['ground'] / 2) if self.is_swallowed: self.position = self.swallowed['by'].position self.speed['fly'] = 0 self.speed['ground'] = 0 """ Free from grapple if grappler has died """ if self.grappled["state"]: self.speed['fly'] = 0 self.speed['ground'] = 0 if self.grappled["by"].is_dead: self.set_grapple(state=False, dc=0, save='str', source=None) else: dc = self.grappled["dc"] ability = self.grappled["save"] if R.roll_save(self, ability, dc): self.set_grapple(state=False, dc=0, save=None) return False if self.paralyzed["state"]: self.speed['fly'] = 0 self.speed['ground'] = 0 if self.restrained["state"]: self.speed['fly'] = 0 self.speed['ground'] = 0 dc = self.restrained["dc"] ability = self.restrained['save'] if R.roll_save(self, ability, dc): self.set_restrain(state=False, dc=0, save=None) return False return True
def check_status(self, source): if self.damage_count >= self.breakout_dmg: self.regurgitate() self.damage_count = 0 else: for target in self.contents: messages.IO.reset() messages.IO.log += "{source} digests {target}.".format( source=source.name, target=target.name) R.roll_damage(source, target, self)
def use(self, source, target, always_hit=False): """ Roll d20 to hit """ hit, crit_multiplier, hitroll = R.roll_hit(source, target, self, always_hit) """ Iterate all different damage types in weapon if successful """ if hit: #total_damage = R.iterate_damage(source, target, self, crit_multiplier) total_damage = R.roll_damage(source, target, self, crit_multiplier) """ Apply weapon's special abilities on target""" if self.special: for on_hit_effect in self.special: on_hit_effect.use(source, target, total_damage, crit_multiplier)
def use(self, source, target, total_damage=0, crit_multipiler=1): messages.IO.reset() messages.IO.log += "{source} on-hit effect on {target}.".format( source=source.name, target=target.name) save_success = R.roll_save(target, self.save, self.dc) if self.damage is not None: R.roll_damage(source, target, self, crit_multipiler, self.success, self.save, self.dc) if not save_success and self.duration is not None: self.apply_condition(target)
def use(self, source, target, total_damage=0, crit_multipiler=1): if source.distance >= self.charge_distance: if not R.roll_save(target, self.save, self.dc): target.set_prone(True) if self.bonus_action is not None: self.bonus_action.use(source, target, always_hit=False) source.distance = 0
def use(self, creature, damage, damage_type, critical): if critical > self.min_crit or damage_type in self.vulnerabilities: return creature.hp else: if R.roll_save(creature, self.save, damage + self.penalty): messages.IO.conditions.append('%s resists death with %s!' % (creature.name, self.name)) return self.minimum_hp return creature.hp
def use(self, creature, allies, enemies=[]): for e in (e for e in enemies.get_alive() if world.get_dist(creature.position, e.position) <= 8 and self.name not in e.immunities): if R.roll_save(e, self.save, self.dc): e.immunities.append(self.name) break else: e.set_fear(state=True, dc=self.dc, save=self.save, duration=2, by=creature) if R.roll_save(e, self.save, self.dc + 5): e.set_paralysis(state=True, dc=self.dc + 5, save=self.save, duration=2) break
def use(self, source, target, total_damage=0, crit_multipiler=1): if source.distance >= self.charge_distance: if self.bonus_action is not None: self.bonus_action.use(source, target, always_hit=True) if not R.roll_save(target, self.save, self.dc): target.set_prone(True) knockback_path = world.get_opposite(target.position, source.position, self.knockback_distance) world.force_move(source, target, knockback_path, self.name) source.distance = 0
def use(self, creature, allies, enemies=[]): for e in (e for e in enemies.get_alive() if world.get_dist(creature.position, e.position) <= int( self.range / 5) and self.name not in e.immunities): if R.roll_save(e, self.save, self.dc): e.immunities.append(self.name) else: e.set_fear(state=True, dc=self.dc, save=self.save, duration=self.duration, by=creature)
def use(self, creature, allies, enemies=[]): """ Check if enemies are nearby """ for enemy in (e for e in enemies.get_alive()): if world.is_adjacent(enemy.position, creature.position): """ Roll save and set immunity if success""" if R.roll_save(enemy, self.save, self.dc): enemy.immunities.append(self.name) else: """ Else apply poison """ if self.name not in enemy.immunities \ or not enemy.is_poisoned \ or 'poison' not in enemy.immunities: enemy.set_poison(state=True, dc=self.dc, save=self.save, duration=1)
def use(self, source, target, total_damage=0, crit_multipiler=1): save_success = R.roll_save(target, self.save, self.dc) if save_success: pass else: multi = 1 if self.damage_type in target.immunities \ or self.name in target.immunities: pass elif self.damage_type in target.resistances: multi = 0.5 else: target.take_max_hp_damage(source, {'necrotic': 10 * multi}, self.name) target.prevent_heal = True target.immunities.append(self.name) source.damage_dealt += 10 * multi
def use(self, source, target, total_damage=0, crit_multipiler=1): if not R.roll_save(target, self.save, self.dc) \ and source.size - target.size >= 2: target.set_swallowed(state=True, source=source) source.focused_enemy = None
def use(self, source, target, total_damage=0, crit_multipiler=1): if not R.roll_save(target, self.save, self.dc): target.set_grapple(True, self.dc, self.save, source)
def use(self, source, target, total_damage=0, crit_multipiler=1): if R.roll_hit(source, target, self): target.set_restrain(True, self.dc, self.save) self.available = False
def use(self, source, target, total_damage, crit_multipiler=1): if not R.roll_save(target, self.save, self.dc): target.take_max_hp_damage(source, total_damage, self.name)