• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] Help with a sliding trigger

Status
Not open for further replies.
Level 2
Joined
Jun 24, 2008
Messages
15
Okay, So I made this sliding trigger for a map I am making, But it seems to have a bug and I can't seem to figure out why. I decided to come to you all for help :).
When I'm alone in the game as Red, I slide normally at a normal speed and fine. But if I have more players in the game, Red moves very slow and the other players move very fast.
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Countdown Timer - Start TerrainTimer as a Repeating timer that will expire in 0.05 seconds
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Unit - Create 1 Demon Hunter for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees) else do (Do nothing)
          • Set HeroArray[(Integer A)] = (Last created unit)
          • Selection - Select HeroArray[(Integer A)] for (Owner of HeroArray[(Integer A)])
  • OnIceTerrain
    • Events
      • Time - TerrainTimer expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set Facing = (Facing of HeroArray[(Integer A)])
          • Set TempPoint = (Position of HeroArray[(Integer A)])
          • If ((Terrain type at TempPoint) Equal to Northrend - Ice) then do (Unit - Move HeroArray[(Integer A)] instantly to (TempPoint offset by 2.50 towards Facing degrees)) else do (Do nothing)
          • Custom script: call RemoveLocation(udg_TempPoint)
  • OnIceTurn
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Ordered unit)) Equal to Demon Hunter
    • Actions
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Target point of issued order)
          • Set TempPoint2 = (Position of HeroArray[(Integer A)])
          • If ((Terrain type at TempPoint2) Equal to Northrend - Ice) then do (Unit - Make HeroArray[(Integer A)] face TempPoint over 0.00 seconds) else do (Do nothing)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
If anyone knows why this happens or what is wrong with it, I would really appreciate help, Thanks.
P.S. if it has any leaks could you notify me of them? Thanks!
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Countdown Timer - Start TerrainTimer as a Repeating timer that will expire in 0.05 seconds
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • If (((Player((Integer A))) slot status) Equal to Is playing) then do (Unit - Create 1 Demon Hunter for (Player((Integer A))) at ((Player((Integer A))) start location) facing Default building facing degrees) else do (Do nothing)
          • Set HeroArray[(Integer A)] = (Last created unit)
          • Selection - Select HeroArray[(Integer A)] for (Owner of HeroArray[(Integer A)])
The problem is you only have the anti unit creation in the if statement and not the other actions which asign the variables.
Thus when you are alone you are moving red 11 times every move.
With 2 players red moves normally but player 2 moves 10 times a every move.

To fix, put the veriable actions in the same if statement as the unit creation.

You are also leaking 220 locations a second and 11 every point order from the deamon hunters. This is a major leak and needs fixing.
 
Level 2
Joined
Jun 24, 2008
Messages
15
I'm not quite clear on how this solves the sliding problem, Or if it's just a leak..
But would this work more efficient then?

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Countdown Timer - Start TerrainTimer as a Repeating timer that will expire in 0.05 seconds
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set Player[(Integer A)] = (Player((Integer A)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player[(Integer A)] slot status) Equal to Is playing
            • Then - Actions
              • Set TempPoint = (Player[(Integer A)] start location)
              • Unit - Create 1 Demon Hunter for Player[(Integer A)] at TempPoint facing Default building facing degrees
              • Set HeroArray[(Integer A)] = (Last created unit)
              • Custom script: call RemoveLocation(udg_TempPoint)
            • Else - Actions
          • Selection - Select HeroArray[(Integer A)] for (Owner of HeroArray[(Integer A)])
 
Level 1
Joined
Jul 22, 2008
Messages
1
As far as the leak is concerned, his point was not that the init trigger leaks (though it does), his point was that your timer does. Even though you enumerate and remove the unit's position, the line stating "TempPoint offset by 2.50 towards Facing degrees" leaks because it creates an additional temp location via WE that you don't see.

Next, the reason your original trigger didn't work was that the if statement within the loop was only being applied to the first action. You were saying If player is active then create unit, but the action to set the unit to a variable and select that unit ran regardless. Basically, that means that if Player 1 is the only one playing, each array value will be red's unit. If Red and Blue are playing, then Red is the first and Blue is every unit after that because it is the Last Created Unit (since the if statement makes it so no more are made after Blue's).
 
Level 2
Joined
Jun 24, 2008
Messages
15
Okay, I think I have to trigger all ready and working...
I'll go ahead and put it up.

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Countdown Timer - Start TerrainTimer as a Repeating timer that will expire in 0.05 seconds
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set Player[(Integer A)] = (Player((Integer A)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player[(Integer A)] slot status) Equal to Is playing
            • Then - Actions
              • Set TempPoint = (Player[(Integer A)] start location)
              • Unit - Create 1 Demon Hunter for Player[(Integer A)] at TempPoint facing Default building facing degrees
              • Set HeroArray[(Integer A)] = (Last created unit)
              • Custom script: call RemoveLocation(udg_TempPoint)
            • Else - Actions
          • Selection - Select HeroArray[(Integer A)] for Player[(Integer A)]
  • TC
    • Events
      • Time - TerrainTimer expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set Facing[(Integer A)] = (Facing of HeroArray[(Integer A)])
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Set TempPoint = (Position of HeroArray[(Integer A)])
          • Set TempPoint2 = (TempPoint offset by 2.50 towards Facing[(Integer A)] degrees)
          • If ((Terrain type at TempPoint) Equal to Northrend - Ice) then do (Unit - Move HeroArray[(Integer A)] instantly to TempPoint2) else do (Do nothing)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
  • IT
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Ordered unit)) Equal to Demon Hunter
    • Actions
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Target point of issued order)
          • Set TempPoint2 = (Position of HeroArray[(Integer A)])
          • If ((Terrain type at TempPoint2) Equal to Northrend - Ice) then do (Unit - Make HeroArray[(Integer A)] face TempPoint over 0.00 seconds) else do (Do nothing)
          • Custom script: call RemoveLocation(udg_TempPoint)
          • Custom script: call RemoveLocation(udg_TempPoint2)
If there's any MORE leaks or problems...You know what to do :thumbs_up:
 

Dr Super Good

Spell Reviewer
Level 64
Joined
Jan 18, 2005
Messages
27,258
Yes, appears leak free although you are clearing TempPoint before use when the location it contains should already be leak free but this is a minor slowdown and should not affect anything ingame at all (the GUI itself causes more slowdown than that line).

Anyway, it should work like you wish now so go and try it.
 
Level 2
Joined
Jun 24, 2008
Messages
15
Ok, So everything is working fine now for the most part, Sliding, and no leaks as far as I can tell..
But I still have a problem where all my units face the point that one player is issued..
  • IT
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set TempPoint2 = (Position of HeroArray[(Integer A)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint2) Equal to Northrend - Ice
            • Then - Actions
              • Set TempPoint = (Target point of issued order)
              • Unit - Make HeroArray[(Integer A)] face TempPoint over 0.00 seconds
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call RemoveLocation(udg_TempPoint2)
            • Else - Actions
That is my turning trigger, I can't figure out what's wrong with it.
Help is appreciated +Rep if you can try :)
 
Last edited:
Level 2
Joined
Jun 24, 2008
Messages
15
Thank you for your help again, Dr Super Good!
I finally have everything working and leakless!

  • Init
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Countdown Timer - Start TerrainTimer as a Repeating timer that will expire in 0.05 seconds
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set Player[(Integer A)] = (Player((Integer A)))
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Player[(Integer A)] slot status) Equal to Is playing
            • Then - Actions
              • Set TempPoint = (Player[(Integer A)] start location)
              • Unit - Create 1 Demon Hunter for Player[(Integer A)] at TempPoint facing Default building facing degrees
              • Set HeroArray[(Integer A)] = (Last created unit)
              • Custom script: call RemoveLocation(udg_TempPoint)
            • Else - Actions
          • Selection - Select HeroArray[(Integer A)] for Player[(Integer A)]
  • TC
    • Events
      • Time - TerrainTimer expires
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set TempPoint = (Position of HeroArray[(Integer A)])
          • Set Facing[(Integer A)] = (Facing of HeroArray[(Integer A)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint) Equal to Northrend - Ice
            • Then - Actions
              • Set TempPoint2 = (TempPoint offset by 10.00 towards Facing[(Integer A)] degrees)
              • Unit - Move HeroArray[(Integer A)] instantly to TempPoint2
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call RemoveLocation(udg_TempPoint2)
            • Else - Actions
  • IT
    • Events
      • Unit - A unit Is issued an order targeting a point
    • Conditions
      • (Unit-type of (Ordered unit)) Equal to Demon Hunter
    • Actions
      • For each (Integer A) from 1 to 11, do (Actions)
        • Loop - Actions
          • Set TempPoint2 = (Position of HeroArray[(Integer A)])
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • (Terrain type at TempPoint2) Equal to Northrend - Ice
            • Then - Actions
              • Set TempPoint = (Target point of issued order)
              • Set TempUnit = (Ordered unit)
              • Unit - Make TempUnit face TempPoint over 0.00 seconds
              • Custom script: call RemoveLocation(udg_TempPoint)
              • Custom script: call RemoveLocation(udg_TempPoint2)
            • Else - Actions
 
Status
Not open for further replies.
Top