• 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.

[Trigger] Max builded.

Status
Not open for further replies.
Level 12
Joined
Mar 30, 2013
Messages
664
Greeting,

Some one knows how to allow a player to build max 5 (in my case ; Farms)
When the player have builded 5 farms he cannot build any more.
And if he should lose like 2 farms, he can build 2 more so he can get up to 5.

Hope some one can help me out. +Rep for those who helps.
 
Level 15
Joined
Oct 29, 2012
Messages
1,474
Easy, two gui trigger :
  • Finished Building
    • Events
      • Unit - A unit Finishes construction
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Constructed structure)) Equal to Farm
        • Then - Actions
          • Set FarmInteger[(Player number of (Owner of (Constructing structure)))] = (FarmInteger[(Player number of (Owner of (Constructing structure)))] + 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FarmInteger[(Player number of (Owner of (Constructing structure)))] Equal to 5
        • Then - Actions
          • Player - Make Farm Unavailable for training/construction by (Owner of (Constructing structure))
        • Else - Actions
  • Destoyed Building
    • Events
      • Unit - A unit Dies
    • Conditions
    • Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • (Unit-type of (Dying unit)) Equal to Farm
        • Then - Actions
          • Set FarmInteger[(Player number of (Owner of (Dying unit)))] = (FarmInteger[(Player number of (Owner of (Dying unit)))] - 1)
        • Else - Actions
      • If (All Conditions are True) then do (Then Actions) else do (Else Actions)
        • If - Conditions
          • FarmInteger[(Player number of (Owner of (Constructing structure)))] Less than 5
        • Then - Actions
          • Player - Make Farm Available for training/construction by (Owner of (Dying unit))
        • Else - Actions
 
Level 25
Joined
May 11, 2007
Messages
4,650
I made a map example of this for another guy asking the same question, but can't find it at the moment.

Anyhow, you need triggers and some object editing.
There's two ways of doing this.

#1 The shitty way:
Use Player - Limit training of <Insert-Building> here, should work.

#2 Other Shitty Way:
Use a trigger that detect when a building is built, check if the unit-type of the constructed building is equal to your building, then check how many of that building that exists, if they are more than 5, prevent the player from building more by using
Player - Set Training/Constructing UnAvailable for player (owner of constructed building).

Have a separate trigger that detects when units are dying, check if they are a building, check if they are the building type you have and check how many of that building you have. If less than 5, enable constructing of it.

#3 The good interface way
Create some units called "Max X allowed"
go to the building you want to have a limit of max 5, set the building requirements for that building to "Max 5 allowed", you're going to need an UNIQUE "Max X allowed" unit for each of the building types.

Building%20Limit.PNG


Then use a trigger to create the "Max 5 allowed units" for the players at map-start.

Then use a trigger that detect when a building is built, check if the unit-type of the constructed building is equal to your building, then check how many of that building that exists, if they are more than 5, remove the "Max 5 allowed" unit that is the requirement of that building.

Use a separate trigger that detects when a building is destroyed (unit - a unit is dying event), check how many buildings that the player owns, if less than 5, create 1 "Max 5 allowed" for that player.

The 3rd option is the best as the player gets a hint on why he can't build his building anymore rather than it just vanishing from the build menu suddenly.

I have the map on a separate harddrive that is in my home which I'm going back to in 15th August, if you want I can send it to you if you remember to PM me about it then.
 
Status
Not open for further replies.
Top