Range check for tower attacks is off by 8
Closed this issue · 1 comments
PiotrKaszuba commented
Observations:
- a lot of range checks (one per creep I assume) when creeps out of range - would the same apply for every tower * every creep?
- when in range - checks are much more rare (when attack is ready). I get that it is known and optimized specifically for bonus round when towers almost always have attacks on cooldowns
- however, we get one check with 772 range - most likely missing +8 from RANGE_CHECK_BONUS_FOR_OTHER_UNITS
- same for this boss
- we get some checks that would allow the boss to be attacked (distance 777) range: 780 from code (tower.gd):
var creeps_in_range: Array = Utils.get_units_in_range(self, _attack_target_type, get_position_wc3_2d(), attack_range)
- and other one that does not (distance 772) in tower.gd too:
'var target_is_valid: bool = _target_is_valid(new_target)'
- and then checks get less frequent but still 780 and 772:
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
From these notes, I mainly see that Tower._update_target_list()
has a bug about RANGE_CHECK_BONUS_FOR_OTHER_UNITS
.
- It calls
Utils.get_units_in_range()
which addsRANGE_CHECK_BONUS_FOR_OTHER_UNITS
- It also calls
_target_is_valid()
which does NOT addRANGE_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)