• 🏆 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] My first spell, needs help

Status
Not open for further replies.
Level 9
Joined
Apr 23, 2010
Messages
312
So as the title says, this is my first spell so don't be too rough on the criticism if you can help it. Anyways, I have a couple of problems.

Problem #1: When I use "bj_wantDestroyGroup = true" or "call DestroyGroup(udg_groupvar)" it ruins the trigger below and does not damage or create special effects on the units in the group. Please not that this trigger is initially off and is turned on by the next trigger.
  • Spell Loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer IndexLoop) from 1 to Index, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Time[Index] Equal to 20
                  • (Caster[Index] is alive) Equal to False
                  • (Caster[Index] has buff Sleep (Pause)) Equal to True
                  • (Caster[Index] has buff Stunned (Pause)) Equal to True
            • Then - Actions
              • Unit Group - Pick every unit in DamageGroup[Index] and do (Actions)
                • Loop - Actions
                  • Unit Group - Remove (Picked unit) from DamageGroup[Index]
              • Set Caster[Index] = No unit
              • Set Time[Index] = 0
              • Set Index = 0
              • Trigger - Turn off (This trigger)
              • Skip remaining actions
            • Else - Actions
              • Unit Group - Pick every unit in DamageGroup[Index] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is dead) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from DamageGroup[Index]
                    • Else - Actions
                      • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - Damage[Index])
                      • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                      • Special Effect - Destroy (Last created special effect)
      • Set Time[Index] = (Time[Index] + 1)
Problem #2: I can't get this to be MUI. When the ability is cast with 2 heroes, the first cast spell works but the 2nd cast spell does nothing.

Here is the other trigger.
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Blast
    • Actions
      • Set Index = (Index + 1)
      • Set Caster[Index] = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Mind Blast for Caster[Index]) Equal to 1
        • Then - Actions
          • Set Damage[Index] = ((Real((Intelligence of Caster[Index] (Exclude bonuses)))) / 3.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Mind Blast for Caster[Index]) Equal to 2
            • Then - Actions
              • Set Damage[Index] = ((Real((Intelligence of Caster[Index] (Exclude bonuses)))) / 2.00)
            • Else - Actions
              • Set Damage[Index] = (Real((Intelligence of Caster[Index] (Exclude bonuses))))
      • Set CasterOwner[Index] = (Owner of Caster[Index])
      • Set Target[Index] = (Target point of ability being cast)
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of Target[Index] matching ((((Picked unit) is A structure) Equal to False) and ((((Picked unit) belongs to an ally of CasterOwner[Index]) Equal to False) and (((Picked unit) is Magic Immune) Equal to False)))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
            • Else - Actions
              • Unit Group - Add (Picked unit) to DamageGroup[Index]
      • Trigger - Turn on Spell Loop <gen>
      • Custom script: call RemoveLocation(udg_Target[udg_Index])
If anyone could help me out it would be very appreciated!
 
Your first trigger's arrays should all have the value of IndexLoop, not Index. You are resetting the Index to 0, once one instance ends, preventing other instances that run at the same time to properly function. You should be using a new Index kind of variable (e.g. Index2), which you will be decreasing by 1, once an instance is over. If its value is Equal to 0, then set Index2 = 0.
Did you create the groups?:
  • Custom script: if udg_DamageGroup[udg_Index] == null then
  • Custom script: set udg_DamageGroup[udg_Index] = CreateGroup()
  • Custom script: endif
You have to realize how arrays work. Here is a really helpful demonstration:

JASS:
1   2   3   4   5   // initial arrangement
-   2   3   4   5   // struct 1 ends
5   2   3   4   -   // move struct 5 to struct 1's place and decrease the total number of structs running
5   -   3   4   -   // struct 2 ends
5   4   3   -   -   // repeat
5   4   -   -   -   // struct 3 ends
4   -   -   -   -   // struct 5 ends
-   -   -   -   -   // struct 4 ends, no structs running and timer stops
(replace "struct" with "instance" in your head)
from Dynasti's tutorial on indexing.
 
Level 9
Joined
Apr 23, 2010
Messages
312
Ok so I did all those changes that you mentioned.
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Blast
    • Actions
      • Set Index1 = (Index1 + 1)
      • Set Index2 = (Index2 + 1)
      • Set Caster[Index1] = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Mind Blast for Caster[Index1]) Equal to 1
        • Then - Actions
          • Set Damage[Index1] = ((Real((Intelligence of Caster[Index1] (Exclude bonuses)))) / 3.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Mind Blast for Caster[Index1]) Equal to 2
            • Then - Actions
              • Set Damage[Index1] = ((Real((Intelligence of Caster[Index1] (Exclude bonuses)))) / 2.00)
            • Else - Actions
              • Set Damage[Index1] = (Real((Intelligence of Caster[Index1] (Exclude bonuses))))
      • Set CasterOwner[Index1] = (Owner of Caster[Index1])
      • Set Target[Index1] = (Target point of ability being cast)
      • Custom script: if udg_DamageGroup[udg_Index1] == null then
      • Custom script: set udg_DamageGroup[udg_Index1] = CreateGroup()
      • Custom script: endif
      • Unit Group - Pick every unit in (Units within 200.00 of Target[Index1] matching ((((Picked unit) is A structure) Equal to False) and ((((Picked unit) belongs to an ally of CasterOwner[Index1]) Equal to False) and (((Picked unit) is Magic Immune) Equal to False)))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
            • Else - Actions
              • Unit Group - Add (Picked unit) to DamageGroup[Index1]
      • Trigger - Turn on Spell Loop <gen>
      • Custom script: call RemoveLocation(udg_Target[udg_Index1])
  • Spell Loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer IndexLoop) from 1 to Index1, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Time[IndexLoop] Equal to 20
                  • (Caster[IndexLoop] is alive) Equal to False
                  • (Caster[IndexLoop] has buff Sleep (Pause)) Equal to True
                  • (Caster[IndexLoop] has buff Stunned (Pause)) Equal to True
            • Then - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index2 Equal to 0
                • Then - Actions
                  • Unit Group - Remove all units from DamageGroup[IndexLoop]
                  • Set Caster[IndexLoop] = No unit
                  • Set Time[IndexLoop] = 0
                  • Set Index2 = (Index2 - 1)
                  • Set Index1 = 0
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Unit Group - Pick every unit in DamageGroup[IndexLoop] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is dead) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from DamageGroup[IndexLoop]
                    • Else - Actions
                      • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - Damage[IndexLoop])
                      • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                      • Special Effect - Destroy (Last created special effect)
      • Set Time[IndexLoop] = (Time[IndexLoop] + 1)
I'm not sure i'm doing the whole indexing thing correctly though because it's still doing the same thing as before.
 
  • Unit Group - Pick every unit in (Units within 200.00 of Target[Index1] matching ((((Picked unit) is A structure) Equal to False) and ((((Picked unit) belongs to a
Replace the (Picked unit) in there with (Matching unit).

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
  • If - Conditions
  • ((Picked unit) is dead) Equal to True
  • Then - Actions
  • Else - Actions
  • Unit Group - Add (Picked unit) to DamageGroup[Index1]
Just use

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • ((Picked unit) is dead) Equal to False
    • Then - Actions
      • Unit Group - Add (Picked unit) to DamageGroup[Index1]
    • Else - Actions
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Index2 Equal to 0
    • Then - Actions
      • Unit Group - Remove all units from DamageGroup[IndexLoop]
      • Set Caster[IndexLoop] = No unit
      • Set Time[IndexLoop] = 0
      • Set Index2 = (Index2 - 1)
      • Set Index1 = 0
      • Trigger - Turn off (This trigger)
    • Else - Actions
-->
  • Unit Group - Remove all units from DamageGroup[IndexLoop]
  • Set Caster[IndexLoop] = No unit
  • Set Time[IndexLoop] = 0
  • Set Index2 = (Index2 - 1)
  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • Index2 Equal to 0
    • Then - Actions
      • Set Index1 = 0
      • Trigger - Turn off (This trigger)
    • Else - Actions
 
Level 9
Joined
Apr 23, 2010
Messages
312
Haha it works now! I posted the triggers below if you wouldn't mind taking a look at it to check if I missed something. +rep to you!

  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Blast
    • Actions
      • Set Index1 = (Index1 + 1)
      • Set Index2 = (Index2 + 1)
      • Set Caster[Index1] = (Triggering unit)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Level of Mind Blast for Caster[Index1]) Equal to 1
        • Then - Actions
          • Set Damage[Index1] = ((Real((Intelligence of Caster[Index1] (Exclude bonuses)))) / 3.00)
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Level of Mind Blast for Caster[Index1]) Equal to 2
            • Then - Actions
              • Set Damage[Index1] = ((Real((Intelligence of Caster[Index1] (Exclude bonuses)))) / 2.00)
            • Else - Actions
              • Set Damage[Index1] = (Real((Intelligence of Caster[Index1] (Exclude bonuses))))
      • Set CasterOwner[Index1] = (Owner of Caster[Index1])
      • Set Target[Index1] = (Target point of ability being cast)
      • Custom script: set udg_DamageGroup[udg_Index1] = CreateGroup()
      • Unit Group - Pick every unit in (Units within 200.00 of Target[Index1] matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of CasterOwner[Index1]) Equal to False) and (((Matching unit) is Magic Immune) Equal to False)))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
            • Else - Actions
              • Unit Group - Add (Picked unit) to DamageGroup[Index1]
      • Trigger - Turn on Spell Loop <gen>
      • Custom script: call RemoveLocation(udg_Target[udg_Index1])
  • Spell Loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer IndexLoop) from 1 to Index1, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Time[IndexLoop] Equal to 20
                  • (Caster[IndexLoop] is alive) Equal to False
                  • (Caster[IndexLoop] has buff Sleep (Pause)) Equal to True
                  • (Caster[IndexLoop] has buff Stunned (Pause)) Equal to True
            • Then - Actions
              • Set Caster[IndexLoop] = No unit
              • Set Time[IndexLoop] = 0
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index2 Equal to 0
                • Then - Actions
                  • Unit Group - Remove all units from DamageGroup[IndexLoop]
                  • Set Index2 = (Index2 - 1)
                  • Set Index1 = 0
                  • Custom script: call DestroyGroup(udg_DamageGroup[udg_Index1])
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Unit Group - Pick every unit in DamageGroup[IndexLoop] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is dead) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from DamageGroup[IndexLoop]
                    • Else - Actions
                      • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - Damage[IndexLoop])
                      • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                      • Special Effect - Destroy (Last created special effect)
      • Set Time[IndexLoop] = (Time[IndexLoop] + 1)
 
Level 26
Joined
Mar 19, 2008
Messages
3,140
You use old, inefficient indexing system. Your trigger won't work since you use reference (Picked unit) instead of (Matching unit) + trigger leaks. I'll add fixed version in a minute.
Location array variable is uneeded - normal one is enought. You do not need to save owning player. Why Set Time[IndexLoop] = (Time[IndexLoop] + 1) outside the loop? It will do nothing afterall ;( Use damage formula to add efficiency. Checking the value of Index2 before actually lowering it? Isn't it silly?

EDIT #141: Why do you destroy group only when all instances are finished? And action - remove all units from group isn't needed for sure - unit is either removed or group gets destroyed.
Group was destroyed incorrectly anyways.
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Blast
    • Actions
      • Set Index1 = (Index1 + 1)
      • Set Index2 = (Index2 + 1)
      • Set Caster[Index1] = (Triggering unit)
      • Set Damage[Index1] = ((Real((Intelligence of Caster[Index1] (Exclude bonuses)))) / (4 - (Level of Mind Blast for Caster[Index1])))
      • Set Time[Index1] = 0.00
      • Set p = (Target point of ability being cast)
      • Custom script: set udg_DamageGroup[udg_Index1] = CreateGroup()
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 200.00 of p matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of CasterOwner[Index1]) Equal to False) and (((Matching unit) is Magic Immune) Equal to False) and ((Matching unit) is dead) Equal to False))) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to DamageGroup[Index1]
      • Trigger - Turn on Spell Loop <gen>
      • Custom script: call RemoveLocation(udg_p)
  • Spell Loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer IndexLoop) from 1 to Index1, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Time[IndexLoop] Equal to 20
                  • (Caster[IndexLoop] is alive) Equal to False
                  • (Caster[IndexLoop] has buff Sleep (Pause)) Equal to True
                  • (Caster[IndexLoop] has buff Stunned (Pause)) Equal to True
            • Then - Actions
              • Set Caster[IndexLoop] = No unit
              • Custom script: call DestroyGroup(udg_DamageGroup[udg_IndexLoop])
              • Set Index2 = (Index2 - 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index2 Equal to 0
                • Then - Actions
                  • Set Index1 = 0
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Set Time[IndexLoop] = (Time[IndexLoop] + 0.5)
              • Unit Group - Pick every unit in DamageGroup[IndexLoop] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is dead) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from DamageGroup[IndexLoop]
                    • Else - Actions
                      • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - Damage[IndexLoop])
                      • Special Effect - Create a special effect attached to the origin of (Picked unit) using Abilities\Spells\Undead\DeathPact\DeathPactTarget.mdl
                      • Special Effect - Destroy (Last created special effect)
 
Last edited:
Prefer using formulas that support multiple levels of a spell (in fact, if it would be uploaded in the Spells section, that would be a requirement: JESP) instead of a whole block of if/then/else (I am referring to the Damage variable).

You don't need to store the Caster's owner. Use (Triggering player) in the first trigger and (Owner of Caster[IndexLoop]) in the second.

Use more informative names for variables, e.g. Target usually refers to a unit; use TargetPoint instead.

"Target[]" variable doesn't need to use an Index; you don't use it in the loop trigger anyway as a reference. Make it non-array'd.

You didn't add the block that checks if udg_DamageGroup[udg_Index] != null, to create it.

Null the Caster variable in the end of the instance.

Edit: Oh, I was late checking something else. Nevermind.
 
Level 9
Joined
Apr 23, 2010
Messages
312
Would this work for the formula?
  • Set AbilityLevel[Index1] = (Level of Mind Blast for (Triggering unit))
  • Set LevelDamage[Index1] = ((Real((Intelligence of (Triggering unit) (Exclude bonuses)))) / (4.00 - (Real(AbilityLevel[Index1]))))
Removed CasterOwner variable and replaced it with owner of triggering unit.

Added "if udg_DamageGroup[udg_Index] != null then" block in. I had put this in before but it didn't work for some reason that's why I took it out, but it works fine now :)

Changed Time variable from integer to real.

Doesn't "Set Caster[IndexLoop] = No unit" null the caster variable?

Spell now ends when time = 20, thanks for that spinnaker!
  • Spell
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Blast
    • Actions
      • Set Index1 = (Index1 + 1)
      • Set Index2 = (Index2 + 1)
      • Set Caster[Index1] = (Triggering unit)
      • Set AbilityLevel[Index1] = (Level of Mind Blast for (Triggering unit))
      • Set LevelDamage[Index1] = ((Real((Intelligence of (Triggering unit) (Exclude bonuses)))) / (4.00 - (Real(AbilityLevel[Index1]))))
      • Set TargetPoint = (Target point of ability being cast)
      • Custom script: if udg_DamageGroup[udg_Index1] == null then
      • Custom script: set udg_DamageGroup[udg_Index1] = CreateGroup()
      • Custom script: endif
      • Unit Group - Pick every unit in (Units within 200.00 of TargetPoint matching ((((Matching unit) is A structure) Equal to False) and ((((Matching unit) belongs to an ally of (Owner of (Triggering unit))) Equal to False) and (((Matching unit) is Magic Immune) Equal to False)))) and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked unit) is dead) Equal to True
            • Then - Actions
            • Else - Actions
              • Unit Group - Add (Picked unit) to DamageGroup[Index1]
      • Trigger - Turn on Spell Loop <gen>
      • Custom script: call RemoveLocation(udg_TargetPoint)
  • Spell Loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • For each (Integer IndexLoop) from 1 to Index1, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • Time[IndexLoop] Greater than or equal to 20.00
                  • (Caster[IndexLoop] is alive) Equal to False
                  • (Caster[IndexLoop] has buff Sleep (Pause)) Equal to True
                  • (Caster[IndexLoop] has buff Stunned (Pause)) Equal to True
            • Then - Actions
              • Set Caster[IndexLoop] = No unit
              • Set Time[IndexLoop] = 0.00
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • Index2 Equal to 0
                • Then - Actions
                  • Unit Group - Remove all units from DamageGroup[IndexLoop]
                  • Set Index2 = (Index2 - 1)
                  • Set Index1 = 0
                  • Custom script: call DestroyGroup(udg_DamageGroup[udg_Index1])
                  • Trigger - Turn off (This trigger)
                • Else - Actions
            • Else - Actions
              • Set Time[IndexLoop] = (Time[IndexLoop] + 1.00)
              • Unit Group - Pick every unit in DamageGroup[IndexLoop] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is dead) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from DamageGroup[IndexLoop]
                    • Else - Actions
                      • Unit - Set life of (Picked unit) to ((Life of (Picked unit)) - LevelDamage[IndexLoop])
                      • Special Effect - Create a special effect attached to the head of (Picked unit) using Abilities\Spells\Undead\OrbOfDeath\AnnihilationMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
Thank you Pharaoh_ for helping me out with this spell!
 
Last edited:
- That formula may crash the map for level 4 of the ability, because the divisor becomes 0.
- Use (Triggering player); it procs faster than (Owner of (Triggering unit)).
- You still use your old indexing; refer to my post: http://www.hiveworkshop.com/forums/1984988-post4.html
- You forgot the "set bj_wantDestroyGroup = true" expression.
- Your new post is actually your first spell; use your "Working spell" from your previous post.
 
Level 9
Joined
Apr 23, 2010
Messages
312
Ah ok I see what your saying, so I should change the time check to 10 instead of 20 and make time increase by 0.5.

EDIT: I attached the map below because now after a few uses, it wont create the group(s) needed and does nothing. I'm not really sure what's going on.

EDIT 2: Removed "Custom script: if udg_DamageGroup[udg_Index] == null then" and "Custom script: endif" and just left the "Custom script: set udg_DamageGroup[udg_Index] = CreateGroup()" and it works now.
 

Attachments

  • first spell.w3x
    26 KB · Views: 55
Last edited:
Level 9
Joined
Apr 23, 2010
Messages
312
So while trying to change the indexing to Hanky's Dynamic Indexing, everything works fine except for the part where the loop never stop's. It's as if the trigger is ignoring the conditions.

Below is the spell with Hanky's dynamic indexing. I was using debug method to try and find out whats going on and the only messages i keep getting are "[debug] on", "[debug] then" and "[debug] end cycle".
  • Mind Blast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Mind Blast
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MB_Index_Size Equal to 0
        • Then - Actions
          • Trigger - Turn on Mind Blast Loop <gen>
        • Else - Actions
      • Set MB_Index_Size = (MB_Index_Size + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MB_Index_Size Greater than MB_Index_maxSize
        • Then - Actions
          • Set MB_Index[MB_Index_Size] = MB_Index_Size
          • Set MB_Index_maxSize = MB_Index_Size
        • Else - Actions
      • Set MB_TempInt = MB_Index[MB_Index_Size]
      • Set MB_Caster[MB_TempInt] = (Triggering unit)
      • Set MB_AbilityLevel[MB_TempInt] = (Level of Mind Blast for (Triggering unit))
      • Set MB_AbilityDamage[MB_TempInt] = ((Real((Intelligence of (Triggering unit) (Exclude bonuses)))) / (4.00 - (Real(MB_AbilityLevel[MB_TempInt]))))
      • Set MB_Duration[MB_TempInt] = 0.00
      • Set MB_TotalDamage[MB_TempInt] = 0.00
      • Set MB_TempPoint = (Target point of ability being cast)
      • Custom script: if udg_MB_DamageGroup[udg_MB_TempInt] == null then
      • Custom script: set udg_MB_DamageGroup[udg_MB_TempInt] = CreateGroup()
      • Custom script: endif
      • Custom script: set bj_wantDestroyGroup = true
      • Unit Group - Pick every unit in (Units within 160.00 of MB_TempPoint matching ((((Matching unit) is A structure) Not equal to True) and ((((Matching unit) belongs to an ally of (Triggering player)) Not equal to True) and (((Matching unit) is Magic Immune) Not equal to True)))) and do (Actions)
        • Loop - Actions
          • Unit Group - Add (Picked unit) to MB_DamageGroup[MB_TempInt]
      • Special Effect - Create a special effect at MB_TempPoint using Abilities\Spells\Human\MarkOfChaos\MarkOfChaosTarget.mdl
      • Special Effect - Destroy (Last created special effect)
      • Trigger - Turn on Mind Blast Loop <gen>
      • Custom script: call RemoveLocation(udg_MB_TempPoint)
  • Mind Blast Loop
    • Events
      • Time - Every 0.50 seconds of game time
    • Conditions
    • Actions
      • Game - Display to (All players) for 1.00 seconds the text: [debug] on
      • For each (Integer MB_Loop) from 1 to MB_Index_Size, do (Actions)
        • Loop - Actions
          • Set MB_TempInt = MB_Index[MB_Loop]
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Or - Any (Conditions) are true
                • Conditions
                  • MB_Duration[MB_Loop] Greater than or equal to (7.50 + ((Real(MB_AbilityLevel[MB_Loop])) x 2.50))
                  • (MB_Caster[MB_Loop] has buff Sleep (Pause)) Equal to False
                  • (MB_Caster[MB_Loop] has buff Stunned (Pause)) Equal to False
            • Then - Actions
              • Game - Display to (All players) for 1.00 seconds the text: [debug] then
              • Set MB_TotalDamage[MB_Loop] = (MB_Duration[MB_Loop] + MB_AbilityDamage[MB_Loop])
              • Set MB_Duration[MB_Loop] = (MB_Duration[MB_Loop] + 0.50)
              • Unit Group - Pick every unit in MB_DamageGroup[MB_Loop] and do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Picked unit) is dead) Equal to True
                    • Then - Actions
                      • Unit Group - Remove (Picked unit) from MB_DamageGroup[MB_Loop]
                    • Else - Actions
                      • Game - Display to (All players) for 1.00 seconds the text: [debug] damage group
                      • Unit - Cause MB_Caster[MB_Loop] to damage (Picked unit), dealing MB_TotalDamage[MB_Loop] damage of attack type Spells and damage type Normal
                      • Unit - Set mana of (Picked unit) to ((Mana of (Picked unit)) - MB_TotalDamage[MB_Loop])
                      • Special Effect - Create a special effect attached to the head of (Picked unit) using Abilities\Spells\Undead\OrbOfDeath\AnnihilationMissile.mdl
                      • Special Effect - Destroy (Last created special effect)
            • Else - Actions
              • Game - Display to (All players) for 1.00 seconds the text: [debug] else
              • Set MB_Caster[MB_Loop] = No unit
              • Custom script: call DestroyGroup(udg_MB_DamageGroup[udg_MB_Loop])
              • Set MB_Index[MB_Loop] = MB_Index[MB_Index_Size]
              • Set MB_Index[MB_Index_Size] = MB_TempInt
              • Set MB_Index_Size = (MB_Index_Size - 1)
              • Set MB_Loop = (MB_Loop - 1)
      • Game - Display to (All players) for 1.00 seconds the text: [debug] end cycle
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • MB_Index_Size Equal to 0
        • Then - Actions
          • Game - Display to (All players) for 1.00 seconds the text: [debug] off
          • Trigger - Turn off (This trigger)
        • Else - Actions
 
Status
Not open for further replies.
Top