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

Unit Limit without using Food/Resources

Status
Not open for further replies.
Level 14
Joined
Aug 31, 2009
Messages
775
So here's the concept: I have some races that are controlled by players, but 2 races only uses gold, 2 races use only lumber and 1 race uses both.

I want to limit the amount of a specific building that these players can create, but I cannot use Food, as that is used to limit something already. Additionally, I cannot make the buildings cost 1 lumber/gold and refund on a tower death as their allied players could give them lumber/gold to make them build more towers. And no, I cannot disable ally resource transfers as there are other races who use the same resource as you, and such trading with each other can give you an advantage, and is designed as a tactical aspect of the game.

Specifically, I want the players to be only allowed to build 5 towers at any one time, but if they get destroyed, they can make a new one.

Short Version:
I want to limit the creation of a certain tower to 5 per player. You cannot use Lumber/Gold/Food as a way to limit them.

So, how could this be done?
 
Level 14
Joined
Aug 31, 2009
Messages
775
Well, that'd detect how many you have, but then how would you make it so you can't build more?

Preferably without killing the tower and refunding resources, I'd rather it simply did not allow you to build it at all, sort of like you didn't have the required research and it was greyed out.
 
Level 19
Joined
Feb 25, 2009
Messages
2,004
Use an techtree upgrade, so when a specific player reaches the maximum, set the level to 0 and make all towers to use the upgrade so they can be build. This will disallow the player to build anything, then if he destroy/sells a tower, give it the upgrade back to level 1 so he can build up something else.
 
Level 14
Joined
Aug 31, 2009
Messages
775
I thought Researches couldn't be "unresearched" by setting the level back down again, or am I mistaken? Pretty sure in the action tooltip for setting a research level it specifically says that the research cannot be undone by this action.
 
Level 5
Joined
May 3, 2009
Messages
129
somthing like this ?
  • building
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Scout Tower
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set player1 = (player1 + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • player1 Equal to 6
            • Then - Actions
              • Unit - Remove (Constructing structure) from the game
              • Set player1 = (player1 - 1)
            • Else - Actions
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Set player2 = (player2 + 1)
          • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
            • If - Conditions
              • player2 Equal to 6
            • Then - Actions
              • Unit - Remove (Constructing structure) from the game
              • Set player2 = (player2 - 1)
            • Else - Actions
        • Else - Actions
  • dead building
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Scout Tower
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 1 (Red)
        • Then - Actions
          • Set player1 = (player1 - 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Owner of (Triggering unit)) Equal to Player 2 (Blue)
        • Then - Actions
          • Set player2 = (player2 - 1)
        • Else - Actions
 
This would work perfectly actually, along with adding the resource refunding.

Is there a way that the icon for constructing the building could also be greyed out at the time when you're full on the structures?

It should work if you disable the builders build abillity. If it doesnt work, you can try to remove all the unit's buildable towers with a trigger. Then the button should be remove automatically.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

Hmm I just read this and I want give a little edit to PvSvN: You trigger works but with this its easier and faster to create:

  • Build
    • Events
      • Unit - A unit Begins construction
    • Conditions
      • (Unit-type of (Constructing structure)) Equal to Scout Tower
    • Actions
      • Set StoreTowers[(Player number of (Owner of (Constructing structure)))] = ((Player number of (Owner of (Constructing structure))) + 1)
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • StoreTowers[(Player number of (Owner of (Constructing structure)))] Equal to 6
        • Then - Actions
          • Unit - Remove (Constructing structure) from the game
          • Set StoreTowers[(Player number of (Owner of (Constructing structure)))] = ((Player number of (Owner of (Constructing structure))) - 1)
        • Else - Actions
  • Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Dying unit)) Equal to Scout Tower
    • Actions
      • Set StoreTowers[(Player number of (Owner of (Dying unit)))] = ((Player number of (Owner of (Dying unit))) - 1)
Again: your trigger works!!!! just want give a shorter form (you don't need to add so much and need only 1 variable)


1) You create a variable (in my example "StoreTowers" - (integer) and mark "Array"

2) If you use now the action "Set Variable", you choose your variable and if will look like: "Set StoreTowers[Index] = value"

3) Klick on [Index] and search in the function list for: "Player - Player Number"

4) If you got this you need to change the triggering Player into Constructing Unit"
 
Level 14
Joined
Aug 31, 2009
Messages
775
:confused:
Doesnt the action; "Limit training of unit for player" Work for buildings?
Actually, yes it does.

Though I should've mentioned that these buildings will also be upgradeable into different towers, and as such the player would be able to upgrade the towers, and then build new ones. Putting a limit on the upgraded tower would still allow say, 5 of the upgraded towers and 5 non-upgraded. Though what I want is 5 total.

Loving Dr.Boom's trigger method, very concise.

I think I'll use Dr.Boom's method, and I'll add an extra line to the tooltip + error message if you try to build >5 to make it known that 5 is the max, rather than the tooltip greying out.

Thanks for all involved +rep to those that helped.
 
Level 16
Joined
May 1, 2008
Messages
1,605
Seas =)

About the error massage: I post something for you how to get a normal leakless massage for only the constructing player.

BUT: If you can do it without help, just ignore the hidden trigger. Try it out for yourself and only if you don't get it, you can look at the hidden text.

  • Set Build_Group = (Player group((Owner of (Constructing structure))))
  • Game - Display to Build_Group for 5.00 seconds the text: You can't build more
  • Custom script: call DestroyForce(udg_Build_Group)
1) Build_Group is a PLAYER_GROUP variable.


EDIT: Mom you right - I missed something while writing this trigger: You need to use:
  • Set StoreTowers[(Player number of (Owner of (Constructing structure)))] = (StoreTowers[(Player number of (Owner of (Constructing structure)))] + 1)
  • Set StoreTowers[(Player number of (Owner of (Constructing structure)))] = (StoreTowers[(Player number of (Owner of (Constructing structure)))] - 1)
Thanks PvSvN for finding this error ;)
 
Level 14
Joined
Aug 31, 2009
Messages
775
Aye aye, I picked up on that mistake when I read through it, but I knew what you meant :wink:

And don't worry, I've got my fair share of GUI triggering under my belt, so I get how to execute the messages etc. Thanks for being so considerate though to actually give a tutorial on how to make it all.
:thumbs_up:
 
Status
Not open for further replies.
Top