• Listen to a special audio message from Bill Roper to the Hive Workshop community (Bill is a former Vice President of Blizzard Entertainment, Producer, Designer, Musician, Voice Actor) 🔗Click here to hear his message!
  • Read Evilhog's interview with Gregory Alper, the original composer of the music for WarCraft: Orcs & Humans 🔗Click here to read the full interview.
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!
  • ✅ The POLL for Hive's Texturing Contest #34 is OPEN! Vote for the TOP 3 SKINS! 🔗Click here to cast your vote!
  • ✅ The POLL for Hive's Techtree Contest #20 is OPEN! Vote for the TOP 3 FACTIONS! 🔗Click here to cast your vote!

Is there a trigger to buy units from shops?

Status
Not open for further replies.
So let's say you have a Troll in there that costs 50 gold.

  • Buy Unit
    • Events
      • Unit - A unit comes within 350.00 of Ziggurat 0002 <gen>
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • ((Owner of (Triggering unit)) Current gold) Greater than 50
        • Then - Actions
          • Player - Add -50 to (Owner of (Triggering unit)) Current gold
          • Unit - Create 1 Footman for (Owner of (Triggering unit)) at (Position of Ziggurat 0002 <gen>) facing Default building facing (270.0) degrees
        • Else - Actions
Pretty simple though. If you have more units in the Merchant, wich is pretty likely, you should put a delay on lower prices (a wait action just before the If, Then, Else action).
Example:
2000 - no delay
1500 - wait 0.1 seconds
1350 - wait 0.2 seconds
1000 - wait 0.3 seconds
500 - wait 0.4 seconds
200 - wait 0.5 seconds
100 - wait 0.6 seconds
50 - wait 0.7 seconds

These prices are just examples. What I want to show you is that the lower the price gets, the higher delay you make before buying it. If you do that the AI will only buy the most expensive unit he... it can aford. Lets say it has 2010 gold, then it will buy the 2000 gold unit and nothing more cause it's out of gold. If it has 1560 gold, it will buy the 1500 gold unit and then the 50 gold unit.
 
Well you'll have to add a condition that causes only the AI units to buy from the shop. You can buy whatever you want but the AI's are restricted to the trigger functions.
Add all AI controlled units to a unit group (variable), and then make the following condition:

Boolean - Unit is in Unit Group Equal to True

Then only the AI units will buy from the shop.
 
Status
Not open for further replies.
Back
Top