• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[Trigger] Need Help

Status
Not open for further replies.
Level 2
Joined
Nov 5, 2014
Messages
23
Can you guys help me find whats wrong? my spell is supposed to stun (2sec) and reduce armor of every unit within range by 3/6/9/12 (6sec) but after the 6 seconds timer SOME of the affected unit still retains their armor penalty,
Base Spell : Silence
Range : 300 AOE

heres the code
  • Collapse Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • Player - Disable SC - Spell Book for (Player((Integer A)))

  • Collapse Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Collapse
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Collapse_Has[Collapse_LastRecycled] Equal to True
        • Then - Actions
          • Set Collapse_Max = (Collapse_Max + 1)
          • Set Collapse_Index = Collapse_Max
        • Else - Actions
          • Set Collapse_Index = Collapse_LastRecycled
          • Set Collapse_LastRecycled = Collapse_RecycledList[Collapse_LastRecycled]
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Set Collapse_Caster[Collapse_Index] = (Triggering unit)
      • Set Collapse_Point[Collapse_Index] = (Target point of ability being cast)
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Set Collapse_Dummy[Collapse_Index] = Caster Dummy
      • Set Collapse_DSpell = Stun Dummy
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Set Collapse_Group = (Units within 300.00 of Collapse_Point[Collapse_Index] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is Magic Immune) Equal to False) and (((Matching unit) belongs to an enem
      • -------- ----------------------------------- --------
      • -------- --------
      • Unit - Create 1 SFX Dummy for (Owner of Collapse_Caster[Collapse_Index]) at Collapse_Point[Collapse_Index] facing Collapse_Point[Collapse_Index]
      • Animation - Play (Last created unit)'s birth animation
      • Animation - Change (Last created unit)'s animation speed to 100.00% of its original speed
      • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
      • -------- --------
      • Unit Group - Pick every unit in Collapse_Group and do (Actions)
        • Loop - Actions
          • Set Collapse_Picked[Collapse_Index] = (Picked unit)
          • -------- --------
          • Unit - Create 1 Collapse_Dummy[Collapse_Index] for (Owner of Collapse_Caster[Collapse_Index]) at (Position of Collapse_Picked[Collapse_Index]) facing (Position of Collapse_Picked[Collapse_Index])
          • -------- --------
          • Unit - Add SC - Spell Book to Collapse_Picked[Collapse_Index] <<Armor Penalty
          • Unit - Set level of SC - Spell Book for Collapse_Picked[Collapse_Index] to (Level of Collapse for Collapse_Caster[Collapse_Index])
          • -------- --------
          • Special Effect - Create a special effect attached to the origin of Collapse_Picked[Collapse_Index] using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
          • -------- --------
          • Unit - Add Collapse_DSpell to (Last created unit)
          • Unit - Set level of Collapse_DSpell for (Last created unit) to (Level of M - 1 - Spacial Collapse (Manifold Paradox) for Collapse_Caster[Collapse_Index])
          • Unit - Order (Last created unit) to Mountain King - Storm Bolt Collapse_Picked[Collapse_Index]
          • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
          • -------- --------
          • Special Effect - Destroy (Last created special effect)
          • -------- --------
      • Custom script: call DestroyGroup(udg_Collapse_Group)
      • Custom script: call RemoveLocation(udg_Collapse_Point[udg_Collapse_Index])
      • -------- ----------------------------------- --------
      • Set Collapse_Has[Collapse_Index] = True
      • Set Collapse_Count = (Collapse_Count + 1)
      • Set Collapse_Timer[Collapse_Index] = 6.00
      • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Collapse Loop <gen> is on) Equal to False
        • Then - Actions
          • Trigger - Turn on Collapse Loop <gen>
        • Else - Actions

  • [/COLOR]
  • Collapse Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Collapse_Integer) from 0 to Collapse_Max, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Collapse_Has[Collapse_Integer] Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Collapse_Timer[Collapse_Integer] Greater than 0.00
                • Then - Actions
                  • Set Collapse_Timer[Collapse_Integer] = (Collapse_Timer[Collapse_Integer] - 0.03)
                • Else - Actions
                  • Unit - Remove SC - Spell Book from Collapse_Picked[Collapse_Integer]
                  • -------- ----------------------------------- --------
                  • Set Collapse_Count = (Collapse_Count - 1)
                  • Set Collapse_Has[Collapse_Integer] = False
                  • Set Collapse_RecycledList[Collapse_Integer] = Collapse_LastRecycled
                  • Set Collapse_LastRecycled = Collapse_Integer
                  • -------- ----------------------------------- --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Collapse_Count Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                      • For each (Integer A) from 0 to Collapse_Max, do (Set Collapse_RecycledList[(Integer A)] = 0)
                      • Set Collapse_LastRecycled = 0
                      • Set Collapse_Max = 0
                    • Else - Actions
            • Else - Actions
  • [COLOR=#ffffff]

Thank you in advance
 
Level 2
Joined
Nov 5, 2014
Messages
23
you mean something like this?

  • Set Collapse_Picked[Collapse_Index] = (Picked unit)
  • Set Collapse_Picked 2[Collapse_Index] = Collapse_Picked[Collapse_Index]
 
No, I mean that you have to save each affected unit with a unique Index.
This has to be done fore each affect Target before you save it.
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • empty.gif
    line.gif
    joinminus.gif
    cond.gif
    If - Conditions
    • empty.gif
      line.gif
      line.gif
      joinbottom.gif
      if.gif
      Collapse_Has[Collapse_LastRecycled] Equal to True
  • empty.gif
    line.gif
    joinminus.gif
    actions.gif
    Then - Actions
    • empty.gif
      line.gif
      line.gif
      join.gif
      set.gif
      Set Collapse_Max = (Collapse_Max + 1)
    • empty.gif
      line.gif
      line.gif
      joinbottom.gif
      set.gif
      Set Collapse_Index = Collapse_Max
  • empty.gif
    line.gif
    joinbottomminus.gif
    actions.gif
    Else - Actions
    • empty.gif
      line.gif
      empty.gif
      join.gif
      set.gif
      Set Collapse_Index = Collapse_LastRecycled
    • empty.gif
      line.gif
      empty.gif
      joinbottom.gif
      set.gif
      Set Collapse_LastRecycled = Collapse_RecycledList[Collapse_LastRecycled]
Edit: The Problem is that Collapse_Index needs a unique Value for each affect Unit.
Edit: Short you need to move alot inside the Group - Action - Block
 
Last edited:
Level 2
Joined
Nov 5, 2014
Messages
23
im sorry ...i still dont get it sir ... im still not that far when it comes to triggering ...
 
Collapse Cast
Let's check out what your Trigger does Human speak:
  1. You ask if Slot Last Recyled is used.
  2. Yes -> you create a new one |-| No -> you load a free Index
  3. you save caster and Target Location
  4. Search for units affected
  5. Display some Grafical Effect
  6. Loop all affected Units
    1. save the current unit in the In Action 2 loaded Index
    2. reduce Armor
    3. Display Effect on Affected
    4. Stun
  7. Remove Leak
  8. Save Duration
  9. Count Up
  10. Enable Loop
Now The Problem:

Point 6 Is done for each Unit beeing affected.

Simulate first cast with Real values:
  1. false == true
  2. Else-Action -> Index = 0; Last Recyeld = 0
  3. caster[0] = hero; point [0] = whatever
  4. Group; we do it for 3 units
  5. Bumm
  6. Group Loop
    1. Unit
      • target[0] = picked
      • - armor
      • zap
      • stun
    2. Unit
      • target[0] = picked
      • -armor
      • zap
      • stun
    3. Unit
      • target[0] = picked
      • -armor
      • zap
      • stun
  7. Destroy Group/Point
  8. collaps_Has[0] =true
  9. Count = 0 + 1 -> 1
  10. Colapase_Timer[0] = 6 seconds
  11. start Loop-Trigger
You see your Code leaks 2 targets.
Hmm and I Believe that you have to negate the first check, too. It feels somehow wrong now after the simulation. But might be good as it is.

This might have made you know understand the Problem. You save three Units at slot 0.
 
Last edited:
Level 2
Joined
Nov 5, 2014
Messages
23
I reworked the spell and it does the job now

all i did is added the affected units into a separate group (as you advised) so i can remove the effects after the timer expires (hopefully i cleared out the leaks)

im so sad to say your other advice is way to advanced for me :(






  • Collapse 2
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Spacial Collapse
    • Actions
      • -------- ----------------------------------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • COL_Index_Size Equal to 0
        • Then - Actions
          • Trigger - Turn on Collapse 2 Loop <gen>
        • Else - Actions
      • Set COL_Index_Size = (COL_Index_Size + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • COL_Index_Size Greater than COL_Index_Max
        • Then - Actions
          • Set COL_Index1[COL_Index_Size] = COL_Index_Size
          • Set COL_Index_Max = COL_Index_Size
        • Else - Actions
      • -------- ----------------------------------- --------
      • Set COL_Index2 = COL_Index1[COL_Index_Size]
      • -------- ----------------------------------- --------
      • Set COL_Caster[COL_Index2] = (Triggering unit)
      • -------- ----------------------------------- --------
      • Set COL_Timer[COL_Index2] = 6.00
      • -------- ----------------------------------- --------
      • Set COL_Target_Point = (Target point of ability being cast)
      • -------- ----------------------------------- --------
      • Unit - Create 1 SFX dummy for (Owner of COL_Caster[COL_Index2]) at COL_Target_Point facing COL_Target_Point
      • Animation - Play (Last created unit)'s birth animation
      • Animation - Change (Last created unit)'s animation speed to 100.00% of its original speed
      • -------- ----------------------------------- --------
      • Set COL_Dummy[COL_Index2] = (Last created unit)
      • -------- ----------------------------------- --------
      • Custom script: set udg_COL_Target_Group[udg_COL_Index2] = CreateGroup()
      • -------- ----------------------------------- --------
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 300.00 of COL_Target_Point matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an enemy of (Owner of COL_Caster[COL_Index2])) Equal to True) and (((Matching unit) is alive) Equal to True)))) and do (Actions)
        • Loop - Actions
          • -------- ----------------------------------- --------
          • Unit Group - Add (Picked unit) to COL_Target_Group[COL_Index2]
          • -------- ----------------------------------- --------
          • Unit - Create 1 Dummy for (Owner of COL_Caster[COL_Index2]) at (Position of (Picked unit)) facing (Position of (Picked unit))
          • -------- ----------------------------------- --------
          • Unit - Add Armor Penalty to (Picked Unit)
          • Unit - Set level of Armor Penalty for (Picked Unit) to (Level of Spacial Collapse for COL_Caster[COL_Index2])
          • -------- ----------------------------------- --------
          • Unit - Add Stun Dummy to (Last created unit)
          • Unit - Set level of Stun Dummy for (Last created unit) to (Level of Spacial Collapse for COL_Caster[COL_Index2])
          • Unit - Order (Last created unit) to Mountain King - Storm Bolt (Picked unit)
          • Unit - Add a 0.50 second Generic expiration timer to (Last created unit)
          • -------- ----------------------------------- --------
          • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathCoil\DeathCoilSpecialArt.mdl
          • Special Effect - Destroy (Last created special effect)
          • -------- ----------------------------------- --------
      • -------- ----------------------------------- --------
      • Custom script: call RemoveLocation (udg_COL_Target_Point)




  • Collapse 2 Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer COL_Index3) from 1 to COL_Index_Size, do (Actions)
        • Loop - Actions
          • Set COL_Index2 = COL_Index1[COL_Index3]
          • -------- ----------------------------------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • COL_Timer[COL_Index2] Greater than 0.00
            • Then - Actions
              • -------- ----------------------------------- --------
              • Set COL_Timer[COL_Index2] = (COL_Timer[COL_Index2] - 0.03)
              • -------- ----------------------------------- --------
            • Else - Actions
              • -------- ----------------------------------- --------
              • Unit Group - Pick every unit in COL_Target_Group[COL_Index2] and do (Actions)
                • Loop - Actions
                  • Unit - Remove Armor Penalty to (Picked Unit)
                  • -------- ----------------------------------- --------
                  • Unit Group - Remove (Picked unit) from COL_Target_Group[COL_Index2]
              • -------- ----------------------------------- --------
              • Custom script: call DestroyGroup (udg_COL_Target_Group[udg_COL_Index2])
              • -------- ----------------------------------- --------
              • -------- ----------------------------------- --------
              • Set COL_Index1[COL_Index3] = COL_Index1[COL_Index_Size]
              • Set COL_Index1[COL_Index_Size] = COL_Index2
              • Set COL_Index_Size = (COL_Index_Size - 1)
              • Set COL_Index3 = (COL_Index3 - 1)
              • -------- ----------------------------------- --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • COL_Index_Size Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
 
I would advice a simple change:

Instead of destroying the group at the cast. I would destroy it at the effect end inside the loop trigger.
Remove this Lines in Collapse Cast:
  • Unit Group - Add (Picked unit) to COL_Target_Group[COL_Index2]
  • Custom script: set bj_wantDestroyGroup = true
Create a new
  • Actions
    • Set Target_Point = (Target point of ability being cast)
    • Set COL_Target_Group[Col_Index2] = (Units within 300.00 of Target_Point matching ((((Matching unit) is a Structur) Equal False) and ((((Matching unit) belongs to an enemy of (Triggering player)) Equal True) and (((Matching unit) is alive) Equal True))))
    • Einheitengruppe - Pick every unit in COL_Target_Group[Col_Index2] and do (Actions)
      • Schleifen - Aktionen
 
Last edited:
Status
Not open for further replies.
Top