Skip to content

Commit

Permalink
fix stomach, special attacks and regeneration
Browse files Browse the repository at this point in the history
- creatures no longer remain in limbo if the creature that swallowed them dies from another source.
- special secondary attacks are no longer done on corpses (those were counted as excess kills)
- dead creatures can no longer regenerate (fixes bugging trolls)
  • Loading branch information
asahala authored Nov 21, 2021
1 parent 1ed6ee5 commit b32b5c7
Show file tree
Hide file tree
Showing 5 changed files with 38 additions and 13 deletions.
8 changes: 8 additions & 0 deletions abilities.py
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,19 @@ def check_status(self, source):
self.regurgitate()
self.damage_count = 0
else:
dissolved = set()
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)
""" If target dies, dissolve it """
if target.is_dead:
dissolved.add(target)

""" Destroy dissolved targets """
for target in dissolved:
self.contents.remove(target)


""" ================================================================ """
Expand Down
8 changes: 8 additions & 0 deletions creature.py
Original file line number Diff line number Diff line change
Expand Up @@ -498,12 +498,19 @@ def take_damage(self, source, damage_types, crit_multiplier):
messages.IO.target_name = self.name
messages.IO.printlog()

""" If creature dies, prevent healing it and purge its stomach """
if self.is_dead:
self.deaths += 1
self.prevent_heal = True

if self.stomach is not None:
self.stomach.regurgitate()

if source != self:
source.kills += 1
else:
self.suicides += 1

messages.IO.printmsg("-> %s is dead. " % self.name, 2, True, False)
world.Map.remove(self)
world.Map.statics[self.position] = ' † '
Expand Down Expand Up @@ -550,6 +557,7 @@ def check_passives(self, allies, enemies, type_=None):
def attack(self):
""" Set focus on enemy and attack it """

#if not self.focused_enemy.is_dead:
self.active_weapon.use(self, self.focused_enemy)
self.active_weapon.ammo -= 1
self.first_attack = False
Expand Down
10 changes: 5 additions & 5 deletions definitions.py
Original file line number Diff line number Diff line change
Expand Up @@ -628,15 +628,15 @@
'int': 7, 'wis': 9, 'cha': 7},
melee_attacks={'basic': [troll_bite, troll_claws, troll_claws],
},
passives=[Regeneration(name="Regeneration",
amount=10,
type_="initial"),
AvoidDeath(name="Kill it with fire!",
passives=[AvoidDeath(name="Kill it with fire!",
save='con',
vulnerabilities=[acid, fire],
minimum_hp=0,
min_crit_to_kill=1000,
penalty=-1000)])
penalty=-1000),
Regeneration(name="Regeneration",
amount=10,
type_="initial")])

wight = BaseCreature(name='wight', cr=3, ac=14, hp=45, speed=30,
size=medium,
Expand Down
18 changes: 13 additions & 5 deletions main.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,28 +72,36 @@ def fight(self):
# if isinstance(value, BaseCreature):
# print(name)

matches = 1
matches = 50

i = 0
results = []
messages.VERBOSE_LEVEL = 3
messages.VERBOSE_LEVEL = 0

statisticsA = defaultdict(list)
statisticsB = defaultdict(list)

stat_order = ['avg. lifetime', 'avg. dmg', 'kills', 'deaths', 'suicides', 'hits', 'misses']
stat_order = ['avg. lifet.', 'avg. dmg', 'kills', 'deaths', 'suicides', 'hits', 'misses']

while i < matches:
if i in range(0, matches, max(int(matches/10), 1)):
print("Match %i" % i)

team1 = Party(name='Team A')
team1.add(copy.deepcopy(troll))
team1.add(copy.deepcopy(troll))
team1.add(copy.deepcopy(troll))
team1.add(copy.deepcopy(troll))
team1.add(copy.deepcopy(giant_crocodile))

team1.set_formation((0, 3, 0))

team2 = Party(name='Team B')
team2.add(copy.deepcopy(orc))

team2.add(copy.deepcopy(purple_worm))
team2.add(copy.deepcopy(purple_worm))
team2.add(copy.deepcopy(purple_worm))
team2.add(copy.deepcopy(mammoth))
team2.add(copy.deepcopy(skeleton))
team2.set_formation((0, -3, 0))

x = Encounter(team1, team2)
Expand Down
7 changes: 4 additions & 3 deletions weapons.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,13 +46,14 @@ def use(self, source, target, always_hit=False):
#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:
""" Apply weapon's special abilities on target unless the target is
already dead """
if self.special and not target.is_dead:
for on_hit_effect in self.special:
on_hit_effect.use(source, target, total_damage, crit_multiplier)

class MultiWeapon(Weapon):

def __init__(self, **kwargs):
super().__init__(**kwargs)
self.multiattack = True
self.multiattack = True

0 comments on commit b32b5c7

Please sign in to comment.