need help on trigger(randomly select unit)

squorpion

New Member
Reaction score
12
i know i have posted about this trigger before but i still never recieved an answer that worked so posting agien. here is the trigger all i need is to add a if,then,else loop.

variables used in trigger
Code:
Sheeps
    Events
        Map initialization
    Conditions
    Actions
        Unit Group - Pick every unit in (Units in Sheeps <gen>) and do (Actions)
            Loop - Actions
                Unit Group - Add (Picked unit) to Sheeps
Code:
RandomSheep
    Events
    Conditions
    Actions
        Set RandomSheep = (Random unit from Sheeps)
trigger it self
Code:
Randomize spawn Copy
    Events
        Time - Elapsed game time is 0.01 seconds
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Player 1 (Red) slot status) Equal to Is playing) and ((Player 1 (Red) controller) Equal to User)
            Then - Actions
                If ((Owner of RandomSheep) Equal to Neutral Passive) then do (Unit - Change ownership of (Matching unit) to Player 1 (Red) and Change color) else do (-------- Loop untill red recieves a unit from random sheep --------)
            Else - Actions
                Unit - Remove (Random unit from Sheeps) from the game
so what i need in this trigger is this.
instead of this(wich is just an explination of what i need)
Code:
else do (-------- Loop untill red recieves a unit from random sheep --------)
i need this.
Code:
else Loop. End loop when player1 red owns 1 unit from sheeps.

that is what i have no idea how to do. i know in jass you can do that but im not to good at jass and can't figure out how to loop the trigger correctly.

if you need the trigger itself post and i will attach a map containing this trigger and the required variables.
 

garion992

TH.net Regular
Reaction score
17
so, for example, you have a unit from player 2. but it must be for player one, so you search further among your sheep group to find a player 1 sheep and skip the player 2 sheep?
you could make the trigger start over again, so it runs again if it hasnt found a player 1 unit, you know, something like Trigger - Run this trigger checking conditions
 

squorpion

New Member
Reaction score
12
so, for example, you have a unit from player 2. but it must be for player one, so you search further among your sheep group to find a player 1 sheep and skip the player 2 sheep?

i have no ideaa what you just said but this is what is going on.

variables
sheeps- when i set the variable sheeps i have a region named sheeps with 8 different sheep inside of it.
randomsheep - it just picks a ranodom unit from the 8 sheeps set inside of sheeps.
trigger
what i want to happen is as followed
first for that map doesnt have that enormus lag at start i set event to map time 0.01 with a condition of play is playing and is a user then run action. pick a random sheep, if the sheep is ownd by anyother player then nutral passive then reroll the sheep and keep on doing so untill it finds one not ownd by nuetral passive. oce it finds one cange the ownership to the player this trigger is for and teleport is to center of map.
 

garion992

TH.net Regular
Reaction score
17
I think it must be something like this

Then - Actions
If Sheep is from Neutral Passive
>then: Trigger - Run this trigger checking conditions (so it starts the trigger over again, if it has again a Neutral Passive sheep it will start again and again untill it has a player controlled sheep, that will be teleported to centre)
>else (so if you have a player controlled sheep): teleport Sheep to centre
 

squorpion

New Member
Reaction score
12
FINALLY!!!! i think i figured something out that will work. here are the trigger.
red
Code:
Randomize spawn red
    Events
        Time - Elapsed game time is 0.01 seconds
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Player 1 (Red) slot status) Equal to Is playing) and ((Player 1 (Red) controller) Equal to User)
            Then - Actions
                If ((Owner of RandomSheep) Equal to Neutral Passive) then do (Unit - Change ownership of (Matching unit) to (Matching player) and Change color) else do (Do nothing)
                Unit Group - Remove (Matching unit) from Sheeps
            Else - Actions
                Unit - Remove (Random unit from Sheeps) from the game
blue
Code:
Randomize spawn blue
    Events
        Time - Elapsed game time is 0.02 seconds
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Player 2 (Blue) slot status) Equal to Is playing) and ((Player 2 (Blue) controller) Equal to User)
            Then - Actions
                If ((Owner of RandomSheep) Equal to Neutral Passive) then do (Unit - Change ownership of (Matching unit) to (Matching player) and Change color) else do (Do nothing)
                Unit Group - Remove (Matching unit) from Sheeps
            Else - Actions
                Unit - Remove (Random unit from Sheeps) from the game

and so on. each trigger starts 0.01 seconds later and removes the sheep picked from the unit group. i have a cuestion though. since this trigger is useing 2 variables()one of them inderectly) will both update with each new trigger???
 

squorpion

New Member
Reaction score
12
going to test it in a few minutes i need to find people to test the trigger.
actually im going to just cange conditions.

edit

for somereason it change the owner ship.
 

garion992

TH.net Regular
Reaction score
17
thats not so weird, cause you tell it to do :p

(Unit - Change ownership of (Matching unit) to (Matching player) and Change color)


i think you want to do this:

Then - Actions
If Sheep is from Neutral Passive
>then: Trigger - Run this trigger checking conditions (so it starts the trigger over again, if it has again a Neutral Passive sheep it will start again and again untill it has a player controlled sheep, that will be teleported to centre)
>else (so if you have a player controlled sheep): teleport Sheep to centre

you could send me the map, if it doesnt works
 

squorpion

New Member
Reaction score
12
i made seperate triggers for each player now. and each trigger removes the sheep that is change ownership for them from the unit group sheeps which is the unit selection in randomsheep. and i only want it to change ownership of a sheep that is controlled by nuetral passive.
 

garion992

TH.net Regular
Reaction score
17
this:

"and each trigger removes the sheep that is change ownership for them from the unit group sheeps which is the unit selection in randomsheep."
 

squorpion

New Member
Reaction score
12
this:

"and each trigger removes the sheep that is change ownership for them from the unit group sheeps which is the unit selection in randomsheep."

you see the part of the trigger that removes the matching unit from unit group sheep? that is the part i was explaining there.
 

garion992

TH.net Regular
Reaction score
17
sec :p

so this:

If ((Owner of RandomSheep) Equal to Neutral Passive) then do (Unit - Change ownership of (Matching unit) to (Matching player) and Change color) else do (Do nothing)

does not only changes your Neutral Passive units but also player bleus's or red's sheeps to another player and color??
 

squorpion

New Member
Reaction score
12
sec :p

so this:

If ((Owner of RandomSheep) Equal to Neutral Passive) then do (Unit - Change ownership of (Matching unit) to (Matching player) and Change color) else do (Do nothing)

does not only changes your Neutral Passive units but also player bleus's or red's sheeps to another player and color??

why would it change red or blues sheeps? that what the condition is for. remember i have the sheeps in a unit group sheeps and then i have sheeps set in a trigger not what your saying but i think reading the variables that i posted in original post would help

my explorer closed and i didnt notice what i typed was still in the box when i reopened.
 

garion992

TH.net Regular
Reaction score
17
Trigger - Run (This trigger) (checking conditions)
this should work then, if you replace it with (----blahblah----)

edit: XD
 

squorpion

New Member
Reaction score
12
Trigger - Run (This trigger) (checking conditions)
this should work then, if you replace it with (----blahblah----)

edit: XD

so use the original trigger just replace the comment with run this trigger checking conditions??? should i make it 1 trigger so reduce lag and just make a player vairable array for each player and +1 the array after each trigger for it runs itfor each play? do you think that would work?
 

squorpion

New Member
Reaction score
12
here is the trigger now.
Code:
Randomize spawn red
    Events
        Time - Elapsed game time is 0.01 seconds
    Conditions
    Actions
        If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            If - Conditions
                ((Player 1 (Red) slot status) Equal to Is playing) and ((Player 1 (Red) controller) Equal to User)
            Then - Actions
                If ((Owner of RandomSheep) Equal to Neutral Passive) then do (Unit - Change ownership of (Matching unit) to Player 1 (Red) and Change color) else do (Trigger - Run (This trigger) (checking conditions))
            Else - Actions
                Unit - Remove (Random unit from Sheeps) from the game
im having a differnt trigger move all the units in sheeps to the center of the map so don't worry about that missing
 

squorpion

New Member
Reaction score
12
lol game closes as soon as map hits 0.01 seconds. prob because its a cuntinues loop and keeps on repeating. how do i end the loop?
 

garion992

TH.net Regular
Reaction score
17
wait is see it i think

Then - Actions
If ((Owner of RandomSheep) Equal to Neutral Passive) then do (Unit - Change ownership of (Matching unit) to Player 1 (Red) and Change color and Trigger -Run this trigger checking conditions) else do <move sheep>or<nothing>
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Members online

      No members online now.

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top