Snippet ReplaceUnit

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
As mentioned in a thread a few days ago, and as suggested by Mr. Zero,
I'd like to submit a snippet of code that can be helpful at times:

For some reason it can be useful to add the locust ability to units, to make them unselectable. But once locust is on, it can't be taken off again. To get the units back to normal nonetheless, they have to be replaced, and that's where my few lines set in:

JASS:
function ReplaceUnit takes nothing returns nothing
local unit u=GetEnumUnit()
call CreateUnit(GetOwningPlayer(u), GetUnitTypeId(u), GetUnitX(u), GetUnitY(u), GetUnitFacing(u))
call RemoveUnit(u)
set u=null
endfunction


as a further little annotation: the units have to be grouped before adding locust.
 

~GaLs~

† Ғσſ ŧħə ѕαĸε Φƒ ~Ğ䣚~ †
Reaction score
180
erm...locust can be remove.....

It is by
First hide that unit
Remove that locust
Unhide that unit
____________________
What is snippet?
and what is GetEnumUnit() ?
 

Prometheus

Everything is mutable; nothing is sacred
Reaction score
589
Snippet is just a piece of code.
GetEnumUnit() = Picked Unit in GUI
 

Doomhammer

Bob Kotick - Gamers' corporate spoilsport No. 1
Reaction score
67
GetEnumUnit won't do it, once your unit has locust on. You can't even group units once they have the locust ability, otherwise I wouldn't make the effort to replace them.

go for it and find out yourself. Don't forget to come back and report your results.
 

Hero

─║╣ero─
Reaction score
250
OK even if this works...it will be Tedious when adding Locust to a Hero that has certain skills learned and what not
 
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