• 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.

GUI Hashtables & Periodic Events

Status
Not open for further replies.
Apparently, I came along with a problem. I am using the fancy Hashtables in GUI, so, there is a problem I can't get to work out.

I want to have a spell, that, when a unit casts it, it will create a unit, which will slowly fade, until vanish (don't ask why, just have the concept).

The trigger in non-MUI-involved thing would go like:
  • Trigger
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Vanish
  • Actions
    • Set Point1 = (Position of (Triggering unit))
    • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Point1 facing default building degrees
    • Set Unit1 = (Last created unit)
    • Custom script: call RemoveLocation (udg_Point1)
  • Trigger1
  • Events
    • Time - Every 0.6 seconds of game-time
  • Conditions
    • (Unit1 is alive) Equal to True
  • Actions
    • Set Transparency = ((Transparency) + 1)
    • Animation - Change (Unit1)'s vertex modifier to (100.00, 100.00, 100.00)% and (Transparency)% transparency
Ok, using Hashtables, how would I translate that? The first step seems easy, but the loading part is what concerns me and prevents me from working this out. Here:
  • Trigger
  • Events
    • Unit - A unit starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to Vanish
  • Actions
    • Set Point1 = (Position of (Triggering unit))
    • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Point1 facing default building degrees
    • Hastable - Save Handle of (Last created unit) as 0 of (Key (Triggering unit)) at (Hash1)
    • Custom script: call RemoveLocation (udg_Point1)
  • Trigger1
  • Events
    • Time - Every 0.6 seconds of game-time
  • Conditions
    • ((Load 0 of (Key([U][B]WHAT KEY goes here?[/B][/U])) in (Hash1)) is alive) Equal to True
  • Actions
    • ---Now, I want an increasing integer. How can I use it in a Hash, when I still use a global variable? How can I make it work as MUI?---
    • Set Transparency = ((Transparency) + 1)
    • Hashtable - Save (Transparency) as 1 of (Key([U][B]What key here? I need this "Transparency" variable attached to the "Last created unit" of the previous trigger; so, how can I attach it?[/B][/U])) in (Hash1)
    • Unit - Change (Load 0 of (Key(What key??))) vertex modifier to (100.00, 100.00, 100.00)% and (Load 1 of (Key([U][B]This will refer to the "Transparency" variable, but, what Load again?[/B][/U]))% transparency
Yes, I have checked tutorials
 
Level 37
Joined
Mar 6, 2006
Messages
9,243
Add the dummy into a unit group in the first trigger.

In the second trigger, pick every unit in that group. You can use Picked Unit as the key.

When all is done, clear the child hahstable and remove the unit from the group.

At the end of the second trigger, check if the group is empty. If it is, turn off the trigger.
 
I initially used a unit group, but... there is a small problem:

The spell is castable twice.
When you initially cast it, the custom value of the triggering unit becomes equal to 1.
When you cast it for the second time, it will kill the unit you created in the first time instantly, resetting the custom value to 0.

So, I have an if/then/else statement, which goes like this:

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Custom value of (Triggering unit)) Equal to 1
    • Then - Actions
      • Unit - Set the custom value of (Triggering unit) to 2
      • Unit - Kill (How to refer to the (Last created unit) of the first cast? I need to attach the last created unit to the triggering unit and the Transparency variable to the Last created unit, but how?)
    • Else - Actions
      • Unit - Set the custom value of (Triggering unit) to 1
      • Set Point1 = (Position of (Triggering unit))
      • Unit - Create 1 Dummy for (Owner of (Triggering unit)) at Point1 facing Default building facing degrees
      • Hashtable - Save Handle Of(Last created unit) as 0 of (Key (Last created unit)) in hash1
      • Hashtable - Save Handle Of(Triggering unit) as 2 of (Key (Triggering unit)) in Hash1
      • Unit - Order (Load 0 of (Key (Triggering unit)) in Hash1) to Follow (Load 2 of (Key (Triggering unit)) in Hash1)
      • Unit Group - Add (Load 0 of (Key (Triggering unit)) in Hash1) to P_Group
      • Custom script: call RemoveLocation (udg_Point1)
 
Status
Not open for further replies.
Top