• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.

[Trigger] I'm in troubl with numbers. I need to get last number?

Status
Not open for further replies.
  • AI create allies
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • Num_of_alliance Equal to 0 - this checks there are no more players to choose heroes
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • And - All (Conditions) are true
            • Conditions
              • (Player 1 (Red) controller) Equal to Computer
              • AHEROES[(Random integer number between 1 and 6)] Equal to No unit - unit array
        • Then - Actions
          • Unit - Create 1 heroes[1] for Player 1 (Red) at (Center of Alli Spawn <gen>) facing 270.00 degrees -[color=red]unit-type array[/color]
          • AHEROES[] = (Last created unit) - this actually also have to depend on number of unit-type
          • Unit - Order AHEROES[] to Attack-Move To (Center of attack horde <gen>)
        • Else - Actions
With this I'm trying to pick a random unit from a unit-type,check if the unit array for this number is empty and create it for the player. I do thsi trigger to be similar to <computers buy unit>Can you help me? I need to 1.check this random number or 2. to create the unit-type if matching condition for unit array is <no unit>(empty)
 
Level 15
Joined
Oct 18, 2008
Messages
1,591
I'm not sure if you really want this to run every 2s throughout the game...

You should store an integer and raise it every time the trigger runs:
  • AI create allies
    • Events
      • Time - Every 2.00 seconds of game time
    • Conditions
      • Num_of_alliance Equal to 0 - this checks there are no more players to choose heroes
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Player 1 (Red) controller) Equal to Computer
          • AHEROES[Hero_Count] Equal to No unit
          • Hero_Count Less than 7
        • Then - Actions
          • Unit - Create 1 heroes[1] for Player 1 (Red) at (Center of Alli Spawn <gen>) facing 270.00 degrees
          • AHEROES[Hero_Count] = (Last created unit) - this actually also have to depend on number of unit-type
          • Unit - Order AHEROES[Hero_Count] to Attack-Move To (Center of attack horde <gen>)
          • Set Hero_Count = ( Hero_Count + 1 )
        • Else - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • Hero_Count Greater than or Equal to 7
            • Then - Actions
              • Trigger - Turn off (this trigger)
Something like that?

Not sure what you want to do though

Also, the If-Then-Else statement is an "AND" condition by default, no need to add an "AND" inside it.
 
Level 7
Joined
Mar 6, 2006
Messages
282
I don't really understand. Are you trying to do this?

  • AI create allies
  • Events
    • Time - Every 2.00 seconds of game time
  • Conditions
    • Num_of_alliance Equal to 0 - this checks there are no more players to choose heroes
  • Actions
    • Set RandomInt = (Random integer number between 1 and 6)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
      • Conditions
        • (Player 1 (Red) controller) Equal to Computer
        • AHEROES[RandomInt] Equal to No unit - unit array
    • Then - Actions
      • Unit - Create 1 heroes[1] for Player 1 (Red) at (Center of Alli Spawn <gen>) facing 270.00 degrees -[color=red]unit-type array[/color]
      • AHEROES[RandomInt] = (Last created unit) - this actually also have to depend on number of unit-type
      • Unit - Order AHEROES[RandomInt] to Attack-Move To (Center of attack horde <gen>)
  • Else - Actions
 
I don't really understand. Are you trying to do this?

  • AI create allies
  • Events
    • Time - Every 2.00 seconds of game time
  • Conditions
    • Num_of_alliance Equal to 0 - this checks there are no more players to choose heroes
  • Actions
    • Set RandomInt = (Random integer number between 1 and 6)
    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
    • If - Conditions
      • And - All (Conditions) are true
      • Conditions
        • (Player 1 (Red) controller) Equal to Computer
        • AHEROES[RandomInt] Equal to No unit - unit array
    • Then - Actions
      • Unit - Create 1 heroes[1] for Player 1 (Red) at (Center of Alli Spawn <gen>) facing 270.00 degrees -[color=red]unit-type array[/color]
      • AHEROES[RandomInt] = (Last created unit) - this actually also have to depend on number of unit-type
      • Unit - Order AHEROES[RandomInt] to Attack-Move To (Center of attack horde <gen>)
  • Else - Actions

Thanks, I never thought about this. Will try it.
 
Status
Not open for further replies.
Top