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

Why Doesn't This MUI Spell Work Right?

Status
Not open for further replies.
Level 11
Joined
Aug 6, 2009
Messages
697
Heres the problem,this spell IS MUI but when 2 users cast at the exact same time the collision is turned off after the spell is cast and done.
Trigger 1,Starting and setting up the loop:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to ShockyWavey
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Index Equal to 0
      • Then - Actions
        • Trigger - Turn on Loop <gen>
      • Else - Actions
    • Set MUI = (MUI + 1)
    • Set Index = (Index + 1)
    • Set TurnOn[MUI] = True
    • Set Caster[MUI] = (Casting unit)
    • Set casterpos = (Position of Caster[MUI])
    • Set targetpoint = (Target point of ability being cast)
    • Set distance[MUI] = (Distance between casterpos and targetpoint)
    • Set angle[MUI] = (Angle from casterpos to targetpoint)
    • Set moved[MUI] = 0.00
    • Unit - Turn collision for Caster[MUI] Off
    • Custom script: call RemoveLocation(udg_targetpoint)
    • Custom script: call RemoveLocation(udg_casterpos)
Trigger 2,The Loop:
  • Events
    • Time - Every 0.03 seconds of game time
  • Actions
    • For each (Integer Loop) from 1 to MUI, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TurnOn[Loop] Equal to True
          • Then - Actions
            • Set slide1 = (Position of Caster[Loop])
            • Set slide2 = (slide1 offset by 30.00 towards angle[Loop] degrees)
            • Set moved[Loop] = (moved[Loop] + 30.00)
            • Special Effect - Create a special effect attached to the origin of Caster[Loop] using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
            • Special Effect - Destroy (Last created special effect)
            • Unit - Move Caster[Loop] instantly to slide2
            • Custom script: call RemoveLocation(udg_slide1)
            • Custom script: call RemoveLocation(udg_slide2)
            • Unit Group - Pick every unit in (Units within 500.00 of (Position of Caster[Loop]) matching (((Matching unit) belongs to an enemy of (Owner of Caster[Loop])) Equal to True)) and do (Actions)
              • Loop - Actions
                • Unit - Cause Caster[Loop] to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Normal
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Caster[Loop] is dead) Equal to True) or (moved[Loop] Greater than or equal to distance[Loop])
              • Then - Actions
                • Unit - Turn collision for Caster[MUI] On
                • Set Index = (Index - 1)
                • Set Caster[Loop] = No unit
                • Set angle[Loop] = 0.00
                • Set distance[Loop] = 0.00
                • Set moved[Loop] = 0.00
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Index Equal to 0
                  • Then - Actions
                    • Trigger - Turn off (This trigger)
                    • Set MUI = 0
                  • Else - Actions
              • Else - Actions
          • Else - Actions
 
Last edited:

Bannar

Code Reviewer
Level 26
Joined
Mar 19, 2008
Messages
3,140
I see you haven't read my post in your thread, it's sad because I've showed you have to learn MUI with spells next to teory and man..
It's an old type of indexing it's inefficient. My second link will move you to next level of indexing. if you understood this, you will quickly get what's going around in dynamic indexing.
After all you can also move to Bibe's Indexer :D

Back to trigger. Trigger loop leaks Position of Caster[Loop], you do not set TurnOn[X] to False when instance is done. Dont null real/integers/boolean/strings, its nonsense because it doesn't save you memory at all.
But good that you have nulled array variable unit =) Your caster does not have collision turned on since you refer to Caster[MUI], not theCaster[Loop] how it should be. And, you dont need moved[] variable, distance[] is enough.

Using this indexing you should try this:
  • Events
    • Unit - A unit Starts the effect of an ability
  • Conditions
    • (Ability being cast) Equal to ShockyWavey
  • Actions
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • Index Equal to 0
      • Then - Actions
        • Trigger - Turn on Loop <gen>
      • Else - Actions
    • Set MUI = (MUI + 1)
    • Set Index = (Index + 1)
    • Set TurnOn[MUI] = True
    • Set Caster[MUI] = (Casting unit)
    • Set casterpos = (Position of Caster[MUI])
    • Set targetpoint = (Target point of ability being cast)
    • Set distance[MUI] = (Distance between casterpos and targetpoint)
    • Set angle[MUI] = (Angle from casterpos to targetpoint)
    • Unit - Turn collision for Caster[MUI] Off
    • Custom script: call RemoveLocation(udg_targetpoint)
    • Custom script: call RemoveLocation(udg_casterpos)
Trigger 2,The Loop:
  • Events
    • Time - Every 0.03 seconds of game time
  • Actions
    • For each (Integer Loop) from 1 to MUI, do (Actions)
      • Loop - Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • TurnOn[Loop] Equal to True
          • Then - Actions
            • Set slide1 = (Position of Caster[Loop])
            • Set slide2 = (slide1 offset by 30.00 towards angle[Loop] degrees)
            • Set distance[Loop] = (distance[Loop] - 30.00)
            • Special Effect - Create a special effect attached to the origin of Caster[Loop] using Abilities\Spells\Human\Thunderclap\ThunderClapCaster.mdl
            • Special Effect - Destroy (Last created special effect)
            • Unit - Move Caster[Loop] instantly to slide2
            • Unit Group - Pick every unit in (Units within 500.00 of slide2 matching (((Matching unit) belongs to an enemy of (Owner of Caster[Loop])) Equal to True)) and do (Actions)
              • Loop - Actions
                • Unit - Cause Caster[Loop] to damage (Picked unit), dealing 10.00 damage of attack type Spells and damage type Normal
            • Custom script: call RemoveLocation(udg_slide1)
            • Custom script: call RemoveLocation(udg_slide2)
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • ((Caster[Loop] is dead) Equal to True) or (distance[Loop] Lower than or equal to 0.00)
              • Then - Actions
                • Unit - Turn collision for Caster[Loop] On
                • Set Caster[Loop] = No unit
                • Set TurnOn[Loop] = False
                • Set Index = (Index - 1)
                • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                  • If - Conditions
                    • Index Equal to 0
                  • Then - Actions
                    • Trigger - Turn off (This trigger)
                    • Set MUI = 0
                  • Else - Actions
              • Else - Actions
          • Else - Actions
 
Status
Not open for further replies.
Top