- Joined
- Apr 5, 2011
- Messages
- 245
(Multiple questions throughout the post)
I wanna talk about IsUnitInRange function.
Question 1: I should always check if IsUnitInRect before (to prevent a lot of calculations), do I?
Question 2: I should always use squared range constants if calculate distance by geometry (to not use square root), do I?
Question 3: How works UnitInRange event? Does it calculate distances periodically (with rects probably) or something kind of ... smart?
Then I got an idea, that needs to be discussed as well.
In most cases this function uses .../600/700/800/...10N range. There is no real need in more sharpness for most triggered spells.
So, there is an idea to create a function that determines result approximately (but still with high accuracy).
1. Function has a spectre of 100/200/300/.../5000 distances
(50 values)
Let's call this an integer array R[50], R = 100 * i, i = 1..50
2. There is a constant (in that meaning that it is calculated once) real array K[50], K = 100 / R (= 1 / i), i = 1..50
3. There is a boolean array C[2500] that represents an image of 1/4 circle (with some special indexing probably, have not thought about it yet)
4. Condition itself:
(C array supposed to have simple 2D indexing here)
Question 4: Is this viable idea?
I wanna talk about IsUnitInRange function.
Question 1: I should always check if IsUnitInRect before (to prevent a lot of calculations), do I?
Question 2: I should always use squared range constants if calculate distance by geometry (to not use square root), do I?
Question 3: How works UnitInRange event? Does it calculate distances periodically (with rects probably) or something kind of ... smart?
Then I got an idea, that needs to be discussed as well.
In most cases this function uses .../600/700/800/...10N range. There is no real need in more sharpness for most triggered spells.
So, there is an idea to create a function that determines result approximately (but still with high accuracy).
1. Function has a spectre of 100/200/300/.../5000 distances
(50 values)
Let's call this an integer array R[50], R = 100 * i, i = 1..50
2. There is a constant (in that meaning that it is calculated once) real array K[50], K = 100 / R (= 1 / i), i = 1..50
3. There is a boolean array C[2500] that represents an image of 1/4 circle (with some special indexing probably, have not thought about it yet)
4. Condition itself:
JASS:
return C[R2I(Abs(x - x0) * K[Range]), R2I(Abs(y - y0) * K[Range])]
Question 4: Is this viable idea?
Last edited: