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

[Trigger] Limitations of units and buildings

Status
Not open for further replies.
Level 4
Joined
Aug 6, 2014
Messages
87
Hey, I'm curious how I make it that the option to create units/buildings is removed when they've reached their cap. Means, I want max. 15 Footmen, if the player has 15 Footmen, remove the unit-creation Icon from all buildings which can create them, if it's below 15 add the icon again.


That's how my trigger looks right now:

  • limit swordsman
    • Events
      • Unit - A unit Finishes training a unit
    • Conditions
      • (Number of units in (Units owned by (Owner of (Trained unit)) of type Swordsman)) Greater than 5
    • Actions
      • Unit - Remove (Trained unit) from the game
      • Player - Add 15 to (Owner of (Trained unit)) Current gold
      • Player - Add 90 to (Owner of (Trained unit)) Current lumber
      • Game - Display to (All players matching ((Owner of (Triggering unit)) Equal to (Matching player))) the text: You've exceeded the...
I just think I should make it in a smoother way than this "shit".
Thanks in advance
 
There's a rather convenient trigger that already exists for that:
  • Player - Limit training of Footman to 15 for TempPlayer
Here's how do apply this to all players:
  • Unit Limit
    • Events
      • Map initialization
    • Conditions
    • Actions
      • Set TempPlayerGroup = (All players)
      • Player Group - Pick every player in TempPlayerGroup and do (Actions)
        • Loop - Actions
          • Set TempPlayer = (Picked player)
          • Player - Limit training of Footman to 15 for TempPlayer
      • Custom script: call DestroyForce(udg_TempPlayerGroup)
EDIT: To anyone who has experience with player groups, do I need to do this if working with (All Players)?
 
Last edited:
Level 4
Joined
Aug 6, 2014
Messages
87
Uhm, why not just player group (All Players) ? I thought that's something which doesn't leak since it can't/won't get destroyed.
And thanks
 
Level 4
Joined
Aug 6, 2014
Messages
87
Well yeah I got it working like that, you were helpful, both of you. Thanks for that :)
And I'm sure your method is safe and works perfectly, I just don't feel like making variables if it's not needed.

Now I got a short question feeling like it's uneccesary openeing a new thread for that. Is it possible, and if so how, can I activate that when you get the gold for killing neutral hostile units also works with players? For example you kill buildings/units of a player and it grants you gold, kinda don't want to make a trigger for each unit.
 
Status
Not open for further replies.
Top