• 🏆 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!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

Tiny Buildings Limits 1.0

This bundle is marked as pending. It has not been reviewed by a staff member yet.
  • Like
Reactions: FlameofChange
Motivation
Player buildings limits which can be specified with the JASS function
JASS:
constant native SetPlayerTechMaxAllowed takes player whichPlayer, integer techid, integer maximum returns nothing
when using a building ID for the parameter techid are not checked for items like "Tiny Farm" or "Ivory Tower" by default. This system adds such checks to the map as long as the user registers all ability IDs with the corresponding building types. I use this system in my map World of Warcraft Reforged since many buildings like custom gold mines, towers or unique buildings are limited in the map and have corresponding tiny items.

Usage
Use the function
JASS:
function AddTinyBuildingItem takes integer abilityId, integer buildingTypeId returns integer
to register any ability ID with the corresponding building type to prevent any constructions if the limit has already been reached.

This is an example for the Tiny Farm item:

JASS:
call AddTinyBuildingItem('AIbf', 'hhou')

Future Work

Unfortunately, it was not possible to cancel the construction event of a building and return the item to the inventory. Hence, it requires registering all item types.
However, I could extract the structure type from the ability ID by adding it to a dummy unit/item and retrieving the object data field 'Ibl1' but the field seems not available in the common.j file. I might add this feature in the future if the field will ever become available to avoid endless IDs.
Contents

Tiny Buildings Limits 1.0 (Map)

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,889
You could use a hashtable to map the ability to the build unit type using a hashtable, it will most likely be faster than looping through all the array
I think you can actually return the item charge to the inventory by "uses an item", since this event is triggered after the construction event. You'd basically register the building and associate it with the unit who built.
So if unit dies, check if has a "tiny" builder associated with, and give the charge back :)

Quite a useful system that expands on the "limit" concept from the standard way of building. If you want I can make an official review right now, but I don't think it is fair since it has this incompletion. Also, add GUI tag since you're also making support for it.
 
Level 25
Joined
Feb 2, 2006
Messages
1,689
Hm I thought about just preventing the construction event and not the ability event in the beginning but then I have to kill the building and yes return the charge. I guess it is not possible that the hero uses the item and starts the construction of a building with a human build ability before it starts the construction with the item since it is already used. Not sure what prevented me from doing it this way. Not registering anything would be much better yes.

edit:
I think that the issue might be that you are not 100% sure if the associated item is the one which helped to construct the building.

The hero might use an item which does something completely different and then construct a limited building with a unit ability which might be very unlikely but possible. The unit ability could be based on a Tiny XXX ability and would not check the limits? In this case, you would return charges to the wrong item.

Maybe I could add some "exclusion" functions for this very unlikely but possible usecase.
 
Last edited:

Wrda

Spell Reviewer
Level 26
Joined
Nov 18, 2012
Messages
1,889
edit:
I think that the issue might be that you are not 100% sure if the associated item is the one which helped to construct the building.

The hero might use an item which does something completely different and then construct a limited building with a unit ability which might be very unlikely but possible. The unit ability could be based on a Tiny XXX ability and would not check the limits? In this case, you would return charges to the wrong item.

Maybe I could add some "exclusion" functions for this very unlikely but possible usecase.
Good point. Yes I think it's safe to say that the "exclusion" functions protect the users from themselves and the game.
Implement whenever you can :)
 
Top