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.
  • Ghan Ghan:
    Still lurking
    +3
  • The Helper The Helper:
    I am great and it is fantastic to see you my friend!
    +1
  • The Helper The Helper:
    If you are new to the site please check out the Recipe and Food Forum https://www.thehelper.net/forums/recipes-and-food.220/
  • Monovertex Monovertex:
    How come you're so into recipes lately? Never saw this much interest in this topic in the old days of TH.net
  • Monovertex Monovertex:
    Hmm, how do I change my signature?
  • tom_mai78101 tom_mai78101:
    Signatures can be edit in your account profile. As for the old stuffs, I'm thinking it's because Blizzard is now under Microsoft, and because of Microsoft Xbox going the way it is, it's dreadful.
  • The Helper The Helper:
    I am not big on the recipes I am just promoting them - I use the site as a practice place promoting stuff
    +2
  • Monovertex Monovertex:
    @tom_mai78101 I must be blind. If I go on my profile I don't see any area to edit the signature; If I go to account details (settings) I don't see any signature area either.
  • The Helper The Helper:
    You can get there if you click the bell icon (alerts) and choose preferences from the bottom, signature will be in the menu on the left there https://www.thehelper.net/account/preferences
  • The Helper The Helper:
    I think I need to split the Sci/Tech news forum into 2 one for Science and one for Tech but I am hating all the moving of posts I would have to do
  • The Helper The Helper:
    What is up Old Mountain Shadow?
  • The Helper The Helper:
    Happy Thursday!
    +1
  • Varine Varine:
    Crazy how much 3d printing has come in the last few years. Sad that it's not as easily modifiable though
  • Varine Varine:
    I bought an Ender 3 during the pandemic and tinkered with it all the time. Just bought a Sovol, not as easy. I'm trying to make it use a different nozzle because I have a fuck ton of Volcanos, and they use what is basically a modified volcano that is just a smidge longer, and almost every part on this thing needs to be redone to make it work
  • Varine Varine:
    Luckily I have a 3d printer for that, I guess. But it's ridiculous. The regular volcanos are 21mm, these Sovol versions are about 23.5mm
  • Varine Varine:
    So, 2.5mm longer. But the thing that measures the bed is about 1.5mm above the nozzle, so if I swap it with a volcano then I'm 1mm behind it. So cool, new bracket to swap that, but THEN the fan shroud to direct air at the part is ALSO going to be .5mm to low, and so I need to redo that, but by doing that it is a little bit off where it should be blowing and it's throwing it at the heating block instead of the part, and fuck man
  • Varine Varine:
    I didn't realize they designed this entire thing to NOT be modded. I would have just got a fucking Bambu if I knew that, the whole point was I could fuck with this. And no one else makes shit for Sovol so I have to go through them, and they have... interesting pricing models. So I have a new extruder altogether that I'm taking apart and going to just design a whole new one to use my nozzles. Dumb design.
  • Varine Varine:
    Can't just buy a new heatblock, you need to get a whole hotend - so block, heater cartridge, thermistor, heatbreak, and nozzle. And they put this fucking paste in there so I can't take the thermistor or cartridge out with any ease, that's 30 dollars. Or you can get the whole extrudor with the direct driver AND that heatblock for like 50, but you still can't get any of it to come apart
  • Varine Varine:
    Partsbuilt has individual parts I found but they're expensive. I think I can get bits swapped around and make this work with generic shit though
  • Ghan Ghan:
    Heard Houston got hit pretty bad by storms last night. Hope all is well with TH.
  • The Helper The Helper:
    Power back on finally - all is good here no damage
    +2
  • V-SNES V-SNES:
    Happy Friday!
    +1
  • The Helper The Helper:
    New recipe is another summer dessert Berry and Peach Cheesecake - https://www.thehelper.net/threads/recipe-berry-and-peach-cheesecake.194169/

      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