Staredit Network > Forums > SC2 Assistance > Topic: [SOLVED] Execution took too long
[SOLVED] Execution took too long
Nov 28 2012, 1:04 pm
By: payne  

Nov 28 2012, 1:04 pm payne Post #1

:payne:

Here is my Action Definition:

Code
Assign units to random players
   Options: Action
   Return Type: (None)
   Parameters
       Players' units region = No Region <Region>
   Grammar Text: Assign units to random players(Players' units region)
   Hint Text: (None)
   Custom Script Code
   Local Variables
       Successful attempts = 0 <Integer>
       Players' units = (Empty unit group) <Unit Group>
       Random Unit = No Unit <Unit>
       SelectedPlayer = 0 <Integer>
   Actions
       General - While (Conditions) are true, do (Actions)
           Conditions
               (Number of Living units in (Any units in Players' units region owned by player 0 matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) != 0
           Actions
               Variable - Set Players' units = (Any units in Players' units region owned by player 0 matching Excluded: Missile, Dead, Hidden, with at most Any Amount)
               General - If (Conditions) then do (Actions) else do (Actions)
                   If
                       Successful attempts == (Number of players in human players)
                   Then
                       General - Pick each integer from 1 to number of players, and do (Actions)
                           Actions
                               Variable - Set PlayersIsChosen[(Picked integer)] = False
                   Else
               Variable - Set SelectedPlayer = (Random integer between 1 and number of players)
               General - While (Conditions) are true, do (Actions)
                   Conditions
                       Or
                           Conditions
                               (Controller of player SelectedPlayer) != User
                               PlayersIsChosen[SelectedPlayer] == True
                   Actions
                       Variable - Set SelectedPlayer = (Random integer between 1 and number of players)
               Variable - Set PlayersIsChosen[SelectedPlayer] = True
               Variable - Modify Successful attempts: + 1
               Variable - Set Random Unit = (Random Living unit from Players' units)
               Unit - Change ownership of Random Unit to player SelectedPlayer and Change Color
               Unit - Make Random Unit Vulnerable
               Unit Group - Remove Random Unit from Players' units


Whenever I run it, sc2 warns me that the execution took too long and it stops running it.
I haven't seen it change ownership of more than 2 units out of the total of units.
My goal is to have it so that it selects a random unit in a region, and gives it to a random player. Then does the same thing for all the players of a certain Player Group. However, it must not give another unit to a player as long as all players haven't received their unit (this is to make sure I do not end up with Player 1 controlling all the units).

Additional (global) variables:
Code
PlayersIsChosen = False <Boolean[6]>
human players = (Empty player group) <Player Group>
number of players = 6 <Integer>


"human players" player group is containing the User players of another player group containing all the team 1 allied players. The map is set up for 6 allied players, but say the Players 4 and 6 are missing, "human players" would contain Players 1, 2, 3, and 5.

EDIT: No idea why I didn't think about that solution before.
Code
Assign units to random players
   Options: Action
   Return Type: (None)
   Parameters
       Players' units region = No Region <Region>
   Grammar Text: Assign units to random players(Players' units region)
   Hint Text: (None)
   Custom Script Code
   Local Variables
       Players' units = (Empty unit group) <Unit Group>
       Random Unit = No Unit <Unit>
   Actions
       General - While (Conditions) are true, do (Actions)
           Conditions
               (Number of Living units in (Any units in Players' units region owned by player 0 matching Excluded: Missile, Dead, Hidden, with at most Any Amount)) != 0
           Actions
               Player Group - Pick each player in human players and do (Actions)
                   Actions
                       Variable - Set Players' units = (Any units in Players' units region owned by player 0 matching Excluded: Missile, Dead, Hidden, with at most Any Amount)
                       Variable - Set Random Unit = (Random Living unit from Players' units)
                       Unit - Change ownership of Random Unit to player (Picked player) and Change Color
                       Unit - Make Random Unit Vulnerable
                       Unit Group - Remove Random Unit from Players' units


Post has been edited 8 time(s), last time on Nov 28 2012, 1:55 pm by payne.



None.

Options
  Back to forum
Please log in to reply to this topic or to report it.
Members in this topic: None.
[02:45 pm]
NudeRaider -- Oh_Man
Oh_Man shouted: have i ever told u guys my SC2 pro-gamer story
how many GSL titles?
[2026-7-27. : 10:41 am]
ManCubuS -- Seems like something's broken regarding the site then. Sadge...
[2026-7-27. : 7:36 am]
Oh_Man -- have i ever told u guys my SC2 pro-gamer story
[2026-7-26. : 11:30 pm]
Ultraviolet -- That's strange, it looks like you targeted the base image file (sometimes people make the mistake of just using the imgur page link which doesn't work for embedding) but it still didn't work it sounds like.
[2026-7-26. : 3:34 pm]
ManCubuS -- Used : " [img=https://i.imgur.com/gpOjTuD.jpeg] "
[2026-7-26. : 3:28 pm]
ManCubuS -- Even tried with imgur, doesn't attach.
[2026-7-26. : 3:14 pm]
ManCubuS -- I should try a workaround, thanks! Sadly imgur is blocked in my country for some unknown reason.
[2026-7-26. : 3:05 pm]
NudeRaider -- I think SEN has trouble with https or hotlinking is forbidden. It certainly is nothing about the size, it just fails to get any size. You can get it working if you use imgur and include the actual image link for the img tag. Like this: [img=https://i.imgur.com/ddYqXZa.jpeg]
[2026-7-26. : 11:15 am]
ManCubuS -- Hey fellas! Anyone knows why when I try to upload an image it says "failed to get image size"? I even tried making it so small. Imgur isn't working here and I tried postimg no luck.
[2026-7-23. : 6:40 am]
Oh_Man -- true
Please log in to shout.


Members Online: Zycorax, Roy