1. Updated Resource Submission Rules: All model & skin resource submissions must now include an in-game screenshot. This is to help speed up the moderation process and to show how the model and/or texture looks like from the in-game camera.
    Dismiss Notice
  2. DID YOU KNOW - That you can unlock new rank icons by posting on the forums or winning contests? Click here to customize your rank or read our User Rank Policy to see a list of ranks that you can unlock. Have you won a contest and still havn't received your rank award? Then please contact the administration.
    Dismiss Notice
  3. The Lich King demands your service! We've reached the 19th edition of the Icon Contest. Come along and make some chilling servants for the one true king.
    Dismiss Notice
  4. The 4th SFX Contest has started. Be sure to participate and have a fun factor in it.
    Dismiss Notice
  5. The poll for the 21st Terraining Contest is LIVE. Be sure to check out the entries and vote for one.
    Dismiss Notice
  6. The results are out! Check them out.
    Dismiss Notice
  7. Don’t forget to sign up for the Hive Cup. There’s a 555 EUR prize pool. Sign up now!
    Dismiss Notice
  8. The Hive Workshop Cup contest results have been announced! See the maps that'll be featured in the Hive Workshop Cup tournament!
    Dismiss Notice
  9. Check out the Staff job openings thread.
    Dismiss Notice
Dismiss Notice
60,000 passwords have been reset on July 8, 2019. If you cannot login, read this.

How to make an AI for your map

Discussion in 'Trigger (GUI) Editor Tutorials' started by sentrywiz, Dec 18, 2013.

  1. I'm glad you found it helpful.

    First, this is just a tutorial. All the triggers involved are to help, not to confuse people who are new to the AI making process. Its ment to inspire you to improve the code on your own and to learn how to make improvements.

    Its good practice and learning that you decided to change how the bolt functions but what you describe as a problem might be a problem for HOW YOU WANT the AI to react. In my case or in the tutorial -- I was ok with the idea of the bot being attacked by multiple units and casting the bolt on the first that was on low health.


    First as an advice, you should avoid using Wait X Seconds, because while it might work for one player it is not MUI friendly (MUI being Multi-Unit Instanceability) so of course its gonna trigger multiple waits that all force the unit to wait and will cause either crashes or infinite loops of stuck-ness.

    Secondly, if you want the trigger to count the cooldown of Storm Bolt and also stop the bot from casting it, here is an example of how I would do it:

    • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
      • If - Conditions
        • (Level of Storm Bolt (Hero) for (Attacking unit)) Greater than 0
        • (Mana of (Attacking unit)) Greater than or equal to 75.00
        • Bolt_ON_Cooldown Equal to False
      • Then - Actions
        • Set Bolt_ON_Cooldown = True
        • Set Bolt_CD_Timer = 11
        • Unit - Order (Attacking unit) to Human Mountain King - Storm Bolt (Attacked unit)
        • Game - Display to (All players) the text: Storm Bolt is on CD.
        • Trigger - Turn on Bolt CD Trigger <gen>
      • Else - Actions


    • Bolt CD Trigger
      • Events
        • Time - Every 1.00 seconds of game time
      • Conditions
      • Actions
        • Set Bolt_CD_Timer = (Bolt_CD_Timer - 1)
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Bolt_CD_Timer Equal to 0
          • Then - Actions
            • Trigger - Turn off (This trigger)
            • Set Bolt_ON_Cooldown = False
          • Else - Actions


    The Bolt CD Trigger will count down the time of the Storm Bolt cooldown and turn itself off when its done. Then when the bot casts the Storm Bolt again,
    the Bolt CD Trigger will be started and will count down from 11 again.,
     
  2. Twilight

    Twilight

    Joined:
    Sep 14, 2012
    Messages:
    398
    Resources:
    14
    Maps:
    14
    Resources:
    14
    This is a grate tutorial and all, rely good, tnx for tutorial, making AI on my map, but just one thing: HOW CAN I MAKE THE AI BYE ITEMS?

    I try every single possible way that I can make the AI bye items, but they endup full with bugs, so please tell me how.
     
  3. There is a section of this tutorial which focuses on buying items.
    Please read it and post any questions regarding that.
     
  4. iamdl

    iamdl

    Joined:
    Mar 6, 2014
    Messages:
    190
    Resources:
    0
    Resources:
    0
    thanks man this tutorial help me on my map ! +rep for you! Btw can this trigger can cast channel spells?
     
  5. grayback222

    grayback222

    Joined:
    Jul 17, 2012
    Messages:
    46
    Resources:
    0
    Resources:
    0
    BUG!!!!!! Theres are bug in itema every time unit comes with in the store it buys 1 item in the loop in his trigger have 6 loops when the unit finish the 6 th loop it started coz a bug it start to buy again the 1sr item in then 1loop until it gets in6 th loop and buy and buy and buy until his base his base full of items
     
    Last edited by a moderator: Aug 6, 2014
  6. Twilight

    Twilight

    Joined:
    Sep 14, 2012
    Messages:
    398
    Resources:
    14
    Maps:
    14
    Resources:
    14

    Try If/Then/Else actions lol,

    [trigger=My Trigger]Buy Items
    Events
    Unit - A unit enters shop000 <gen>
    Conditions
    Actions
    If(All conditions are True)then do(Then Actions)else do(Else Actions)
    If - Conditions
    ((Triggering Unit) hase (Item carried by (Triggering unit) in slot 1)) Equal to False
    Then - Actions
    Item - Create item for (Triggering unit)
    Else -Actions
    Do nothing[/trigger]
     
    Last edited by a moderator: Aug 6, 2014
  7. PurgeandFire

    PurgeandFire

    Code Moderator

    Joined:
    Nov 11, 2006
    Messages:
    7,426
    Resources:
    18
    Icons:
    1
    Spells:
    4
    Tutorials:
    9
    JASS:
    4
    Resources:
    18
    Sorry for the immense delay. I finally got around to reading the tutorial, and it is fine in its current state.

    AI is multi-faceted: there are tons of ways of going about making one. As such, it is nice to have a guide to cover the basics, and your tutorial is well-organized. Hopefully it'll give rise to people making quality, competitive AI's specific to their own maps.

    Approved.
     
  8. So much time has passed from me writing that I totally forgot.
    Glad that you didn't though.
    May it help those that need it.

    Thanks for your approval
     
  9. Yrk

    Yrk

    Joined:
    Apr 1, 2014
    Messages:
    224
    Resources:
    0
    Resources:
    0
    Hi sentrywiz ,

    Can you show me how to make the AI attack / chase the User / Computer ? :)
     
    Last edited: Sep 26, 2014
  10. You mean chase after one specific hero?

    There are many ways to make what you want.

    An example: add a new "Chase Hero" state to the triggers that will be run if the AI is attacked by an enemy hero, it will only attack and cast spells on that hero instead of any other units that attack it.

    And when the AI is engaged by multiple heroes, you can attack only the hero with the lowest health. If both heroes have equal amounts of health, then the AI can select a random of them.
     
  11. Yrk

    Yrk

    Joined:
    Apr 1, 2014
    Messages:
    224
    Resources:
    0
    Resources:
    0
    Yes ( Like in DotA , If you played it :) )

    Can you show me in Trigger ? :)

    Thanks in advance :D
     
  12. DotA's AI is the best AI I have seen. This tutorial is just the base point on which you could make such an amazing AI, but you would need to know plenty of other things.

    Dota is a map that grew for many years and many people worked on it, so it's good to say that plenty of brilliant ideas influenced and made the AI the way it is today. You cannot accomplish such a feat overnight, nor would you want to hence the progression is where the fun is, not the end result.

    No sorry, I won't do it for you. I can help you if you show me some triggers you did yourself and have a problem with, but the point of this tutorial is to teach you how to do it yourself. Otherwise I will just be doing it for you, which isn't in your best interest IF YOU WISH TO LEARN.

    I did tell you how to do it though, in my previous post. Try experimenting with the triggers, and do something yourself.

    However, if you just want a working AI for your map, you can go to the http://www.hiveworkshop.com/forums/requests-341/ page and ask people for it.
     
  13. Yrk

    Yrk

    Joined:
    Apr 1, 2014
    Messages:
    224
    Resources:
    0
    Resources:
    0
    Well , Thanks anyway :D
     
  14. ukn0wnD3str0y3r

    ukn0wnD3str0y3r

    Joined:
    Feb 15, 2013
    Messages:
    364
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    I Would give you credits and +rep if I used on my map =)
    How if i have multiple lane?
     
  15. There are infinite ways to solve multiple lanes.

    I will suggest 3 ways that come to mind right now:

    1. Add all bot heroes to a group and make a region in each lane. Make a boolean variable "Botinlane[x]". Then pick a random unit from the group and if the botinlane[player_number] is equal to false, send it to a random of the X lanes and set its boolean variable to true. When the bot goes back to base to heal or dies, you can set this variable to false

    2. You can make a region array variable that simply says "Whichlane[x]" that you can change throughout the game. That way if a bot hero has revived after death or when it kills an enemy, it will always return to the lane under its player number.

    1. You could do complex checking per X seconds to check how many enemies are in each lane (both enemy and ally) and if there are enemy heroes there. You can use "Units in region" or "Units in group" under conditions and if the number exceeds a certain parameter like "More than 10 enemies" or "More than 1 enemy hero" send multiple bot heroes to that lane.
     
  16. ukn0wnD3str0y3r

    ukn0wnD3str0y3r

    Joined:
    Feb 15, 2013
    Messages:
    364
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    Example... i'm sucks in Boolean here Boolean There Sorry xD
     
  17. Boolean is a simple true/false variable. Its either true or false.

    Here is an example of the first solution.

    • Untitled Trigger 001
      • Events
      • Conditions
      • Actions
        • Set botinlane[1] = False
        • Set botinlane[2] = False
        • Set botinlane[3] = False
        • Set botgroup = (Units in (Playable map area) matching ((((Matching unit) is alive) Equal to True) and (((Owner of (Matching unit)) controller) Equal to Computer)))
        • Set botgroup2 = (Random 1 units from botgroup)
        • Unit Group - Pick every unit in botgroup2 and do (Actions)
          • Loop - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • botinlane[(Player number of (Owner of (Picked unit)))] Equal to False
              • Then - Actions
                • -------- send bot to lane --------
                • Set botinlane[(Player number of (Owner of (Picked unit)))] = True
              • Else - Actions
                • -------- nothing --------
     
  18. ukn0wnD3str0y3r

    ukn0wnD3str0y3r

    Joined:
    Feb 15, 2013
    Messages:
    364
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3
    So you checked it if the unit is computer and set the boolean to true and if true the other trigger will on?
     
  19. Yeah. You would send a bot to the lane and set its boolean to true. Then the next time you do this trigger, if the unit is in lane, it will be skipped. Only bots that aren't in a lane and are alive will be affected
     
  20. ukn0wnD3str0y3r

    ukn0wnD3str0y3r

    Joined:
    Feb 15, 2013
    Messages:
    364
    Resources:
    3
    Maps:
    1
    Spells:
    2
    Resources:
    3