Infintive loop problem

eatbeaver

New Member
Reaction score
7
Code:
Microorganism
    Events
        Unit - A unit enters Reds area <gen>
    Conditions
        (Unit-type of (Triggering unit)) Not equal to Microorganism
    Actions
        Set Temppoint = (Center of Reds area <gen>)
        Set tempgroup = (Units owned by Player 1 (Red) of type Multicellular)
        Unit Group - Pick every unit in tempgroup and do (Actions)
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in tempgroup) Greater than or equal to 3
                    Then - Actions
                        Custom script:   call RemoveLocation(udg_Temppoint)
                        Set Temppoint = (Position of (Random unit from tempgroup))
                        Trigger - Turn off (This trigger)
                        Unit - Create 1 Microorganism for Player 1 (Red) at Temppoint facing Default building facing degrees
                        Trigger - Turn on (This trigger)
                    Else - Actions
        Custom script:   call DestroyGroup(udg_tempgroup)
        Custom script:   call RemoveLocation(udg_Temppoint)

I only want 1 Microorgansim...
 

Azlier

Old World Ghost
Reaction score
461
Too bad we don't have a delete post function. I can't figure it out.
 

Jolly chap*

New Member
Reaction score
34
Why did you put turn off this trigger and turn on this trigger straight away? It would cancel each other out ... maybe that is your problem? Sorry don't have WE open ... again. :(
 

Kazuga

Let the game begin...
Reaction score
110
Code:
Microorganism
    Events
        Unit - A unit enters Reds area <gen>
    Conditions
        (Unit-type of (Triggering unit)) Not equal to Microorganism
    Actions
        Set Temppoint = (Center of Reds area <gen>)
        Set tempgroup = (Units owned by Player 1 (Red) of type Multicellular)
        [B]Unit Group - Pick every unit in tempgroup and do (Actions)[/B]
            Loop - Actions
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in tempgroup) Greater than or equal to 3
                    Then - Actions
                        Custom script:   call RemoveLocation(udg_Temppoint)
                        Set Temppoint = (Position of (Random unit from tempgroup))
                        Trigger - Turn off (This trigger)
                        Unit - Create 1 Microorganism for Player 1 (Red) at Temppoint facing Default building facing degrees
                        Trigger - Turn on (This trigger)
                    Else - Actions
        Custom script:   call DestroyGroup(udg_tempgroup)
        Custom script:   call RemoveLocation(udg_Temppoint)
It's because of the unit group loop. It loops through all your unit and for each unit it checks if the unit group contains 3 or more of the unit.
 

Jolly chap*

New Member
Reaction score
34
Right. Take the If Then Else out of the Unit Group Action and then delete the Unit Group Action. You won't need it anymore.
 

darkbeer

Beer is Good!
Reaction score
84
in other words:

Code:
Microorganism
    Events
        Unit - A unit enters Reds area <gen>
    Conditions
        (Unit-type of (Triggering unit)) Not equal to Microorganism
    Actions
        Set Temppoint = (Center of Reds area <gen>)
        Set tempgroup = (Units owned by Player 1 (Red) of type Multicellular)
                If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    If - Conditions
                        (Number of units in tempgroup) Greater than or equal to 3
                    Then - Actions
                        Unit - Create 1 Microorganism for Player 1 (Red) at Temppoint facing Default building facing degrees
                    Else - Actions
        Custom script:   call DestroyGroup(udg_tempgroup)
        Custom script:   call RemoveLocation(udg_Temppoint)
 
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