Closed pkillthetoy closed 7 months ago
You are right, I messed up there. I'll have a look soon what parts of the code use the distance calculation. I think the only other part is the lightning scroll. I don't know if using Chebyshev distance should be used for the lightning scroll, as it might make judging the distance unintuitive for players. However, I do like the idea to fully committing to Chebyshev instead of Euclidian.
does this fix work as intended? it nukes all orcs in my screen. with radius being 3 and having identical code for fireball scroll.
Used the fireballs i had on me without moving from my spawn tile. killed the orcs outside my vision and the radius.
the red dot thingies are corpses.
First of all I really like what you've done with the visuals! Unfortunately though, I cannot reproduce the bug you're describing. Using the code from part 9 I am now able to affect orcs in the corner of the targeting square, but orcs outside it remain unaffected. Does the same happen with the lightning scroll? Could you maybe use a breakpoint to check what happens in the distance calculation / fireball scroll?
Hmm, alright, so it is on my end. makes sense, but i had to make sure.
also: Thanks! was going more for a surface with forests vibe, and used this tutorial as a small starting point with godot. thank you for your hardwork.
I am terribly sorry @Devengel, I did not test properly/enough. You were right (at least three quarters right). I forgot to take the absolute values of the relative vector. That means that it works properly in one quadrant, but results in negative distances in the other four. Incidentally, when I tried it out the enemies outside the fireball range happened to be in the right quadrant, which is why it looked to me as if everything worked as it should.
The proper distance calculation looks as follows:
func distance(other_position: Vector2i) -> int:
var relative: Vector2i = other_position - grid_position
return maxi(abs(relative.x), abs(relative.y))
I'll soon upload the corrected version.
No need to apologize and thank you for your work as always
The reticle for aiming the fireball draws a rectangle around the selected tile. But the fireball consumable uses euclidean distance instead of the max-of-abs distance used by enemies to determine if they're within range 1 of the player (I forget the name).
Because of this, increasing fireball radius and then trying to clip an enemy with the corner of it will fail to affect them.