• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

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

Status
Not open for further replies.
Level 4
Joined
Oct 28, 2007
Messages
72
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....
 
Level 7
Joined
Jun 4, 2006
Messages
127
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 ^_^...
 
Level 4
Joined
Oct 28, 2007
Messages
72
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 .
 
Status
Not open for further replies.
Top