• 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 problem! (Map contains unit...)

Status
Not open for further replies.

yip

yip

Level 3
Joined
Jan 15, 2014
Messages
69
I'm having a problem with the following trigger. (I'm sorry if the post format or place is wrong, if it is, feel free to move it or correct me.)

-------------

  • Soulnado Switch On
    • Events
      • Unit - A unit enters (Playable map area)
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Soulnado
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Playable map area) contains SoulnadoUnit_1) Equal to True
        • Then - Actions
          • Set SoulnadoUnit_2 = (Triggering unit)
          • Trigger - Turn on Soulnado Ticker 2 <gen>
          • Unit Group - Pick every unit in (Units owned by (Owner of SoulnadoUnit_2) matching ((Unit-type of (Matching unit)) Equal to Warlock)) and do (Actions)
            • Loop - Actions
              • Set SoulnadoOwner_2 = (Picked unit)
        • Else - Actions
          • Set SoulnadoUnit_1 = (Triggering unit)
          • Trigger - Turn on Soulnado Ticker 1 <gen>
          • Unit Group - Pick every unit in (Units owned by (Owner of SoulnadoUnit_1) matching ((Unit-type of (Matching unit)) Equal to Warlock)) and do (Actions)
            • Loop - Actions
              • Set SoulnadoOwner_1 = (Picked unit)

----------

What I want to happen is:
If said unit 'Soulnado' (a summoned unit based on Tornado) comes into the playing map area, it'll be set as a unit variable named 'SoulnadoUnit_1' or 'SoulnadoUnit_2', in case there's already a 'SoulnadoUnit_1'.

That's why I used the conditions to check if there already is such a unit on the map and set the variable accordingly.

What happens is:
Whether there actually is or isn't a Soulnado on the map, it doesn't matter - it runs the 'Then' part of the branch and sets the variable to 'SoulnadoUnit_2', executing the rest of the actions as well.


I thought at first that the trigger was triggering itself somehow, and tried adding a 'turn off this trigger' at the beggining and 'turn on this trigger' at the end, but to no avail. Any ideas? Help will be greatly appreciated.
 

yip

yip

Level 3
Joined
Jan 15, 2014
Messages
69
Make:

If SoulnadoUnit_1 = No unit
Then:
set SoulnadoUnit_1 =Triggering unit
Else:
SoulnadoUnit_2 = triggering unit
Turn off this trigger

It worked and solved my problem, thanks a bunch.

Although I'm still curious as to why my trigger didn't work. There's no other 'Set Variable' trigger in the map that uses 'SoulnadoUnit_1'.
 
Last edited:

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,255
Why not put all those units in a single unit group and avoid this problem altogether? It would support any number of such summons.

Anyway the problem may be related to checking if null is in a rect always returning true? It seems the sort of logical thing to happen.
 
  • Like
Reactions: yip

yip

yip

Level 3
Joined
Jan 15, 2014
Messages
69
When you set the variable it is saved to the rest of the map, so it cause your problem. You need set nothing in the var if you use it after you want.

That wasn't the problem, since the variable wasn't even being used. Thanks for the reply.

Why not put all those units in a single unit group and avoid this problem altogether? It would support any number of such summons.

Anyway the problem may be related to checking if null is in a rect always returning true? It seems the sort of logical thing to happen.

That was me being lazy, as usual~

I think I see what you mean. Thanks!
 
Status
Not open for further replies.
Top