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

[General] Help with player specific (move unit trigger)

Status
Not open for further replies.
Level 2
Joined
Mar 15, 2012
Messages
9
i want to try and make it so when XX time goes by all of a player colors units (exclude buildings obviously.) are moved to a location, sorta like in hero survival (hoihoi custom hero survival is a really good example).

this is what i have, and it doesnt seem to work, suggestions?

then~ how do i port all units out after all enemy units in area are dead.
im assuming a ( units in unit group = 0 in xx region?)
tho i was hoping to avoid a variable :D







this is what i have atm. (not working. and i want ALL player owned units to follow, so summons and such)




wave 1
Events
Time - Elapsed game time is 55.00 seconds
Conditions
Actions
Set players = (Units in (Playable map area))
Unit Group - Remove all units of (Units within 5000.00 of (Center of (Playable map area)) matching (((Triggering unit) is A structure) Equal to True)) from players
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Picked unit)) Equal to Player 1 (Red)
Then - Actions
Unit Group - Pick every unit in players and do (Unit - Move (Picked unit) instantly to (Center of red arena hero <gen>))
Else - Actions
If (All Conditions are True) then do (Then Actions) else do (Else Actions)
If - Conditions
(Owner of (Picked unit)) Equal to Player 2 (Blue)
Then - Actions
Unit Group - Pick every unit in players and do (Unit - Move (Picked unit) instantly to (Center of blue arena hero <gen>))
Else - Actions

EDIT: im very new (second day using world editor) so dont kill me for bad triggers , and be simple please! or at least try.
 
Level 2
Joined
Mar 14, 2012
Messages
20
Think I've Got it

I'm new to world editor myself, but since no one else has replied yet, I thought I'll have ago at fixing your problem for you ^.^

do54aq.jpg


Also since I'm also fairly new to the world editor, someone more experienced may contribute something more efficient. But if they don't, mine should work fine.

I've attached a very quick map to demonstrate that trigger in action =]

As for calculating if all enemys are dead, im not totally sure ^.^. If no one has answered in a few hours, then i'll have a crack at that problem as well.

Variables ain't that bad once you get to use them. If you want any explanation on what apart does what and why, just ask and ill reply when i can.

-----Edit-----
Also if you do use this, make sure you set up the array and regions accordingly. I only made this example really quick so i didn bother with specific details.
If your having 8 players for example, you'll need an array with a size of 9 (Arrays always start on 0, but the for loop can only start as low as 1, so we wont store anything in array 0 and basically ignore it. Then you would set the variable regions
Set Arena_array[1] = Red Arena
Set Arena_array[2] = Blue Arena
Set Arena_array[3] = Etc
Set Arena_array[4] = Etc
Set Arena_array[5] = Etc
Set Arena_array[6] = Etc
Set Arena_array[7] = Etc
Set Arena_array[8] = Etc

And the For loop will be set to:
For each (integer A) from 1 to 8, do (actions)
 

Attachments

  • test.w3x
    23.4 KB · Views: 73
Last edited:
Level 14
Joined
Apr 20, 2009
Messages
1,543
I'm new to world editor myself, but since no one else has replied yet, I thought I'll have ago at fixing your problem for you ^.^

do54aq.jpg


Also since I'm also fairly new to the world editor, someone more experienced may contribute something more efficient. But if they don't, mine should work fine.

I've attached a very quick map to demonstrate that trigger in action =]

As for calculating if all enemys are dead, im not totally sure ^.^. If no one has answered in a few hours, then i'll have a crack at that problem as well.

Variables ain't that bad once you get to use them. If you want any explanation on what apart does what and why, just ask and ill reply when i can.

-----Edit-----
Also if you do use this, make sure you set up the array and regions accordingly. I only made this example really quick so i didn bother with specific details.
If your having 8 players for example, you'll need an array with a size of 9 (Arrays always start on 0, but the for loop can only start as low as 1, so we wont store anything in array 0 and basically ignore it. Then you would set the variable regions
Set Arena_array[1] = Red Arena
Set Arena_array[2] = Blue Arena
Set Arena_array[3] = Etc
Set Arena_array[4] = Etc
Set Arena_array[5] = Etc
Set Arena_array[6] = Etc
Set Arena_array[7] = Etc
Set Arena_array[8] = Etc

And the For loop will be set to:
For each (integer A) from 1 to 8, do (actions)

You are leaking several locations and a unit group.
Also, playable map area does not leak and does not need to be stored unless used frequently in order to improve efficiency.
It's a bj:
bj_PlayableMapRect

(I'm not sure about PlayableMapRect though since I don't have the world editor open at this moment and therefore do not have a solid refference. I'll give one when I get home...)


  • Trigger
    • Events
      • Time - Elapsed game time is 55.00 seconds
    • Conditions
    • Actions
      • Set Arena[1] = (Center of Arena 1 <gen>)
      • Set Arena[2] = (Center of Arena 2 <gen>)
      • Set Arena[3] = (Center of Arena 3 <gen>)
      • Set Arena[4] = (Center of Arena 4 <gen>)
      • Set Arena[5] = (Center of Arena 5 <gen>)
      • Custom script: set bj_wantDestroyGroup = true
      • For each (Integer A) from 1 to 10, do (Actions)
        • Loop - Actions
          • Unit Group - Pick every unit in (Units in Playable map area) and do (Actions)
            • Loop - Actions
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • (Owner of (Picked unit)) Equal to (Player(Integer A))
                • Then - Actions
                  • Unit - Move (Picked unit) instantly to (Arena[Integer A]), facing Default building degrees
                  • Custom script: call RemoveLocation(udg_Arena[ForLoopIndexA])
This:
  • Custom script: set bj_wantDestroyGroup = true
Destroys the next unit group created so that it does not stay in memory after it is used (Removing Leaks).

This:
  • Custom script: call RemoveLocation(udg_Arena[ForLoopIndexA])
Destroys the location Arena[Integer A] after being used so that it doesn't stay in memory (Removing Leaks).

I might have made a few typo's here, because I didn't use the world editor to make this trigger.

EDIT: also next time, please use trigger tags instead of posting a picture.
Simply right click the name of the trigger within the trigger's functions, click on copy as text, and paste it between
[ TRIGGER] [ / TRIGGER] tags (without spacebars inbetween)
This way users can collapse/expend blocks and copy/paste triggers within the thread.


EDIT2:
For a system like this you might want to use timers instead of elapsed game time, this way you can show/hide timer windows to the players. And make it repeat.
 
Level 2
Joined
Mar 14, 2012
Messages
20
Ahhh Leaks

I wasn't totally sure where to put the custom scripts to prevent the leaks, thanks for showing me =).

Also what is a bj? (no sexual innuendo intended xD).
 
Level 19
Joined
Aug 8, 2007
Messages
2,765
a bj is something thats automatically set by game code.

ex. bj_lastcreatedunit is set whenever a unit is created (the GUI counterpart would be "Last Created Unit")
bj_wantDestroyGroup is set by code to false initially but can be set to true and if its set to true than all unit groups are deleted at the end of the triger
 
Level 14
Joined
Apr 20, 2009
Messages
1,543
This is what happens in Jass when using Unit group - Pick every unit in:

JASS:
function ForGroupBJ takes group whichGroup, code callback returns nothing
    // If the user wants the group destroyed, remember that fact and clear
    // the flag, in case it is used again in the callback.
    local boolean wantDestroy = bj_wantDestroyGroup
    set bj_wantDestroyGroup = false

    call ForGroup(whichGroup, callback)

    // If the user wants the group destroyed, do so now.
    if (wantDestroy) then
        call DestroyGroup(whichGroup)
    endif
endfunction

As you can see a local boolean called wantDestroy is created and set to be bj_wantDestroyGroup which is then set to false.
On the bottom it checks wether wantDestroy is true, if it is it will destroy the group. So by setting bj_wantDestroyGroup to true right before you use Unit group - Pick every unit. That unit group that will be used will automatically be destroyed afterwards instead of having to do this manually.

Illidans911 said:
if its set to true than all unit groups are deleted at the end of the triger
This is wrong, as I've explained above only the next used Unit group - Pick every unit's unit group will be destroyed.

Not every unit group since whenever a new Unit group - Pick every unit will be used, the variable will be reset to false.
 
Status
Not open for further replies.
Top