Skip to content

Posts from Scripts for beginners. Auto-translated

4.5 (2 ratings)
In reply to Bendy
#166
Auto-translated
Regarding the burning effect, you can see it in the 2nd mission of the "Awakening of Evil" campaign. As for Korovin, I think it's done through a trigger, but I'm not sure, so you can learn how to do it yourself in the Nival manual or look at the "2 Sisters" scenario, and you can also browse the scripting section, as it was discussed there.
In reply to Годрикова впадина
#167
Auto-translated
There's a question about scripts.
I wrote a map a while ago, I don't remember which version of the game it was for, it's similar to 3.0.
And I don't remember which mod I used.
I spent a long time working on the script.
Now I decided to write a map for another Heroes game.
I can't open the map.
Please give me some advice or assistance.
User Avatar
#168
Auto-translated
JORAJAN, is the map file definitely working? Is its size not 22 bytes? Does it open with an archiver and show the directories inside? Does the editor open other maps?
In reply to Jack_of_shadows
#169
Auto-translated
Jack_of_shadows
JORAJAN, is the map file definitely working? Is its size not 22 bytes? Does it open with an archiver and show the directories inside? Does the editor open other maps?
Kara is playing, but the maps don't open in the editors; I've tried a lot of them.
The archiver opens it... but where should I look?
User Avatar
#170
Auto-translated
Upload the map here as an option, and I can check if it opens for me. I've never heard of this problem before.
In reply to Jack_of_shadows
#171
Auto-translated
Jack_of_shadows
Please upload the map here as an option, and I can check if it opens for me. I've never heard of this problem before.

Thanks everyone, I found the problem – it was due to the mess on the disks.
In reply to JORAJAN
#172
Auto-translated
created a map for 8 players or AI opponents... noticed that the AI plays somewhat awkwardly; one AI immediately sends its units running straight to the opponent, bypassing mines and dwellings, and even empty cities, to capture them because the opponent barely moves around before being defeated...
I have a question: is it possible to configure the AI to follow a specific order when exploring locations on this map?
User Avatar
#173
Auto-translated
By the way, the same question... well, slightly different.

The AI takes a town with the highest priority, then it should take another one, also with the highest priority, but it just stays in the first one... even though the priority has been removed from the first town.
Карты для героев 5

"Плата за любовь"
"Путь некроманта"
"Темные грани"
"Рок Гримхейма"
In reply to AstralLein
User Avatar
#174
Auto-translated
Hello everyone.

Does anyone know if there's a script that allows you to change the creatures available for recruitment at outposts during gameplay? I'm talking about the dwellings of creatures of levels 4-7 that are located on the map. In the map editor, when you place such a dwelling, you can specify in its properties which creature of levels 4-7 will be available for recruitment. Is there a command to do the same thing with a script during the game? For example, druids are recruited in a dwelling, and after the script runs, druids are no longer recruited, but dragons are recruited instead.

Or, at least, is there a command that controls the number of recruited creatures? Something similar to "SetObjectDwellingCreatures," but for a dwelling located outside the city. Maybe I'm using "SetObjectDwellingCreatures" incorrectly? I'm using it like this: "SetObjectDwellingCreatures( "altdwell", CREATURE_BLADE_JUGGLER, 50 );"
It works fine for cities, but when I try to apply it to an "outdoor" dwelling, the script gives an error, something like "altdwell" is not a town object.

Thank you in advance if anyone can share some helpful information.
User Avatar
#175
Auto-translated
zahar0z, there is an option to replace a dwelling with another using:
ReplaceDwelling(SCRIPT_NAME, TOWN_ID, CREATURE_1, CREATURE_2, CREATURE_3, CREATURE_4)
The maximum number of creatures that can be in the new dwelling is equal to the number of creatures that were available in the original dwelling. You can place any creatures, regardless of the dwelling type.
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо
In reply to Jack_of_shadows
User Avatar
#176
Auto-translated
Thank you, that helped. I didn't know that this command could be used to place creatures without tying them to a Faction.

Added 2 hours 42 minutes ago
Asking for advice again.

I wrote this script:
function activatorF ()
s_dwe_fa=GetObjectNamesByType("BUILDING_FAIRIE_TREE");
ReplaceDwelling(s_dwe_fa[0], TOWN_PRESERVE, 991 );
Trigger(OBJECT_TOUCH_TRIGGER, "activator", nil );
end;

Trigger(OBJECT_TOUCH_TRIGGER, "activator", "activatorF" );

SetObjectEnabled("activator", nil);

The script replaces the creatures available for recruitment in the first object found with the type "BUILDING_FAIRIE_TREE" with the 991st creature. This is done when touching "activator", but that's just a minor detail and purely for testing.

The question is, how can I make the script replace not only the first, but all found objects of this type? Another nuance is that the script should be universal and work on different maps, so the number of such objects is not only unknown, but can also be different.

And immediately a second question, for clarification, purely theoretically, is it possible to write such a script and put it somewhere in a root script file or something like that, so that it runs automatically on all maps?

Thank you in advance for your help.
User Avatar
#177
Auto-translated
zahar0z, does your script work? I suspect it might be related to `s_dwe_fa[0]`, because if you don't specify the indices manually, the tables here are indexed starting from 1 by default. To make it work for all buildings, simply iterate through all of them using a loop: ```lua s_dwe_fa=GetObjectNamesByType("BUILDING_FAIRIE_TREE"); for i, dwe in s_dwe_fa do ReplaceDwelling(dwe, TOWN_PRESERVE, 991 ); end ``` To make it work on all maps, you probably need to edit some script from data.pak/scripts/: advmap-startup.lua or advmap-common.lua or common.lua.
РПГ-сценарий для HoMM5: Путь героя
ЧаВо по созданию карт для HoMM5: ЧаВо
In reply to Jack_of_shadows
User Avatar
#178
Auto-translated
Thank you again for your help; it worked both with the loop and with advmap-common.lua.

P.S. Yes, that script worked as I described.
User Avatar
#179
Auto-translated
Some people are so lucky.
For me, the scripts don't work at all, even though I enter them correctly. (I'm using the HoMM5 MapScriptEditor program)

Added 1 minute ago
I came across an FAQ. Maybe it will help me

Added 16 hours ago
A miracle!
Firstly, the script editor opened in the map editor and didn't crash (!).
Secondly, the scripts themselves started working. It seems I was making a mistake somewhere.
Справедливость - авторский глобальный мод

ColouredText - список заклинаний и их уровень в описании существ-колдунов
In reply to Андраил
User Avatar
#180
Auto-translated
Hello everyone, and once again, I have some questions.

I wrote the following:
function capt_alt_dw (prevowner, newowner, hero, dwell)
alt_dw_x, alt_dw_y, alt_dw_fl = GetObjectPosition(dwell);
QuestionBox("text with a question, blah blah blah", "add_alt_dw", nil);
end;

function add_alt_dw()
for i, pix_dw in allpix_dw do
pix_dw_x, pix_dw_y, pix_dw_fl = GetObjectPosition(pix_dw);
if pix_dw_x == alt_dw_x and
pix_dw_y == alt_dw_y and
pix_dw_fl == alt_dw_fl then
sleep(1);
ReplaceDwelling(pix_dw, TOWN_ACADEMY, 991);
end;
end;
end;

allpix_dw = GetObjectNamesByType("BUILDING_FAIRIE_TREE");
for i, pix_dw in allpix_dw do
Trigger(OBJECT_CAPTURE_TRIGGER, pix_dw, "capt_alt_dw");
end;

Now, when capturing any Fairy dwelling on the map, a question appears. If the answer is positive, the building is rebuilt into an alternative dwelling with creature ID 991.

The problem was that the QuestionBox command refers to a new function, in which the "dwell" value from the "capt_alt_dw" function is lost, so the game cannot determine which dwelling to rebuild at that moment. I have temporarily solved this by comparing the object locations, but perhaps there is a more adequate and simpler way to do this?

And the main question is, why doesn't this script work on the original Multiplayer maps in Multiplayer mode? The script execution is specified in advmap-startup.lua. On the same original Multiplayer maps, in Single mode, the script works. It also works on a test Multiplayer map that I created, but for this, it needs to be specified directly in the map. But on the original maps in Multiplayer, it doesn't work at all. Does anyone know what the reason is and how to fix it?

In addition, there is another small bug: when a hero captures a dwelling, the recruitment window immediately pops up, and the question about rebuilding appears only after the hero exits this window. Thus, in the case of rebuilding, the hero has the opportunity to recruit units from both the original and the alternative building, and he actually does.
Is there anyone who has ideas on how to solve this problem? "Disabling" the buildings until the player touches them is also not an option, because in this case, the AI ignores these buildings.

And one more question (probably even more newbie than the others, please forgive me), do all these scripts heavily load the game? And does this depend on the length of the assigned values, i.e., should I make the assigned names as short as possible, or does this not matter at all?

As always, thank you in advance for your help.