Return to repo list

heart-of-gold

Tactical RPG written in python, using pygame.
Return to HMagellan.com

commit 0afd464a03ccdca725fe4d14a8af1748a7991df5
parent 4a09ddf982532784490df20cf4009f1a70d4b5e3
Author: Erik Letson <hmagellan@hmagellan.com>
Date:   Tue, 22 Dec 2020 14:47:05 -0600

better guard anim changeout and added simple guard element to damage calc

Diffstat:
Msrc/piece.py | 14++++++++++++--
Msrc/turn.py | 6++++--
2 files changed, 16 insertions(+), 4 deletions(-)

diff --git a/src/piece.py b/src/piece.py @@ -555,6 +555,11 @@ class Piece(entity.Entity): raw_damage = 0 hit = False + # Next, figure in guarding + guard_factor = 1 + if self.guarding: + guard_factor = 0.5 + # Next, notation handling for n in notations: if n == ATTACK_NOTATIONS.backattack: @@ -574,7 +579,7 @@ class Piece(entity.Entity): if raw_damage <= 0: self.damage_to_receive = 0 else: - self.damage_to_receive = max(0, round(((raw_damage - (self.active_stats["DEF"] * 1.4)) + random.randint(-(self.active_stats["LUK"] // 2), self.active_stats["LUK"])) * affmod)) + self.damage_to_receive = max(0, round(((raw_damage - (self.active_stats["DEF"] * 1.4)) + random.randint(-(self.active_stats["LUK"] // 2), self.active_stats["LUK"])) * affmod * guard_factor)) self.damage_timer = 100 if hit: self.being_damaged = True @@ -732,6 +737,8 @@ class Piece(entity.Entity): if self.active_stats["HP"] <= 0: self.manager.kill_piece(self) self.manager.bus.perform_turn_manager_kill_piece(self) + elif self.guarding: + self.set_animation(self.sheet.animations["block_" + self.facing.name], True) else: self.set_animation(self.sheet.animations["stand_" + self.facing.name], True) self.manager.bus.perform_turn_manager_refresh_state() @@ -741,7 +748,10 @@ class Piece(entity.Entity): if self.damage_timer == 68: self.set_animation(self.sheet.animations["dodge_" + self.facing.name], True) elif self.damage_timer == 60: - self.set_animation(self.sheet.animations["stand_" + self.facing.name], True) + if self.guarding: + self.set_animation(self.sheet.animations["block_" + self.facing.name], True) + else: + self.set_animation(self.sheet.animations["stand_" + self.facing.name], True) else: self.dodging = False self.damage_notations = [] diff --git a/src/turn.py b/src/turn.py @@ -100,8 +100,10 @@ class TurnManager(manager.Manager): self.current_active_piece.taking_turn = True self.current_active_piece.has_moved = False self.current_active_piece.has_acted = False - self.current_active_piece.has_guarded = False - self.current_active_piece.guarding = False + if self.current_active_piece.has_guarded: + self.current_active_piece.has_guarded = False + self.current_active_piece.guarding = False + self.current_active_piece.set_animation(self.current_active_piece.sheet.animations["stand_" + self.current_active_piece.facing.name], True) self.camera.snap_to_position(self.current_active_piece.rect.center) # Predict the next turn order