• 🏆 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] GUI Missile Trigger

Status
Not open for further replies.

sentrywiz

S

sentrywiz

I wonder, what is a simple yet effective trigger for those "skillshot" missile spells. Assuming I already have the spell based on Shockwave for example.

I've been triggering them but they always seem kind of slow and even though I clear the leaks I can see, they make the game laggy in the long run, like after 10 or so minutes. That means there are leaks I am not cleaning properly.

So can you make an example of yours for a GUI trigger that would handle skillshot spells, I want to learn a better way to do it. Also, is it better to create one trigger that would move all dummy units or make each spell in two triggers?

Here is my example of how I make the trigger if you want to compare.
This is from my "Weapons Arena" map. Also take note that after 5 or so
minutes, the game gets laggy in-game.


  • Staff Launch
    • Events
      • Unit - A unit Starts the effect of an ability
    • Conditions
      • (Ability being cast) Equal to Attack (Staff)
    • Actions
      • Set staff_caster = (Casting unit)
      • Set loc_start = (Position of staff_caster)
      • Set loc_end = (Target point of ability being cast)
      • Unit - Create 1 Staff Dummy for (Owner of staff_caster) at loc_start facing (Facing of staff_caster) degrees
      • Set the_ball = (Last created unit)
      • Unit Group - Add the_ball to staff_group
      • Set total_staff_balls = (total_staff_balls + 1)
      • Trigger - Turn on Move Ball <gen>
      • Custom script: call RemoveLocation ( udg_loc_start )
      • Custom script: call RemoveLocation ( udg_loc_end )
  • Move Ball
    • Events
      • Time - Every 0.04 seconds of game time
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in staff_group) Equal to 0
        • Then - Actions
          • Trigger - Turn off (This trigger)
        • Else - Actions
          • Unit Group - Pick every unit in staff_group and do (Actions)
            • Loop - Actions
              • Set moving_ball = (Picked unit)
              • Set index_staff = (Player number of (Owner of moving_ball))
              • Set loc_move = (Position of moving_ball)
              • Set staff_hit = (Units within 110.00 of loc_move matching ((((Matching unit) is alive) Equal to True) and (((Matching unit) belongs to an enemy of (Owner of moving_ball)) Equal to True)))
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • staff_range_ctr[index_staff] Less than (Integer(ITEM_Staff_Range[index_staff]))
                  • (moving_ball is in forbidden_group) Not equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • (Number of units in staff_hit) Greater than 0
                    • Then - Actions
                      • Set ball_hit_target = (Random unit from staff_hit)
                      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                        • If - Conditions
                          • Mastery_Melee[(Player number of (Owner of ball_hit_target))] Equal to True
                        • Then - Actions
                          • Unit - Cause staff_caster to damage ball_hit_target, dealing 45.00 damage of attack type Normal and damage type Universal
                          • Floating Text - Create floating text that reads -45 above ball_hit_target with Z offset 0.00, using font size 8.00, color (100.00%, 5.00%, 0.00%), and 40.00% transparency
                          • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
                          • Floating Text - Change (Last created floating text): Disable permanence
                          • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
                          • Special Effect - Create a special effect attached to the origin of ball_hit_target using Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl
                          • Special Effect - Destroy (Last created special effect)
                          • Set Player_MagicKSpree[index_staff] = (Player_MagicKSpree[index_staff] + 45)
                        • Else - Actions
                          • Unit - Cause staff_caster to damage ball_hit_target, dealing 50.00 damage of attack type Normal and damage type Universal
                          • Floating Text - Create floating text that reads -50 above ball_hit_target with Z offset 0.00, using font size 8.00, color (100.00%, 5.00%, 0.00%), and 40.00% transparency
                          • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
                          • Floating Text - Change (Last created floating text): Disable permanence
                          • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
                          • Special Effect - Create a special effect attached to the origin of ball_hit_target using Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl
                          • Special Effect - Destroy (Last created special effect)
                          • Set Player_MagicKSpree[index_staff] = (Player_MagicKSpree[index_staff] + 50)
                      • Unit Group - Remove moving_ball from staff_group
                      • Set staff_range_ctr[index_staff] = 0
                      • Set total_staff_balls = (total_staff_balls - 1)
                      • Unit - Remove moving_ball from the game
                    • Else - Actions
                      • Set loc_move2 = (loc_move offset by 35.00 towards (Facing of moving_ball) degrees)
                      • Set staff_range_ctr[index_staff] = (staff_range_ctr[index_staff] + 35)
                      • Unit - Move moving_ball instantly to loc_move2
                      • Custom script: call RemoveLocation ( udg_loc_move2 )
                • Else - Actions
                  • Unit Group - Remove moving_ball from forbidden_group
                  • Set staff_range_ctr[index_staff] = 0
                  • Set total_staff_balls = (total_staff_balls - 1)
                  • Unit - Remove moving_ball from the game
                  • Unit Group - Remove moving_ball from staff_group
              • Custom script: call RemoveLocation ( udg_loc_move )
              • Custom script: call DestroyGroup ( udg_staff_hit )
 
You should use carrion swarm or crushing wave, shockwave causes terrain deforms or well last I remember. Change your GUI move unit action to the fastest JASS/custom script version with setunit x,y.

Don't remove units from game, kill them instead and set the correct death in object editor which I forgot however I think it is don't rise and doesn't decay.

Also if your using a spell or a type of effect you might also save some RAM and operation speed by not having to move a dummy unit/creating one. Fails horribly if you want some kind of shield/force field or block ability.
 

sentrywiz

S

sentrywiz

You should use carrion swarm or crushing wave, shockwave causes terrain deforms or well last I remember. Change your GUI move unit action to the fastest JASS/custom script version with setunit x,y.

Don't remove units from game, kill them instead and set the correct death in object editor which I forgot however I think it is don't rise and doesn't decay.

Also if your using a spell or a type of effect you might also save some RAM and operation speed by not having to move a dummy unit/creating one. Fails horribly if you want some kind of shield/force field or block ability.

I found Carrion Swarm to leave the 'hit' effect even if I remove it. That's the problem I had with it. Crushing Wave I haven't tried.

Okay that's something I read somewhere too, but will do that.

But that's how the skillshot missile works, by moving a dummy. How can you create the effect of the missile moving otherwise?
 
Level 5
Joined
Jan 27, 2014
Messages
164
The trigger seems pretty well made.
I can't spot any leaks so far.
I trigger these missile shots using your method as well.
This is pretty typical for GUI coders.
But I don't encounter much lag in my map, except for spamming cases.

> is it better to create one trigger that would move all dummy units or make each spell in two triggers?
Make in separate triggers. Too many if then else in a single trigger don't make things better imo. Besides, it's easier to configure if you have separate triggers.

Your lag may be due to some other reasons. Check your other triggers.
Also make sure your arrays (especially unit groups or timers, if you have any) do not hit or approach limit.
 

sentrywiz

S

sentrywiz

The trigger seems pretty well made.
I can't spot any leaks so far.
I trigger these missile shots using your method as well.
This is pretty typical for GUI coders.
But I don't encounter much lag in my map, except for spamming cases.

> is it better to create one trigger that would move all dummy units or make each spell in two triggers?
Make in separate triggers. Too many if then else in a single trigger don't make things better imo. Besides, it's easier to configure if you have separate triggers.

Your lag may be due to some other reasons. Check your other triggers.
Also make sure your arrays (especially unit groups or timers, if you have any) do not hit or approach limit.

Thanks for posting.
So you're saying that my trigger is leak free? I've checked it myself, but something makes the game laggy.
 
Yo this trigger seems to be leakfree. But still some tips:

  • (Number of units in staff_group) Equal to 0[/stable]
-->
  • (total_staff_balls) < 1[/stable]
  • (Number of units in staff_hit) Greater than 0[/stable]
-->
  • (total_staff_balls) > 1[/stable]
  • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
  • Floating Text - Change (Last created floating text): Disable permanence
  • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
  • Special Effect - Create a special effect attached to the origin of ball_hit_target using Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl
  • Special Effect - Destroy (Last created special effect)[/stable]
Should be moved below the If/Then/Else becausae you do this exactly same in Then and in Else actions.

Floating text could be stored into a variable to prevent useles function calls.

You should not create a dummy each casting. Create a dummy for each playing player once at start of the game.

  • Set index_staff = (Player number of (Owner of moving_ball))[/stable]
This is MPI(Multiple Player Instancebility) but not MUI(Multiple Unit Instancebility), because you use PlayerNumber Of Player as index.

So if a player uses this spell a 2nd time before his 1st unit finished with it, they will collide.

Use instead a index/deindex method. You will find a tutorial how todo so if you fillow my link "GUI-Tutorial" in my signature.

  • (staff_range_ctr[index_staff] Less than (Integer(ITEM_Staff_Range[index_staff]))[/stable]
I don't see where you set "ITEM_Staff_Range[index_staff])" somewhere.

But itself PickingUnits each .04 seconds is ok. Do you have other periodic triggers?
If no maybe it was this MPI problem that you use it more often, and then group gets never get cleared and causes always more and more useles checks/actions which are never be done.
 

sentrywiz

S

sentrywiz

Yo this trigger seems to be leakfree. But still some tips:

  • (Number of units in staff_group) Equal to 0[/stable]
-->
  • (total_staff_balls) < 1[/stable]
  • (Number of units in staff_hit) Greater than 0[/stable]
-->
  • (total_staff_balls) > 1[/stable]
  • Floating Text - Set the velocity of (Last created floating text) to 75.00 towards 90.00 degrees
  • Floating Text - Change (Last created floating text): Disable permanence
  • Floating Text - Change the lifespan of (Last created floating text) to 1.00 seconds
  • Special Effect - Create a special effect attached to the origin of ball_hit_target using Abilities\Spells\Other\CrushingWave\CrushingWaveDamage.mdl
  • Special Effect - Destroy (Last created special effect)[/stable]
Should be moved below the If/Then/Else becausae you do this exactly same in Then and in Else actions.

Floating text could be stored into a variable to prevent useles function calls.

You should not create a dummy each casting. Create a dummy for each playing player once at start of the game.

  • Set index_staff = (Player number of (Owner of moving_ball))[/stable]
This is MPI(Multiple Player Instancebility) but not MUI(Multiple Unit Instancebility), because you use PlayerNumber Of Player as index.

So if a player uses this spell a 2nd time before his 1st unit finished with it, they will collide.

Use instead a index/deindex method. You will find a tutorial how todo so if you fillow my link "GUI-Tutorial" in my signature.

  • (staff_range_ctr[index_staff] Less than (Integer(ITEM_Staff_Range[index_staff]))[/stable]
I don't see where you set "ITEM_Staff_Range[index_staff])" somewhere.

But itself PickingUnits each .04 seconds is ok. Do you have other periodic triggers?
If no maybe it was this MPI problem that you use it more often, and then group gets never get cleared and causes always more and more useles checks/actions which are never be done.


Thanks for your advices.
I will remake that index and change the top unit groups and check if it improves the game lag.

Yes I have six triggers like this one. All of them add to game lag probably or maybe some leak I didn't find.
You can check my "Weapons Arena" map. Its open, so you can check it out.
 
Status
Not open for further replies.
Top