• 🏆 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!
  • 🏆 Hive's 6th HD Modeling Contest: Mechanical is now open! Design and model a mechanical creature, mechanized animal, a futuristic robotic being, or anything else your imagination can tinker with! 📅 Submissions close on June 30, 2024. Don't miss this opportunity to let your creativity shine! Enter now and show us your mechanical masterpiece! 🔗 Click here to enter!

[General] limit buildings with upgrades

Level 6
Joined
May 13, 2023
Messages
49
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
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,724
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:

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,724
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

  • Farm Limit 1.w3m
    18.3 KB · Views: 3

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,724
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

  • Farm Limit 2.w3m
    18.5 KB · Views: 0
Last edited:
Level 26
Joined
Sep 26, 2009
Messages
2,427
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)
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,724
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:
Level 23
Joined
Dec 3, 2020
Messages
602
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!
 
Level 4
Joined
Dec 23, 2023
Messages
47
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.
 

Uncle

Warcraft Moderator
Level 65
Joined
Aug 10, 2018
Messages
6,724
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)
 
Level 4
Joined
Dec 23, 2023
Messages
47
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:
Top