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

Restrict Trainable Units Based on Region/Location

Level 13
Joined
Oct 16, 2010
Messages
731
Hi,

I am starting a map where you capture multiple town hall like structures which resemble locations (each location is named and shows text above the halls with this name)

I wanted to play around with the idea of multiple tiers of units, but ideally I wanted to be able to restrict these to the locations, and also have special buildings in these areas that are linked to each of the halls

For example -
"Town Hall A" has a Barracks in it's area that can train a Footman or Knight, the Knight requires a Castle to be able to be trained
"Town Hall B" has been upgraded to a Castle - Barracks A still cannot train a Knight because "Town Hall A" hasn't been upgraded

The idea is that you would have to upgrade each of the areas if you wanted to train the more advanced units in different areas, rather than having 1 upgraded base and everything else being unlocked because of it

I have no idea where to start with this or whether it is even possible? I know I could add units with "Neutral Building" but I ideally wanted the units to trained rather than bought?
 

Remixer

Map Reviewer
Level 31
Joined
Feb 19, 2011
Messages
1,957
I don't see why restricting the availability of unit types would not work, it would only depend on the required logic to toggle the unit availability on and off, which you could base on for example on the barracks selected.
  • Player - Limit training of Footman to 1 for Player 1 (Red)
Alternatively you could just use dummy units that are gated by requirements that you code to be unlocked based on the 'Level' of the Barracks. You could even use a dummy ability to trigger the production of a unit (this would probably be the easiest approach code-wise, using the Charge Gold and Lumber ability. With the ability approach you could add and remove the available units for production on Barrack-specific basis.
 
Level 35
Joined
Feb 5, 2009
Messages
4,561
There are a couple of simpler ways to approach this, neither of which may be "ideal" but they may give you some options to play around with.

One is that upgrading Town Hall B to a Castle will use a Chaos ability or an upgrade effect on all structures within its region, turning them into new versions of the same structure with different units available. This would mean you would need to have a copy of each structure for every possible combination that exists, so depending on your techtree layout, this may not be an ideal approach. It would also make it so that selecting multiple Barracks', for example, would have them being treated as different structures.

Another approach could be to use a "set training/construction availability of unit" trigger to disable all units for each player that has techtree requirements. When techtree requirements are met within a region, you can use your own approach of identifying the structures as now meeting these requirements and enable the availability of that unit only when those structures are selected. Any time they are deselected, you would need to set training/construction availability of the unit back to the default status unless the structure you are selecting meets the requirements. For selecting multiple Barracks' structures, you would want to catch when a unit with a unique requirement has been selected for training, so that you can appropriately remove it from training in any structure that does not meet the specified requirements.

One alternative approach could be to use hiring mechanics. This would allow you to add units to the structures in a region however you wish.

Another possibility could be that the structures which train these specific units are created separately, or as a slight variation of the first approach you could have a Barracks become a "Garrison" or something to that effect, where it becomes a new structure to reflect the new availability.

Anything more advanced than these options would likely require a great deal of experimentation, but for now maybe this outlines some of the more readily available options that I can think of (somebody smarter than I might be able to come up with some better options).
 

Remixer

Map Reviewer
Level 31
Joined
Feb 19, 2011
Messages
1,957
There are a couple of simpler ways to approach this, neither of which may be "ideal" but they may give you some options to play around with.

One is that upgrading Town Hall B to a Castle will use a Chaos ability or an upgrade effect on all structures within its region, turning them into new versions of the same structure with different units available. This would mean you would need to have a copy of each structure for every possible combination that exists, so depending on your techtree layout, this may not be an ideal approach. It would also make it so that selecting multiple Barracks', for example, would have them being treated as different structures.

Another approach could be to use a "set training/construction availability of unit" trigger to disable all units for each player that has techtree requirements. When techtree requirements are met within a region, you can use your own approach of identifying the structures as now meeting these requirements and enable the availability of that unit only when those structures are selected. Any time they are deselected, you would need to set training/construction availability of the unit back to the default status unless the structure you are selecting meets the requirements. For selecting multiple Barracks' structures, you would want to catch when a unit with a unique requirement has been selected for training, so that you can appropriately remove it from training in any structure that does not meet the specified requirements.

One alternative approach could be to use hiring mechanics. This would allow you to add units to the structures in a region however you wish.

Another possibility could be that the structures which train these specific units are created separately, or as a slight variation of the first approach you could have a Barracks become a "Garrison" or something to that effect, where it becomes a new structure to reflect the new availability.

Anything more advanced than these options would likely require a great deal of experimentation, but for now maybe this outlines some of the more readily available options that I can think of (somebody smarter than I might be able to come up with some better options).
I would argue that using an ability as the trigger to initiate unit production is by far the easiest solution, since it removes the need for extra unit types or trickery with Chaos or current selections.

I don't think Chaos is a very practical approach in this scenario either, since it would require hefty amounts of variations, each with their own unit type.
 
Level 35
Joined
Feb 5, 2009
Messages
4,561
I would argue that using an ability as the trigger to initiate unit production is by far the easiest solution, since it removes the need for extra unit types or trickery with Chaos or current selections.

I don't think Chaos is a very practical approach in this scenario either, since it would require hefty amounts of variations, each with their own unit type.
Oh yeah, I forgot to mention using an ability to initiate unit production is an option. I sort of overlooked it because to my awareness there isn't a way to display food costs with it, but it might be possible with some funky exploit of the Destroyer ability? But then if food costs aren't a thing in the map (which for some maps they aren't), then there would be no downsides at all to this approach tbh.

And yeah the Chaos approach is horrendous for how many variations there would be. It is... technically an option, not one I would recommend, unless content is super light haha
 
Top