• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!

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