What's wrong with this one? - Replacing a unit and giving items to it

leo120120

New Member
Reaction score
0
When i try to do that when you finish the upgrading of a building, you get a replace of that building and you recieve the items of the old building to the new one, bui went i go to test it, you get the replacement but the items dissapear.


Trigger:
  • LoboFantasmagorico
    • Events
      • Unit - A unit Finishes an upgrade
    • Coditions
      • (Unit-type of (Triggering unit)) Equal to Lobo Fantasmagorico
    • Actions
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hashtable - Save Handle Of(Item carried by (Triggering unit) in slot (Integer A)) as (Integer A) of (Player number of (Owner of (Triggering unit))) in items
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Drop (Load (Integer A) of (Player number of (Owner of (Triggering unit))) in items) from (Trained unit)
      • Unit - Replace (Triggering unit) with a (Unit-type of (Triggering unit)) using The old unit's relative life and mana
      • Set unitB[(Player number of (Owner of (Triggering unit)))] = (Last replaced unit)
      • Unit - Order (Last replaced unit) to Stop
      • For each (Integer A) from 1 to 6, do (Actions)
        • Loop - Actions
          • Hero - Give (Load (Integer A) of (Player number of (Owner of (Triggering unit))) in items) to unitB[(Player number of (Owner of (Triggering unit)))]
      • Unit - Set level of Desfase Astral (este si) for (Last created unit) to 2
      • Item - Pick every item in (Region centered at (Position of (Last created unit)) with size (128.00, 128.00)) and do (Actions)
        • Loop - Actions
          • Hero - Give (Picked item) to (Last created unit)


Maybe add some waits? i don't know...
 

Avaleirra

Is back. Probably.
Reaction score
128
It would probably jsut be easier to do al of that like this:

Trigger:
  • Events
    • A unit finishes an upgrade
    • Conditions
    • (Unit-type of (Triggering unit)) Equal to Lobo Fantasmagorico
    • Actions
    • unit - add chaos to triggering unit


jsut make a custom chaos ability
 

mylemonblue

You can change this now in User CP.
Reaction score
7
So adding Chaos to a unit through upgrades/triggers morphis it to the unit specified in the Data field? That is how that ability works? I've been doing it wrong all this time o_O
 

leo120120

New Member
Reaction score
0
What exactly adding to a unit chaos does? i have a building that when it upgrades the it allows the training of various units, but also i need that the building keeps some items, so the problem is that when you upgrade it, the units that you can train there don't appaer, so i have to replace the builidng with another similar, but now i have the problem that the items dissapear...

I don't know how to explain it better...
 

mylemonblue

You can change this now in User CP.
Reaction score
7
Remember in the RoC orc campaign where the orcs drank from the blood well? They used the Chaos abiklity to swap unit types.
 

leo120120

New Member
Reaction score
0
I tried, and it worked, but the training units don't show up, so is like the same thing that upgrading without adding chaos, and don't really solve the problem...
 

leo120120

New Member
Reaction score
0
Problem solved by the original way (with (replacing unit) and hashtables), the problem was that i never did the Hashtable - Create a new table part :p , here is the final code if anyone can find it useful:

Trigger:
  • LoboFantasmagorico
    • Events
      • Unit - A unit Finishes an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Lobo Fantasmagorico
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Triggering unit) is selected by (Owner of (Triggering unit))) Equal to True
        • Then - Actions
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hashtable - Save Handle Of(Item carried by (Triggering unit) in slot (Integer A)) as (Integer A) of (Player number of (Owner of (Triggering unit))) in items
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hero - Drop (Item carried by (Triggering unit) in slot (Integer A)) from (Triggering unit)
          • Unit - Replace (Triggering unit) with a (Unit-type of (Triggering unit)) using The old unit's relative life and mana
          • Unit - Order (Last replaced unit) to Stop
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hero - Give (Load (Integer A) of (Player number of (Owner of (Last replaced unit))) in items) to (Last replaced unit)
          • Selection - Select (Last replaced unit) for (Owner of (Last replaced unit))
        • Else - Actions
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hashtable - Save Handle Of(Item carried by (Triggering unit) in slot (Integer A)) as (Integer A) of (Player number of (Owner of (Triggering unit))) in items
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hero - Drop (Item carried by (Triggering unit) in slot (Integer A)) from (Triggering unit)
          • Unit - Replace (Triggering unit) with a (Unit-type of (Triggering unit)) using The old unit's relative life and mana
          • Unit - Order (Last replaced unit) to Stop
          • For each (Integer A) from 1 to 6, do (Actions)
            • Loop - Actions
              • Hero - Give (Load (Integer A) of (Player number of (Owner of (Last replaced unit))) in items) to (Last replaced unit)



:thup:
 
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