• Check out the results of the Techtree Contest #19!
  • 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.
  • Create a void inspired texture for Warcraft 3 and enter Hive's 34th Texturing Contest: Void! Click here to enter!
  • The Hive's 22nd Icon Contest: Creep Abilities is now concluded, time to vote for your favourite set of icons! Click here to vote!

[General] limit buildings with upgrades

Status
Not open for further replies.
Level 8
Joined
May 13, 2023
Messages
111
Hi hive, I have a farm building in which i want to limit per player, of course i can use this
  • Player Group - Pick every player in Players and do (Actions)
    • Loop - Actions
      • Player - Limit training of Farm to 6 for (Picked player)
But the Farm has an Upgrade so when the Farm upgrades the Player can still build more initial Farm building leading to more than 6 Farms
 
Not sure of an easy solution, but you could try adjusting this Limit value in response to a Farm upgrading and in response to an upgraded Farm dying. So when you upgrade a Farm you Limit Farms to 5 for the owner and continue subtracting from this value for each new upgraded Farm. When an upgraded Farm dies, you do the opposite and increase the Limit value. You can track the Farms using an Integer array.
 
Last edited:
Well I did think of this solution but couldn't get my head around it.
Sucks there isn't any easy way
Thanks for the Reply
Turns out it's still really easy:
  • Begin Farm Upg
    • Events
      • Unit - A unit Begins an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Super Farm
    • Actions
      • Set VariableSet Farm_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Farm_Limit[Farm_PN] = (Farm_Limit[Farm_PN] - 1)
      • Player - Limit training of Farm to Farm_Limit[Farm_PN] for (Player(Farm_PN))
  • Cancel Farm Upg
    • Events
      • Unit - A unit Cancels an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Farm
    • Actions
      • Set VariableSet Farm_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Farm_Limit[Farm_PN] = (Farm_Limit[Farm_PN] + 1)
      • Player - Limit training of Farm to Farm_Limit[Farm_PN] for (Player(Farm_PN))
  • Farm Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Super Farm
    • Actions
      • Set VariableSet Farm_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Farm_Limit[Farm_PN] = (Farm_Limit[Farm_PN] + 1)
      • Player - Limit training of Farm to Farm_Limit[Farm_PN] for (Player(Farm_PN))
Farm_PN = Integer
Farm_Limit = Integer (ARRAY)

Set Farm_Limits Initial Value to 6 inside of the Variable Editor (Control + B). Do NOT try to change this value outside of the variable menu, it's bugged and will reset.

I set it to 3 in my demo map to make things easy to manage.
 

Attachments

Thank You Uncle for the Solution
1 small notice was that initially the triggers didn't work but when I changed the Unit-Type of Upgrade Trigger to normal Farm not the Upgraded Farm it worked
That sounds wrong. I tested it again and everything works the way I originally had it.

I think the only issue is that I never set the initial limit to 3:
  • Farm Setup
    • Events
      • Time - Elapsed game time is 0.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet Farm_PN = (Player number of (Picked player))
          • Set VariableSet Farm_Limit[Farm_PN] = 3
          • Player - Limit training of Farm to Farm_Limit[Farm_PN] for (Picked player)
I saw you had already done this in your map and forgot to do it in my own.
 

Attachments

Last edited:
This can be achieved without triggers.
If you have a 'Farm' and 'Upgraded Farm' buildings, go to object editor, find the 'Farm' building and add to its 'Techtree - Dependency Equivalents' the 'Upgraded Farm' unit.
Then your original action will work:
  • Player Group - Pick every player in Players and do (Actions)
    • Loop - Actions
      • Player - Limit training of Farm to 6 for (Picked player)
 
This can be achieved without triggers.
If you have a 'Farm' and 'Upgraded Farm' buildings, go to object editor, find the 'Farm' building and add to its 'Techtree - Dependency Equivalents' the 'Upgraded Farm' unit.
Then your original action will work:
  • Player Group - Pick every player in Players and do (Actions)
    • Loop - Actions
      • Player - Limit training of Farm to 6 for (Picked player)
Whoops... You know, a little voice in my head whispered "Dependencies" before I made my first post. But I was unsure... lol. My overcomplicated way is more fun anyway :p
 
Last edited:
This can be achieved without triggers.
If you have a 'Farm' and 'Upgraded Farm' buildings, go to object editor, find the 'Farm' building and add to its 'Techtree - Dependency Equivalents' the 'Upgraded Farm' unit.
Then your original action will work:
  • Player Group - Pick every player in Players and do (Actions)
    • Loop - Actions
      • Player - Limit training of Farm to 6 for (Picked player)
Man this is hella useful! Thank you so much!
 
Turns out it's still really easy:
  • Begin Farm Upg
    • Events
      • Unit - A unit Begins an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Super Farm
    • Actions
      • Set VariableSet Farm_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Farm_Limit[Farm_PN] = (Farm_Limit[Farm_PN] - 1)
      • Player - Limit training of Farm to Farm_Limit[Farm_PN] for (Player(Farm_PN))
  • Cancel Farm Upg
    • Events
      • Unit - A unit Cancels an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Farm
    • Actions
      • Set VariableSet Farm_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Farm_Limit[Farm_PN] = (Farm_Limit[Farm_PN] + 1)
      • Player - Limit training of Farm to Farm_Limit[Farm_PN] for (Player(Farm_PN))
  • Farm Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Super Farm
    • Actions
      • Set VariableSet Farm_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Farm_Limit[Farm_PN] = (Farm_Limit[Farm_PN] + 1)
      • Player - Limit training of Farm to Farm_Limit[Farm_PN] for (Player(Farm_PN))
Farm_PN = Integer
Farm_Limit = Integer (ARRAY)

Set Farm_Limits Initial Value to 6 inside of the Variable Editor (Control + B). Do NOT try to change this value outside of the variable menu, it's bugged and will reset.

I set it to 3 in my demo map to make things easy to manage.
Hello I try to use this for my own map to, where I want the limit to be 2 for each Turret type. I tried to do it but it still don't work.

These are the triggers I currently have for it:
Variables:
Rapidfire_PN - Integer
Rapidfire_Limit - Integer (Array)
  • Beginn RF Upg
    • Events
      • Unit - A unit Begins an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Rapidfire |cff00ffff[Rang 1 | Level 1]|r
    • Actions
      • Player Group - Pick every player in (All allies of Player 12 (Brown).) and do (Actions)
        • Loop - Actions
          • Set VariableSet Rapidfire_PN = (Player number of (Owner of (Triggering unit)))
          • Set VariableSet Rapidfire_Limit[Rapidfire_PN] = (Rapidfire_Limit[Rapidfire_PN] - 1)
          • Player - Limit training of Rapidfire |cff00ffff[Rang 1 | Level 1]|r to Rapidfire_Limit[Rapidfire_PN] for (Player(Rapidfire_PN))
  • Cancel RF Upg
    • Events
      • Unit - A unit Cancels an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Rapidfire |cff00ffff[Rang 1 | Level 1]|r
    • Actions
      • Player Group - Pick every player in (All allies of Player 12 (Brown).) and do (Actions)
        • Loop - Actions
          • Set VariableSet Rapidfire_PN = (Player number of (Owner of (Triggering unit)))
          • Set VariableSet Rapidfire_Limit[Rapidfire_PN] = (Rapidfire_Limit[Rapidfire_PN] + 1)
          • Player - Limit training of Rapidfire |cff00ffff[Rang 1 | Level 1]|r to Rapidfire_Limit[Rapidfire_PN] for (Player(Rapidfire_PN))
  • Farm dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Rapidfire |cff00ffff[Rang 1 | Level 2]|r
    • Actions
      • Player Group - Pick every player in (All allies of Player 12 (Brown).) and do (Actions)
        • Loop - Actions
          • Set VariableSet Rapidfire_PN = (Player number of (Owner of (Triggering unit)))
          • Set VariableSet Rapidfire_Limit[Rapidfire_PN] = (Rapidfire_Limit[Rapidfire_PN] + 1)
          • Player - Limit training of Rapidfire |cff00ffff[Rang 1 | Level 1]|r to Rapidfire_Limit[Rapidfire_PN] for (Player(Rapidfire_PN))
  • Set Tower Variables
    • Events
      • Time - Elapsed game time is 1.00 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet Rapidfire_PN = (Player number of (Picked player))
          • Set VariableSet Rapidfire_Limit[Rapidfire_PN] = 2
          • Player - Limit training of Rapidfire |cff00ffff[Rang 1 | Level 1]|r to Rapidfire_Limit[Rapidfire_PN] for (Picked player)
What am I missing? If I upgrade one of them to Level 2, I can build anotherone.
 
Does the dependency solution that Nichilus suggested not work? It's a much easier fix.

Anyway, your triggers aren't really the same as mine. Why are you using a Player Group to limit them for everyone? Don't you want to limit it to 2 per Player?
  • RF Begin Upg
    • Events
      • Unit - A unit Begins an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Rapidfire |cff00ffff[Rang 1 | Level 2]|r
    • Actions
      • Set VariableSet Rapidfire_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Rapidfire_Limit[Rapidfire_PN] = (Rapidfire_Limit[Rapidfire_PN] + 1)
      • Player - Limit training of Rapidfire |cff00ffff[Rang 1 | Level 1]|r to Rapidfire_Limit[Rapidfire_PN] for (Player(Rapidfire_PN))
  • RF Cancel Upg
    • Events
      • Unit - A unit Cancels an upgrade
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Rapidfire |cff00ffff[Rang 1 | Level 1]|r
    • Actions
      • Set VariableSet Rapidfire_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Rapidfire_Limit[Rapidfire_PN] = (Rapidfire_Limit[Rapidfire_PN] - 1)
      • Player - Limit training of Rapidfire |cff00ffff[Rang 1 | Level 1]|r to Rapidfire_Limit[Rapidfire_PN] for (Player(Rapidfire_PN))
  • RF Dies
    • Events
      • Unit - A unit Dies
    • Conditions
      • (Unit-type of (Triggering unit)) Equal to Rapidfire |cff00ffff[Rang 1 | Level 2]|r
    • Actions
      • Set VariableSet Rapidfire_PN = (Player number of (Owner of (Triggering unit)))
      • Set VariableSet Rapidfire_Limit[Rapidfire_PN] = (Rapidfire_Limit[Rapidfire_PN] + 1)
      • Player - Limit training of Rapidfire |cff00ffff[Rang 1 | Level 1]|r to Rapidfire_Limit[Rapidfire_PN] for (Player(Rapidfire_PN))
  • RF Setup
    • Events
      • Time - Elapsed game time is 0.01 seconds
    • Conditions
    • Actions
      • Player Group - Pick every player in (All players) and do (Actions)
        • Loop - Actions
          • Set VariableSet Rapidfire_PN = (Player number of (Picked player))
          • Set VariableSet Rapidfire_Limit[Rapidfire_PN] = 2
          • Player - Limit training of Rapidfire |cff00ffff[Rang 1 | Level 1]|r to Rapidfire_Limit[Rapidfire_PN] for (Picked player)
 
Why are you using a Player Group to limit them for everyone?
Misunderstanding of how it works. I thought I need to, to make it work for more than 1 Player.

OK I changed it to look like the ones you shown above my post now.

Does the dependency solution that Nichilus suggested not work?
I had no idea what it meant, but now I understood and yes it seem to work right now.

Do I still need the "RG beginn", "RF cancel" and "RF dies", RF Setup" Trigger? Or can I remove them?
If I can only remove the RF Setup, which i think because it worked without it (xD), I think I need to set it up for all the others, correct?

EDIT: Sorry I always forget I can easaly disable the trigger to test something like this, and OMG it seems like I really don't need them.
Thank you very much.
 
Last edited:
Status
Not open for further replies.
Back
Top