Skip to content

Scripts for beginners.

User Avatar
#191
Auto-translated
zahar0z, you can implement a check, for example, in a trigger for a new day. You need to check all possible dwellings, count how many have been built, and when the condition is met, prohibit the construction of those that haven't been built. Here's a description of suitable functions from the Novice's Manual (I haven't personally tested them):
nLevel GetTownBuildingLevel( sTownName, nBuildingID )
nLevel GetTownBuildingLimitLevel( sTownName, nBuildingID )
nLevel GetTownBuildingMaxLevel( sTownName, nBuildingID )

These functions allow you to find out the level/development limit/maximum level of building nBuildingID in a town with the name sTownName. The corresponding TOWN_BUILDING_* constants for nBuildingID can be found in /scripts/advmap-startup.lua. I won't list them here due to their large number.
Level 0 means that the corresponding building is absent.

void SetTownBuildingLimitLevel( sTownName, nBuildingID, nLevel )

This function allows you to set a limit on the development level of building nBuildingID in a town with the name sTownName. Attempting to set a level higher than the maximum possible will cause an error. Level 0 means prohibiting the construction of the building.
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо