Skip to content

Commit

Permalink
Clamp displayed attackspeed value
Browse files Browse the repository at this point in the history
When displaying in tower details
It was clamped before, but only when calculating cooldown
  • Loading branch information
Kvel2D committed Mar 7, 2024
1 parent a8bf981 commit 1cece46
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
2 changes: 1 addition & 1 deletion Scenes/Towers/Tower.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1131,7 +1131,7 @@ func get_base_attackspeed() -> float:
func get_current_attackspeed() -> float:
var attackspeed: float = get_base_attackspeed()
var attackspeed_mod: float = get_attackspeed_modifier()
var current_attackspeed: float = attackspeed / clampf(attackspeed_mod, Constants.MOD_ATTACKSPEED_MIN, Constants.MOD_ATTACKSPEED_MAX)
var current_attackspeed: float = attackspeed / attackspeed_mod

return current_attackspeed

Expand Down
14 changes: 13 additions & 1 deletion Scenes/Unit/Unit.gd
Original file line number Diff line number Diff line change
Expand Up @@ -1391,8 +1391,20 @@ func get_spell_crit_chance() -> float:
func get_spell_crit_damage() -> float:
return max(1.0, _mod_value_map[Modification.Type.MOD_SPELL_CRIT_DAMAGE])


# NOTE: in original game, attackspeed mod is not clamped
# when displayed, only when used. So if attackspeed is -50%
# it would show as "-50%" in tower details but would
# actually by clamped to the min value (20%).
#
# Changed it so that both displayed and actually used values
# are clamped.
func get_attackspeed_modifier() -> float:
return _mod_value_map[Modification.Type.MOD_ATTACKSPEED]
var attackspeed_mod: float = _mod_value_map[Modification.Type.MOD_ATTACKSPEED]
attackspeed_mod = clampf(attackspeed_mod, Constants.MOD_ATTACKSPEED_MIN, Constants.MOD_ATTACKSPEED_MAX)

return attackspeed_mod


func get_level() -> int:
return _level
Expand Down

0 comments on commit 1cece46

Please sign in to comment.