• 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.

[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