• 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.

[Spell] AI Pick Hero System...FAILURE : (

Status
Not open for further replies.
  • AI Pick
    • Events
      • Time - Elapsed game time is 30.00 seconds
    • Conditions
    • Actions
      • For each (Integer A) from 1 to 12, do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Player((Integer A))) controller) Equal to Computer
              • (Player((Integer A))) Not equal to Player 1 (Red)
              • (Player((Integer A))) Not equal to Player 7 (Green)
            • Then - Actions
              • Set CurrentHero = (CurrentHero + 1)
              • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                • If - Conditions
                  • ((Player((Integer A))) is an ally of Player 1 (Red)) Equal to True
                • Then - Actions
                  • Set AIRegion = Hero Creation Sentinel <gen>
                • Else - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • ((Player((Integer A))) is an ally of Player 7 (Green)) Equal to True
                    • Then - Actions
                      • Set AIRegion = Hero Creation Undead <gen>
                    • Else - Actions
              • For each (Integer B) from CurrentHero to 37, do (Actions)
                • Loop - Actions
                  • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
                    • If - Conditions
                      • AIPicked[(Integer B)] Equal to False
                    • Then - Actions
                      • Set AI_UnitTypeConfirmed[(Integer A)] = AIType[(Integer B)]
                      • Set AIPicked[(Integer B)] = True
                    • Else - Actions
              • Player - Make AI_UnitTypeConfirmed[(Integer A)] Unavailable for training/construction by (Player((Integer A)))
              • Unit - Create 1 AI_UnitTypeConfirmed[(Integer A)] for (Player((Integer A))) at (Center of AIRegion) facing Default building facing degrees
              • Set AIUnit[(Integer A)] = (Last created unit)
              • Game - Display to (All players) the text: ((Name of (Owner of AIUnit[(Integer A)])) + ( has picked + (Name of AIUnit[(Integer A)])))
            • Else - Actions
Open the triggers then help me : (

The Problem is this:
I waited 30 seconds...
After that, it successfuly picked, but the picked hero won't show up, or sometimes it'll be always the number 37 type....

EDIT:
just noticed i made a wrong post, sorry mods..

Someone move this to Triggers& SCripts please?
 
Level 28
Joined
Jan 26, 2007
Messages
4,789
First of all: try setting all computers in a player group (at map init).
Then set all allies of player 1 red in a player group (team 1) and all allies of player 7 in another player group (team 2).

Second: you do NOT need the variable "AIRegion".
You also do not need the else-if: if the player is not an ally of player 1, it is ALWAYS an ally of player 7.
You should use a POINT location though, to remove the memory leaks.


  • AI Pick
    • Events
      • Time - Elapsed game time is 30.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in AIplayers and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) is in team1) Equal to True
            • Then - Actions
              • Set tempLoc = (Center of Hero Creation Sentinel <gen>)
            • Else - Actions
              • Set tempLoc = (Center of Hero Creation Undead <gen>)
          • set tempInt = (Random integer number between 1 and 37)
          • Unit - Create 1 AIType[tempInt] for (Picked player) at tempLoc facing Default building facing degrees
          • Set AIUnit[(Player number of (Picked player))] = (Last created unit)
          • Game - Display to (All players) the text: ((Name of (Picked player) + ( has picked + (Name of AIUnit[tempInt]))))
          • Custom script: call RemoveLocation(udg_tempLoc)
...Or something like that.
 
try looking for the DotA template on epicwar... it has a trigger for randomized hero... I think it will be fine for a test map...

btw, the trigger by Apocalypse can create a hero more than once (a hero can be obtained by more than one player)... but there's a lot of workarounds... if you look at the dota template map, it keeps track of the total number of heroes that can still be chose, then once a hero is picked, it sets the array index in which the chosen hero is stored to the hero at the index equal to the total number of heroes that can still be chosen, then reduces the number of heroes that can be chosen by 1...

someting like this:
  • AI Pick
    • Events
      • Time - Elapsed game time is 30.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in AIplayers and do (Actions)
        • Loop - Actions
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • ((Picked player) is in team1) Equal to True
            • Then - Actions
              • Set tempLoc = (Center of Hero Creation Sentinel <gen>)
            • Else - Actions
              • Set tempLoc = (Center of Hero Creation Undead <gen>)
            • Set tempInt = (Random integer number between 1 and ChoosableHeroes)
            • Unit - Create 1 AIType[tempInt] for (Picked player) at tempLoc facing Default building facing degrees
            • Set AIUnit[(Player number of (Picked player))] = (Last created unit)
            • Game - Display to (All players) the text: ((Name of (Picked player) + ( has picked + (Name of AIUnit[tempInt]))))
            • Set AIType[tempInt] = AIType[ChoosableHeroes]
            • Set ChoosableHeroes = ChoosableHeroes - 1
            • Custom script: call RemoveLocation(udg_tempLoc)
 
Status
Not open for further replies.
Top