• 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] Removing picked units doesn't work

Status
Not open for further replies.
Level 5
Joined
Aug 15, 2012
Messages
139
My trigger looks like this:
  • Events
    • Time - Every 0.03 seconds of game-time
  • Conditions
  • Actions
    • For Each Integer B from 1 to USBFX_BuffCount, do Actions
      • Loop - Actions
        • Unit Group - Pick every unit in BuffedUnitsGroup[(Integer B)] and do (Actions)
          • Loop - Actions
            • Set USBFX_PerOldPickedUnitHandle = (Key (Picked unit))
            • Set USBFX_PerRemainingTime = (Load 0 of (Key (Picked unit)) from USBFX_Hashtable)
            • Set USBFX_PerDummyUG = (Load 2 of (Key (Picked unit)) from USBFX_Hashtable)
            • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • USBFX_PerRemainingTime Greater than 0.00
              • Then - Actions
                • Hashtable - Save (USBFX_PerRemainingTime - 0.03) as 0 of (Key (Picked unit)) in USBFX_Hashtable
                • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • (Number of units in (Load 2 of (Key (Picked unit))) in USBFX_Hashtable)) Not equal to (Load 3 of (Key (Picked unit)) in USBFX_Hashtable)
                  • Then - Actions
                    • Game - Display to (All players) the text: ============
                    • Unit Group - Pick every unit in (Load 2 of (Key (Picked unit)) in USBFX_Hashtable) and do (Actions)
                      • Loop - Actions
                        • -------- THESE ACTIONS DONT WORK! --------
                        • Game - Display to (All players) the text: (Name of (Picked unit)
                        • Unit - Remove (Picked unit) from the game
                    • Game - Display to (All players) the text: ============
                    • Unit Group - Remove all units of (Load 2 of (Key (Picked unit)) in USBFX_Hashtable) from (Load 2 of (Key (Picked unit)) in USBFX_Hashtable)
                    • Hashtable - Save 0.00 as 4 of (Key (Picked unit)) in USBFX_Hashtable
                    • For each (USBFX_PerIntegerC) from 1 to (Load 3 of (Key (Picked unit)) in USBFX_Hashtable), do (Actions)
                      • Loop - Actions
                        • Unit - Create 1 USBFX Dummy Unit for (Owner of (Picked unit)) at ALocationItDoesntMatterHere, facing X degrees
                        • Unit Group - Add (Last created unit) to (Load 2 of (Key (Picked unit)) in USBFX_Hashtable)
                        • Special Effect - Create a special effect attached to, etc...
                  • Else - Actions
                    • -------- It doesn't really matter what is there, it has nothing to do with the problem --------
              • Else - Actions
                • Game - Display to (All players) the text: TIME OUT!!!
                • Game - Display to (All players) the text: !!!!!!!!!!!!!!!!
                • Unit Group - Pick every unit in (Load 2 of (Key (Picked unit)) in USBFX_Hashtable) and do (Actions)
                  • Loop - Actions
                    • -------- AND THESE ACTIONS WORK! WTF --------
                    • Game - Display to (All players) the text: (Name of (Picked unit)
                    • Unit - Remove (Picked unit) from the game
                    • Unit Group - Remove all units of (Load 2 of (Key (Picked unit)) in USBFX_Hashtable) from (Load 2 of (Key (Picked unit)) in USBFX_Hashtable)
                    • Unit Group - Remove (Picked unit) from USBFX_UnitGroups[(Integer B)]
                    • Hashtable - Clear all chlid hashtables of child (Key (Picked unit)) in USBFX_Hashtable
As you can see, i used the same actions two times.
  • Unit Group - Pick every unit in (Load 2 of (Key (Picked unit)) in USBFX_Hashtable) and do (Actions)
    • Loop - Actions
      • Game - Display to (All players) the text: (Name of (Picked unit)
      • Unit - Remove (Picked unit) from the game
First time it was under a condition. But i think there is nothing wrong with the condition. Other actions in this condition work properly. It should display something like this in game (assuming there were 3 units in the unit group at time):
Code:
===========
USBFX Dummy Unit
USBFX Dummy Unit
USBFX Dummy Unit
===========
USBFX Dummy Unit is name of unit in the unit group, that i stored in a hashtable. But, that appears instead:
Code:
===========
===========
Actions under the condition, and under that unit group loop DON'T WORK.
But, in the second use, that should clean the unit group and hashtable after the RemainingTime hits 0.00 (buff ends), it shows this:
Code:
TIMEOUT!!!
!!!!!!!!!!!!!!
USBFX Dummy Unit
USBFX Dummy Unit
USBFX Dummy Unit
!!!!!!!!!!!!!!
That means it works correctly. I also tried moving the first unit group actions, the ones that DONT work, out of the condition, and they worked. But i need it to be *under* condition. I don't want it to apply every 0.03 if the buff is on. I have tried something like:
  • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in (Load 2 of (Key (Picked unit))) in USBFX_Hashtable)) Not equal to (Load 3 of (Key (Picked unit)) in USBFX_Hashtable)
    • Then - Actions
      • Set UBSFX_RemoveGroup = TRUE
    • Else - Actions
      • Set UBSFX_RemoveGroup = FALSE
  • Trigger - Run USBFX Clean Unit Group <gen> (ignoring conditions)
And in seperate trigger:
  • If (UBSFX_RemoveGroup = FALSE) then do (Skip remaining actions) else do (Do nothing)
  • Unit Group - Pick every unit in (Load 2 of USBFX_PerOldPickedUnitHandle in USBFX_Hashtable) and do (Actions)
    • Loop - Actions
      • Game - Display to (All players) the text: (Name of (Picked unit))
      • Unit - Remove (Picked unit) from the game
IT DIDN'T WORK. Other thing i have tried is:

  • Set USBFX_PerCount = 0
  • Unit Group - Pick every unit in (Load 2 of (Key (Picked unit)) in USBFX_Hashtable) and do (Actions)
    • Loop - Actions
      • Set USBFX_PerCount = (USBFX_PerCount + 1)
      • Set USBFX_PerDummyUnits[USBFX_PerCount] = (Picked unit)
  • If (All Conditions Are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • (Number of units in (Load 2 of (Key (Picked unit))) in USBFX_Hashtable)) Not equal to (Load 3 of (Key (Picked unit)) in USBFX_Hashtable)
    • Then - Actions
      • For each (USBFX_PerIntegerD) from 1 to USBFX_PerCount do (Actions)
        • Loop - Actions
          • Game - Display to (All players) the text: (Name of USBFX_PerDummyUnits[USBFX_PerIntegerD])
          • Unit - Remove USBFX_PerDummyUnits[USBFX_PerIntegerD] from the game
IT DIDN'T WORK EITHER.

Does anyone know what should i do to make this sh*t run properly?
 
Level 5
Joined
Aug 15, 2012
Messages
139
But look, i used double Picked unit later, and it worked. This is not the problem.
Double picked unit works fine as long as i don't want to refer to picked unit from the first group (BuffedUnitsGroup[]). This isn't it. It must be something different.
 
Level 5
Joined
Aug 15, 2012
Messages
139
Yes, it is, the first unit group block is at the very beginning of the trigger, just under For Each Integer B loop. There are 2 units group used here. BuffedUnitsGroup[], and the one from hashtable. Picked unit in the line you are talking about is the one from BuffedUnitsGroup[].
I have also tried using
  • Set USBFX_PerOldPickedUnitHandle = (Key (Picked unit))
Variable, instead of Key (Picked unit), but it didn't change anything, like i have expected.
 
Level 5
Joined
Aug 15, 2012
Messages
139
http://www.hiveworkshop.com/forums/pastebin_data/16g0z0/_files/UnelithStackingBuffVFX01.w3x

I just changed some variables' names since then, now every variable begins with USBFX so it doesn't accidently collide with other systems. The trigger that i have posted is called USBFX Periodic.


If you want to test it in game - just order the Lich to cast Chain Lightning at Dummy who looks like Mal'Ganis, and buff will gain 1 stack. Then cast it again - buff will gain another stack, but some visual effects will stay in one place and these are ones who i cannot remove. Visual effects are based on dummy units (USBFX Dummy Unit). Dummy units are stored in one group, which is saved to a hashtable. The condition:
  • (Number of units in (Load 2 of (Key (Picked unit))) in USBFX_Hashtable)) Not equal to (Load 3 of (Key (Picked unit)) in USBFX_Hashtable)
Checks if number of dummy units (visible visual effects) is equal to current stacks of the buff on specific unit.
So everytime stacks are increased, i want to remove all units from dummy unit group, and create as much as there are stacks. But only the second thing works. Surprising thing is that after buff expires (6 seconds from last application), the dummy unit group cleans properly.

And you may se something like this, for example:
Load (2+(5x(Integer B-1)))
That's because i changed it so multiple buffs can be applied to one unit depending on buff's id.
For example: Buff #1 is stored in 0-4 keys in hashtable. Buff #2 in 5-9 etc.
 
Level 5
Joined
Aug 15, 2012
Messages
139
But after i apply the buff for 2nd time, current stacks value is set to 2, and number of units in unit group is equal to 1. 2 != 1 so it does activate the "Then - Actions" part, but still the unit group isn't cleaned. Atleast i think so.
 
Level 5
Joined
Aug 15, 2012
Messages
139
I think i understand! The problem is in the trigger which applies the buff?

EDIT: I did this:
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • USBFX_AppCurrentStacks Lesser than 1
    • Then - Actions
      • Set USBFX_TempIntegerP = (2 + (5 x (USBFX_Apply_ID - 1)))
      • Set USBFX_TempIntegerC = (Key (Target unit of ability being cast))
      • Custom script: call SaveGroupHandleBJ(CreateGroup(), udg_USBFX_TempIntegerP, udg_USBFX_TempIntegerC, udg_USBFX_Hashtable)
And it works now. Thanks!
 
Status
Not open for further replies.
Top