• 🏆 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!

Hi, need help with making unit limit(shop)

Status
Not open for further replies.
Level 14
Joined
Jan 8, 2015
Messages
424
So as in title i want to make certain units being capped to certain amount, so it cant be massed, it about several units, and all of them are not trained but in shop. Is it possible to limit amount of units being bought by one player while other can buy it still from same source?
 
Level 1
Joined
Jun 13, 2008
Messages
132
How about making the shop have a "button" (an unit) that leads you to a hidden shop nearby that actually sells the units, looks professional and you can remove units if the limit is reached, easy to do, if you want it I'm making it right now.
 

Chaosy

Tutorial Reviewer
Level 40
Joined
Jun 9, 2011
Messages
13,183
There is a GUI action the limits training X number of a unit type for a player, I do not know if it works for buying as well.

A simple solution is to check if number of unit type of unit owner by player is greater than or equal to X
then just refund the gold etc with triggers, not really difficult.
  • sda
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • Set g = (Units owned by (Owner of (Buying unit)) of type (Unit-type of (Sold unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in g) Greater than or equal to 5
        • Then - Actions
          • Player - Add 150 to (Owner of (Buying unit)) Current gold
          • Neutral Building - Add (Unit-type of (Sold unit)) to (Triggering unit) with 1 in stock and a max stock of 1
        • Else - Actions
 
Level 14
Joined
Jan 8, 2015
Messages
424
There is a GUI action the limits training X number of a unit type for a player, I do not know if it works for buying as well.

A simple solution is to check if number of unit type of unit owner by player is greater than or equal to X
then just refund the gold etc with triggers, not really difficult.
  • sda
    • Events
      • Unit - A unit Sells a unit
    • Conditions
    • Actions
      • Set g = (Units owned by (Owner of (Buying unit)) of type (Unit-type of (Sold unit)))
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Number of units in g) Greater than or equal to 5
        • Then - Actions
          • Player - Add 150 to (Owner of (Buying unit)) Current gold
          • Neutral Building - Add (Unit-type of (Sold unit)) to (Triggering unit) with 1 in stock and a max stock of 1
        • Else - Actions

I have trouble finding "unit owned" in set variable. Also i have a question i need to add part which removed bought unit at end of then - Actions?
 
Level 14
Joined
Jan 8, 2015
Messages
424
Ah, yes. True you need to remove it as well. Just put it bellow the neutral building action.

g is a unit group variable, should be easy to find.

Thanks it works :)
I have some other "self-buying" building which is owned by certain player so i dont know how to adapt the trigger to that specific, tough i think standard limit and swap to training will be easier. It works on other shops i needed it, thanks :)
 
Status
Not open for further replies.
Top