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

[Solved] Making 1 Unit cast multiple Instances of same Spell (Dynamic Indexing)

Level 12
Joined
May 7, 2008
Messages
345
Greetings.

Before posting this I've looked to see if there's anything like this but sadly I could not find something similar.

What I would like to do is to turn this Spell fully MUI for 1 Player.
Reason for that is that in my map there can be only 1 Unique Hero at the time.

Currently it's setup like this, and I assume the Points and Timers have to be an arrays? I tried asking ChatGPT but it told me to create a PN variable which won't help in this case, lol.

  • Consecration Cast Copy
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Consecration (Squire 6th Spell)
    • Actions
      • Set VariableSet Consecration_Level = (Level of (Ability being cast) for Squire_Unit)
      • Set VariableSet Consecration_PN = (Player number of Squire_Player)
      • Set VariableSet Consecration_Point = (Position of Squire_Unit)
      • -------- --------
      • Special Effect - Create a special effect at Consecration_Point using war3mapImported\Empyrean Nova.mdx
      • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(Consecration_Level))))
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • Trigger - Turn on Consecration Loop <gen>
      • -------- --------
  • Consecration Loop Copy
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • Set VariableSet Consecration_Timer = (Consecration_Timer + 1.00)
      • -------- --------
      • Special Effect - Create a special effect at Consecration_Point using war3mapImported\Empyrean Nova.mdx
      • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(Consecration_Level))))
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
      • Set VariableSet Consecration_Group = (Units within Consecration_AoE[Consecration_Level] of Consecration_Point matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Magic Immune) Equal to False))).)
      • -------- --------
      • Unit Group - Pick every unit in Consecration_Group and do (Actions)
        • Loop - Actions
          • -------- Set Main Variable --------
          • Set VariableSet Consecration_Unit = (Picked unit)
          • -------- --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Consecration_Unit belongs to an ally of Squire_Player.) Equal to True
            • Then - Actions
              • -------- --------
              • Set VariableSet NextHealTarget = Consecration_Unit
              • Set VariableSet NextHealSource = Squire_Unit
              • Set VariableSet NextHealAmount = (Consecration_Heal[Consecration_Level] + Heal_Event_Boost[Consecration_PN])
              • -------- --------
              • Trigger - Run Heal Unit <gen> (ignoring conditions)
              • -------- --------
              • Special Effect - Create a special effect attached to the origin of Consecration_Unit using war3mapImported\Penance.mdx
              • Special Effect - Set Scale of (Last created special effect) to 0.50
              • Special Effect - Destroy (Last created special effect)
              • -------- --------
            • Else - Actions
              • -------- --------
              • Unit - Cause Squire_Unit to damage Consecration_Unit, dealing Consecration_Damage[Consecration_Level] damage of attack type Spells and damage type Normal
              • -------- --------
              • Special Effect - Create a special effect attached to the origin of Consecration_Unit using Abilities\Spells\Other\Incinerate\IncinerateBuff.mdl
              • Special Effect - Destroy (Last created special effect)
              • -------- --------
      • -------- --------
      • Custom script: call DestroyGroup(udg_Consecration_Group)
      • -------- --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • Consecration_Timer Greater than or equal to 3.99
        • Then - Actions
          • Set VariableSet Consecration_Timer = 0.00
          • -------- --------
          • Custom script: call RemoveLocation(udg_Consecration_Point)
          • -------- --------
          • Trigger - Turn off (This trigger)
          • -------- --------
        • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,688
So here's the two most common GUI methods that you can use:

Unit Indexing:
This is what we've been using this whole time in our private discussions and is the easiest of the two. It allows each caster to have it's own instance of the custom spell by relying on it's custom value as the [index] of our variable arrays. However, it suffers when you want to have multiple instances coming from the same caster since your Arrays can only really track one value at a time. This method is ideal for designing custom spells that function like Howl of Terror (applies instantly and replaces existing buffs) and Blizzard (it's channeled so a caster can't have more than one instance at a time). On the other hand, a spell like Shockwave would run into issues since it'll be difficult to track multiple Shockwaves coming from the same caster.

Dynamic Indexing:
This method allows you to create a near infinite number of instances and does not have any limitations on the number of instances per caster. This method is ideal for spells like Shockwave since we want the spell to work regardless of the cooldown/number of Shockwaves active on the field. However, it's not a good option for a spell like Howl of Terror since a unit can only ever have one Howl of Terror buff applied at a time. In other words, it's bad for spells that have "replacement" effects and good for spells that "stack".

What I would like to do is to turn this Spell fully MUI for 1 Player.
What you want to do is use Dynamic Indexing. This will make the spell both MUI and support multiple instances from the same caster.

Note that MUI implies that there would be more than 1 unit casting, which is not the case here. You simply want that 1 unit to be able to have multiple instances of the spell active at a time.
 
Last edited:
Level 26
Joined
Sep 26, 2009
Messages
2,414
One thing I noticed is your use of Consecration_Timer.
Rather than counting up elapsed time, you should count down the remaining time. In "Consecration Cast" trigger set the remaining time into Consecration_Timer, and in "Consecration Loop" trigger decrement value of Consecration_Timer. In the if/then/else check if remaining time is ~0.00.

While this way of doing things will not help you make the spell MUI, it allows you to have dynamic durations of the spell (for example different duration per spell level), etc.

On top of that, the Consecration_Timer does not have to be of type 'real'. It's better if it is type 'integer'.
Then this variable does not represent how much time is left/has elapsed, it represents "how many times has 'Consecration Loop' been executed" or "how may times has 'Consecration Loop' yet to be executed".
The reason why this is better is only because then you can avoid comparisons like this:
  • Consecration_Timer Greater than or equal to 3.99
in favor of this:
  • Consecration_Timer Equal to 4
 
Level 12
Joined
May 7, 2008
Messages
345
@Uncle - Thank you, I followed up on your advice and read a small Dynamic Indexing tutorial which helped me understand what I need to do a bit further.

@Daffa - my apologies, I usually just post the trigger, I totally forgot. What I'm trying to replicate is Consecrate ability from WoW, only twist to it is that it heals allies and damages enemies as well. And yes, I'm using Bribe's Heal Event for all Healing Events in my map.

Ability description: Purifies the ground around the Hero, dealing X damage per second to all enemy units. Allied units inside the zone heal for the same amount instead. Lasts for X seconds.

@Nichilus I've heard that Integer timers can be off sometimes and overlap, since value of 1 for example mathematically in computer language can be (or is, idk) at 0.99999999999 value. I guess for 4 seconds that doesn't really matter, but for general rule of thumb I try to follow that rule. Might be wrong though, lol.

Anyway guys, these are my new triggers, hopefully I did something right:

  • Init Consecration
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set VariableSet CN_Damage[1] = 20.00
      • Set VariableSet CN_Damage[2] = 30.00
      • Set VariableSet CN_Damage[3] = 40.00
      • Set VariableSet CN_Damage[4] = 50.00
      • Set VariableSet CN_Damage[5] = 60.00
      • -------- --------
      • Set VariableSet CN_Heal[1] = 20.00
      • Set VariableSet CN_Heal[2] = 30.00
      • Set VariableSet CN_Heal[3] = 40.00
      • Set VariableSet CN_Heal[4] = 50.00
      • Set VariableSet CN_Heal[5] = 60.00
      • -------- --------
      • Set VariableSet CN_AoE[1] = 300.00
      • Set VariableSet CN_AoE[2] = 325.00
      • Set VariableSet CN_AoE[3] = 350.00
      • Set VariableSet CN_AoE[4] = 375.00
      • Set VariableSet CN_AoE[5] = 400.00
      • -------- --------
  • Consecration Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Consecration (Squire 6th Spell)
    • Actions
      • -------- Setup variables: --------
      • Set VariableSet CN_Index = (CN_Index + 1)
      • Set VariableSet CN_Unit[CN_Index] = (Triggering unit)
      • Set VariableSet CN_Counter[CN_Index] = 0
      • Set VariableSet CN_PN = (Player number of (Owner of CN_Unit[CN_Index]))
      • Set VariableSet CN_Level = (Level of (Ability being cast) for CN_Unit[CN_Index])
      • -------- Check the Index size: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CN_Index Equal to 1
        • Then - Actions
          • -------- Run the Loop: --------
          • Trigger - Turn on Consecration Loop <gen>
        • Else - Actions
      • -------- Set Index Point: --------
      • Set VariableSet CN_Point[CN_Index] = (Position of CN_Unit[CN_Index])
      • -------- Set effect: --------
      • Special Effect - Create a special effect at CN_Point[CN_Index] using war3mapImported\Empyrean Nova.mdx
      • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(CN_Level))))
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
  • Consecration Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • -------- Set Index timer: --------
      • Set VariableSet CN_Timer[CN_Index] = 4.00
      • Set VariableSet CN_Timer[CN_Index] = (CN_Timer[CN_Index] - 1.00)
      • -------- Set effect: --------
      • Special Effect - Create a special effect at CN_Point[CN_Index] using war3mapImported\Empyrean Nova.mdx
      • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(CN_Level))))
      • Special Effect - Destroy (Last created special effect)
      • -------- Create unit group: --------
      • Set VariableSet CN_Group = (Units within CN_AoE[CN_Level] of CN_Point[CN_Index] matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Magic Immune) Equal to False))).)
      • -------- Pick units in group (damage enemies, heal allies): --------
      • Unit Group - Pick every unit in CN_Group and do (Actions)
        • Loop - Actions
          • -------- Set variable for picked unit: --------
          • Set VariableSet CN_Target = (Picked unit)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CN_Target belongs to an ally of (Owner of CN_Unit[CN_Index]).) Equal to True
            • Then - Actions
              • -------- Setup Heal Event variables: --------
              • Set VariableSet NextHealTarget = CN_Target
              • Set VariableSet NextHealSource = CN_Unit[CN_Index]
              • Set VariableSet NextHealAmount = (CN_Heal[CN_Level] + Heal_Event_Boost[CN_PN])
              • -------- Run Bribe's Heal Event trigger: --------
              • Trigger - Run Heal Unit <gen> (ignoring conditions)
              • -------- Setup effect for picked unit: --------
              • Special Effect - Create a special effect attached to the origin of CN_Target using war3mapImported\Penance.mdx
              • Special Effect - Set Scale of (Last created special effect) to 0.50
              • Special Effect - Destroy (Last created special effect)
              • -------- --------
            • Else - Actions
              • -------- Unit is an enemy, damage it: --------
              • Unit - Cause CN_Unit[CN_Index] to damage CN_Target, dealing CN_Damage[CN_Level] damage of attack type Spells and damage type Normal
              • -------- Setup effect for picked unit: --------
              • Special Effect - Create a special effect attached to the origin of CN_Target using Abilities\Spells\Other\Incinerate\IncinerateBuff.mdl
              • Special Effect - Destroy (Last created special effect)
              • -------- --------
      • -------- Destroy Group: --------
      • Custom script: call DestroyGroup(udg_CN_Group)
      • -------- Check Index Timer: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CN_Timer[CN_Index] Less than or equal to 0.00
        • Then - Actions
          • -------- Reset Index Timer value: --------
          • Set VariableSet CN_Timer[CN_Index] = 0.00
          • -------- Remove Index Point: --------
          • Custom script: call RemoveLocation(udg_CN_Point[udg_CN_Index])
          • -------- --------
          • Trigger - Turn off (This trigger)
          • -------- --------
        • Else - Actions
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,688
Integers are precise, it's Reals that could be 0.99999 after arithmetic. Integers are whole numbers after all. He was suggesting using an Integer for the duration rather than a Real for this very reason. It doesn't really matter though as long as you account for it, which you were doing with the 3.99.

Dynamic Indexing requires that you use a For Loop to enumerate over all of the Arrays. Check out that dynamic indexing tutorial again and copy exactly how they do it, don't try to improvise or reuse what you already have.
 
Level 12
Joined
May 7, 2008
Messages
345
Integers are precise, it's Reals that could be 0.99999 after arithmetic. Integers are whole numbers after all. He was suggesting using an Integer for the duration rather than a Real for this very reason. It doesn't really matter though as long as you account for it, which you were doing with the 3.99.

Dynamic Indexing requires that you use a For Loop to enumerate over all of the Arrays. Check out that dynamic indexing tutorial again and copy exactly how they do it, don't try to improvise or reuse what you already have.

Oh woops, I forgot to add the Loop part, my bad.

EDIT: added Index reduction at the bottom of the Loop.

  • Consecration Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Consecration (Squire 6th Spell)
    • Actions
      • -------- Setup variables: --------
      • Set VariableSet CN_Index = (CN_Index + 1)
      • Set VariableSet CN_Unit[CN_Index] = (Triggering unit)
      • Set VariableSet CN_Counter[CN_Index] = 0
      • Set VariableSet CN_PN = (Player number of (Owner of CN_Unit[CN_Index]))
      • Set VariableSet CN_Level = (Level of (Ability being cast) for CN_Unit[CN_Index])
      • -------- Check the Index size: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CN_Index Equal to 1
        • Then - Actions
          • -------- Run the Loop: --------
          • Trigger - Turn on Consecration Loop <gen>
        • Else - Actions
      • -------- Set Index Point: --------
      • Set VariableSet CN_Point[CN_Index] = (Position of CN_Unit[CN_Index])
      • -------- Set effect: --------
      • Special Effect - Create a special effect at CN_Point[CN_Index] using war3mapImported\Empyrean Nova.mdx
      • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(CN_Level))))
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
  • Consecration Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer CN_Loop) from 1 to CN_Index, do (Actions)
        • Loop - Actions
          • -------- Set Index timer: --------
          • Set VariableSet CN_Timer[CN_Index] = 4
          • Set VariableSet CN_Timer[CN_Index] = (CN_Timer[CN_Index] - 1)
          • -------- Set effect: --------
          • Special Effect - Create a special effect at CN_Point[CN_Index] using war3mapImported\Empyrean Nova.mdx
          • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(CN_Level))))
          • Special Effect - Destroy (Last created special effect)
          • -------- Create unit group: --------
          • Set VariableSet CN_Group = (Units within CN_AoE[CN_Level] of CN_Point[CN_Index] matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Magic Immune) Equal to False))).)
          • -------- Pick units in group (damage enemies, heal allies): --------
          • Unit Group - Pick every unit in CN_Group and do (Actions)
            • Loop - Actions
              • -------- Set variable for picked unit: --------
              • Set VariableSet CN_Target = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CN_Target belongs to an ally of (Owner of CN_Unit[CN_Index]).) Equal to True
                • Then - Actions
                  • -------- Setup Heal Event variables: --------
                  • Set VariableSet NextHealTarget = CN_Target
                  • Set VariableSet NextHealSource = CN_Unit[CN_Index]
                  • Set VariableSet NextHealAmount = (CN_Heal[CN_Level] + Heal_Event_Boost[CN_PN])
                  • -------- Run Bribe's Heal Event trigger: --------
                  • Trigger - Run Heal Unit <gen> (ignoring conditions)
                  • -------- Setup effect for picked unit: --------
                  • Special Effect - Create a special effect attached to the origin of CN_Target using war3mapImported\Penance.mdx
                  • Special Effect - Set Scale of (Last created special effect) to 0.50
                  • Special Effect - Destroy (Last created special effect)
                  • -------- --------
                • Else - Actions
                  • -------- Unit is an enemy, damage it: --------
                  • Unit - Cause CN_Unit[CN_Index] to damage CN_Target, dealing CN_Damage[CN_Level] damage of attack type Spells and damage type Normal
                  • -------- Setup effect for picked unit: --------
                  • Special Effect - Create a special effect attached to the origin of CN_Target using Abilities\Spells\Other\Incinerate\IncinerateBuff.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • -------- --------
          • -------- Destroy Group: --------
          • Custom script: call DestroyGroup(udg_CN_Group)
          • -------- Check Index Timer: --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CN_Timer[CN_Index] Less than or equal to 0
            • Then - Actions
              • -------- Reduce Index size by 1: --------
              • Set VariableSet CN_Index = (CN_Index - 1)
              • -------- Reset Index Timer value: --------
              • Set VariableSet CN_Timer[CN_Index] = 0
              • -------- Remove Index Point: --------
              • Custom script: call RemoveLocation(udg_CN_Point[udg_CN_Index])
              • -------- --------
              • Trigger - Turn off (This trigger)
              • -------- --------
            • Else - Actions
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,688
This doesn't make sense:
  • -------- Set Index timer: --------
  • Set VariableSet CN_Timer[CN_Index] = 4
  • Set VariableSet CN_Timer[CN_Index] = (CN_Timer[CN_Index] - 1)
This is an infinite timer :p

You can get rid of this:
  • Set VariableSet CN_PN = (Player number of (Owner of CN_Unit[CN_Index]))
Looks like a leftover.

Also, that's not how you remove an instance from the For Loop, see the tutorial again for what to do once you're ready to "remove" an instance. As of right now you'll be turning off the trigger when the first of the instances finishes, causing the rest to stop prematurely.
 
Level 12
Joined
May 7, 2008
Messages
345
This doesn't make sense:
  • -------- Set Index timer: --------
  • Set VariableSet CN_Timer[CN_Index] = 4
  • Set VariableSet CN_Timer[CN_Index] = (CN_Timer[CN_Index] - 1)
This is an infinite timer :p

You can get rid of this:
  • Set VariableSet CN_PN = (Player number of (Owner of CN_Unit[CN_Index]))
Looks like a leftover.

Also, that's not how you remove an instance from the For Loop, see the tutorial again for what to do once you're ready to "remove" an instance. As of right now you'll be turning off the trigger when the first of the instances finishes, causing the rest to stop prematurely.

Now that you pointed that out, yeah that makes no sense to me either. :peasant-popcorn:

I've fixed that part by moving Timer in the Cast trigger, and added a new If check for Index size.

  • Consecration Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Consecration (Squire 6th Spell)
    • Actions
      • -------- Setup variables: --------
      • Set VariableSet CN_Index = (CN_Index + 1)
      • Set VariableSet CN_Unit[CN_Index] = (Triggering unit)
      • Set VariableSet CN_Timer[CN_Index] = 0
      • Set VariableSet CN_PN = (Player number of (Owner of CN_Unit[CN_Index]))
      • Set VariableSet CN_Level = (Level of (Ability being cast) for CN_Unit[CN_Index])
      • -------- Check the Index size: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CN_Index Equal to 1
        • Then - Actions
          • -------- Run the Loop: --------
          • Trigger - Turn on Consecration Loop <gen>
        • Else - Actions
      • -------- Set Index Point: --------
      • Set VariableSet CN_Point[CN_Index] = (Position of CN_Unit[CN_Index])
      • -------- Set effect: --------
      • Special Effect - Create a special effect at CN_Point[CN_Index] using war3mapImported\Empyrean Nova.mdx
      • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(CN_Level))))
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
  • Consecration Loop
    • Events
      • Time - Every 1.00 seconds of game time
    • Conditions
    • Actions
      • For each (Integer CN_Loop) from 1 to CN_Index, do (Actions)
        • Loop - Actions
          • -------- Set Index timer: --------
          • Set VariableSet CN_Timer[CN_Loop] = (CN_Timer[CN_Loop] + 1)
          • -------- Set effect: --------
          • Special Effect - Create a special effect at CN_Point[CN_Index] using war3mapImported\Empyrean Nova.mdx
          • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(CN_Level))))
          • Special Effect - Destroy (Last created special effect)
          • -------- Create unit group: --------
          • Set VariableSet CN_Group = (Units within CN_AoE[CN_Level] of CN_Point[CN_Index] matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Magic Immune) Equal to False))).)
          • -------- Pick units in group (damage enemies, heal allies): --------
          • Unit Group - Pick every unit in CN_Group and do (Actions)
            • Loop - Actions
              • -------- Set variable for picked unit: --------
              • Set VariableSet CN_Target = (Picked unit)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (CN_Target belongs to an ally of (Owner of CN_Unit[CN_Index]).) Equal to True
                • Then - Actions
                  • -------- Setup Heal Event variables: --------
                  • Set VariableSet NextHealTarget = CN_Target
                  • Set VariableSet NextHealSource = CN_Unit[CN_Index]
                  • Set VariableSet NextHealAmount = (CN_Heal[CN_Level] + Heal_Event_Boost[CN_PN])
                  • -------- Run Bribe's Heal Event trigger: --------
                  • Trigger - Run Heal Unit <gen> (ignoring conditions)
                  • -------- Setup effect for picked unit: --------
                  • Special Effect - Create a special effect attached to the origin of CN_Target using war3mapImported\Penance.mdx
                  • Special Effect - Set Scale of (Last created special effect) to 0.50
                  • Special Effect - Destroy (Last created special effect)
                  • -------- --------
                • Else - Actions
                  • -------- Unit is an enemy, damage it: --------
                  • Unit - Cause CN_Unit[CN_Index] to damage CN_Target, dealing CN_Damage[CN_Level] damage of attack type Spells and damage type Normal
                  • -------- Setup effect for picked unit: --------
                  • Special Effect - Create a special effect attached to the origin of CN_Target using Abilities\Spells\Other\Incinerate\IncinerateBuff.mdl
                  • Special Effect - Destroy (Last created special effect)
                  • -------- --------
          • -------- Destroy Group: --------
          • Custom script: call DestroyGroup(udg_CN_Group)
          • -------- Check Index Timer: --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • CN_Timer[CN_Loop] Greater than or equal to 4
            • Then - Actions
              • -------- Remove Index Point: --------
              • Custom script: call RemoveLocation(udg_CN_Point[udg_CN_Index])
              • -------- Swap Array variables: --------
              • Set VariableSet CN_Timer[CN_Loop] = CN_Counter[CN_Index]
              • -------- Subtract Loop by 1: --------
              • Set VariableSet CN_Loop = (CN_Loop - 1)
              • -------- Subtract Index by 1: --------
              • Set VariableSet CN_Index = (CN_Index - 1)
              • -------- --------
              • -------- Check if Index size is 0: --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CN_Index Equal to 0
                • Then - Actions
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
 
Last edited:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,688
Everything below this line has issues:
  • -------- Check Index Timer: --------
With dynamic indexing you need to take extra steps when it comes time to "remove" an instance. This is to ensure that all of the other instances will still work properly.

Also, you only need to check the state of CN_Index after subtracting it, no reason to ask that question if it hasn't changed.

What you do is swap the current instance with the last instance, then drop the total number of instances down by 1, and finally set the loop back 1 cycle as to not skip the next instance in queue. Again, the tutorial should break this down. Sort of imagine it like a totem pole that has 3 segments, when you remove the middle segment the segment on top will fall down one level.
 
Last edited:
Level 12
Joined
May 7, 2008
Messages
345
Alright boys, I've polished the trigger, added comments inside the setups and renamed the variables for more convenience.

This is the final product and it should be good to go!

Thanks to everyone who helped, I appreciate it.

SOLVED! :peasant-popcorn:

  • Init Consecration
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Set VariableSet CN_Damage[1] = 20.00
      • Set VariableSet CN_Damage[2] = 30.00
      • Set VariableSet CN_Damage[3] = 40.00
      • Set VariableSet CN_Damage[4] = 50.00
      • Set VariableSet CN_Damage[5] = 60.00
      • -------- --------
      • Set VariableSet CN_Heal[1] = 20.00
      • Set VariableSet CN_Heal[2] = 30.00
      • Set VariableSet CN_Heal[3] = 40.00
      • Set VariableSet CN_Heal[4] = 50.00
      • Set VariableSet CN_Heal[5] = 60.00
      • -------- --------
      • Set VariableSet CN_AoE[1] = 300.00
      • Set VariableSet CN_AoE[2] = 325.00
      • Set VariableSet CN_AoE[3] = 350.00
      • Set VariableSet CN_AoE[4] = 375.00
      • Set VariableSet CN_AoE[5] = 400.00
      • -------- --------
  • Consecration Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Consecration (Squire 6th Spell)
    • Actions
      • -------- Setup variables: --------
      • Set VariableSet CN_Index = (CN_Index + 1)
      • Set VariableSet CN_Unit[CN_Index] = (Triggering unit)
      • Set VariableSet CN_Counter[CN_Index] = 0
      • -------- --------
      • Set VariableSet CN_PN[CN_Index] = (Player number of (Owner of CN_Unit[CN_Index]))
      • Set VariableSet CN_Level[CN_Index] = (Level of (Ability being cast) for CN_Unit[CN_Index])
      • -------- Check the Index size: --------
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • CN_Index Equal to 1
        • Then - Actions
          • -------- Run the Loop: --------
          • Trigger - Turn on Consecration Loop <gen>
        • Else - Actions
      • -------- Set Index Point: --------
      • Set VariableSet CN_Point[CN_Index] = (Position of CN_Unit[CN_Index])
      • -------- Set Effect: --------
      • Special Effect - Create a special effect at CN_Point[CN_Index] using war3mapImported\Empyrean Nova.mdx
      • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(CN_Level[CN_Index]))))
      • Special Effect - Destroy (Last created special effect)
      • -------- --------
  • Consecration Loop
    • Events
      • Time - Every 0.05 seconds of game time
    • Conditions
    • Actions
      • For each (Integer CN_Loop) from 1 to CN_Index, do (Actions)
        • Loop - Actions
          • -------- Set Index timer: --------
          • Set VariableSet CN_Counter[CN_Loop] = (CN_Counter[CN_Loop] + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (CN_Counter[CN_Loop] mod 20) Equal to 0
            • Then - Actions
              • -------- Set Effect: --------
              • Special Effect - Create a special effect at CN_Point[CN_Loop] using war3mapImported\Empyrean Nova.mdx
              • Special Effect - Set Scale of (Last created special effect) to (0.70 + (0.11 x (Real(CN_Level[CN_Loop]))))
              • Special Effect - Destroy (Last created special effect)
              • -------- Create Unit Group: --------
              • Set VariableSet CN_Group = (Units within CN_AoE[CN_Level[CN_Loop]] of CN_Point[CN_Loop] matching ((((Matching unit) is alive) Equal to True) and ((((Matching unit) is A structure) Equal to False) and (((Matching unit) is Magic Immune) Equal to False))).)
              • -------- Pick units in group (damage enemies, heal allies): --------
              • Unit Group - Pick every unit in CN_Group and do (Actions)
                • Loop - Actions
                  • -------- Set variable for picked unit: --------
                  • Set VariableSet CN_Target = (Picked unit)
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (CN_Target belongs to an ally of (Owner of CN_Unit[CN_Loop]).) Equal to True
                    • Then - Actions
                      • -------- Setup Heal Event variables: --------
                      • Set VariableSet NextHealTarget = CN_Target
                      • Set VariableSet NextHealSource = CN_Unit[CN_Loop]
                      • Set VariableSet NextHealAmount = (CN_Heal[CN_Level[CN_Loop]] x Heal_Event_Boost[CN_PN[CN_Loop]])
                      • -------- Run Bribe's Heal Event trigger: --------
                      • Trigger - Run Heal Unit <gen> (ignoring conditions)
                      • -------- Setup effect for picked unit: --------
                      • Special Effect - Create a special effect attached to the origin of CN_Target using war3mapImported\Penance.mdx
                      • Special Effect - Set Scale of (Last created special effect) to 0.50
                      • Special Effect - Destroy (Last created special effect)
                      • -------- --------
                    • Else - Actions
                      • -------- Unit is an enemy, damage it: --------
                      • Unit - Cause CN_Unit[CN_Loop] to damage CN_Target, dealing CN_Damage[CN_Level[CN_Loop]] damage of attack type Spells and damage type Normal
                      • -------- Setup effect for picked unit: --------
                      • Special Effect - Create a special effect attached to the origin of CN_Target using Abilities\Spells\Other\Incinerate\IncinerateBuff.mdl
                      • Special Effect - Destroy (Last created special effect)
                      • -------- --------
              • -------- --------
              • -------- Destroy Group: --------
              • Custom script: call DestroyGroup(udg_CN_Group)
              • -------- --------
              • -------- Proceed to check the If / Then / Else: --------
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • CN_Counter[CN_Loop] Greater than or equal to 80
                • Then - Actions
                  • -------- Remove Index Point: --------
                  • Custom script: call RemoveLocation(udg_CN_Point[udg_CN_Loop])
                  • -------- Swap Index Point: --------
                  • Set VariableSet CN_Point[CN_Loop] = CN_Point[CN_Index]
                  • -------- Swap Array variables: --------
                  • Set VariableSet CN_Unit[CN_Loop] = CN_Unit[CN_Index]
                  • Set VariableSet CN_Counter[CN_Loop] = CN_Counter[CN_Index]
                  • Set VariableSet CN_PN[CN_Loop] = CN_PN[CN_Index]
                  • Set VariableSet CN_Level[CN_Loop] = CN_Level[CN_Index]
                  • -------- Subtract Loop by 1: --------
                  • Set VariableSet CN_Loop = (CN_Loop - 1)
                  • -------- Subtract Index by 1: --------
                  • Set VariableSet CN_Index = (CN_Index - 1)
                  • -------- --------
                  • -------- Check if Index size is 0: --------
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • CN_Index Equal to 0
                    • Then - Actions
                      • Trigger - Turn off (This trigger)
                    • Else - Actions
                • Else - Actions
            • Else - Actions
 
Top