Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
Yes, you understood correctly.
And how can I make the heroname global in this situation? I mean, I need to "remember" the heroname before the talkbox, and then use it in the function specified by the talkbox? Wouldn't this affect all similar functions with the heroname?

Added 2 minutes later
Ps: Perhaps it would be better with an example, at least showing the order and which function to use, if possible...

Added 9 minutes later
Ugh, no, never mind, it was easy, I just didn't fully understand something at the beginning =)

Thank you very much, I probably wouldn't have figured it out myself =)

Added 3 hours 20 minutes later
Now, seriously:

Is it possible to create a function that, when a hero touches any object of a given type (for example, a peasant hut), removes that object from the map and replaces it with another (create dwelling, goblin huts, or something like that).

I understand that it's easier to specify it for each object, but that would be very time-consuming in this case.

Whatever
User Avatar
Auto-translated
test = GetObjectNamesByType ('PeasantHut')

I would like a little more detail.

I don't think

ObjectTouchTrigger.....(...... 'test' , 'remove')
function remove (heroname)
if heroname == 'Gottai' then
GetObjectPosition (test)
RemoveObject (test)
CreateDwelling....(...,test)
end
end

will work...

Whatever
In reply to Heroist
User Avatar
Auto-translated
`GetObjectNamesByType('PEASANT_HUT')` will return an array containing the names of all peasant huts, even if you didn't assign them names in the editor. It's better to use the `ReplaceDwelling` function to change the type of building.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Okay, but how do I write the function itself then? Should I set the touch trigger specifically to the name "test"? And should I also write "test" in the replace dwelling? Wouldn't that then convert all dwellings of that type on the map?

Whatever
In reply to Heroist
User Avatar
function start()
for i,hut in GetObjectNamesByType('PEASANT_HUT') do
SetObjectEnabled(hut, nil)
Trigger(4, hut, 'replace_hut')
end
end
startThread(start)

function replace_hut(hero, hut)
Trigger(4, hut, nil)
SetObjectEnabled(hut, 1)
ReplaceDwelling(hut, 7)
end
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
ReplaceDwelling(hut, 7) -- Is "7" the ID of the Orc dwelling, as I understand it?

Whatever
User Avatar
Auto-translated
Everything works, thanks a lot to everyone! I made a few changes, but I left the main part as it was.

Added 13 minutes later
Oh yes, I completely forgot, where do you find the exact names of these objects? Because I wrote 'ARCHERS_TOWER' and it didn't work.

Whatever
User Avatar
Auto-translated
Ah, I see. I was looking for it in the game files, but I should have used the editor. Got it, thanks.

Whatever
User Avatar
Auto-translated
Is it possible to use a script to reduce a town to level 1 buildings?

Whatever
In reply to Heroist
User Avatar
Auto-translated
Heroist
Is it possible to use a script to reduce a town's buildings to level 1?
DestroyTownBuildingToLevel(town, building, level)
In the town, the building is destroyed so that its level becomes equal to level. Well, you can figure out the loops/conditions for destruction.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
Okay, I just accidentally deleted the folder with the new features, I thought there was an easier way. I'll have to do it this way. Thanks.

Added 1 minute ago
By the way, if you use the "transform town" ability, does it not destroy the town completely?

Whatever
In reply to Heroist
User Avatar
Auto-translated
It is being destroyed. Only the Elder’s House remains, but a hero at the gate can be buried under the rubble ;).

Added 2 minutes later
Heroist
Is it possible to destroy a town down to level 1 buildings using a script?
But you only need it down to the first level.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4

Statistics

Welcome our newest member: Emil