• 0

    posted a message on Forcing AI to Build a Base and Train Units

    Finally got my final step in place for what my original goal was with this project:  being able to add the units that I have trained to a wave and have the AI send an attack against the player.  According to tutorials that I had watched, it looked like this would be an easy affair, but it turned out to be a little less than obvious as you've gotta hold the AI's hand the entire way through the process.  Here are those Trigger snippets:

     

    First, gotta start up the AI Personality that you wish to use.  I put this in the Melee Initialization trigger:

    AI -Start AI for player 2 using Attack Wave 1

    That is in lieu of using Campaign AI or Melee AI - specifically initializing the AI Personality that I created.  After that, you need to tell the AI to add the unit that you've trained to the next attack wave.  The following trigger adds any unit that you train that isn't an SCV to the next Attack Wave.  For the zerg, I'd change that to drone, and add a second condition that it isn't a queen, as well as a third to exclude overlords (unless I specifically want to send an overlord, too, of course!).

    Events:

    Unit - Any Unit training progress is Completed

     

    Conditions: 

    (Triggering progress unit type) != SCV

    (Owner of (Triggering progress unit)) == 2

     

    Actions:

    AI Advanced -Add unit (Triggering progress unit) to wave (Last attack wave created for player 2)

     

    Then lastly, I have a trigger that is nothing but sending the wave... but it also ensures that the wave isn't sent until it's full.  This wave required 6 marines:

    Events:

    Unit - Any Unit training progress is Completed

     

    Conditions: 

    (Owner of (Triggering progress unit)) == 2

    (Marine count for player 2, counting Complete)  >= 6

     

    Actions:

    AI /Run attack wave Attack Wave 1 / Wave 1 for player 2, targeting (Player group (1)), and wait until it completes

     

    Altogether, these three posts have now allowed me to force the AI to produce a specific build order and attack me with it.  ...but only on a specific map that I've created.  Now that I've figured out all of these necessary triggers, I'm thinking that it might be better to create this as a mod that could be played on any map, rather than tying it to any one map in particular.

     

    Mostly though, I just wanted to share these rather basic triggers with others here in the primary resource for SC2 mapping... it took me a long time to figure all of this out, despite it being so basic.  Maybe leaving it here will save someone else all of the trouble that I went through!  :-)

    Posted in: AI Development
  • 0

    posted a message on Forcing AI to Build a Base and Train Units

    Update:

     

    Via the use of AI Build()  and AI Train()  I've been able to get the AI to train a full set of SCVs, while constructing several supply depots, a barracks, and two refineries.  I also got it to train up a few marines and drop a new Command Center at another mineral field (marked by a specific point created via the map UI).

     

    Unfortunately, most of the triggers are time-based.  This is because they're generally permanently active, meaning that if the condition set is true anew (i.e.  "when a supply depot is built"), the action ("train a marine") will happen once for ever single depot built... obviously, I don't want that kind of connection to happen... so the easiest way that I've found to keep that from happening is to make them time-based triggers.  So far, with just a barracks (not even a standard 1-1-1, yet) I'm up to about 10 triggers.

     

    Here are what two of my triggers look like - first the one-time Action (builds a supply depot and trains 1 SCV):

    Build Order 24 - Depot 1:

    Events:

    Timer -Elapsed time is 24.0 Game Time seconds

    Local Variables:
    Conditions:
    Actions:

    AI Advanced -Build 1 units of type Supply Depot in player 2's town -1 with priority 1 using build flags -1
    AI Advanced -Train 1 units of type SCV in player 2's town -1 with priority 0

    The recurring action (lowers all Supply Depots after they are built):

    Lower Depots:

    Events:

    Unit -Any Unit construction progress is Completed

    Local Variables:

    Conditions:

    (Unit type of (Triggering progress unit)) == Supply Depot

    Actions:

    Unit -Order (Triggering progress unit) to (Supply Depot - Lower (Supply Depot)) (Replace Existing Orders)

     

    Gettin' there!  :-)

    Posted in: AI Development
  • 0

    posted a message on Forcing AI to Build a Base and Train Units

    I've been attempting to make this work for the past three days, now... I'm rather fed up with the process.  Did Blizzard not expect us to want to have the AI function via precise build orders and attack us with precise waves?  ::sigh::

     

    I can't even get the AI to train a single SCV.  I have the Campaign AI initiated, all players are getting resources to start the game, harvesting is initialized, etc, etc.  The very first build command that I enter is AITrain  I have also tried AISetStock.  Yes, these are set for the appropriate Player.  I've tried it with and without AIEnableStock.

     

    All I want is to force the AI into specific builds...  Is it really going to be this hard?

     

    On a more direct note:  How do I accomplish this all?

     

    I have figured out how to create triggers for when a building or unit is completed.  If I am going to use a unit in an Attack Wave that I've already created, do I have to actually create a label/group and add the created unit to the wave, or will the AI automatically pick what's available for the wave whether I specifically set aside each unit one-by-one?

     

    As you can tell... I'm just plain stuck.  At step one.  The things that I actually want to accomplish:

     

    1.  Train a few SCVs

    2.  Build out my base building-by-building, just as a player would.

    3.  Train specific units to fulfill Attack Wave requirements

    4.  Send Attack Waves at the player.

    5.  Eventually, expand to a 2nd, 3rd, and 4th base.  ...but this should be a simple extension of the rest of the work if I can figure out 1-4.

     

    It feels like this is probably a very simple thing once I get my hands on the appropriate commands.  Thanks for taking the time to help.

     

    ----------------------------------------------------------------

    Edit:  If it's easier to catch up via Discord, I'm on SC2Mapster's discord as CheTranqui#6328.

    Posted in: AI Development
  • To post a comment, please or register a new account.