Unit Recycling

PurgeandFire

zxcvmkgdfg
Reaction score
509
I seem to have some problems with dummy unit recycling.

I have a spell which basically starts out with units revolving around the caster. After 5 seconds are up it stops. (It does more if units are in range, but this is just the part I'm trying to focus on)

Since I shouldn't create/remove units every time I cast the spell, I tried the whole "ShowUnit()" recycling method. The problem is, is that these dummies have locust. When I use the spell, it works fine the first time, but the second time I am able to select the dummies. I tried adding locust after the unit was displayed, and I also tried adding the units after they are hidden, but it didn't work...

If needed, I can post the code. But it is most likely a mess since I'm not up-to-date on the most efficient way to code, and it with recycling isn't even functional at the moment. (The one without dummy recycling works fine)
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
Recycling is good. But you need to limit the number of units in recycle bin, else the map will lag.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
hiding a unit does something with locust doesn't it?
 

PurgeandFire

zxcvmkgdfg
Reaction score
509
Recycling is good. But you need to limit the number of units in recycle bin, else the map will lag.

Could I get an example of that? But anyway, I think for right now I shouldn't worry about the final result since there is still this problem.

hiding a unit does something with locust doesn't it?

Yep, it removes it. I am not sure whether or not you need to use the RemoveAbility(u,'Aloc'). I don't have that anywhere in my code, my unit has the locust ability in the object editor, and it still gets removed. It is also using the same units, so it must be the hiding that's being done when they get recycled. :(
 

Kenny

Back for now.
Reaction score
202
I'm pretty sure that to recycle units you are meant to do something like this:

JASS:
//--------------------------------------------------
// When released:
call UnitRemoveAbility(Unit,'Aloc')
call ShowUnit(Unit,false)
// Optionally:
call PauseUnit(Unit,true)
call SetUnitPosition(Unit,X,Y) // X and Y should be somewhere safe.

//--------------------------------------------------
// When retrieved:
call ShowUnit(Unit,true)
call UnitAddAbility(Unit,'Aloc')
// Optionally:
call PauseUnit(Unit,false)
call SetUnitPosition(Unit,X,Y) // X and Y should be the new coordinates of the dummy.
 

Narks

Vastly intelligent whale-like being from the stars
Reaction score
90
you could probably move it off the normal map bounds (like x-coordinate -999999, I only think very high y-coordinates cause a crash)
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
According to Vexorian it can crash if the unit is outside the whole map (GetWorldBounds()), but not immediately, it's more like you are putting a children in a little room with a red button that mustn't be pressed, soon or late it will be pressed.

It doesn't crash when it's outside the playable map area though (bj_....)
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top