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

Unit Group handles bugged?

Status
Not open for further replies.
Level 2
Joined
Jun 1, 2014
Messages
18
I was trying to save a unit group handle to a casting unit, so every time i called the handle back up the trigger would recognize "unit group containing these units is associated to that unit". The triggers looked like this: Set "unit group" as "load # from key casting unit", create 1 dummy unit, add last created unit to "unit group", save "unit group" as # of key casting unit.

However, in later triggers, when i try to call the handle back up, it simply does not work. Could anyone possibly help me out on this one?

Thanks.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
could you provide some code example?

please use [trigger][/trigger], you can right click the trigger in Trigger Editor and select Copy as Text.

Also you dont need to store the group back in, because you never create a copy of the group, when you try to load the group from hashtable you load the group itself(simplified, but should do the job)
 
Level 2
Joined
Jun 1, 2014
Messages
18
I need the group to be stored for every caster separately. What is happening is: every few spellcasts, the caster gains one rotating orb (a dummy unit). Now, when the caster uses a specific ability (i called this one Shatter), the orbs fly out and deal AOE damage. However, i do not want all of the orbs from all the casters to fly out, simply the ones that are native to the casting unit ( the "owner" of the orbs).

Also, here are the triggers.

This trigger should create the units and add them to the unit groups. GroupCKine1 is used for the rotating of the orbs around the caster, and works by storing the identity of the caster within the orbs.

  • CKineIni
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to DummyCryomancer
      • (Ability being cast) Not equal to Shatter! (Neutral Hostile)
    • Actions
      • Set LoadingMeterCKine1 = (Load 1 of (Key (Triggering unit)) from HashtableCKine)
      • Set LoadingMeterCKine1 = (LoadingMeterCKine1 + 1.00)
      • Set LoadingMeterCKine2 = (Load 2 of (Key (Triggering unit)) from HashtableCKine)
      • Set GroupCKine2 = (Load 9 of (Key (Triggering unit)) in HashtableCKine)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • LoadingMeterCKine1 Greater than 4.00
        • Then - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LoadingMeterCKine2 Less than (2.00 + ((Real((Level of Cold Kinesis for (Triggering unit)))) / 5.00))
            • Then - Actions
              • Unit - Create 1 ColdKinesisDummy for (Owner of (Triggering unit)) at (Position of (Triggering unit)) facing Default building facing degrees
              • Set CasterCKine1 = (Triggering unit)
              • Hashtable - Save Handle OfCasterCKine1 as 5 of (Key (Last created unit)) in HashtableCKine
              • Unit Group - Add (Last created unit) to GroupCKine1
              • Unit Group - Add (Last created unit) to GroupCKine2
              • Set LoadingMeterCKine2 = (LoadingMeterCKine2 + 1.00)
              • Floating Text - Create floating text that reads + Charge! at ((Position of (Triggering unit)) offset by 100.00 towards 45.00 degrees) with Z offset 0.00, using font size 12.00, color (0.00%, 50.00%, 100.00%), and 20.00% transparency
              • Floating Text - Change (Last created floating text): Disable permanence
              • Floating Text - Set the velocity of (Last created floating text) to 25.00 towards 45.00 degrees
              • Floating Text - Change the lifespan of (Last created floating text) to 1.20 seconds
              • Hashtable - Save LoadingMeterCKine2 as 2 of (Key (Triggering unit)) in HashtableCKine
              • Hashtable - Save Handle OfGroupCKine2 as 9 of (Key (Triggering unit)) in (Last created hashtable)
            • Else - Actions
          • Set LoadingMeterCKine1 = 0.00
          • Hashtable - Save LoadingMeterCKine1 as 1 of (Key (Triggering unit)) in HashtableCKine
        • Else - Actions
          • Hashtable - Save LoadingMeterCKine1 as 1 of (Key (Triggering unit)) in HashtableCKine
This next trigger makes the orbs rotate. Not very interesting in the case i am trying to solve but putting it here nonetheless.

  • CKineLoop
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in GroupCKine1 and do (Actions)
        • Loop - Actions
          • Set CasterCKine1 = (Load 5 of (Key (Picked unit)) in HashtableCKine)
          • Set LoadingMeterCKine3 = (Load 4 of (Key (Picked unit)) from HashtableCKine)
          • Set LoadingMeterCKine3 = (LoadingMeterCKine3 + 2.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LoadingMeterCKine3 Greater than 360.00
            • Then - Actions
              • Set LoadingMeterCKine3 = 0.00
            • Else - Actions
          • Unit - Move (Picked unit) instantly to ((Position of CasterCKine1) offset by 180.00 towards LoadingMeterCKine3 degrees)
          • Hashtable - Save LoadingMeterCKine3 as 4 of (Key (Picked unit)) in HashtableCKine
This trigger SHOULD theoretically load up the unit group native to the caster when the caster uses Shatter. Those units should then get processed by the next trigger (it does not work though, therein lies my problem).

  • CKineSpecial
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Shatter! (Neutral Hostile)
    • Actions
      • Set GroupCKine2 = (Load 9 of (Key (Triggering unit)) in HashtableCKine)
      • Floating Text - Create floating text that reads Shatter for me! at ((Position of (Triggering unit)) offset by 100.00 towards 45.00 degrees) with Z offset 0.00, using font size 14.00, color (0.00%, 50.00%, 100.00%), and 20.00% transparency
      • Floating Text - Change (Last created floating text): Disable permanence
      • Floating Text - Set the velocity of (Last created floating text) to 25.00 towards 45.00 degrees
      • Floating Text - Change the lifespan of (Last created floating text) to 1.20 seconds
      • Unit Group - Pick every unit in GroupCKine2 and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to GroupCKine3
This trigger should be making the dummy units native to the caster slowly move away from him. This is where im stuck at.

  • CKineLoop2
    • Events
      • Time - Every 0.02 seconds of game time
    • Conditions
    • Actions
      • Unit Group - Pick every unit in GroupCKine3 and do (Actions)
        • Loop - Actions
          • Set CasterCKine1 = (Load 5 of (Key (Picked unit)) in HashtableCKine)
          • Set LoadingMeterCKine4 = (Load 8 of (Key (Picked unit)) from HashtableCKine)
          • Set LoadingMeterCKine4 = (LoadingMeterCKine4 + 2.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • LoadingMeterCKine4 Greater than 200.00
            • Then - Actions
              • Unit Group - Remove (Picked unit) from GroupCKine3
            • Else - Actions
              • Unit - Move (Picked unit) instantly to ((Position of CasterCKine1) offset by (((40000.00 - (LoadingMeterCKine4 x LoadingMeterCKine4)) x 0.01) x 0.01) towards (Angle from (Position of CasterCKine1) to (Position of (Picked unit))) degrees)
          • Hashtable - Save LoadingMeterCKine4 as 8 of (Key (Picked unit)) in HashtableCKine
 
Level 2
Joined
Jun 1, 2014
Messages
18
Ahhh. The problem might come from the fact I did not initialize the group stored in hashtable? I did not think it would be needed, since I have been storing reals without ever needing to initialize them.

Here is where I initialize the hashtables:

  • Hashtables
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Hashtable - Create a hashtable
      • Set HashtableRangedAttack = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set HashtableMagShot = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set HashtableStats = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set HashtableCKine = (Last created hashtable)
      • Hashtable - Create a hashtable
      • Set HashtableIceCham = (Last created hashtable)
By the way, I found a somewhat roundabout solution to my problem in the meantime. This is what it looks like:

  • CKineSpecial
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Shatter! (Neutral Hostile)
    • Actions
      • Unit Group - Pick every unit in GroupCKine1 and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Triggering unit) Equal to (Load 5 of (Key (Picked unit)) in HashtableCKine)
            • Then - Actions
              • Unit Group - Remove (Picked unit) from GroupCKine1
              • Unit Group - Add (Picked unit) to GroupCKine2
            • Else - Actions
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
yes, the problem is that any handle type(everything except real, integer, string, boolean) must be first initialized, or it will return null.

You dont need to initialize reals and other basic types, because their default values are:
- 0 for integer
- 0.00 for float
- ""(either this or null) for string
- false for booleans

but default values for handles(units, items, unit groups, locations) is null and you didnt store any existing unit group into the hashtable, so when you try reading it, you get null group
 
Level 12
Joined
Feb 22, 2010
Messages
1,115
These unit group variables are not arrayed so they don't need to be initialized it is done automatically.
 
Level 2
Joined
Jun 1, 2014
Messages
18
I feel like I'm receiving mixed messages here. I HAVE stored the unit group in my hashtable, but only after loading it up first. I would really like to know: if you load up an undefined (variable not set) unit group handle, does it return an EMPTY unit group, or does it return a NON-EXISTENT unit group? In the second case it would make sense my trigger does not work, however if the first case (empty unit group loaded by default) applies, then my trigger should theoretically work and I'm sitting here scratching my head.

PS: I did solve my immediate problem, but I would like to clear this little mystery.
 
Level 23
Joined
Apr 16, 2012
Messages
4,041
I asked you to show how you load the unit group to the hashtable, you showed some triggers and I didnt see it anywhere.

Maybe it would be easier if you provided either the map, or some test map with relevant triggers to the ability.

If you try to load something that is handle(as I said, everything except integer, real, string, boolean) and it wasnt placed there before you will end up with nonexistant value, which is refered to in Jass(underlying type after GUI gets converted) as "null"
 
Status
Not open for further replies.
Top