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.

[AI] How to order AI to buy items??

Discussion in 'Triggers & Scripts' started by R1DL3R, May 14, 2008.

  1. R1DL3R

    R1DL3R

    Joined:
    Oct 28, 2007
    Messages:
    72
    Resources:
    0
    Resources:
    0
    Am intresting if i can do like AI or i must do GUI ???
    can some body help me?
    I just want to give order Ai to buy some item from shop....
     
  2. DenZel94

    DenZel94

    Joined:
    Jun 4, 2006
    Messages:
    127
    Resources:
    5
    Maps:
    3
    Tutorials:
    2
    Resources:
    5
    I have it on my simple AI tut for GUI but i think ill just give this other one...


    There are some ways to do so, if you want it to buy more then there is, if only once then there is as well.. I'll just submit the once... (twice and thrice is also possible)

    Firstly, create a boolean (ignore arrays in trigger) and set the ai hero into a variable..

    Then, we order the AI to go to a certain region where should be placed nearby the shop..

    • Order Buy P1
      • Events
        • Time - Every (Random real number between 95.01 and 125.01) seconds of game time
      • Conditions
      • Actions
        • Set AIUnitLocP[1] = (Center of ai shop spot 1 <gen>)
        • Unit - Order AIUnitP[1] to Move To AIUnitLocP[1]
        • Custom script: call RemoveLocation(udg_AIUnitLocP[1])


    We then set the boolean to true when he enters the region

    • Buy Activate P1
      • Events
        • Unit - A unit enters ai shop spot 1 <gen>
      • Conditions
        • (Triggering unit) Equal to AIUnitP[1]
      • Actions
        • Set AIBuyingP[1] = True


    Then the buying starts:

    • Buy Dexters Edge P1
      • Events
        • Time - Every 0.03 seconds of game time
      • Conditions
        • AIBuyingP[1] Equal to True
      • Actions
        • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
          • If - Conditions
            • Or - Any (Conditions) are true
              • Conditions
                • (Item-type of (Item carried by AIUnitP[1] in slot 1)) Equal to (Item-type of No item)
                • (Item-type of (Item carried by AIUnitP[1] in slot 2)) Equal to (Item-type of No item)
                • (Item-type of (Item carried by AIUnitP[1] in slot 3)) Equal to (Item-type of No item)
                • (Item-type of (Item carried by AIUnitP[1] in slot 4)) Equal to (Item-type of No item)
                • (Item-type of (Item carried by AIUnitP[1] in slot 5)) Equal to (Item-type of No item)
                • (Item-type of (Item carried by AIUnitP[1] in slot 6)) Equal to (Item-type of No item)
            • (Player 1 (Red) Current gold) Greater than or equal to 4600
          • Then - Actions
            • Hero - Create Dexter's Edge and give it to AIUnitP[1]
            • Player - Add -4600 to Player 1 (Red) Current gold
            • Trigger - Turn off (This trigger)
          • Else - Actions
            • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
              • If - Conditions
                • Or - Any (Conditions) are true
                  • Conditions
                    • (Player 1 (Red) Current gold) Greater than or equal to 4600
                    • ((Player 1 (Red) Current gold) + (150 x (Charges remaining in (Item carried by AIUnitP[1] of type Minor Mana Potion)))) Greater than or equal to 4600
              • Then - Actions
                • Player - Add (150 x (Charges remaining in (Item carried by AIUnitP[1] of type Minor Mana Potion))) to Player 1 (Red) Current gold
                • Item - Remove (Item carried by AIUnitP[1] of type Minor Mana Potion)
                • Hero - Create Dexter's Edge and give it to AIUnitP[1]
                • Player - Add -4600 to Player 1 (Red) Current gold
                • Trigger - Turn off (This trigger)
              • Else - Actions


    As you can see from the bottom, it will sell mana potions so that it could buy the desired item.. This is not needed but this is what i just want XD..

    REMOVING TURN OFF will make this trigger repeatable* and would buy 2 at one time IF it has enough money to buy 2 then would buy when comming back then etc..

    Now, we put a disable to the boolean when the hero leaves

    • Buy Deactivate P1
      • Events
        • Unit - A unit leaves ai shop spot 1 <gen>
      • Conditions
        • (Triggering unit) Equal to AIUnitP[1]
      • Actions
        • Set AIBuyingP[1] = False



    There you go ^_^...
     
  3. R1DL3R

    R1DL3R

    Joined:
    Oct 28, 2007
    Messages:
    72
    Resources:
    0
    Resources:
    0
    thx

    DenZel94 thx for this i will try it when i get free time now school its trouble...
    btw its look very easy to create...and one more thing
    you send unit to that region but why send when we can add
    • Actions (Player 1 (Red) Current gold) Greater than or equal to 4600

    to fcondition in first triger
    • Order Buy P1
    • Events
    • Time - Every (Random real number between 95.01 and 125.01) seconds of game time
    • Conditions
    • "Triggering unit equal to hero=true"
    • Triggering unit current gold greater or equal to 4600 =true"
    • Actions
    • Set AIUnitLocP[1] = (Center of ai shop spot 1 <gen>)
    • Unit - Order AIUnitP[1] to Move To AIUnitLocP[1]
    • Custom script: call RemoveLocation(udg_AIUnitLocP[1])

    Its beter that hero dont go there then see that he dindt got enought gold
    its better this way if he got gold then he can go to buy some item....
    But realy THX .
     
  4. DenZel94

    DenZel94

    Joined:
    Jun 4, 2006
    Messages:
    127
    Resources:
    5
    Maps:
    3
    Tutorials:
    2
    Resources:
    5
    I just did the order to move with no condition cuz i had other things in mind but suite yourself