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

[Solved] Placing an integer ID

Status
Not open for further replies.
Level 6
Joined
Oct 4, 2011
Messages
226
I have used this before to keep track of certain projectile units and such. I am making an AoE over time ability and need to track the summoned dummy unit. So I am trying to save the "AA01_IdInteger" Integer variable as the created unit and then saving it as the temp unit in the loop trigger. But the real value of 4.00 is never saved or is not properly loaded so the values arn't loaded.
  • Shadow bind
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Ability 1 (Maybe Black Wizard)
    • Actions
      • Set AA01_TargetLoc = (Target point of ability being cast)
      • Unit - Create 1 Peasant for (Owner of (Triggering unit)) at AA01_TargetLoc facing (Random angle) degrees
      • Custom script: call RemoveLocation(udg_AA01_TargetLoc)
      • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
      • Unit Group - Add (Last created unit) to AA01_LoopGroup
      • Set AA01_TempUnit = (Last created unit)
      • Custom script: set udg_AA01_IdInteger = GetHandleId(udg_AA01_TempUnit)
      • Hashtable - Save 4.00 as 1 of AA01_IdInteger in AA01_Hash
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Shadow bind loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Shadow bind loop <gen>
        • Else - Actions
  • Shadow bind loop
    • 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
          • (Number of units in AA01_LoopGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in AA01_LoopGroup and do (Actions)
            • Loop - Actions
              • Set AA01_LoopTempUnit = (Picked unit)
              • Custom script: set udg_AA01_IdInteger = GetHandleId(udg_AA01_LoopTempUnit)
              • Set AA01_TempReal = (Load 1 of AA01_IdInteger from AA01_Hash)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AA01_TempReal Greater than 0.00
                • Then - Actions
                  • Hashtable - Save (AA01_TempReal - 0.02) as 1 of AA01_IdInteger in AA01_Hash
                • Else - Actions
                  • Hashtable - Clear all child hashtables of child AA01_IdInteger in AA01_Hash
                  • Unit Group - Remove AA01_LoopTempUnit from AA01_LoopGroup
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Game - Display to (All players) for 0.50 seconds the text: |cff22ccffLOOP OFF|...
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Dude, there's no need to create global variables por each thing you do. As long as you don't use a "Wait" action, you don't need to create variables to handle every different thing in your map. The game is smart, and keep's track of stuff for you.

  • Shadow bind
    • Events
      • Unit - A unit Begins casting an ability
    • Conditions
      • (Ability being cast) Equal to Ability 1 (Maybe Black Wizard)
    • Actions
      • Set AA01_TargetLoc = (Target point of ability being cast)
      • Unit - Create 1 Peasant for (Triggering Player) at AA01_TargetLoc facing (Random angle) degrees
      • Custom script: call RemoveLocation(udg_AA01_TargetLoc)
      • Set AA01_TempUnit = (Last created unit)
      • Unit - Add a 4.10 second Generic expiration timer to AA01_TempUnit
      • Unit Group - Add AA01_TempUnit to AA01_LoopGroup
      • Custom script: set udg_AA01_IdInteger = GetHandleId(udg_AA01_TempUnit)
      • Hashtable - Save 4.00 as 1 of AA01_IdInteger in AA01_Hash
      • Trigger - Turn on Shadow bind loop <gen>
Doesn't matter if the trigger is on/off. If it's on, it will do nothing. If it's on, it will turn the trigger on. Also set AA01_TempUnit after creating, and then use it. There's no need to use twice "Last Created Unit" and then setting "AA01_TempUnit = Last Created Unit". Increased the Expiration timer to 4.10 to give 0.10 secs to clear the unit hash and stuff after the Real becomes 0.
  • Shadow bind loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in AA01_LoopGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in AA01_LoopGroup and do (Actions)
            • Loop - Actions
              • Set AA01_TempUnit = (Picked unit)
              • Custom script: set udg_AA01_IdInteger = GetHandleId(udg_AA01_TempUnit)
              • Set AA01_TempReal = (Load 1 of AA01_IdInteger from AA01_Hash)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • AA01_TempReal Greater than 0.00
                • Then - Actions
                  • Hashtable - Save (AA01_TempReal - 0.03) as 1 of AA01_IdInteger in AA01_Hash
                • Else - Actions
                  • Hashtable - Clear all child hashtables of child AA01_IdInteger in AA01_Hash
                  • Unit Group - Remove AA01_TempUnit from AA01_LoopGroup
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Game - Display to (All players) for 0.50 seconds the text: |cff22ccffLOOP OFF|...
There's no need to use a different Unit Global Variable for the unit inside the loop.

Anyway, I improved it a bit, but I should still work the way you had it.
 
Level 6
Joined
Oct 4, 2011
Messages
226
  • Shadow bind
    • Events
      • Unit - A unit Finishes casting an ability
    • Conditions
      • (Ability being cast) Equal to Ability 1 (Maybe Black Wizard)
    • Actions
      • Set TempLocation = (Target point of ability being cast)
      • Set TempUnit2 = (Casting unit)
      • Unit - Create 1 Peasant for (Owner of TempUnit2) at TempLocation facing (Random angle) degrees
      • Custom script: call RemoveLocation(udg_TempLocation)
      • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
      • Unit Group - Add (Last created unit) to TempGroup
      • Set TempUnit = (Last created unit)
      • Custom script: set udg_AA01_IdInteger = GetHandleId(udg_TempUnit)
      • Hashtable - Save 4.10 as 1 of AA01_IdInteger in AA01_Hash
      • Hashtable - Save 0.30 as 2 of AA01_IdInteger in AA01_Hash
      • Hashtable - Save Handle OfTempUnit2 as 3 of AA01_IdInteger in AA01_Hash
      • Trigger - Turn on Shadow bind loop <gen>
  • Shadow bind loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in TempGroup2) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in TempGroup and do (Actions)
            • Loop - Actions
              • Set TempUnit2 = (Picked unit)
              • Set TempLocation = (Position of TempUnit2)
              • Custom script: set udg_AA01_IdInteger = GetHandleId(udg_TempUnit2)
              • Set TempReal = (Load 1 of AA01_IdInteger from AA01_Hash)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempReal Greater than 0.00
                • Then - Actions
                  • Hashtable - Save (TempReal - 0.03) as 1 of AA01_IdInteger in AA01_Hash
                  • Set TempReal2 = (Load 2 of AA01_IdInteger from AA01_Hash)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempReal2 Greater than 0.00
                    • Then - Actions
                      • Hashtable - Save (TempReal2 - 0.03) as 2 of AA01_IdInteger in AA01_Hash
                    • Else - Actions
                      • Set TempGroup2 = (Units within 400.00 of TempLocation matching ((((Matching unit) belongs to an ally of (Owner of (Load 3 of AA01_IdInteger in AA01_Hash))) Equal to False) and (((((Matching unit) is Magic Immune) Equal to False) and ((Owner of (Matching unit)) Not equal to (O
                      • Unit Group - Pick every unit in TempGroup2 and do (Actions)
                        • Loop - Actions
                          • Unit - Cause (Load 3 of AA01_IdInteger in AA01_Hash) to damage (Picked unit), dealing 9.00 damage of attack type Spells and damage type Normal
                      • Hashtable - Save 0.30 as 2 of AA01_IdInteger in AA01_Hash
                      • Unit Group - Remove all units from TempGroup2
                • Else - Actions
                  • Hashtable - Clear all child hashtables of child AA01_IdInteger in AA01_Hash
                  • Unit Group - Remove TempUnit2 from TempGroup
              • Custom script: call RemoveLocation(udg_TempLocation)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Game - Display to (All players) for 0.50 seconds the text: |cff22ccffLOOP OFF|...
So now what happens is, the temp location in trigger 1 isnt found or something because the dummy unit is created in the center of the map. I tried to implement a quick damage feature to see if it was really working also because everytime I cast the spell it would tell me LOOP OFF right away so the 4.10 second duration didnt pass yet but it gives this message. No damage is done also.
 
Level 20
Joined
Jul 14, 2011
Messages
3,213
Set TempUnit2 = (Casting unit)
-> Set TempUnit2 = (Triggering Unit)

Unit - Create 1 Peasant for (Owner of TempUnit2) at TempLocation facing (Random angle) degrees
-> Unit - Create 1 Peasant for (Triggering Player) at TempLocation facing (Random angle) degrees


Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
Unit Group - Add (Last created unit) to TempGroup
Set TempUnit = (Last created unit)
->
Set TempUnit = (Last created unit)
Unit - Add a 4.00 second Generic expiration timer to TempUnit
Unit Group - Add TempUnit to AbilityGroup

This is a Group you'll use only for this ability, and shouldn't be public to use for any other ability

You can also use generic TempInteger and there's no need for TempUnit2

Custom script: set udg_AA01_IdInteger = GetHandleId(udg_TempUnit)
Hashtable - Save Handle OfTempUnit2 as 3 of AA01_IdInteger in AA01_Hash
-> You are saving the Handle of the TempUnit as 3 of Handle of the Temp Unit...

Remove the conditions for the TempGroup 2 and check if it deals the damage. Or create a special effect attached to the head (like the "!" sign) to Picked units to see which units are added in the group.

You can also try to change the event from "Finishes Casting an Ability" to "Starts the Effect of an Ability" -> That's the moment when mana is taken out.
 
Level 6
Joined
Oct 4, 2011
Messages
226
Okay about the tempgroup. I already switched to "Finishes casting an ability" and I was saving the handle of the tempunit2 not tempunit which is supposed to be the caster so that when the damage is done it comes from the caster unit.
 
Level 6
Joined
Oct 4, 2011
Messages
226
Currently it doesn't do anything right, it creates the dummy unit at "Center of playable map area" and no damage is done.
 
Level 6
Joined
Oct 4, 2011
Messages
226
Yeah that fixes the location problem so thats better. it doesnt effect the units though. I think my group conditions are fine..
 
Level 6
Joined
Oct 4, 2011
Messages
226
  • Shadow bind
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Ability 1 (Maybe Black Wizard)
    • Actions
      • Set TempLocation = (Target point of ability being cast)
      • Set TempUnit2 = (Casting unit)
      • Unit - Create 1 Peasant for (Owner of TempUnit2) at TempLocation facing (Random angle) degrees
      • Custom script: call RemoveLocation(udg_TempLocation)
      • Unit - Add a 4.00 second Generic expiration timer to (Last created unit)
      • Unit Group - Add (Last created unit) to AA01_UGroup
      • Set TempUnit = (Last created unit)
      • Custom script: set udg_AA01_IdInteger = GetHandleId(udg_TempUnit)
      • Hashtable - Save 4.10 as 1 of AA01_IdInteger in AA01_Hash
      • Hashtable - Save 0.27 as 2 of AA01_IdInteger in AA01_Hash
      • Hashtable - Save Handle OfTempUnit2 as 3 of AA01_IdInteger in AA01_Hash
      • Trigger - Turn on Shadow bind loop <gen>
  • Shadow bind loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in AA01_UGroup) Greater than 0
        • Then - Actions
          • Unit Group - Pick every unit in AA01_UGroup and do (Actions)
            • Loop - Actions
              • Set TempUnit2 = (Picked unit)
              • Set TempLocation = (Position of TempUnit2)
              • Custom script: set udg_AA01_IdInteger = GetHandleId(udg_TempUnit2)
              • Set TempReal = (Load 1 of AA01_IdInteger from AA01_Hash)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • TempReal Greater than 0.00
                • Then - Actions
                  • Hashtable - Save (TempReal - 0.03) as 1 of AA01_IdInteger in AA01_Hash
                  • Set TempReal2 = (Load 2 of AA01_IdInteger from AA01_Hash)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • TempReal2 Greater than 0.00
                    • Then - Actions
                      • Hashtable - Save (TempReal2 - 0.03) as 2 of AA01_IdInteger in AA01_Hash
                    • Else - Actions
                      • Set AA01_TargetUGroup = (Units within 400.00 of TempLocation matching ((((Matching unit) belongs to an ally of (Owner of TempUnit2)) Equal to False) and (((((Matching unit) is Magic Immune) Equal to False) and ((Owner of (Matching unit)) Not equal to (Owner of TempUnit2))) and ((((M
                      • Unit Group - Pick every unit in AA01_TargetUGroup and do (Actions)
                        • Loop - Actions
                          • Set TempUnit = (Picked unit)
                          • Unit - Cause (Load 3 of AA01_IdInteger in AA01_Hash) to damage TempUnit, dealing 9.00 damage of attack type Spells and damage type Normal
                          • Unit Group - Remove TempUnit from AA01_TargetUGroup
                      • Hashtable - Save 0.27 as 2 of AA01_IdInteger in AA01_Hash
                • Else - Actions
                  • Hashtable - Clear all child hashtables of child AA01_IdInteger in AA01_Hash
                  • Unit Group - Remove TempUnit2 from AA01_UGroup
              • Custom script: call RemoveLocation(udg_TempLocation)
        • Else - Actions
          • Trigger - Turn off (This trigger)
          • Game - Display to (All players) for 0.35 seconds the text: |cff22ccffAA01_UGro...
I should've corrected the unit group mistake. Still 0 damage is dealt atm, Everytime I cast the ability it instantly tells me the "AA01_UGroup" is empty.
 
Status
Not open for further replies.
Top