Posts from Scripts for beginners.
Auto-translated
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.
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?
The archiver opens it... but where should I look?
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.
I have a question: is it possible to configure the AI to follow a specific order when exploring locations on this map?
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.
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.
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.
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.
P.S. Yes, that script worked as I described.
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 - список заклинаний и их уровень в описании существ-колдунов
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.