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

Better way to stack dummies (w/ out structs)

Status
Not open for further replies.
Level 7
Joined
Apr 27, 2011
Messages
272
Is this method better
JASS:
library DummyStack 
//===========================================================================
    globals
        private group G=CreateGroup()
    endglobals
    
//===========================================================================
    function NewDummy takes player pl, real x, real y, real f returns unit
        local unit u=FirstOfGroup(G)
        if(u==null)then
            set u=CreateUnit(...)
        else
            call SetUnitOwner(...)
            ...
            call GroupRemoveUnit(G,u)
        endif
        return u
    endfunction
    
//===========================================================================
    function RecycleDummy takes unit u returns nothing
        call SetUnitOwner(u,Player(15),false)
        call GroupAddUnit(G,u)
    endfunction
    
//===========================================================================
endlibrary

than just using an instance counter and an unit array?
 
It allocates a handle, and units in a group take up more RAM than units in an array,
however this method is doable. The only issue is that dummy recycling should only
be used for projectile systems. For casters, you can use one dummy unit for all
purposes. So using this system would not be good because projectile units need to
have instant, correct facing when launched, but turn speed takes time. I advise
indexing recycled dummy units by the direction they're facing and if the requested
facing value is accurate to the nearest 45 degrees then use a recycled dummy, else
create a new dummy.
 
Status
Not open for further replies.
Top