Need equation or method

MasterOfRa

New Member
Reaction score
10
I'm trying to make a ability that creates a bolt of lightning that goes for a certain distance, or till it hits the edge of the map. it will be a bolt of lightning, instantly going the the end point of the line, and i need a way to determine the end point from inputting the start point, the (angle or dx,dy) and the distance.

I could of course use a loop that goes down the line, checking until it gets the the edge, but that would be inefficient.
 

Exide

I am amazingly focused right now!
Reaction score
448
Easiest way to do it is probably to draw four regions, like a border.
Then have a trigger remove any *Lightning Bolt Unit* that enters any of these regions.
 

MasterOfRa

New Member
Reaction score
10
im not useing a dummy unit as a missile, here is the map which lets you see what the problem is

Here is the function that isnt working

JASS:
function GetEdgePoint takes real x, real y, real radians returns nothing
    local real deltaY
    set deltaY = Tan(radians)*(MAP_SIZE - RAbsBJ(x))
    if RAbsBJ(deltaY + y) <= MAP_SIZE then
        set TempReal_Y = deltaY + y
        set TempReal_X = RSignBJ(x)*MAP_SIZE
    else
        set deltaY = MAP_SIZE - RAbsBJ(y)
        set TempReal_Y = RSignBJ(y)*MAP_SIZE
        set TempReal_X = deltaY / Tan(radians)
    endif
endfunction
 

Rainther

I guess I should write something of value here...
Reaction score
61
I tried with comming up with some kind of efficient method, but I didn't make it, so I made this simple thingie instead :D
JASS:
function OrbitX takes real X, real dist, real angle returns real
    return ( X + dist * Cos(angle * bj_DEGTORAD) )
endfunction

function OrbitY takes real Y, real dist, real angle returns real
    return ( Y + dist * Sin(angle * bj_DEGTORAD) )
endfunction

//use it as function or something
    local real Dis = 25
    local real x = GetUnitX(caster)
    local real y = GetUnitY(caster)
    local real Angle = GetUnitFacing(caster) //or Anglebetween unit and spelltarget point, it's safier
    loop
        set x = OrbitX(x,Dis+25,Ang)
        set y = OrbitY(y,Dis+25,Ang)
        exitwhen x > GetRectMaxX(bj_mapInitialPlayableArea) or x < GetRectMinX(bj_mapInitialPlayableArea) or y > GetRectMaxY(bj_mapInitialPlayableArea) or y < GetRectMaxY(bj_mapInitialPlayableArea)
        return Dis
    endloop
It's supposed to loop until either x or y gets outside playable map. And when you have the distance you can repeat the moving a number of times as returned distance / move speed per loop.
 

Weep

Godspeed to the sound of the pounding
Reaction score
400
This works:

JASS:
function MapBoundsIntersectionRad takes location A, real angle returns location
    local real Sine = Sin(angle)
    local real Cosine = Cos(angle)
    local real x = 9999999999.
    local real y = 9999999999.
    if(Sine > 0) then
        set x = GetLocationX(A) + (GetRectMaxY(bj_mapInitialPlayableArea) - GetLocationY(A))*Cosine/Sine
    elseif(Sine < 0) then
        set x = GetLocationX(A) + (GetRectMinY(bj_mapInitialPlayableArea) - GetLocationY(A))*Cosine/Sine
    endif
    if(Cosine > 0) then
        set y = GetLocationY(A) + (GetRectMaxX(bj_mapInitialPlayableArea) - GetLocationX(A))*Sine/Cosine
    elseif(Cosine < 0) then
        set y = GetLocationY(A) + (GetRectMinX(bj_mapInitialPlayableArea) - GetLocationX(A))*Sine/Cosine
    endif
    return Location(RMaxBJ(RMinBJ(x, GetRectMaxX(bj_mapInitialPlayableArea)),GetRectMinX(bj_mapInitialPlayableArea)), RMaxBJ(RMinBJ(y, GetRectMaxY(bj_mapInitialPlayableArea)),GetRectMinY(bj_mapInitialPlayableArea)))
endfunction

function MapBoundsIntersectionDeg takes location A, real angle returns location
    return MapBoundsIntersectionRad(A, angle * bj_DEGTORAD)
endfunction
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top