Praytic / youtd2

Classic community-driven session-based Tower Defense game with RPG elements.
https://youtd2.com/
MIT License
97 stars 17 forks source link

Range check for tower attacks is off by 8 #472

Closed PiotrKaszuba closed 1 month ago

PiotrKaszuba commented 1 month ago

Observations:

range_checks2

Zrzut ekranu 2024-10-11 225219

Zrzut ekranu 2024-10-11 225354

Zrzut ekranu 2024-10-11 225449

Zrzut ekranu 2024-10-11 225548

My initial idea would be to fix _target_is_valid in tower.gd by adding: attack_range = Utils.apply_unit_range_extension(attack_range, _attack_target_type)

Kvel2D commented 1 month ago

From these notes, I mainly see that Tower._update_target_list() has a bug about RANGE_CHECK_BONUS_FOR_OTHER_UNITS.

  1. It calls Utils.get_units_in_range() which adds RANGE_CHECK_BONUS_FOR_OTHER_UNITS
  2. It also calls _target_is_valid() which does NOT add RANGE_CHECK_BONUS_FOR_OTHER_UNITS

I can confirm, current behavior is incorrect.

This fix is fine:

My initial idea would be to fix _target_is_valid in tower.gd by adding: attack_range = Utils.apply_unit_range_extension(attack_range, _attack_target_type)