Duplicating a unit

cmann

New Member
Reaction score
1
Is there a way to duplicate a unit that has been placed inside the World Editor?

Using 'Create units of unit type' just makes a unit of the same unit type, what I need is it to copy that units hit-points, mana, dropped items and if it's a hero - strength, inventory, abilities...

Is there a way to do this?
 

tommerbob

Minecraft. :D
Reaction score
110
You could store all of the unit's data inside a hashtable (level, stats, items, etc.), and then create a unit of the same type, and then give the new unit the same data that you stored in the hashtable.
 

Moridin

Snow Leopard
Reaction score
144
The only way I can think of duplicating heroes is saving all their relevent data (level, abilities, inventory, etc) into variables, and then doing the whole:

1) Create a unit of the same type
2) Set it to the correct level
3) Make it learn the right skills
4) Give it the same items
5) Transfer ownership to right player.
 

cmann

New Member
Reaction score
1
Thanks.
I thought that maybe there was a single command to do this but I guess I''l just have to do it myself.

Another question : Is there a way to check if a unit is a hero?
 

Bogrim

y hello thar
Reaction score
154
Yes, it's a unit classification under boolean comparisons ("Unit is A hero Equal to True").
 

cmann

New Member
Reaction score
1
Thanks.

Now how do I find out what items a unit drops and add it to the duplicate unit?
 

cmann

New Member
Reaction score
1
So after some searching it seems like copying a unit might not be completely possible.

Copying the life and mana can be done.
Copying a hero's level can be done.
Copying a hero's attributes seems to be possible.
Copying a hero's inventory seems to be possible.

What you can't seem to do though is
- find out all of a hero's abilities and the level or
- finding out what items a unit drops.

Can anybody confirm this?
Or maybe if this can be done point me in the right direction.
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
just use game cache. save the unit and load it again, BAAAM exact copy.
by the way this is what campaigns use to take the hero from one map into an other so its absolutely safe.
 

cmann

New Member
Reaction score
1
That's exactly what I was looking for, it copies an entire unit in a single easy step.
The only problem is that it doesn't seem to copy the items that the unit is set to drop.
Is there absolutely no way to do it?
 

Accname

2D-Graphics enthusiast
Reaction score
1,464
as far as i know you cannot check items a unit drops (i might be wrong though) so you would have to make a workaround.
either trigger a item-drop-system yourself, like:
(BEWARE Handwritten)
Trigger:
  • Events
    • Unit - A unit dies
    • Conditions
      • (Unit type of (Triggering Unit)) Equal Bandit
    • Actions
      • set TempPoint = (Position of (Triggering unit))
      • Item - create potion at TempPoint
      • custom script: call RemoveLocation (udg_TempPoint)

or maybe add the items a neutral unit shall drop inside its inventory. give all creeps an inventory which doesnt allow them to use items make a trigger like:
(BEWARE Handwritten)
Trigger:
  • Events
    • Unit - A unit dies
    • Conditions
      • (Owner of (Triggering unit)) Equal to Neutral Hostile
    • Actions
      • set TempPoint = (Position of (Triggering unit))
      • For each (IntegerA) from 1 to 6, do (Actions)
        • loop - Actions
          • Item - Create (Item-type of (Item carried by (Triggering unit) in slot (Integer A))) at TempPoint
      • custom script: call RemoveLocation (udg_TempPoint)


pros of the second method:
is rather easy, doesnt need to have that many if/then/else statements

cons
no item pools and a limit of 6 items to be dropped by a creep at once.
 

cmann

New Member
Reaction score
1
That's unfortunate. I think for now I can go without any item drops but later on if I find really do want it, I'll probably use the second method.
 
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