Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

Need help in a trigger to create units!!!!

Discussion in 'Triggers & Scripts' started by Shiroaisu, Jan 18, 2010.

  1. Shiroaisu

    Shiroaisu

    Joined:
    Jul 17, 2008
    Messages:
    202
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Hi...

    basically what i want to do is to create 20 units in different random points of the map, but when i do this:

    • Unit - Create 20 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees


    This creates 20 mines only at 1 random position, so i changed the trigger:

    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees
    • Unit - Create 1 Goblin Land Mine for Player 4 (Purple) at (Random point in (Playable map area)) facing Default building facing degrees


    this seems a very ridiculous thing and i wanted to know how to do it in a better way

    Help pls...
     
  2. Titanhex

    Titanhex

    Joined:
    Jul 26, 2008
    Messages:
    1,007
    Resources:
    2
    Maps:
    2
    Resources:
    2
    What you'll want to do is create a loop that loops up to 20 times. Probably For Each Integer A, from 1 to 20, do actions. Place that creation trigger within the loop.
     
  3. Shiroaisu

    Shiroaisu

    Joined:
    Jul 17, 2008
    Messages:
    202
    Resources:
    1
    Maps:
    1
    Resources:
    1
    hmm ok i got how it works, but can you explain to me why do we have for each integer A and B?? and those 2 mean?
     
  4. cl0s3dy

    cl0s3dy

    Joined:
    Apr 10, 2009
    Messages:
    96
    Resources:
    3
    Maps:
    3
    Resources:
    3
    Well if you have a hard time doing it a good way whats the problem with doing it the "ridiculous" way?
     
  5. Maker

    Maker

    Joined:
    Mar 6, 2006
    Messages:
    9,174
    Resources:
    17
    Maps:
    2
    Spells:
    14
    Tutorials:
    1
    Resources:
    17
    You have integer A and integer B because you may want to have a loop inside of a loop.

    Using

    • For every (Integer A) from 1 to 6
      • Loop
        • For every (Integer A) from 1 to 6
          • Loop
            • *do your things*


    Would not work too well. So you need to use integer B for the other.

    And your trigger:
    • For every (Integer A) from 1 to 20
      • Loop
        • Set Temp_Loc_1 = (Random point in (Playable map area))
        • Unit - Create 1 *unit* at Temp_Loc_1 facing...
        • call RemoveLocation(udg_Temp_Loc_1)
     
  6. Shiroaisu

    Shiroaisu

    Joined:
    Jul 17, 2008
    Messages:
    202
    Resources:
    1
    Maps:
    1
    Resources:
    1
    Ok tks everyone...

    SOLVED

    btw:
    ... the ridiculous way its WAY harder..
     
  7. Reaper2008

    Reaper2008

    Joined:
    Jul 27, 2008
    Messages:
    1,117
    Resources:
    1
    Spells:
    1
    Resources:
    1
    So that he learns something...

    Although the "ridiculous" way is faster, it's uglier, and harder to change (must change 20 times). Knowing about loops is fundamental anyway.