Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
#1109
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
#1110
GetObjectNamesByType( sObjectTypeSubstr ) в помощь.
 

К А
Стикеры GBF в Telegram
User Avatar
#1111
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
#1112
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
#1113
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
#1114
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
#1115
Auto-translated
ReplaceDwelling(hut, 7) -- Is "7" the ID of the Orc dwelling, as I understand it?

Whatever
In reply to Heroist
User Avatar
#1116
Auto-translated
Heroist
ReplaceDwelling(hut, 7) -- "7" is the dwelling ID for Orcs, is that correct?
Yes.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
#1117
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
#1119
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
#1120
Auto-translated
Is it possible to use a script to reduce a town to level 1 buildings?

Whatever
In reply to Heroist
User Avatar
#1121
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
#1122
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
#1123
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