• 🏆 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] Help fixing a dynamic indexing trigger with loop

Status
Not open for further replies.
Level 12
Joined
Feb 5, 2018
Messages
521
  • Frost Tomb
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frost Tomb (text not done)
    • Actions
      • -------- Start of Index --------
      • Set VariableSet FrostTomb_Index = (FrostTomb_Index + 1)
      • Set VariableSet FrostTomb_Loop = (FrostTomb_Loop + 1)
      • -------- ------ --------
      • Set VariableSet FrostTomb_Caster[FrostTomb_Index] = (Triggering unit)
      • Set VariableSet FrostTomb_Loc[FrostTomb_Index] = (Target point of ability being cast)
      • -------- ----- --------
      • Set VariableSet FrostTomb_Level[FrostTomb_Index] = (Level of Frost Tomb (text not done) for FrostTomb_Caster[FrostTomb_Index])
      • Set VariableSet FrostTomb_Time[FrostTomb_Index] = (75.00 + (25.00 x (Real(FrostTomb_Level[FrostTomb_Index]))))
      • -------- ----- --------
      • Set VariableSet FrostTomb_Damage[FrostTomb_Index] = ((Real(FrostTomb_Level[FrostTomb_Index])) x (60.00 + ((Real((Intelligence of FrostTomb_Caster[FrostTomb_Index] (Include bonuses)))) x 0.25)))
      • Game - Display to (All players) the text: (String(FrostTomb_Damage[FrostTomb_Index]))
      • Set VariableSet FrostTomb_Group[FrostTomb_Index] = (Units within 725.00 of FrostTomb_Loc[FrostTomb_Index].)
      • Unit Group - Pick every unit in FrostTomb_Group[FrostTomb_Index] and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) belongs to an enemy of (Owner of FrostTomb_Caster[FrostTomb_Index]).) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Mechanical) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
            • Then - Actions
            • Else - Actions
              • Unit Group - Remove (Picked unit) from FrostTomb_Group[FrostTomb_Index].
      • Unit Group - Pick every unit in FrostTomb_Group[FrostTomb_Index] and do (Actions)
        • Loop - Actions
          • Set VariableSet FrostTomb_Target[FrostTomb_Index] = (Picked unit)
          • Unit - Cause FrostTomb_Caster[FrostTomb_Index] to damage FrostTomb_Target[FrostTomb_Index], dealing FrostTomb_Damage[FrostTomb_Index] damage of attack type Spells and damage type Magic
          • Animation - Change FrostTomb_Target[FrostTomb_Index]'s animation speed to 0.00% of its original speed
          • Unit - Pause FrostTomb_Target[FrostTomb_Index]
          • Special Effect - Create a special effect attached to the chest of FrostTomb_Target[FrostTomb_Index] using Abilities\Spells\Undead\FreezingBreath\FreezingBreathTargetArt.mdl
          • Set VariableSet FrostTomb_SFX[FrostTomb_Index] = (Last created special effect)
      • Custom script: call RemoveLocation (udg_FrostTomb_Loc[udg_FrostTomb_Index])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FrostTomb_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Frost Tomb Loop <gen>
        • Else - Actions

  • Frost Tomb Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer FrostTomb_Loop) from 1 to FrostTomb_Index, do (Actions)
        • Loop - Actions
          • Set VariableSet FrostTomb_Time[FrostTomb_Loop] = (FrostTomb_Time[FrostTomb_Loop] - 1.00)
          • Set VariableSet FrostTomb_SFX[FrostTomb_Loop] = FrostTomb_SFX[FrostTomb_Index]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FrostTomb_Time[FrostTomb_Loop] Greater than 0.00
            • Then - Actions
              • Unit Group - Pick every unit in FrostTomb_Group[FrostTomb_Loop] and do (Actions)
                • Loop - Actions
                  • Set VariableSet FrostTomb_Target[FrostTomb_Loop] = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (FrostTomb_Target[FrostTomb_Loop] is dead) Equal to True
                    • Then - Actions
                      • Unit Group - Remove FrostTomb_Target[FrostTomb_Loop] from FrostTomb_Group[FrostTomb_Loop].
                      • Unit - Unpause FrostTomb_Target[FrostTomb_Loop]
                      • Animation - Change FrostTomb_Target[FrostTomb_Loop]'s animation speed to 100.00% of its original speed
                      • Special Effect - Destroy FrostTomb_SFX[FrostTomb_Loop]
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • (Number of units in FrostTomb_Group[FrostTomb_Loop]) Equal to 0
                        • Then - Actions
                          • Set VariableSet FrostTomb_Caster[FrostTomb_Loop] = FrostTomb_Caster[FrostTomb_Index]
                          • Set VariableSet FrostTomb_Time[FrostTomb_Loop] = FrostTomb_Time[FrostTomb_Index]
                          • Unit Group - Remove all units from FrostTomb_Group[FrostTomb_Loop].
                          • Custom script: call DestroyGroup (udg_FrostTomb_Group[udg_FrostTomb_Loop])
                          • Set VariableSet FrostTomb_Group[FrostTomb_Loop] = FrostTomb_Group[FrostTomb_Index]
                          • -------- - --------
                          • Set VariableSet FrostTomb_Index = (FrostTomb_Index - 1)
                          • Set VariableSet FrostTomb_Loop = (FrostTomb_Loop - 1)
                        • Else - Actions
                    • Else - Actions
            • Else - Actions
              • Unit Group - Pick every unit in FrostTomb_Group[FrostTomb_Loop] and do (Actions)
                • Loop - Actions
                  • Set VariableSet FrostTomb_Target[FrostTomb_Loop] = (Picked unit)
                  • Unit Group - Remove FrostTomb_Target[FrostTomb_Loop] from FrostTomb_Group[FrostTomb_Loop].
                  • Unit - Unpause FrostTomb_Target[FrostTomb_Loop]
                  • Animation - Change FrostTomb_Target[FrostTomb_Loop]'s animation speed to 100.00% of its original speed
                  • Special Effect - Destroy FrostTomb_SFX[FrostTomb_Loop]
                  • Set VariableSet FrostTomb_Caster[FrostTomb_Loop] = FrostTomb_Caster[FrostTomb_Index]
                  • Set VariableSet FrostTomb_Time[FrostTomb_Loop] = FrostTomb_Time[FrostTomb_Index]
                  • Unit Group - Remove all units from FrostTomb_Group[FrostTomb_Loop].
                  • Custom script: call DestroyGroup (udg_FrostTomb_Group[udg_FrostTomb_Loop])
                  • Set VariableSet FrostTomb_Group[FrostTomb_Loop] = FrostTomb_Group[FrostTomb_Index]
                  • -------- - --------
                  • Set VariableSet FrostTomb_Index = (FrostTomb_Index - 1)
                  • Set VariableSet FrostTomb_Loop = (FrostTomb_Loop - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FrostTomb_Index Equal to 0
        • Then - Actions
          • Game - Display to (All players) the text: Loop turned off
          • Trigger - Turn off (This trigger)
        • Else - Actions

List of issues:
1) Special effects are not destroyed.

2) There is something wrong with loop, returning the initial trigger to set the damage of FrostTomb_Damage to 0.00, as long as the loop is running.

3) Units don't unpause.

The idea of this spell was a point target AoE spell, dealing initial damage and then freezing units for a period of time. I know using pause is bad, but forgot how to get the defaultpropwindow of a unit.
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
This spell doesn't require Dynamic Indexing. Create a Dummy and have it cast Storm Bolt on the targets in the AoE. Then create a modified version of the Stunned (Pause) buff to make it look like the targets are frozen.

If you want to freeze the unit's animations, set their animation speed to 0%. You can use a simple Loop to keep track of whether or not the units have the "Freeze buff" and use that to determine when they should have their animation speed reset.


And there's a lot of things going wrong in those triggers.

You're using FrostTomb_Index as the index for variables which are used by multiple units (FrostBomb_Target for example). This doesn't work.

In this case, if you cast the spell once, FrostTomb_Index is equal to 1. If you then set FrostTomb_Target[FrostTomb_Index] = (Picked unit), you're setting every picked unit to be equal to FrostTomb_Target[1].

A proper fix to this would be to scrap FrostTomb_Target altogether, as these units are already kept track of inside of your Unit Group. Instead, keep track of their Special Effects using a Unit Indexer.

---------------------------------------------------------------------------------
I attached a map with an example of the spell using only a Unit Indexer.
  • Cast Frost Tomb
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Frost Tomb (Hero)
    • Actions
      • Set VariableSet TempPoint = (Target point of ability being cast)
      • -------- --------
      • -------- Dummy --------
      • Unit - Create 1 Dummy for (Triggering player) at TempPoint facing Default building facing degrees
      • Unit - Add Frost Tomb (Stun) to (Last created unit)
      • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
      • -------- --------
      • -------- Freeze --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 300.00 of TempPoint.) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) belongs to an enemy of (Triggering player).) Equal to True
              • ((Picked unit) is alive) Equal to True
              • ((Picked unit) is A ground unit) Equal to True
              • ((Picked unit) is A structure) Equal to False
              • ((Picked unit) is Magic Immune) Equal to False
            • Then - Actions
              • Set VariableSet CV = (Custom value of (Picked unit))
              • Set VariableSet FT_Delay[CV] = 1
              • Unit - Order (Last created unit) to Human Mountain King - Storm Bolt (Picked unit)
              • Animation - Change (Picked unit)'s animation speed to 0.00% of its original speed
              • Unit Group - Add (Picked unit) to FT_Group
            • Else - Actions
      • Custom script: call RemoveLocation (udg_TempPoint)
      • -------- --------
      • -------- Start Loop --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Frost Tomb Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Frost Tomb Loop <gen>
        • Else - Actions
  • Frost Tomb Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • -------- Check Loop --------
      • Unit Group - Pick every unit in FT_Group and do (Actions)
        • Loop - Actions
          • Set VariableSet CV = (Custom value of (Picked unit))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • FT_Delay[CV] Equal to 0
              • Or - Any (Conditions) are true
                • Conditions
                  • ((Picked unit) has buff Frost Tomb (Stun)) Equal to False
                  • ((Picked unit) is alive) Equal to False
            • Then - Actions
              • Animation - Change (Picked unit)'s animation speed to 100.00% of its original speed
              • Unit Group - Remove (Picked unit) from FT_Group.
            • Else - Actions
              • Set VariableSet FT_Delay[CV] = 0
      • -------- --------
      • -------- End Loop --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in FT_Group) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
Note:
FT_Delay is used to fix rare cases in which Frost Tomb Loop runs before the Dummy has applied the Frost Tomb (Stun) buff, removing the unit from FT_Group prematurely.

This happens because the Dummy is using Storm Bolt with 0 missile speed (max speed), which is very fast but not instant, so it takes a moment to reach it's target and apply the buff. During that time the Loop could run and see that the unit doesn't have the Frost Tomb buff (yet), and will think that the buff has expired, removing the unit from the group and resetting it's animation speed.
 

Attachments

  • Frost Tomb v.2.w3m
    25.2 KB · Views: 18
Last edited:
Level 12
Joined
Feb 5, 2018
Messages
521
Thanks =) I have a unit indexer already included in my map so I will use this.

There has been something off with my triggering lately. Too long break :D
 

Uncle

Warcraft Moderator
Level 64
Joined
Aug 10, 2018
Messages
6,555
Thanks =) I have a unit indexer already included in my map so I will use this.

There has been something off with my triggering lately. Too long break :D
No problem, and I just realized that I had a rather unnecessary variable (FT_Instances) so I removed it. I edited the above post with the changes.

I was originally using that Variable to detect when multiple casts of the spell were used on the same target. This was needed if I wanted to avoid creating multiple special effects--like how re-applying an existing buff doesn't create an extra copy of the buff art.
 
Last edited:
Status
Not open for further replies.
Top