• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Solved] Carrying Variables Across Triggers

Status
Not open for further replies.
Level 5
Joined
Dec 30, 2022
Messages
36
So I have a trigger here:

  • frozenOrbCast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frozen Orb (Frost Mage)
    • Actions
      • Set VariableSet frozenOrbCaster[(Player number of (Owner of (Triggering unit)))] = (Triggering unit)
      • Set VariableSet frozenOrbPlayerNum = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet frozenOrbCastPoint[(Player number of (Owner of (Triggering unit)))] = (Target point of ability being cast)
      • Set VariableSet frozenOrbCasterLoc[(Player number of (Owner of (Triggering unit)))] = (Position of (Triggering unit))
      • Set VariableSet frozenOrbDistance[(Player number of (Owner of (Triggering unit)))] = (Distance between frozenOrbCasterLoc[(Player number of (Owner of (Triggering unit)))] and frozenOrbCastPoint[(Player number of (Owner of (Triggering unit)))])
      • Set VariableSet frozenOrbInt[(Player number of (Owner of (Triggering unit)))] = 0
      • Unit - Create 1 Frozen Orb (Frost Mage) for (Owner of (Triggering unit)) at frozenOrbCasterLoc[(Player number of (Owner of (Triggering unit)))] facing frozenOrbCastPoint[(Player number of (Owner of (Triggering unit)))]
      • Set VariableSet frozenOrbUnit[(Player number of (Owner of (Triggering unit)))] = (Last created unit)
      • Set VariableSet frozenOrbDamageIntelligence[(Player number of (Owner of (Triggering unit)))] = (Real((Unit: (Triggering unit)'s Integer Field: Intelligence (with Bonus) ('uinb'))))
      • Unit - Add a 10.00 second Generic expiration timer to (Last created unit)
      • Trigger - Turn on frozenOrbDamage <gen>
      • Trigger - Turn on frozenOrbMove <gen>
That leads to this trigger:

  • frozenOrbMove
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • frozenOrbInt[(Player number of (Owner of (Triggering unit)))] Less than or equal to 100
        • Then - Actions
          • Unit - Move frozenOrbUnit[(Player number of (Owner of (Triggering unit)))] instantly to (frozenOrbCasterLoc[(Player number of (Owner of (Triggering unit)))] offset by ((frozenOrbDistance[(Player number of (Owner of (Triggering unit)))] / 100.00) x (Real(frozenOrbInt[(Player number of (Owner of (Triggering unit)))]))) towards (Facing of frozenOrb
          • Set VariableSet frozenOrbInt[(Player number of (Owner of (Triggering unit)))] = (frozenOrbInt[(Player number of (Owner of (Triggering unit)))] + 1)
        • Else - Actions
          • Custom script: call RemoveLocation(udg_frozenOrbCastPoint[udg_frozenOrbPlayerNum])
          • Custom script: call RemoveLocation(udg_frozenOrbCasterLoc[udg_frozenOrbPlayerNum])
          • Trigger - Turn off (This trigger)
I just realized that this trigger ONLY works for player 1, and if player 2+ is the casting unit, the second trigger does not work.

My question is: is there any other way to do what I want to do here without creating 1 "fozenOrbMove" trigger for each person? I'm having a mental block thinking of anything creative.

Thanks!
 
Level 20
Joined
Aug 29, 2012
Messages
825
I think you should use a loop (for each integer A from 1 to the number of players in your map), and then use integer A instead of player number of owner of triggering unit, it should to the trick

Besides, I'm not sure frozenOrbMove would work properly since you're refering to a triggering unit, but the event is a periodic timer, so there's no triggering unit to refer to
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,511
What you can do is put the Frozen Orb units in a Unit Group and Loop over that:
  • Unit - Create 1 Frozen Orb (Frost Mage)...
  • Unit Group - Add (Last created unit) to FrozenOrbGroup
  • Unit Group - Pick every unit in FrozenOrbGroup and do
    • Loop - Actions
      • Unit - Move (Picked unit) instantly to...
You could then combine that with a Unit Indexer in order to save data directly to your Frozen Orb dummy units.

Alternatively, you can use the Dynamic Indexing method which rids the need of the Unit Indexer / Unit Group and makes the spell completely MUI.

When working in GUI, I use both of these methods, often combining them together.

Also, your trigger has a lot of memory leaks and mistakes. It's neither MUI or MPI, but it's close to being MPI if you make some small adjustments. For example, you definitely don't want to Turn Off the frozenOrbMove trigger the way you're doing it. That'll turn it off for everyone that's currently using it.


Here's a more advanced version if you don't want to make it yourself:
 
Last edited:
Status
Not open for further replies.
Top