• 🏆 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!

MUI Spell (Indexing)

Status
Not open for further replies.
Level 16
Joined
Mar 27, 2011
Messages
1,349
So I'm creating a spell which silences an area every 0.5 seconds. I was following this guide: http://www.hiveworkshop.com/forums/...orials-279/visualize-dynamic-indexing-241896/

Here's my triggers:


  • Corruptor Silence
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Silence (Corruptor)
    • Actions
      • Set Silence_Index = (Silence_Index + 1)
      • Set Silence_Caster[Silence_Index] = (Triggering unit)
      • Set Silence_Point[Silence_Index] = (Target point of ability being cast)
      • Unit - Create 1 Dummy Unit for (Owner of (Triggering unit)) at Silence_Point[Silence_Index] facing Default building facing degrees
      • Unit - Add a 12.00 second Generic expiration timer to (Last created unit)
      • Set Silence_Dummy[Silence_Index] = (Last created unit)
      • Set Silence_Counter[Silence_Index] = 0.00
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Silence_Index Equal to 1
        • Then - Actions
          • Trigger - Turn on Corruptor Silence Loop <gen>
        • Else - Actions
  • Corruptor Silence Loop
    • Events
      • Time - Every 0.25 seconds of game time
    • Conditions
    • Actions
      • For each (Integer Silence_LoopInteger) from 1 to Silence_Index, do (Actions)
        • Loop - Actions
          • Unit - Order Silence_Dummy[Silence_LoopInteger] to Neutral Dark Ranger - Silence Silence_Point[Silence_LoopInteger]
          • Set Silence_Counter[Silence_LoopInteger] = (Silence_Counter[Silence_LoopInteger] + 0.25)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Silence_Counter[Silence_LoopInteger] Greater than or equal to 10.00
            • Then - Actions
              • Set Silence_Dummy[Silence_LoopInteger] = Silence_Dummy[Silence_Index]
              • Set Silence_Point[Silence_LoopInteger] = Silence_Point[Silence_Index]
              • Set Silence_Caster[Silence_LoopInteger] = Silence_Caster[Silence_Index]
              • Set Silence_Dummy[Silence_LoopInteger] = Silence_Dummy[Silence_Index]
              • Set Silence_Index = (Silence_Index - 1)
              • Set Silence_LoopInteger = (Silence_LoopInteger - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Silence_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
Two things:

1.) Whenever the duration of the first cast has finished (10 seconds), all of the casts stop regardless of when they were cast. Why? How do I fix it?
2.) How do I fix the point leak? Not sure how to go about that.

I'm not that advanced with this stuff if you can make the explanation simple. Thanks :)
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Sorry I can't find the indexing problem, but for 2, use a custom script:

How to remove a point handle
  • -------- remove point handle --------
  • Custom script: call RemoveLocation(udg_Silence_Point[udg_Silence_LoopInteger])
  • -------- It's okay to set it to another point handle now --------
  • Set Silence_Dummy[Silence_LoopInteger] = Silence_Dummy[Silence_Index]
  • Set Silence_Point[Silence_LoopInteger] = Silence_Point[Silence_Index]
  • Set Silence_Caster[Silence_LoopInteger] = Silence_Caster[Silence_Index]
  • Set Silence_Index = (Silence_Index - 1)
  • Set Silence_LoopInteger = (Silence_LoopInteger - 1)
You also have a duplicate variable set on Silence Dummy.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
1) I believe that the issue is from here, it always remains zero after the first casting unit's spell ends, regardless to whoever casts after him. Don't put this under ITE loop, put this as a single separate line in the trigger and see what happens.If not, I can't really investigate the problem, it would rather need pro indexers
Wrong Spell End Line Position
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • Silence_Index Equal to 0
  • Then - Actions
  • Trigger - Turn off (This trigger)
2) It'd not leak so much positions, it might lag if many units cast it at once especially you're using the point in the loop trigger, but in this case you need the point along casting duration.So after the spell ends, put this custom script under 'If Silence_Index Greater Or Equal To 10.00', because that time, the player won't need the point :
[BOX="How to remove leak']
  • Custom script: call RemoveLocation(udg_Silence_Point[udg_Silence_LoopInteger])
[/BOX]
 
Level 29
Joined
Oct 24, 2012
Messages
6,543
The index problem is simple. You never de-index this variable.
  • Silence_Counter
All instances end because all instances become 0 when you forget to de-index this.

To fix the leak and your de-index problem you need to change this.
  • Set Silence_Dummy[Silence_LoopInteger] = Silence_Dummy[Silence_Index]
    • Set Silence_Point[Silence_LoopInteger] = Silence_Point[Silence_Index]
    • Set Silence_Caster[Silence_LoopInteger] = Silence_Caster[Silence_Index]
    • Set Silence_Dummy[Silence_LoopInteger] = Silence_Dummy[Silence_Index]
    • Set Silence_Index = (Silence_Index - 1)
    • Set Silence_LoopInteger = (Silence_LoopInteger - 1)
to this.
  • Set Silence_Dummy[Silence_LoopInteger] = Silence_Dummy[Silence_Index]
    • Set Silence_Dummy[Silence_Index] = No unit
    • Custom script: call RemoveLocation( udg_Silence_Point[udg_Silence_LoopInteger])
    • Set Silence_Point[Silence_LoopInteger] = Silence_Point[Silence_Index]
    • Custom script: set udg_Silence_Point[udg_Silence_Index] = null
    • Set Silence_Caster[Silence_LoopInteger] = Silence_Caster[Silence_Index]
    • Set Silence_Caster[Silence_Index] = No unit
    • Set Silence_Counter[Silence_LoopInteger] = Silence_Counter[Silence_Index]
    • Set Silence_Index = (Silence_Index - 1)
    • Set Silence_LoopInteger = (Silence_LoopInteger - 1)
 
Level 22
Joined
Sep 24, 2005
Messages
4,821
Or alternatively
  • -------- remove unneeded point handle --------
  • Custom script: call RemoveLocation(udg_Silence_Point[udg_Silence_LoopInteger])
  • -------- It's okay to set it to another point handle now --------
  • Set Silence_Caster[Silence_LoopInteger] = Silence_Caster[Silence_Index]
  • Set Silence_Dummy[Silence_LoopInteger] = Silence_Dummy[Silence_Index]
  • Set Silence_Point[Silence_LoopInteger] = Silence_Point[Silence_Index]
  • Set Silence_Counter[Silence_LoopInteger] = Silence_Counter[Silence_Index]
  • -------- Clear the last index arrays (to prevent leaks) --------
  • Set Silence_Caster[Silence_Index] = No Unit
  • Set Silence_Dummy[Silence_Index] = No Unit
  • Custom script: set udg_Silence_Point[udg_Silence_Index] = null
  • -------- Update the iterator and the instance counter --------
  • Set Silence_Index = (Silence_Index - 1)
  • Set Silence_LoopInteger = (Silence_LoopInteger - 1)
It's the same as death's, just grouped the actions in comment blocks so it's easier to see when you want to add/remove actions when needed.
 
Status
Not open for further replies.
Top