• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

[Snippet] UnitRallyPoint

This resource provides you with 2 nifty functions that return the coordinates of a unit's rally point.

JASS:
/*******************************************
*
*   UnitRallyPoint
*   v1.0.0.0
*   By Magtheridon96
*
*   - Provides GetUnitRallyPointX and GetUnitRallyPointY
*
*   API:
*   ----
*
*       - function GetUnitRallyPointX takes unit u returns real
*           - Returns the x coordinate of the rally point for a given unit
*       - function GetUnitRallyPointY takes unit u returns real
*           - Returns the y coordinate of the rally point for a given unit
*
*******************************************/
library UnitRallyPoint
    
    globals
        private location loc
    endglobals
    
    function GetUnitRallyPointX takes unit u returns real
        local real x
        set loc = GetUnitRallyPoint(u)
        set x = GetLocationX(loc)
        call RemoveLocation(loc)
        return x
    endfunction
    
    function GetUnitRallyPointY takes unit u returns real
        local real y
        set loc = GetUnitRallyPoint(u)
        set y = GetLocationY(loc)
        call RemoveLocation(loc)
        return y
    endfunction
    
endlibrary

Short, sweet and simple.
Feel free to comment..
 
You could also save the rally point via order event.

That's exactly what I did at first, but then I thought:

how would you need it frequently?

And thus, I realized that the overhead is extremely large when compared to how often this function will be used :p

edit
Either way, I'll put this in the SCS.

edit
Ok, TO THE GRAVEYARD WITH THIS.
 
Top