• 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.

Short, but Lagging Trigger, Please Help clean up. :)

Status
Not open for further replies.
Level 5
Joined
Sep 21, 2005
Messages
119
Here it is.. It doesn't lag in SP, at least not on my computer, but it lags like hell when hosted with multiple people. Anyone know how to fix, or remake this a better way?

  • Attack gates
    • Events
      • Time - Every 5.50 seconds of game time
    • Conditions
    • Actions
      • Set ZombieGateAttackGroups = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Zombie (Real Zombie)) or ((Unit-type of (Matching unit)) Equal to Hunter)))
      • Unit Group - Pick every unit in ZombieGateAttackGroups and do (Actions)
        • Loop - Actions
          • Destructible - Pick every destructible within 500.00 of (Position of (Picked unit)) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked destructible) is alive) Equal to True
                • Then - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • Or - Any (Conditions) are true
                        • Conditions
                          • (Destructible-type of (Picked destructible)) Equal to Elven Gate (Diagonal 1)
                          • (Destructible-type of (Picked destructible)) Equal to Elven Gate (Diagonal 2)
                          • (Destructible-type of (Picked destructible)) Equal to Elven Gate (Horizontal)
                          • (Destructible-type of (Picked destructible)) Equal to Elven Gate (Vertical)
                          • (Destructible-type of (Picked destructible)) Equal to Gate (Diagonal 1)
                          • (Destructible-type of (Picked destructible)) Equal to Gate (Diagonal 2)
                          • (Destructible-type of (Picked destructible)) Equal to Gang Door (Horizontal)
                          • (Destructible-type of (Picked destructible)) Equal to Door (Vertical)
                    • Then - Actions
                      • Unit - Order (Picked unit) to Attack (Picked destructible)
                      • Custom script: call DestroyGroup(udg_ZombieGateAttackGroups)
                    • Else - Actions
                      • Custom script: call DestroyGroup(udg_ZombieGateAttackGroups)
                • Else - Actions
                  • Custom script: call DestroyGroup(udg_ZombieGateAttackGroups)
 
Level 5
Joined
Sep 21, 2005
Messages
119
Oh I see, as in take it out of the Else's, and just put it as a seperate function after the first.

Alright I did.. going to test it as well.. Not sure it'll fix it.. I need a JASS way to remove the position of picked destructible, I believe that's the leaking part.
 
Level 29
Joined
Jul 29, 2007
Messages
5,174
  • Destructible - Pick every destructible within 500.00 of (Position of (Picked unit)) and do (Actions)
Leaks a location.
Set Position of (Picked unit) to a point variable and remove it later on.
As to the destructible group, I'm not really sure, but people tend to say that they cannot be removed so don't bother doing anything about it.
 
Level 5
Joined
Sep 21, 2005
Messages
119
Alright.. how does this look?
  • Attack gates
    • Events
      • Time - Every 5.50 seconds of game time
    • Conditions
    • Actions
      • Set ZombieGateAttackGroups = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Zombie (Real Zombie)) or ((Unit-type of (Matching unit)) Equal to Hunter)))
      • Unit Group - Pick every unit in ZombieGateAttackGroups and do (Actions)
        • Loop - Actions
          • Set Temp_Point = (Position of (Picked unit))
          • Destructible - Pick every destructible within 500.00 of Temp_Point and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked destructible) is alive) Equal to True
                  • Or - Any (Conditions) are true
                    • Conditions
                      • (Destructible-type of (Picked destructible)) Equal to Elven Gate (Horizontal)
                      • (Destructible-type of (Picked destructible)) Equal to Elven Gate (Vertical)
                      • (Destructible-type of (Picked destructible)) Equal to Gate (Diagonal 1)
                      • (Destructible-type of (Picked destructible)) Equal to Gate (Diagonal 2)
                      • (Destructible-type of (Picked destructible)) Equal to Gang Door (Horizontal)
                      • (Destructible-type of (Picked destructible)) Equal to Door (Vertical)
                • Then - Actions
                  • Unit - Order (Picked unit) to Attack (Picked destructible)
                • Else - Actions
      • Custom script: call DestroyGroup(udg_ZombieGateAttackGroups)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Pick only destructibles matching condition and put these:
  • ((Matching destructible) is alive) Equal to True
  • And
    • (Destructible-type of (Matching destructible)) Equal to Elven Gate (Horizontal)
    • Or
    • (Destructible-type of (Matching destructible)) Equal to Elven Gate (Vertical)
    • Or
    • (Destructible-type of (Matching destructible)) Equal to Gate (Diagonal 1)
    • Or
    • (Destructible-type of (Matching destructible)) Equal to Gate (Diagonal 2)
    • Or
    • (Destructible-type of (Matching destructible)) Equal to Gang Door (Horizontal)
    • Or
    • (Destructible-type of (Matching destructible)) Equal to Door (Vertical)
as the condition. That will reduce lag significantly.
As redscores sait, you have to remove the location inside the actions part of the Pick every unit in ... blah
Anyway
You've got this quite wrong as you are picking a lot of units this will lag.
You should pick the units around each destructible and order them to attack it - hell less laggy if done correctly.
 
Level 5
Joined
Sep 21, 2005
Messages
119
Hey, yeah sorry I actually added that in AFTER reading my post :p

it still lagged..

Spiwn, I haven't tried it with the modified conditions yet, but I did try to make the pick units around a destructible.. and it didn't work =\
Maybe you can write that one line for me? As far as I know, it can't be done...

Btw, this IS what you ment by modifying conditions, right?
  • Attack gates
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set ZombieGateAttackGroups = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Zombie (Real Zombie)) or ((Unit-type of (Matching unit)) Equal to Hunter)))
      • Unit Group - Pick every unit in ZombieGateAttackGroups and do (Actions)
        • Loop - Actions
          • Set Temp_Point = (Position of (Picked unit))
          • Destructible - Pick every destructible within 500.00 of Temp_Point and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked destructible) is alive) Equal to True
                  • And - All (Conditions) are true
                    • Conditions
                      • ((Destructible-type of (Picked destructible)) Equal to Demonic Gate (Horizontal)) or (((Destructible-type of (Picked destructible)) Equal to Demonic Gate (Vertical)) or (((Destructible-type of (Picked destructible)) Equal to Door (Vertical)) or ((Destructible-type of (Picked destructible)) Equal to Elven Gate (Horizontal))))
                • Then - Actions
                  • Unit - Order (Picked unit) to Attack (Picked destructible)
                • Else - Actions
      • Custom script: call DestroyGroup(udg_ZombieGateAttackGroups)
      • Custom script: call RemoveLocation(udg_Temp_Point)
 
Level 4
Joined
Jun 1, 2007
Messages
92
Move the RemoveLocation part to right after you pick every destructible. Else you would only remove the point only once, with this, it will destroy it every time you set it.

  • Untitled Trigger 001
    • Events
    • Conditions
    • Actions
      • Set group = (Units in (Playable map area))
      • Unit Group - Pick every unit in group and do (Actions)
        • Loop - Actions
          • Set point = (Position of (Picked unit))
          • Destructible - Pick every destructible within 256.00 of point and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                • Then - Actions
                • Else - Actions
          • Custom script: call RemoveLocation(udg_point)
      • Custom script: call DestroyGroup(udg_group)
 
Level 5
Joined
Sep 21, 2005
Messages
119
Alright I JUST tested it with my 2 friends with the following trig:
  • Attack gates Copy
    • Events
      • Time - Every 5.00 seconds of game time.
    • Conditions
    • Actions
      • Set ZombieGateAttackGroups = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Zombie (Real Zombie)) or ((Unit-type of (Matching unit)) Equal to Hunter)))
      • Unit Group - Pick every unit in ZombieGateAttackGroups and do (Actions)
        • Loop - Actions
          • Set Temp_Point = (Position of (Picked unit))
          • Destructible - Pick every destructible within 500.00 of Temp_Point and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Picked destructible) is alive) Equal to True
                  • And - All (Conditions) are true
                    • Conditions
                      • ((Destructible-type of (Picked destructible)) Equal to Demonic Gate (Horizontal)) or (((Destructible-type of (Picked destructible)) Equal to Demonic Gate (Vertical)) or (((Destructible-type of (Picked destructible)) Equal to Door (Vertical)) or ((Destructible-type of (Picked destructible)) Equal to Elven Gate (Horizontal))))
                • Then - Actions
                  • Unit - Order (Picked unit) to Attack (Picked destructible)
                • Else - Actions
          • Custom script: call RemoveLocation(udg_Temp_Point)
      • Custom script: call DestroyGroup(udg_ZombieGateAttackGroups)

Still Lagged. Almost no difference.
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
  • Unit Group - Pick every unit in (Units within 512.00 of (Position of Summer Tree Wall 0000 <gen>) matching (((Matching unit) is alive) Equal to (==) True)) and do (Actions)
    • Loop - Actions
      • Unit - Order (Picked unit) to Attack Summer Tree Wall 0000 <gen>
Just an example.
IF you have a lot of destructibles, consider putting them in an array in the initialization or something, and looping through all of them.
About what I suggested for the conditions - my bad, thought there was Pick every destructible matching condition. Theoretically(if there was such an action) that would lag less.
Now you pick all destructibles around all units and check if they are gates. So if you have 10 units, next to 10 trees, you will wc3 will check your conditions 100 times, and will still do nothing.
 
Last edited:
Level 5
Joined
Sep 21, 2005
Messages
119
Alright about the initialization.. how would that work?
If you have 10 different kinds of gates, and also if the gates have the Death Alternate (so you'd need to make sure they're alive somehow within that)
And then even then, how do you loop through the pre-assigned variables.. there is no 'Destructible Group' var, although there IS a destructible-type.. hmm.. maybe something to do with that.
Now you pick all destructibles around all units and check if they are gates. So if you have 10 units, next to 10 trees, you will wc3 will check your conditions 100 times, and will still do nothing.

Yeah I see that, but how would I make that work?

ON A SEPARATE, Good note... Don't know why yet BUT.. I made the initial trigger the same, turn on, but ONLY do the following:
  • Attack gates
    • Events
      • Time - Every 5.00 seconds of game time
    • Conditions
    • Actions
      • Set ZombieGateAttackGroups = (Units in (Playable map area) matching (((Unit-type of (Matching unit)) Equal to Zombie (Real Zombie)) or ((Unit-type of (Matching unit)) Equal to Hunter)))
      • Wait 5.00 seconds
      • Custom script: call DestroyGroup(udg_ZombieGateAttackGroups)
That's just me testing for creating group lag, etc..
HOWEVER, I made ANOTHER trigger that turns on when I type a command that was exactly like the old trigger,.. *I* think that because it runs every 5 seconds of game time, yet still works.. maybe it's something to do with running the creation of a group and removal of a group before setting it or something.. no idea.. really confusing too :s

Anyway, Im still thinking about rewriting it somehow :s
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Add conditions that suit you.
Change array size to what the gates count is.
 

Attachments

  • gates.w3x
    17.4 KB · Views: 36
Level 5
Joined
Sep 21, 2005
Messages
119
Wow, that's so smart :p

Thanks a lot :)
Have yet to test it. I'm sure it'll work beautifully :)

I wish I could give you more rep, but you're the last person I gave rep to :p lol

Thanks Again.
I'll mention you in the map credits for sure. You have no idea how long I've spent over that one trigger..

On a happier note, I reduced the unplayable part of my lagging thing in my old trigger, but it still skips just a tad, which is annoying. Either way, I have this one now, it's perfect :)
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
You are welcome.

Well, actually I haven't, but theoretically it should work :D

A simple thank you is enough :)

Ps Ok, it is not working (one triggering unit should be matching unit) :D
Also in the initialization trigger the line:
  • Set gc = (gc - 1)
Should be added.
Now it has been tested and works. If you have any problems I will post the 'updated' version ;)
 
Last edited:
Level 5
Joined
Sep 21, 2005
Messages
119
Actually I already moved a couple things around ;)

First of all.. I took out the remove.. because I have close/open gates.. that can still be opened and closed after once destroyed, so the remove thing won't really work.

I also added a small IF statement that it's alive (because I took out the remove)
Also, yeah I fixed that part up, i also added in my condition of zombies/hunters, otherwise, every single unit will attack the gates lol.
Also, if you plan to use that sort of method.. a quick nice thing I added.. just for my alpha testing, I added in a text message to all players the GC + ( gates detected) :p
So that helps me optimize the variable.

Finally.. what's with that line? Why do I need it..? And where exactly do I put it?

Unless.... are you putting it there just so that when it does the For Next loop, it starts at 0? why not just initialize the integer to be -1? or something.. i dunno what you are trying to use it for xP
 
Level 12
Joined
Apr 27, 2008
Messages
1,228
Ah, if you are not using the remove trigger, then you do not need this line.
 
Status
Not open for further replies.
Top