can anyone tell me how to loop this?

Azlier

Old World Ghost
Reaction score
461
set MyUnitVariable = Random Unit From (Sheeps)

Something like that.
 

squorpion

New Member
Reaction score
12
set MyUnitVariable = Random Unit From (Sheeps)

Something like that.

this is what i came up with

Code:
Set random sheep
    Events
    Conditions
    Actions
        Set RandomSheep = (Random unit from Sheeps)

Code:
Sheep Spawn
    Events
        Time - Elapsed game time is 0.01 seconds
    Conditions
    Actions
        If (((Player 1 (Red) slot status) Equal to Is playing) and (((Player 1 (Red) controller) Equal to User) and ((Owner of RandomSheep) Equal to Neutral Passive))) then do (Unit - Change ownership of RandomSheep to Player 1 (Red) and Change color) else do (Unit - Remove RandomSheep from the game)

why i dont think it is going to work is this

Code:
((Owner of RandomSheep) Equal to Neutral Passive)))
radomized unit
Code:
Unit - Change ownership of RandomSheep to Player 1 (Red) and Change color)
and another random
Code:
(Unit - Remove RandomSheep from the game)

that is why i need picked random unit not just random unit from unit group sheeps.
 

Azlier

Old World Ghost
Reaction score
461
>that is why i need picked random unit not just random unit from unit group sheeps.

What's the difference? There's no such function as 'Pick Random Unit' in JASS, either.
Every time you need to 'pick' a random unit, do this action:
Code:
Set RandomSheep = (Random unit from Sheeps)
 

squorpion

New Member
Reaction score
12
>that is why i need picked random unit not just random unit from unit group sheeps.

What's the difference? There's no such function as 'Pick Random Unit' in JASS, either.
Every time you need to 'pick' a random unit, do this action:
Code:
Set RandomSheep = (Random unit from Sheeps)

wait ok so if i set that vaiarble and use it like this
Code:
Event - time elapsed 0.01
condition - 
Action -If,The,Else multiple function
           If player 1 red = user and is playing then random sheep
           If Picked unit owned by nuetral passive then change ownership to player1 red
           else Loop

would that work you think?

wait ok so if i set that vaiarble and use it like this
Code:
Event - time elapsed 0.01
condition - 
Action -If,The,Else multiple function
           If player 1 red = user and is playing then random sheep
           If Picked unit owned by nuetral passive then change ownership to player1 red
           else Loop

would that work you think?

well i just found out that is imposible so it wont work

Code:
f player 1 red = user and is playing [B]then random sheep[/B]

EDIT

this is the trigger i came up with so far

Code:
Randomize spawn
    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
            Else - Actions

i have a then action ready that i am going to do but i cant find a loop. this is my then action
i just put a somment text in there representing where i think the loop should be.

Code:
Randomize spawn
    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 --------)
            Else - Actions
 

saw792

Is known to say things. That is all.
Reaction score
280
Trigger:
  • Untitled Trigger 001
    • 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
          • (Player 1 (Red) controller) Equal to User
        • Then - Actions
          • Set RandomSheep = (Random unit from Sheep)
          • Unit - Explode RandomSheep
          • -------- Or whatever you want to happen. Add more conditions if you need to. --------
        • Else - Actions


Obviously you have to set the unit group variable first...
 

squorpion

New Member
Reaction score
12
Trigger:
  • Untitled Trigger 001
    • 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
          • (Player 1 (Red) controller) Equal to User
        • Then - Actions
          • Set RandomSheep = (Random unit from Sheep)
          • Unit - Explode RandomSheep
          • -------- Or whatever you want to happen. Add more conditions if you need to. --------
        • Else - Actions


Obviously you have to set the unit group variable first...

The Problem now is that i can't find a Loop thingy in the GI
 

saw792

Is known to say things. That is all.
Reaction score
280
For each Integer A from....

OR

Pick every unit in Sheeps and...
 

saw792

Is known to say things. That is all.
Reaction score
280
Both those two actions create loops. What on earth are you trying to loop through?
 

squorpion

New Member
Reaction score
12
Both those two actions create loops. What on earth are you trying to loop through?

what i want to do is loop this trigger
Code:
Randomize spawn
    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 --------)
            Else - Actions
untill conditions are met for that in the end red will only get 1 random unit from the unit group sheep.
 

squorpion

New Member
Reaction score
12
Randomized Spawning trigger help needed

sorry for missnaming topic i ment randomized change unit ownership trigger
i need to create a trigger checks if the user is playing,if its a user or not,if the player owns a unit from unit group sheeps. then if he is a user that is playing, check if "randomSheep" = owned by nuetral passive if all conditions are met then change the ownership of matching unit to player1 red.

this is what i have so far
Code:
Randomize spawn
    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

all i need to do is loop the trigger untill red recieves 1 unit from group sheeps but i can't figure out how to do that. here is my set variable for randomsheep
Code:
RandomSheep
    Events
    Conditions
    Actions
        Set RandomSheep = (Random unit from Sheeps)

can anyone help me on this?
 

squorpion

New Member
Reaction score
12
i need this looped untill player1 red recieves 1 unit from unit group sheeps. i made the trigger in gui but i dont think i can loop it like this with gui.

JASS:
function Trig_Randomize_spawn_Func001Func002001 takes nothing returns boolean
    return ( GetOwningPlayer(udg_RandomSheep) == Player(PLAYER_NEUTRAL_PASSIVE) )
endfunction

function Trig_Randomize_spawn_Func001Func003001 takes nothing returns boolean
    return ( GetPlayerSlotState(Player(0)) == PLAYER_SLOT_STATE_PLAYING )
endfunction

function Trig_Randomize_spawn_Func001Func003002 takes nothing returns boolean
    return ( GetPlayerController(Player(0)) == MAP_CONTROL_USER )
endfunction

function Trig_Randomize_spawn_Func001C takes nothing returns boolean
    if ( not GetBooleanAnd( Trig_Randomize_spawn_Func001Func003001(), Trig_Randomize_spawn_Func001Func003002() ) ) then
        return false
    endif
    return true
endfunction

function Trig_Randomize_spawn_Actions takes nothing returns nothing
    if ( Trig_Randomize_spawn_Func001C() ) then
        if ( Trig_Randomize_spawn_Func001Func002001() ) then
            call SetUnitOwner( GetFilterUnit(), Player(0), true )
        else
            // Loop untill red recieves a unit from random sheep
        endif
    else
        call RemoveUnit( GroupPickRandomUnit(udg_Sheeps) )
    endif
endfunction

//===========================================================================
function InitTrig_Randomize_spawn takes nothing returns nothing
    set gg_trg_Randomize_spawn = CreateTrigger(  )
    call TriggerRegisterTimerEventSingle( gg_trg_Randomize_spawn, 0.01 )
    call TriggerAddAction( gg_trg_Randomize_spawn, function Trig_Randomize_spawn_Actions )
endfunction

i think it should be something like this
JASS:

function Setting takes nothing recieves nothing
    global integer boolean pick
    set pick = false
//this is the part i dont know how to do
    if (player(0) = OWNS_UNIT_IN_SHEEPS) then
    set pick = true
    else 
endfunction

function LoopTrigger teakes nothing recieves nothing
     if pick = false loop
         loop
              exitwhen (pick=true)
         endloop
     else DoNothing

i just started learning jass so there is prob alot of mistakes in the code but that is what i came up with i havnt tryd it yet because i know its not right espesially this part
JASS:
 if (player(0) = OWNS_UNIT_IN_SHEEPS)


here are the variable sets that mite be usefull
Code:
RandomSheep
    Events
    Conditions
    Actions
        Set RandomSheep = (Random unit from Sheeps)
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
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top