Snippet CloneUnit

tooltiperror

Super Moderator
Reaction score
231
JASS:
// Script by Blade.dk
// wc3jass
function CloneUnit takes unit whichUnit, player cloneOwner, real cloneX, real cloneY, real cloneFacing returns unit
    local unit clone
    local gamecache g = InitGameCache("CloneCache.w3v")
    call StoreUnit(g, "clone", "clone", whichUnit)
    set clone = RestoreUnit(g, "clone", "clone", cloneOwner, cloneX, cloneY, cloneFacing)
    call SetUnitState(clone, UNIT_STATE_LIFE, GetUnitState(whichUnit, UNIT_STATE_LIFE))
    call SetUnitState(clone, UNIT_STATE_MANA, GetUnitState(whichUnit, UNIT_STATE_MANA))
    call FlushGameCache(g)
    set g = null
    return clone
endfunction

Perfectly clones a unit. Carries over things like buffs and items and all that jazz (using the other BJ won't).

I figured it was big enough to be a snippet if IsPositionPathable and that stuff is :)
 

tooltiperror

Super Moderator
Reaction score
231
Yeah, this is ready to be graveyarded D:
 

Bribe

vJass errors are legion
Reaction score
67
CloneCache.w3v
cloneOwner
cloneFacing

You didn't even use SetWidgetLife() as you know it's faster. There is no conceivable way you didn't just copy & paste the function.
 

Sevion

The DIY Ninja
Reaction score
413
I'm going to have to agree. The script is literally word for word, letter for letter exactly the same.
 

tooltiperror

Super Moderator
Reaction score
231
I replaced my original script with Blade's because it was obviously better, in case someone searches for cloning units and finds the old one (not good to spread out around bad code) so chill. I'll add in a note to the first post.
 

Sevion

The DIY Ninja
Reaction score
413
You already know that there are improvements available to the existing code. Make the changes. No good to spread out around bad code.

At any rate. There still is no note on the first post.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top