• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

Trigger involving unloading and loading units

Status
Not open for further replies.
Level 2
Joined
Sep 21, 2007
Messages
9
Ok so basically I'm setting up a unit merger system, where they load up into a building, I hit an ability called merge units, and they merge based on what I set the combination to be, for example fire elemental + water elemental = steam manifest. This part below works, which keeps track of which units are loaded into the building, in this case archers. What doesn't work is that when you click on their icons in the loaded building they unload and the number remains the same, so I could unload them and load them back up and the number would jump above the maximum units which I set to be 2 units for merging at this point, which is quite a problem! I used a similar trigger to this one to try and lower the number when you release the unit based on the ability cargo hold being cast to reduce this archer variable in the same fashion as it is increased, but couldn't quite get it. Assistance would be great!

Here's what I've got for the entry trigger, which raises the integer variable for the specific unit entering the building

Soul Absorb
Events
Unit - A unit Begins casting an ability
Conditions
(Ability being cast) Equal to Absorb Soul (Goblin Zeppelin)
Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Unit-type of (Target unit of ability being cast)) Equal to Archer
Then - Actions
Set SFArchers[(Player number of (Owner of (Casting unit)))] = (SFArchers[(Player number of (Owner of (Casting unit)))] + 1)


What I need is a trigger which lowers the same integer variables when a unit leaves the building.
 
Last edited:
  • Soul Count
    • Events
      • Time - Every 0.10 seconds of game time
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Set SFarchers[(Integer A)] = (Number of units in (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Archer) and (((Triggering unit) is loaded into Transports[(Integer A)]) Equal to True))))
You would also need one like

  • Soul Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units owned by (Player((Integer A))) matching ((Unit-type of (Matching unit)) Equal to SoulHero)) and do (Actions)
            • Loop - Actions
              • Set Transports[(Integer A)] = (Picked unit)

These triggers would only work assuming the unit is transporting the units, and every player has one. If every player doesnt have one just change the loop numbers to the player numbers that have them, if they are separated you would have to make copies of the trigger and replace "For Loop Integer A" with the number of the players that have it.
 
Last edited:
Status
Not open for further replies.
Top