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

Creating a spell that makes a projectile jump between units

Status
Not open for further replies.
Level 2
Joined
Apr 24, 2019
Messages
15
Hey guys, I need help on a spell that makes a projectile jump between units (not necessarily the "jump" motion but jump move it into other units nearby) Very much like Dota's Lich's Ultimate - Chain frost.
Im sorry if its a little bit confusing, im not really good with english but i hope that you get what im trying to say. So in detail, I target one enemy, the ball moves into the enemy, after the ball hits, if moves into another enemy, and into another and so on until it hits an x number of units.

The problem is, i can't get it to stop after hitting x amounts of units, because if I try to add 1 to BBnum, and then remove BBMissile, it just almost instantly removes BBMissile. so this trigger here is an edited one, Ive deleted the lines that I thought might be "broken" or "unnecessary".

Also, I know that this trigger leaks but I have no idea on what is leaking, I know how to remove points and units though but about the other ones, I have not understood how to remove them.

  • BouncingBall
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bouncing Ball
    • Actions
      • Custom script: set udg_WitchDoctor[3] = GetTriggerUnit()
      • Custom script: set udg_BBloc[0] = GetUnitLoc( udg_WitchDoctor[3] )
      • Custom script: set udg_BBnum = 1
      • Custom script: set udg_BBTarget[0] = GetSpellTargetUnit()
      • Custom script: set udg_BBloc[1] = GetUnitLoc( udg_BBTarget[0] )
      • Custom script: call CreateNUnitsAtLocFacingLocBJ( 1, 'h004', GetOwningPlayer( udg_WitchDoctor[3] ), udg_BBloc[0], udg_BBloc[udg_BBnum] )
      • Custom script: set udg_BBMissile = GetLastCreatedUnit()
      • Unit Group - Add BBTarget[0] to BBexecption
      • Custom script: call RemoveLocation( udg_BBloc[0] )
      • Custom script: call EnableTrigger( gg_trg_Bouncingloop )
      • Trigger - Turn off (This trigger)
The spell loop
  • Bouncingloop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Custom script: set udg_BBloc[2] = GetUnitLoc(udg_BBMissile)
      • Custom script: set udg_BBloc[1] = GetUnitLoc(udg_BBTarget[0])
      • Set BBAngle = (Angle from BBloc[2] to BBloc[1])
      • Custom script: set udg_BBDistance = DistanceBetweenPoints( udg_BBloc[2], udg_BBloc[1] )
      • Set BBloc[3] = (BBloc[2] offset by 27.00 towards BBAngle degrees)
      • Unit - Move BBMissile instantly to BBloc[3]
      • Custom script: call RemoveLocation(udg_BBloc[3])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer(BBDistance)) Less than or equal to 50
        • Then - Actions
          • Custom script: set udg_BBloc[2] = GetUnitLoc( udg_BBMissile )
          • Unit Group - Pick every unit in (Units within 700.00 of BBloc[2]) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) belongs to an enemy of (Owner of WitchDoctor[3])) Equal to True
                  • ((Picked unit) is in BBexecption) Not equal to True
                • Then - Actions
                  • Unit Group - Add (Picked unit) to BBUnitGroup
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • BBnum Less than or equal to 6
                    • Then - Actions
                      • Unit Group - Pick every unit in (Random 1 units from BBUnitGroup) and do (Actions)
                        • Loop - Actions
                          • Set BBTarget[0] = (Picked unit)
                          • Unit Group - Remove all units from BBexecption
                          • Unit Group - Add BBTarget[0] to BBexecption
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • Custom script: call RemoveLocation(udg_BBloc[1])
Im not that good with triggers and Im just randomly putting stuff in there. It doesnt need to be MUI or something. I just want to have this spell. Thank you

Edit: edited.
 
Last edited:
Level 39
Joined
Feb 27, 2007
Messages
5,013
@Devalut you can use the [plain] tags to show how to type trigger tags.
  • BouncingBall
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Bouncing Ball
    • Actions
      • Custom script: set udg_WitchDoctor[3] = GetTriggerUnit()
      • Custom script: set udg_BBloc[0] = GetUnitLoc( udg_WitchDoctor[3] )
      • Custom script: set udg_BBnum = 1
      • Custom script: set udg_BBTarget[0] = GetSpellTargetUnit()
      • Custom script: set udg_BBloc[1] = GetUnitLoc( udg_BBTarget[0] )
      • Custom script: call CreateNUnitsAtLocFacingLocBJ( 1, 'h004', GetOwningPlayer( udg_WitchDoctor[3] ), udg_BBloc[0], udg_BBloc[udg_BBnum] )
      • Custom script: set udg_BBMissile = GetLastCreatedUnit()
      • Unit Group - Add BBTarget[0] to BBexecption
      • Custom script: call RemoveLocation( udg_BBloc[0] )
      • Custom script: call EnableTrigger( gg_trg_Bouncingloop )
      • Trigger - Turn off (This trigger)
  • Bouncingloop
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • Custom script: set udg_BBloc[2] = GetUnitLoc(udg_BBMissile)
      • Custom script: set udg_BBloc[1] = GetUnitLoc(udg_BBTarget[0])
      • Set BBAngle = (Angle from BBloc[2] to BBloc[1])
      • Custom script: set udg_BBDistance = DistanceBetweenPoints( udg_BBloc[2], udg_BBloc[1] )
      • Set BBloc[3] = (BBloc[2] offset by 27.00 towards BBAngle degrees)
      • Unit - Move BBMissile instantly to BBloc[3]
      • Custom script: call RemoveLocation(udg_BBloc[3])
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Integer(BBDistance)) Less than or equal to 50
        • Then - Actions
          • Custom script: set udg_BBloc[2] = GetUnitLoc( udg_BBMissile )
          • Unit Group - Pick every unit in (Units within 700.00 of BBloc[2]) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked unit) is alive) Equal to True
                  • ((Picked unit) belongs to an enemy of (Owner of WitchDoctor[3])) Equal to True
                  • ((Picked unit) is in BBexecption) Not equal to True
                • Then - Actions
                  • Unit Group - Add (Picked unit) to BBUnitGroup
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • BBnum Less than or equal to 6
                    • Then - Actions
                      • Unit Group - Pick every unit in (Random 1 units from BBUnitGroup) and do (Actions)
                        • Loop - Actions
                          • Set BBTarget[0] = (Picked unit)
                          • Unit Group - Remove all units from BBexecption
                          • Unit Group - Add BBTarget[0] to BBexecption
                    • Else - Actions
                • Else - Actions
        • Else - Actions
      • Custom script: call RemoveLocation(udg_BBloc[1])
  • What doesn't work about the trigger as written? You didn't specify a problem you were having or something you needed help with.
  • Why are you doing almost everything as a custom script (JASS) in the first trigger?
  • Don't use an integer comparison for BBDistance because you have to convert it to an integer; use a real comparison instead.
  • Your spell is not MUI but it could be with a little bit of dynamic indexing
  • You're leaking a few unit groups
  • Where is BBNum being set? I just see you comparing it to 6.
  • Unit Group - Pick every unit in (Random 1 units from BBUnitGroup) and do (Actions) is more complicated than it needs to be. You can set BBTarget[0] = (Random unit from BBUnitGroup) directly
 
Level 2
Joined
Apr 24, 2019
Messages
15
  • What doesn't work about the trigger as written? You didn't specify a problem you were having or something you needed help with.

The problem is I cant get it to stop, and If I try to add BBnum + 1, it just stops right away, i guess it adds 1 every 0.04 seconds? and Also i figured out that it might also have leaks so I need help for that.

Im sorry for the lack of description, my bad. Ill edit this thread and add what i need help with.

  • Why are you doing almost everything as a custom script (JASS) in the first trigger?

Well, about that - i was just trying it out, like i wanted to familiarize custom scripts because I am also planning to learn JASS but i guess I wont for now. Should I add another tag for it or should I change the trigger to GUI and edit this thread?

  • Don't use an integer comparison for BBDistance because you have to convert it to an integer; use a real comparison instead.

I guess that adds another problem? Thanks


Got it, ill try adding it into the spell. It doesnt really need to be MUI though


Yeahhhh, i knew that might have a leak but i didnt know how to remove the leak. or at least didnt understood how to. but also one problem, if I add Unit Group - Clear unit group after I set BBTarget, the BBMissile just wanders off into infinity. Did I put it on the wrong line?

  • Where is BBNum being set? I just see you comparing it to 6.

BBnum is set in the cast trigger, i didnt add a BBnum + 1 in the first trigger because it seems to add 1 every 0.04 seconds.

  • Unit Group - Pick every unit in (Random 1 units from BBUnitGroup) and do (Actions) is more complicated than it needs to be. You can set BBTarget[0] = (Random unit from BBUnitGroup) directly

Got it.
 
Level 2
Joined
Apr 24, 2019
Messages
15
Post your triggers with the "["Trigger"]" Your trigger "[/"Trigger"]"

Doing so makes yours look like this:
  • Blah blah Warcraft math stuff
Additionally this spell may be interesting to you, unless you want help fixing your trigger.
Got it , ill edit this post now.

Checking that out for further reference
 
Status
Not open for further replies.
Top