• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[JASS] Non Understood Syntax :P

Status
Not open for further replies.
Level 9
Joined
Jun 7, 2008
Messages
440
Ive been trying to figure this out for a little while now, while I know this is kinda getting redundant, I'm really not sure why this syntaxed.
JASS:
    local unit u = GetTriggerUnit()
    local player p = GetOwningPlayer(u)
    local group g = CreateGroup()
    local real array x
    local real array y
    local location array t
    set x [0] = (GetRandomReal(GetRectMinX(gg_rct_Start_2), GetRectMaxX(gg_rct_Start_2)))
    set x [1] = (GetRandomReal(GetRectMinX(gg_rct_End_2), GetRectMaxX(gg_rct_End_2)))
    set y [0] = (GetRandomReal(GetRectMinY(gg_rct_Start_2), GetRectMaxY(gg_rct_Start_2)))
    set y [1] = (GetRandomReal(GetRectMinY(gg_rct_End_2), GetRectMaxY(gg_rct_End_2)))
    set t [0] = Location(x[0],y[0])
    set t [1] = Location(x[1],y[1])
    if udg_Lives[GetPlayerId(Player(1))] > 0 then
        if p != Player(1) then
            call SetUnitPositionLoc(u, t[0])
            IssuePointOrderLoc( u, "move" , t[1])//<<<<My Syntax (My Location Syntaxed)
        elseif p == Player(1) then
            call SetUnitPositionLoc(u, t [1])
        endif
    endif

I have not posted the entire trigger, due to the fact that the syntax has already appeared. The variables have been nullified.

Another question : It was said that reals dont leak. Does that include coordinates for Rects?
 
Level 14
Joined
Nov 18, 2007
Messages
1,084
so if I used:
JASS:
 CALL IssuePointOrderLoc( u, "move" , Location (x,y))
Would be faster and would not leak a location?
Oh no, that would cause a leak because Location creates a location.

Do this:
JASS:
call IssuePointOrder(u,"move",x,y)
Similarly
JASS:
call SetUnitPosition(u,x,y)
or even SetUnitX/SetUnitY though that's slightly different since it ignores unit pathing.
 
Level 40
Joined
Dec 14, 2005
Messages
10,532
Or if you want to do, say, sorting, although that isn't as relevant in a language like JASS.

That said, arrays are not a very significant performance hit but they are certainly bad form from a readability perspective when you are just using them instead of two or more independent variables. If you aren't at least sometimes accessing an array element with a non-constant index then you shouldn't be using an array.
 
Status
Not open for further replies.
Top