Merging Buildings

santicpp

New Member
I'm creating a td where you can merge a tower when you have at least two of the same kind.

I have this trigger:
Trigger:
  • UpgradeWhiteT1
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
    • Actions
      • Set VariableSet TempGroup = (Units owned by (Triggering player) matching ((Unit-type of (Matching unit)) Equal to [Tier 1] White Tower).)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup) Greater than or equal to 2
        • Then - Actions
          • Unit Group - Remove (Triggering unit) from TempGroup.
          • Unit - Remove (Random unit from TempGroup) from the game
          • Unit - Replace (Triggering unit) with a [Tier 1] White Tower using The old unit's relative life and mana
        • Else - Actions
      • Custom script: call DestroyGroup(udg_TempGroup)


The trigger is working almost perfect, but: when i have more than 1 tower in my selection it doesnt work properly.
For example:
If i have 7 towers in my selection, the trigger replaces 4 of them instead of 3.
I tried to add a for each selected unit but its not working.
 

Squeekems

TH.net Regular
Immediate issue:
There is no Triggering player associated with the event you are using.
There is a Triggering Unit and you can refer to the Owner of Triggering Unit.

As for you problem:
Maybe you can find a way to label 2 towers as a pair. Do something when a Tower is finished being constructed to label it. Maybe set a custom value to all but 1 tower when there is an uneven number.
 
General chit-chat
Help Users
  • No one is chatting at the moment.

    Staff online

    • Ghan
      Administrator - Servers are fun

    Members online

    Affiliates

    Hive Workshop NUON Dome World Editor Tutorials

    Network Sponsors

    Apex Steel Pipe - Buys and sells Steel Pipe.
    Top