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

Spell problem in MUI.

Status
Not open for further replies.
Level 12
Joined
Apr 16, 2010
Messages
584
Hello, lately I've been working on a spell called Bouncing Ball. So when one instance of spell is finished all other stop running too, i've done almost everythin and couldn't find the solution. So if some can help, i'b be thankful.
  • Bouncing Ball Cast
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bouncing Ball [|c0020c000B|r]
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BB_Index Equal to 0
        • Then - Actions
          • Trigger - Turn on Bouncing Ball Loop <gen>
        • Else - Actions
      • Set BB_Index = (BB_Index + 1)
      • Set BB_Index2 = (BB_Index2 + 1)
      • -------- Setting caster --------
      • Set BB_Caster[BB_Index2] = (Triggering unit)
      • -------- Setting Angle --------
      • Set BB_Angle[BB_Index2] = (Random real number between 0.00 and 360.00)
      • -------- Setting Distance --------
      • Set BB_Distance[BB_Index2] = (Random real number between 150.00 and 300.00)
      • -------- Setting distance when ball will change the heigh down --------
      • Set BB_Expire[BB_Index2] = BB_Distance[BB_Index2]
      • -------- Settings number of jumps --------
      • Set BB_Jumps[BB_Index2] = ((Level of Bouncing Ball [|c0020c000B|r] for BB_Caster[BB_Index2]) x 2)
      • -------- Creating ball --------
      • Unit - Create 1 Dummy for (Owner of BB_Caster[BB_Index2]) at (Position of BB_Caster[BB_Index2]) facing Default building facing degrees
      • Set BB_Dummy[BB_Index2] = (Last created unit)
      • Animation - Change BB_Dummy[BB_Index2]'s size to (300.00%, 300.00%, 300.00%) of its original size
      • Unit - Add Crow Form to BB_Dummy[BB_Index2]
  • Bouncing Ball Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer BB_Index3) from 1 to BB_Index2, do (Actions)
        • Loop - Actions
          • -------- Subtracting 5 distance from current distance to calculate when ball will fly half of all distance --------
          • Set BB_Expire[BB_Index3] = (BB_Expire[BB_Index3] - 5.00)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Expire[BB_Index3] Greater than or equal to (BB_Distance[BB_Index3] / 2.00)
            • Then - Actions
              • -------- Adding height till ball reaches half distance --------
              • Animation - Change BB_Dummy[BB_Index3] flying height to ((Current flying height of BB_Dummy[BB_Index3]) + 10.00) at 0.00
            • Else - Actions
              • -------- Subtracting height when ball reaches half distance --------
              • Animation - Change BB_Dummy[BB_Index3] flying height to ((Current flying height of BB_Dummy[BB_Index3]) - 10.00) at 0.00
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Expire[BB_Index3] Less than or equal to 0.00
            • Then - Actions
              • -------- Setting all settings again for next jump --------
              • Set BB_Jumps[BB_Index3] = (BB_Jumps[BB_Index3] - 1)
              • Set BB_Angle[BB_Index3] = (Random real number between 0.00 and 360.00)
              • Set BB_Distance[BB_Index3] = (Random real number between 150.00 and 300.00)
              • Set BB_Expire[BB_Index3] = BB_Distance[BB_Index3]
              • -------- Creating dummy to cast a Thunder Clap at point where ball reaches ground --------
              • Special Effect - Create a special effect at (Position of BB_Dummy[BB_Index3]) using Objects\Spawnmodels\Undead\UDeathSmall\UDeathSmall.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set BB_Point[BB_Index3] = (Position of BB_Dummy[BB_Index3])
              • Unit - Create 1 Dummy 2 for (Owner of BB_Caster[BB_Index3]) at BB_Point[BB_Index3] facing Default building facing degrees
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Bouncing Ball Dummy to (Last created unit)
              • Unit - Set level of Bouncing Ball Dummy for (Last created unit) to (Level of Bouncing Ball [|c0020c000B|r] for BB_Caster[BB_Index3])
              • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
              • Custom script: call RemoveLocation(udg_BB_Point[udg_BB_Index3])
            • Else - Actions
          • -------- Moving ball to next point --------
          • Set BB_Point2[BB_Index3] = ((Position of BB_Dummy[BB_Index3]) offset by 10.00 towards BB_Angle[BB_Index3] degrees)
          • Unit - Move BB_Dummy[BB_Index3] instantly to BB_Point2[BB_Index3]
          • -------- Removing leaks --------
          • Custom script: call RemoveLocation(udg_BB_Point2[udg_BB_Index3])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Jumps[BB_Index3] Equal to 0
            • Then - Actions
              • Unit - Remove Crow Form from BB_Dummy[BB_Index3]
              • Unit - Kill BB_Dummy[BB_Index3]
              • Set BB_Index = (BB_Index - 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Index Equal to 0
            • Then - Actions
              • Set BB_Index2 = 0
              • Trigger - Turn off (This trigger)
            • Else - Actions
I also attached the the test map if someone would like to test it in-game.
 

Attachments

  • Bouncing Ball.w3x
    61.4 KB · Views: 41
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

Hey dude chill out no bumbing after this short duration ^^ and I found the misstake in the loop trigger:
  • Bouncing Ball Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer BB_Index3) from 1 to BB_Index2, do (Actions)
        • Loop - Actions
          • -------- Subtracting 5 distance from current distance to calculate when ball will fly half of all distance --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Index3 Not equal to 0
            • Then - Actions
              • Set BB_Expire[BB_Index3] = (BB_Expire[BB_Index3] - 5.00)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BB_Expire[BB_Index3] Greater than or equal to (BB_Distance[BB_Index3] / 2.00)
                • Then - Actions
                  • -------- Adding height till ball reaches half distance --------
                  • Animation - Change BB_Dummy[BB_Index3] flying height to ((Current flying height of BB_Dummy[BB_Index3]) + 10.00) at 0.00
                • Else - Actions
                  • -------- Subtracting height when ball reaches half distance --------
                  • Animation - Change BB_Dummy[BB_Index3] flying height to ((Current flying height of BB_Dummy[BB_Index3]) - 10.00) at 0.00
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Expire[BB_Index3] Less than or equal to 0.00
            • Then - Actions
              • -------- Setting all settings again for next jump --------
              • Set BB_Jumps[BB_Index3] = (BB_Jumps[BB_Index3] - 1)
              • Set BB_Angle[BB_Index3] = (Random real number between 0.00 and 360.00)
              • Set BB_Distance[BB_Index3] = (Random real number between 150.00 and 300.00)
              • Set BB_Expire[BB_Index3] = BB_Distance[BB_Index3]
              • -------- Creating dummy to cast a Thunder Clap at point where ball reaches ground --------
              • Special Effect - Create a special effect at (Position of BB_Dummy[BB_Index3]) using Objects\Spawnmodels\Undead\UDeathSmall\UDeathSmall.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set BB_Point[BB_Index3] = (Position of BB_Dummy[BB_Index3])
              • Unit - Create 1 Dummy 2 for (Owner of BB_Caster[BB_Index3]) at BB_Point[BB_Index3] facing Default building facing degrees
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Bouncing Ball Dummy to (Last created unit)
              • Unit - Set level of Bouncing Ball Dummy for (Last created unit) to (Level of Bouncing Ball [|c0020c000B|r] for BB_Caster[BB_Index3])
              • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
              • Custom script: call RemoveLocation(udg_BB_Point[udg_BB_Index3])
            • Else - Actions
          • -------- Moving ball to next point --------
          • Set BB_Point2[BB_Index3] = ((Position of BB_Dummy[BB_Index3]) offset by 10.00 towards BB_Angle[BB_Index3] degrees)
          • Unit - Move BB_Dummy[BB_Index3] instantly to BB_Point2[BB_Index3]
          • -------- Removing leaks --------
          • Custom script: call RemoveLocation(udg_BB_Point2[udg_BB_Index3])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Jumps[BB_Index3] Equal to 0
            • Then - Actions
              • Unit - Remove Crow Form from BB_Dummy[BB_Index3]
              • Unit - Kill BB_Dummy[BB_Index3]
              • Set BB_Index = (BB_Index - 1)
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Index Equal to 0
            • Then - Actions
              • Set BB_Index2 = 0
              • Trigger - Turn off (This trigger)
            • Else - Actions
As you see I add another If then Else at the top of the actions. After adding this it will work

Greetings and Peace
~ Dr. Boom
 

Attachments

  • Bouncing Ball [Work now].w3x
    62.6 KB · Views: 49
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

If I downloaded your map, I have to replaced many stuff ( maybe a bug ) but look at the loop trigger in the first action line in the loop. There is from 1 to 10 - you have to change the 10 into the BB_index2 variable.
Then if I test it, it work without any error.

Greetings and Peace
Dr. Boom
 
Level 12
Joined
Apr 16, 2010
Messages
584
I changed of course, still leaks.
So what you're saying that if you cast this many times it works fine in your map??
Cuz in mine, all balls after 1st is finished jumping, all stop jumping.
I hope it is a bug in my editor, and with spell all is fine)) But bad if bug...

Edit: i added screenshot
attachment.php
 

Attachments

  • Spell.png
    Spell.png
    1.3 MB · Views: 204
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =O

Hmm I really have no problems with the spell, I can spam it and every ball get killed correctly ... Hmm I will look at the trigger again

Edit: Ok after looking again, maybe I have the problem. Look to the new loop trigger:
  • Bouncing Ball Loop
    • Events
      • Time - Every 0.03 seconds of game time
    • Conditions
    • Actions
      • For each (Integer BB_Index3) from 1 to BB_Index2, do (Actions)
        • Loop - Actions
          • -------- Subtracting 5 distance from current distance to calculate when ball will fly half of all distance --------
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Index3 Not equal to 0
            • Then - Actions
              • Set BB_Expire[BB_Index3] = (BB_Expire[BB_Index3] - 5.00)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BB_Expire[BB_Index3] Greater than or equal to (BB_Distance[BB_Index3] / 2.00)
                • Then - Actions
                  • -------- Adding height till ball reaches half distance --------
                  • Animation - Change BB_Dummy[BB_Index3] flying height to ((Current flying height of BB_Dummy[BB_Index3]) + 10.00) at 0.00
                • Else - Actions
                  • -------- Subtracting height when ball reaches half distance --------
                  • Animation - Change BB_Dummy[BB_Index3] flying height to ((Current flying height of BB_Dummy[BB_Index3]) - 10.00) at 0.00
            • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • BB_Expire[BB_Index3] Less than or equal to 0.00
            • Then - Actions
              • -------- Setting all settings again for next jump --------
              • Set BB_Jumps[BB_Index3] = (BB_Jumps[BB_Index3] - 1)
              • Set BB_Angle[BB_Index3] = (Random real number between 0.00 and 360.00)
              • Set BB_Distance[BB_Index3] = (Random real number between 150.00 and 300.00)
              • Set BB_Expire[BB_Index3] = BB_Distance[BB_Index3]
              • -------- Creating dummy to cast a Thunder Clap at point where ball reaches ground --------
              • Special Effect - Create a special effect at (Position of BB_Dummy[BB_Index3]) using Objects\Spawnmodels\Undead\UDeathSmall\UDeathSmall.mdl
              • Special Effect - Destroy (Last created special effect)
              • Set BB_Point[BB_Index3] = (Position of BB_Dummy[BB_Index3])
              • Unit - Create 1 Dummy 2 for (Owner of BB_Caster[BB_Index3]) at BB_Point[BB_Index3] facing Default building facing degrees
              • Unit - Add a 2.00 second Generic expiration timer to (Last created unit)
              • Unit - Add Bouncing Ball Dummy to (Last created unit)
              • Unit - Set level of Bouncing Ball Dummy for (Last created unit) to (Level of Bouncing Ball [|c0020c000B|r] for BB_Caster[BB_Index3])
              • Unit - Order (Last created unit) to Human Mountain King - Thunder Clap
              • Custom script: call RemoveLocation(udg_BB_Point[udg_BB_Index3])
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • BB_Jumps[BB_Index3] Equal to 0
                • Then - Actions
                  • Unit - Remove Crow Form from BB_Dummy[BB_Index3]
                  • Unit - Kill BB_Dummy[BB_Index3]
                  • Set BB_Index = (BB_Index - 1)
                • Else - Actions
            • Else - Actions
          • -------- Moving ball to next point --------
          • Set BB_Point2[BB_Index3] = ((Position of BB_Dummy[BB_Index3]) offset by 10.00 towards BB_Angle[BB_Index3] degrees)
          • Unit - Move BB_Dummy[BB_Index3] instantly to BB_Point2[BB_Index3]
          • -------- Removing leaks --------
          • Custom script: call RemoveLocation(udg_BB_Point2[udg_BB_Index3])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BB_Index Equal to 0
        • Then - Actions
          • Set BB_Index2 = 0
          • Trigger - Turn off (This trigger)
        • Else - Actions
As you see ( I hope ^^ ) I put the if then else part where you check if BB_Jumps are 0 a little up. After done this, it must work 100%!


Greetings and Peace
Dr. Boom
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
First of all, there's no need to check whether or not BB_Index3 is 0 - you're looping from 1 to X.

Second, why do you have BB_Index and BB_Index2 - you only need one of them, and I see a few places where you've interchanged them.

Another thing, when you have dummy units casting spells make sure you set their cast backswing to 0.00 rather than leaving it at the default; also make sure you remove any cooldowns/mana costs from the ability which you are dummy-casting.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

First of all, before I add the check if BB_Index3 is 0, nothing work. After I add it, it works and after the edit it should 100% work now.

Second: I learned it so that you use 1 index for turn on/turn off the loop trigger, 2 index for setting the variables in the cast trigger and 3 index for the variables in the loop trigger. If there is another way, would cool if you can explain it please ^^

Greetings and Peace
Dr. Boom
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Well you only need two indexes. You need one to store the value of the maximum index (the amount of bouncing balls) and then another index that is used when iterating through all instances of bouncing balls.

This is what the last statement in the loop trigger should look like:

  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • BB_Jumps[BB_Index3] Equal to 0
    • Then - Actions
      • Unit - Remove Crow Form from BB_Dummy[BB_Index3]
      • Unit - Kill BB_Dummy[BB_Index3]
      • Set BB_Angle[BB_Index3] = BB_Angle[BB_Index2]
      • Set BB_Caster[BB_Index3] = BB_Caster[BB_Index2]
      • Set BB_Distance[BB_Index3] = BB_Distance[BB_Index2]
      • Set BB_Dummy[BB_Index3] = BB_Dummy[BB_Index2]
      • Set BB_Expire[BB_Index3] = BB_Expire[BB_Index2]
      • Set BB_Index2 = (BB_Index2 - 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • BB_Index2 Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
    • Else - Actions
God how I really hate GUI... it doesn't seem like you seem to be able to draw a real conclusion as to what the problem is though. It isn't wise to simply wiggle things around until they appear to work.

Eh I completely give up on this; I shouldn't be able to radically change what happens in the spell by simply rearranging the code. If I put one of the if-statements where it should be it makes every 2nd bouncing ball last forever. That's what I get for giving GUI a second chance. It truly is what people who don't know what they're doing use to pretend that they do.

The if-statement that checks whether or not the # of jumps left is 0 should be within the if-statement that checks expiry. When I move the if-statement there it never seems to run the expiration actions, thunder clap is never used.

Why are you moving the ball a distance of 10 but only subtracting 5 from the expire-counter. God damn man nothing in this trigger makes any sense. I would suggest restarting from scratch and logically going through what you're doing in your head; half of these actions seem to be completely unstructured.

Oh, and one more thing. You don't take into account anywhere that your periodic interval is 0.03.

And finally I get it to work - there are still problems though when many are used it seems to be prematurely destroying some of the bouncing balls. I've spent enough time scanning through this abomination though, if you care to get it to work properly then I suggest re-coding.
 
Last edited:
Level 16
Joined
May 1, 2008
Messages
1,605
Moin moin =)

That's a reason why I do everything in Jass now and I'm still trying to get those MUI spells in vJass. If you can do it in vJass ( will take time to learn it ), it's much easier as GUI.
(And if you post vJass instead of GUI here, Berb doesn't need so much coffee :wgrin:)

Greetings and Peace
Dr. Boom
 
Status
Not open for further replies.
Top