Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
I encountered some mysterious problem... almost mystical. In the script, I made a transformation of a town of one faction into another, and after that, I prohibited the construction of certain buildings in it. However, after the transformation, these buildings are still available for construction. Here is an example of the code:

function transformation()
  Trigger(OBJECT_CAPTURE_TRIGGER, 'town', nil);
  TransformTown('town', TOWN_NECROMANCY);
  SetTownBuildingLimitLevel('town', TOWN_BUILDING_BLACKSMITH, 0);
end;

Trigger(OBJECT_CAPTURE_TRIGGER, 'town', 'transformation');
Карты для Heroes V: Повелители орды:
Multiplayer: Господство, Извечное противостояние, Война за Магию, Торговая империя, Анатомия войны, Эксперимент
SingleScenario: Последний Рубеж, Трон, Элиралис, Вернуться домой!, Лабиринты разума
Campaign: Колонизация
In reply to KioM
Auto-translated
KioM
I encountered some kind of mysterious problem... almost mystical. In the script, I made a transformation of a town of one faction into another, and after that, I prohibited building certain structures in it. However, after the transformation, these structures are still available for construction. Here's an example of the code:

function transformation()
  Trigger(OBJECT_CAPTURE_TRIGGER, 'town', nil);
  TransformTown('town', TOWN_NECROMANCY);
  SetTownBuildingLimitLevel('town', TOWN_BUILDING_BLACKSMITH, 0);
end;

Trigger(OBJECT_CAPTURE_TRIGGER, 'town', 'transformation');
I forgot to add a sleep function after the transformation.
User Avatar
Auto-translated
...hmm, will it help? I mean, the transformation doesn't happen instantly, and I'm setting the limit in the old city. And how long should the delay be? Thank you in advance.

Added 7 minutes later
it didn't help.
Карты для Heroes V: Повелители орды:
Multiplayer: Господство, Извечное противостояние, Война за Магию, Торговая империя, Анатомия войны, Эксперимент
SingleScenario: Последний Рубеж, Трон, Элиралис, Вернуться домой!, Лабиринты разума
Campaign: Колонизация
In reply to KioM
Auto-translated
KioM
... hmm, will it help? I mean, the transformation doesn't happen instantly, and I'm setting the limit in the old city? And how long should the delay be? Thank you in advance.

Added 7 minutes later
didn't help.
I don't know, the first thing that caught my eye was the sleeps; maybe something else. 10 should be enough, I think. Did you put a sleep after the transformation? In general, it's better to try to check the castle's race (or affiliation) and only then limit the buildings. And you can also disable auto-enter (automatic hero entry into the city).
User Avatar
Auto-translated
I would have given it a 5, but after the delay, I checked the city's allegiance, and by that point, the city was already Necropolis, so it's not about the slips...
Карты для Heroes V: Повелители орды:
Multiplayer: Господство, Извечное противостояние, Война за Магию, Торговая империя, Анатомия войны, Эксперимент
SingleScenario: Последний Рубеж, Трон, Элиралис, Вернуться домой!, Лабиринты разума
Campaign: Колонизация
In reply to KioM
Auto-translated
KioM
I initially gave it a 5, but after the delay, I checked the city's allegiance, and by that point, the city was already Necropolis, so it's not about the slips...
Okay, try this: after capturing the city with the same script, exit the city, then re-enter it by clicking on it twice.
TOWN_BUILDING_BLACKSMITH - is this the market? or what?
In reply to JonnyP
Auto-translated
JonnyP
Okay, try this: use the same script, then exit the town after capturing it, and then re-enter it by clicking on it twice. Is TOWN_BUILDING_BLACKSMITH the marketplace, or what?


It's either the slave market or the trading guild (you can check the resources for a more precise answer).
In reply to antonag07
Auto-translated
antonag07
either a slave market or a trading guild (you can check the resources for a more precise answer).
I know it's possible; I asked because this building might not be available in all castles. :)
In reply to JonnyP
User Avatar
Auto-translated
JonnyP
Okay, but try this: after capturing a town, exit it, then double-click on it to enter it again.
Is TOWN_BUILDING_BLACKSMITH the marketplace, or what?
It's the blacksmith. After capturing a castle, the hero doesn't immediately teleport inside; what's the point? The castle is captured, it transforms, and the hero remains nearby. Go in, go out, it's still the same :smile39:
Карты для Heroes V: Повелители орды:
Multiplayer: Господство, Извечное противостояние, Война за Магию, Торговая империя, Анатомия войны, Эксперимент
SingleScenario: Последний Рубеж, Трон, Элиралис, Вернуться домой!, Лабиринты разума
Campaign: Колонизация
In reply to KioM
Auto-translated
KioM
smithy, so after capturing a castle, the hero doesn't immediately teleport to the castle, what's the point? The castle is captured, transforms, and the hero stands near it; go inside, go outside, it's still the same :smile39:
No, that's not it. The thing is, if he automatically goes inside, the building doesn't have time to be destroyed. On a second visit, everything is fine. I definitely made a mistake somewhere else. :)
In reply to JonnyP
User Avatar
Auto-translated
JonnyP
No, that's the thing, if it automatically logs in, the building doesn't have time to be destroyed. After logging in again, everything is fine. I'm sure of it because I did this with dwellings and a tavern. So, I must have made a mistake somewhere else. :)

It's useless, I logged out and back in. It doesn't help. There's no point, because everything is simple there, and it would be obvious if I had made a mistake.
Карты для Heroes V: Повелители орды:
Multiplayer: Господство, Извечное противостояние, Война за Магию, Торговая империя, Анатомия войны, Эксперимент
SingleScenario: Последний Рубеж, Трон, Элиралис, Вернуться домой!, Лабиринты разума
Campaign: Колонизация
Auto-translated
function capturetown(g1,g2,g3,g4) if g2==PLAYER_1 and g3=='Godric' then DestroyTownBuildingToLevel (g4,4,0,0); for i=7,13 do DestroyTownBuildingToLevel (g4,i,0,0); end; else if g2==PLAYER_1 then DestroyTownBuildingToLevel (g4,4,1,0); for i=7,13 do DestroyTownBuildingToLevel (g4,i,2,0); end; end; end; end; for i=1,6 do SetObjectEnabled ('town_'..i,not nil); Trigger (OBJECT_CAPTURE_TRIGGER,'town_'..i,'capturetown'); end; Well, something like this (found it in an old map draft :). Basically, it destroys the tavern and dwellings for the player and restores them for the AI after the town is captured. It works for all 6 towns. It seems to be working fine... I don't think I missed anything. Oh, I noticed that the function is completely different in your version :D
In reply to JonnyP
User Avatar
Auto-translated
JonnyP

Well, it was something like this (found it in an old map draft :). Basically, it destroys the tavern and dwellings for the player and restores them for the AI after capturing the town. It's designed for 6 towns. It worked fine.... I don't think I missed anything.
Oh, I noticed that the function is completely different for you :D

That's the thing, the building isn't constructed, and setting a limit on construction doesn't work... after the transformation.
Карты для Heroes V: Повелители орды:
Multiplayer: Господство, Извечное противостояние, Война за Магию, Торговая империя, Анатомия войны, Эксперимент
SingleScenario: Последний Рубеж, Трон, Элиралис, Вернуться домой!, Лабиринты разума
Campaign: Колонизация
In reply to KioM
Auto-translated
KioM
That's the thing, my building hasn't been constructed yet, and setting a limit on its construction doesn't work... after the transformation.
It doesn't really matter whether the building is constructed or not. The function sets a limit, in this case, a prohibition. If it's constructed, it destroys it.
DestroyTownBuildingToLevel - I'm talking about this function.
In reply to JonnyP
User Avatar
Auto-translated
JonnyP
It doesn't really matter if the building is constructed. The function imposes a limit, in this case, a prohibition. If it is built, it destroys it.
DestroyTownBuildingToLevel - I am talking about this function.

This function also does not work... In general, this is implemented in my map called "Throne." If you want, take a look; maybe I missed something after all. For now, I have hacked it and completely removed the ability to hire anyone in the tavern.

P.S. My main goal was to prevent taverns from being built in cities.

Throne 1.2
Карты для Heroes V: Повелители орды:
Multiplayer: Господство, Извечное противостояние, Война за Магию, Торговая империя, Анатомия войны, Эксперимент
SingleScenario: Последний Рубеж, Трон, Элиралис, Вернуться домой!, Лабиринты разума
Campaign: Колонизация

Statistics