Exfyre
hmm...
- Reaction score
- 60
As the title says, I'm adding rects to a region in small amounts in order to form a straight line from one point to another based on the units' distances and specified Area of effect.
I've changed this so many times that I don't even know what I'm looking at anymore.
My code:
assume
AOE = 25
RADIUS = 1000
I've changed this so many times that I don't even know what I'm looking at anymore.
My code:
assume
AOE = 25
RADIUS = 1000
Code:
set xt = 0
set yt = 0
set dx = x2 - x1
set dy = y2 - y1
set dist = SquareRoot(dx * dx + dy * dy)
set o = 0
loop
set o = o + 1
if x1 < x2 and y1 < y2 then
set xt = xt + dx/dist
set yt = yt + dy/dist
endif
if x1 > x2 and y1 < y2 then
set xt = xt - dx/dist
set yt = yt + dy/dist
endif
if x1 < x2 and y1 > y2 then
set xt = xt + dx/dist
set yt = yt - dy/dist
endif
if x1 > x2 and y1 > y2 then
set xt = xt - dx/dist
set yt = yt - dy/dist
endif
call RegionAddRect(rr, Rect(x1+xt*RADIUS-AOE/2, y1+yt*RADIUS-AOE/2, x1+xt*RADIUS+AOE/2, y1+yt*RADIUS+AOE/2))
exitwhen o == dist
endloop