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 poll for Hive's 12th Concept Art Contest is up! Go cast your vote for your favourite genie!
    Dismiss Notice
  4. Travel to distant realms and encounter scenes unknown to the common folk. The Greatest of Adventures is upon us with the 8th Cinematic Contest. Join in on a fun ride.
    Dismiss Notice
  5. The 18th Icon Contest is ON! Choose any ingame unit and give him/her Hero abilities. Good luck to all.
    Dismiss Notice
  6. Contestants are to create a scene set in the Stone Age. Come and see what you can come up with. We wish you the best of luck!
    Dismiss Notice
  7. Colour outside the lines! Techtree Contest #13 is a go. The contest is optionally paired.
    Dismiss Notice
  8. Greetings cerebrates, our Swarm needs new spawners that will have numerous children. Join the HIVE's 31st Modeling Contest - Spawners and Spawned! The contest is optionally paired.
    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