can anyone tell me how to loop this?

squorpion

New Member
Reaction score
12
Multiple Trigger Problems

Iknow the problem in this trigger but i cant find a way to fix it here it is

Code:
If (((Player 1 (Red) slot status) Equal to Is playing) and (((Player 1 (Red) controller) Equal to User) and ((Owner of (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 1 (Red) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)

What i figure the problem being is the ((Owner of (Random unit from Sheeps)) part. Sheeps is my unit group variable and if this helps at all this is how i have it set up

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

i have 8 units in the region sheeps added to the variable.

I have 2 problems with the trigger so here if the full thing.

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 (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 1 (Red) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)
        If (((Player 2 (Blue) slot status) Equal to Is playing) and (((Player 2 (Blue) controller) Equal to User) and ((Owner of (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 2 (Blue) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)
        If (((Player 3 (Teal) slot status) Equal to Is playing) and (((Player 3 (Teal) controller) Equal to User) and ((Owner of (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 3 (Teal) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)
        If (((Player 4 (Purple) slot status) Equal to Is playing) and (((Player 4 (Purple) controller) Equal to User) and ((Owner of (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 4 (Purple) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)
        If (((Player 5 (Yellow) slot status) Equal to Is playing) and (((Player 5 (Yellow) controller) Equal to User) and ((Owner of (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 5 (Yellow) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)
        If (((Player 6 (Orange) slot status) Equal to Is playing) and (((Player 6 (Orange) controller) Equal to User) and ((Owner of (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 6 (Orange) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)
        If (((Player 7 (Green) slot status) Equal to Is playing) and (((Player 7 (Green) controller) Equal to User) and ((Owner of (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 7 (Green) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)
        If (((Player 8 (Pink) slot status) Equal to Is playing) and (((Player 8 (Pink) controller) Equal to User) and ((Owner of (Random unit from Sheeps)) Equal to Neutral Passive))) then do (Unit - Change ownership of (Random unit from Sheeps) to Player 8 (Pink) and Change color) else do (Unit - Remove (Random unit from Sheeps) from the game)
        Wait 0.02 game-time seconds
        Unit Group - Pick every unit in (Units in Sheeps <gen>) and do (Actions)
            Loop - Actions
                Unit - Move (Picked unit) instantly to (Center of (Playable map area))

The second problem i have is with the teleport part of the trigger. im guessing it has to do with the wait.
 

squorpion

New Member
Reaction score
12
You can't move a unit to a region if you removed it from the game.

i know. this is whats soposed to happen. lets say player slots 1-4 are taken and the rest are empty. players 1-4 will have a randomly selected sheeps while the left over sheep are removed from the game since they will still be ownd by nuetral passive. then the 4 sheeep left in the region will be teleported to the middle of the map leaving 1 randomly selected sheep for each playing player and no exes sheep to feed.
 

squorpion

New Member
Reaction score
12
If anyone can put this into triggering i think it would work.

Code:
Event - time elapsed game time is 0.01
If player 1 red is user = true and player 1 red is playing = true and player 1 red (this is the part i cant get) [owns no units from unit group sheeps] 
ThenSelect random unit from player group Sheeps If ownership of unit = nuetral passive change ownership to player 1 red 
else (this is another part i can't figure out) [loop untill player 1 red recieves unit from unit group sheeps]
 

squorpion

New Member
Reaction score
12
Please help me on this trigger

i am new to jass and need helping making this trigger in jass since gui can't do it.

Code:
Sheep Spawn
    Events
        Time - Elapsed game time is 0.01 seconds
    Conditions
    Actions
        Unit Group - Pick Random unit in Sheeps and do (Actions)
            Loop - Actions
                If (((Owner of (Triggering unit)) Equal to Neutral Passive) and Player 1 red owns 0 units from unit group Sheeps then do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color) else do Loop actions untill player 1 red recieves 1 unit from unit group sheeps
 

RaiJin

New Member
Reaction score
40
Just to let you know there is no "triggering Unit"

Code:
Sheep Spawn
    Events
        Time - Elapsed game time is 0.01 seconds
    Conditions
    Actions
        Unit Group - Pick Random unit in Sheeps and do (Actions)
            Loop - Actions
                If (((Owner of ([B]Picked unit[/B])) Equal to Neutral Passive) and Player 1 red owns 0 units from unit group Sheeps then do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color) else do Loop actions untill player 1 red recieves 1 unit from unit group sheeps
 

squorpion

New Member
Reaction score
12
Just to let you know there is no "triggering Unit"

Code:
Sheep Spawn
    Events
        Time - Elapsed game time is 0.01 seconds
    Conditions
    Actions
        Unit Group - Pick Random unit in Sheeps and do (Actions)
            Loop - Actions
                If (((Owner of ([B]Picked unit[/B])) Equal to Neutral Passive) and Player 1 red owns 0 units from unit group Sheeps then do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color) else do Loop actions untill player 1 red recieves 1 unit from unit group sheeps

Oh you mean theres no picked unit. ya there is Unit Group - Pick Random unit in Sheeps and do (Actions)
 

RaiJin

New Member
Reaction score
40
i meant if your trying to designate a unit inside a loop action when its a Unit Group then you use Picked Unit instead of Triggering Unit :S
 

squorpion

New Member
Reaction score
12
i meant if your trying to designate a unit inside a loop action when its a Unit Group then you use Picked Unit instead of Triggering Unit :S

what you mean??? i never use triggering unit i used picked unit. i didnt copy all of the gui stuff i typed out most of it because it doesnt have the options for that stuff. im just asking if someone that knows jass can write this out for me.
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
You used triggering unit just about here:
Code:
                If (((Owner of [B](Triggering unit)[/B]) Equal to Neutral Passive) and Player 1 red owns 0 units from unit group Sheeps then do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color) else do Loop actions untill player 1 red recieves 1 unit from unit group sheeps

Just give me a minute and I'll see what I can do.

JASS:
function Filt takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == &#039;Sheep&#039; and IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false
endfunction

function Trig_SheepThing_Actions takes nothing returns nothing
    local group g = CreateGroup()
    local unit u = null
    local integer count = 0
    call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_PASSIVE), Filter(function Filt))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            set count = count + 1
            call GroupRemoveUnit(g, u)
            set u = null
            set u = FirstOfGroup(g)
    endloop
    if count &gt; 0 then
        set u = FirstOfGroup(g)
        call SetUnitOwner(u, Player(0), true)
        set u = null
        call DestroyGroup(g)
        set g = null
    endif
endfunction

function Trig_SheepThing_Conditions takes nothing returns boolean
    local group g = CreateGroup()
    local unit u = null
    local integer c = 0
    call GroupEnumUnitsOfPlayer(g, Player(0), Filter(function Filt))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            set c = c + 1
            call GroupRemoveUnit(g, u)
            set u = null
    endloop
    if c == 0 then
            return true
    endif
    return false
endfunction

//===========================================================================
function InitTrig_SheepThing takes nothing returns nothing
    set gg_trg_SheepThing = CreateTrigger(  )
    call TriggerRegisterTimerEvent(gg_trg_SheepThing, 1, true)
    call TriggerAddCondition(t, Filter(function Trig_SheepThing_Conditions ))
    call TriggerAddAction( gg_trg_SheepThing, function Trig_SheepThing_Actions )
endfunction
 

squorpion

New Member
Reaction score
12
You used triggering unit just about here:
Code:
                If (((Owner of [B](Triggering unit)[/B]) Equal to Neutral Passive) and Player 1 red owns 0 units from unit group Sheeps then do (Unit - Change ownership of (Picked unit) to Player 1 (Red) and Change color) else do Loop actions untill player 1 red recieves 1 unit from unit group sheeps

Just give me a minute and I'll see what I can do.

JASS:
function Filt takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == &#039;Sheep&#039; and IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false
endfunction

function Trig_SheepThing_Actions takes nothing returns nothing
    local group g = CreateGroup()
    local unit u = null
    local integer count = 0
    call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_PASSIVE), Filter(function Filt))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            set count = count + 1
            call GroupRemoveUnit(g, u)
            set u = null
            set u = FirstOfGroup(g)
    endloop
    if count &gt; 0 then
        set u = FirstOfGroup(g)
        call SetUnitOwner(u, Player(0), true)
        set u = null
        call DestroyGroup(g)
        set g = null
    endif
endfunction

function Trig_SheepThing_Conditions takes nothing returns boolean
    local group g = CreateGroup()
    local unit u = null
    local integer c = 0
    call GroupEnumUnitsOfPlayer(g, Player(0), Filter(function Filt))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            set c = c + 1
            call GroupRemoveUnit(g, u)
            set u = null
    endloop
    if c == 0 then
            return true
    endif
    return false
endfunction

//===========================================================================
function InitTrig_SheepThing takes nothing returns nothing
    set gg_trg_SheepThing = CreateTrigger(  )
    call TriggerRegisterTimerEvent(gg_trg_SheepThing, 1, true)
    call TriggerAddCondition(t, Filter(function Trig_SheepThing_Conditions ))
    call TriggerAddAction( gg_trg_SheepThing, function Trig_SheepThing_Actions )
endfunction

ty im going to try it right now.

Hi , I have a jass trigger that i need to put into my map and i thought that you just hit action->custom script but of course nothing in life is that simple. well i have tryd opening up the map in jass craft to put in the jass script but when i open up jass craft all i see is a series of symbols so i have no idea where to stick the code. so how do i put this one jass trigger into my map?
 

T.s.e

Wish I was old and a little sentimental
Reaction score
133
Open the editor, press the big yellow a-sign in the middle-top of the Editor (F4), create a trigger by pressing ctrl + t, and entering its name. Then click it, and click Edit in the top. Then scroll down until you find Convert to Custom Text, replace everything that it says in the field where you enter text with the code you want.
 

squorpion

New Member
Reaction score
12
jass trigger problem

when i save the map a script error window pops up saying there are 63 complied errors. when i test or play the map it wont even load could anyone find the problem with the trigger?

JASS:
function Filt takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == &#039;Sheep&#039; and IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false
endfunction

function Trig_SheepThing_Actions takes nothing returns nothing
    local group g = CreateGroup()
    local unit u = null
    local integer count = 0
    call GroupEnumUnitsOfPlayer(g, Player(PLAYER_NEUTRAL_PASSIVE), Filter(function Filt))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            set count = count + 1
            call GroupRemoveUnit(g, u)
            set u = null
            set u = FirstOfGroup(g)
    endloop
    if count &gt; 0 then
        set u = FirstOfGroup(g)
        call SetUnitOwner(u, Player(0), true)
        set u = null
        call DestroyGroup(g)
        set g = null
    endif
endfunction

function Trig_SheepThing_Conditions takes nothing returns boolean
    local group g = CreateGroup()
    local unit u = null
    local integer c = 0
    call GroupEnumUnitsOfPlayer(g, Player(0), Filter(function Filt))
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            set c = c + 1
            call GroupRemoveUnit(g, u)
            set u = null
    endloop
    if c == 0 then
            return true
    endif
    return false
endfunction

//===========================================================================
function InitTrig_SheepThing takes nothing returns nothing
    set gg_trg_SheepThing = CreateTrigger(  )
    call TriggerRegisterTimerEvent(gg_trg_SheepThing, 1, true)
    call TriggerAddCondition(t, Filter(function Trig_SheepThing_Conditions ))
    call TriggerAddAction( gg_trg_SheepThing, function Trig_SheepThing_Actions )
endfunction
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
JASS:
function Filt takes nothing returns boolean
    return GetUnitTypeId(GetFilterUnit()) == &#039;Sheep&#039; and IsUnitType(GetFilterUnit(), UNIT_TYPE_DEAD) == false
endfunction


'sheep' ain't no unit type ID, check it up in the object editor with ctrl+D.

JASS:
function InitTrig_SheepThing takes nothing returns nothing
    set gg_trg_SheepThing = CreateTrigger(  )
    call TriggerRegisterTimerEvent(gg_trg_SheepThing, 1, true)
    call TriggerAddCondition(t, Filter(function Trig_SheepThing_Conditions ))
    call TriggerAddAction( gg_trg_SheepThing, function Trig_SheepThing_Actions )
endfunction


You have no variable named t in that function, use gg_trg_SheepThing.

JASS:
    loop
        set u = FirstOfGroup(g)
        exitwhen u == null
            set count = count + 1
            call GroupRemoveUnit(g, u)
            set u = null
            set u = FirstOfGroup(g)
    endloop
    if count &gt; 0 then
        set u = FirstOfGroup(g)
        call SetUnitOwner(u, Player(0), true)
        set u = null
        call DestroyGroup(g)
        set g = null
    endif


This part I can't seem to figure out at all what it's supposed to do...
 

squorpion

New Member
Reaction score
12
it isnt my trigger i don't know jass. someone made me the trigger and i put it in the map and it doesn't seem to work. i was just wondering if someone could edit it and fix the problems for that i can use the trigger.
 

Larcenist

REP: Respect, Envy, Prosperity?
Reaction score
211
What is it supposed to do? This could be good to know in order to recreate it.
 

squorpion

New Member
Reaction score
12
Writing this in jass?

Code:
Actions
    Unit Group - Pick every unit in Sheeps and do (Do nothing)

i think that is this

JASS:

function Trig_Untitled_Trigger_001_Actions takes nothing returns nothing
    call ForGroupBJ( udg_Sheeps, function Trig_Untitled_Trigger_001_Func001002 )
endfunction


what i want to do is change this

Code:
Actions
    Unit Group - Pick every unit in Sheeps and do (Do nothing)

to this. (change the word every to random.)

Code:
Actions
    Unit Group - Pick random unit in Sheeps and do (Do nothing)

but since there is no gui for that i need to write it into jass so i just need to know what i have to edit to make the change.
 

Azlier

Old World Ghost
Reaction score
461
Will you stop saying 'GUI can't do this...'? GUI most certainly has the capabilities to check whether a player is playing or not, get a random unit from a unit group, etc. Ever heard of Random Unit from (Unit group)? Just another GUI action.

However, if you want trackables, local players, MAXXXX EFFICIENCYYYY, and timer systems, you're outta luck.
 

squorpion

New Member
Reaction score
12
Will you stop saying 'GUI can't do this...'? GUI most certainly has the capabilities to check whether a player is playing or not, get a random unit from a unit group, etc. Ever heard of Random Unit from (Unit group)? Just another GUI action.

However, if you want trackables, local players, MAXXXX EFFICIENCYYYY, and timer systems, you're outta luck.

im not trying to check if a play is playing or not. im trying to PICK a random unit from unit group sheeps and it doesn't seem to have that option i have look up and down the lists multiple times
 
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