Connection ErrorBad RequestThis page went staleSession ExpiredSign in requiredForbiddenNot FoundToo Many RequestsServer ErrorBad GatewayService UnavailableGateway TimeoutHTTP Version Not Supported
Session Expired
Your session has expired. Please log in to continue.
Sign in required
You need an account to do that. Sign in or create one — it only takes a minute.
This page went stale
Your security token was rejected, usually because the page sat open too long or you signed in elsewhere. Nothing was saved. Reload the page and try again.
Request Failed
We encountered an issue while processing your request.
Please check your internet connection and try again.
Help me! As soon as I create a script (a simple one, for attack animation), the map editor crashes.
Are you writing the script inside the editor? I advise you to use a separate program for this, because the editor itself crashes constantly. It's called HoMM5MapScriptsEditor.
local slot = -1; local i_count = 0; local id, count; local temp_name = NHF_tempName_F("Nemor"); local count_umertvie = GetHeroCreatures("Nemor", CREATURE_WIGHT); if count_umertvie > 0 then for i = 0,6 do id, count = GetObjectArmySlotCreature(temp_name,i); if id == CREATURE_WIGHT then slot = i; end; if count == 0 then i_count = i_count + 1; end; end; if i_count == 6 then AddHeroCreatures("Nemor", CREATURE_SKELETON , 1); sleep(); RemoveHeroCreatures("Nemor", CREATURE_WIGHT, count_umertvie); sleep(); AddHeroCreatures("Nemor", CREATURE_BANSHEE , count_umertvie,slot); sleep(); RemoveHeroCreatures("Nemor", CREATURE_SKELETON, 1); sleep(); else RemoveHeroCreatures("Nemor", CREATURE_WIGHT, count_umertvie); sleep(); AddHeroCreatures("Nemor", CREATURE_BANSHEE , count_umertvie,slot); sleep(); end; end;
In Multiplayer mode, the Wights are immediately replaced with Banshees. In Singleplayer mode, to see the change, you need to exit and re-enter the hero interface. Is it possible to fix this?
Could you please tell me how to make combat scripts work in a town? I place a script on an enemy hero – nothing happens, and the same when I place it on a town – still nothing.
function dwellings() for i, dw_type in {"FAIRIE_TREE", "WOOD_GUARD_QUARTERS", "HIGH_CABINS", "PRESERVE_MILITARY_POST"} do for j, dw in GetObjectNamesByType(dw_type) do ELF_DWLS[dw] = "off" SetObjectEnabled(dw, nil) Trigger(4, dw, "TransformDwelling") end end startThread(dwellings2) end
startThread(dwellings)
function dwellings2() while 1 do repeat sleep() until IsPlayerCurrent(1) for dwelling, state in ELF_DWLS do if state == "on" then ELF_DWLS[dwelling] = "off" SetObjectEnabled(dwelling, nil) Trigger(4, dwelling, "TransformDwelling") end end repeat sleep() until not IsPlayerCurrent(1) for dwelling, state in ELF_DWLS do if state == "off" then ELF_DWLS[dwelling] = "on" SetObjectEnabled(dwelling, 1) Trigger(4, dwelling, nil) end end end end
function TransformDwelling(hero, hut) if GetCurrentPlayer() == 1 then QuestionBox (path.."transformd.txt" , 'transformnok("'..hut..'")' ); end end
function transformnok(hut) if not (GetPlayerResource(1, CRYSTAL) >= 15 and GetPlayerResource(1,GEM) >= 10) then ShowFlyingSign(path.."nores.txt",hut,-1,10) return end SetPlayerResource(1,CRYSTAL, (GetPlayerResource(1,CRYSTAL) - 15)) SetPlayerResource(1,GEM, (GetPlayerResource(1,GEM) - 10)) PlayVisualEffect('/Effects/_(Effect)/Spells/Bless.xdb#xpointer(/Effect)', hut) sleep(5) Trigger(4, hut, nil) ELF_DWLS[hut] = nil ReplaceDwelling(hut,TOWN_HEAVEN) sleep(1) SetObjectOwner(hut,1) SetObjectEnabled(hut,true) sleep(1) return function() end end
I need to make it so that if one quest is active or incomplete, then the building upgrade is allowed, but if it's completed, then it's not. So, could you please tell me where I should add the check?
function TransformDwelling(hero, hut)
local state = GetObjectiveState('required_quest')
if GetCurrentPlayer() == 1 and (state == OBJECTIVE_ACTIVE or state == OBJECTIVE_FAILED) then
QuestionBox (path.."transformd.txt" , 'transformnok("'..hut..'")' );
end
end
```
Something like this, if I understood the conditions correctly.
function TransformDwelling(hero, hut) local state = GetObjectiveState('required_quest') if GetCurrentPlayer() == 1 and (state == OBJECTIVE_ACTIVE or state == OBJECTIVE_FAILED) then QuestionBox (path.."transformd.txt" , 'transformnok("'..hut..'")' ); end end
Something like this, if I understood the conditions correctly.
Hello. Perhaps someone can help with finding the right solution for a script: Basically, there is a specific group of creatures that need to be destroyed as part of a task. At the same time, on a specific game day, a check needs to be performed to see if they still exist, in order to indicate whether the task has been completed or not. If some of these creatures are still on the map, they should be transferred to the army of a specific hero. I know that something similar was implemented in the first mission of Frida's campaign, but unfortunately, I don't understand how it was done there.
Hello. Maybe someone can help me with the script and suggest the right solution: Basically, there is a certain group of creatures that need to be destroyed as part of a task. At the same time, on a specific game day, a check needs to be performed to see if they still exist, in order to indicate whether the task has been completed or not. And if some of these creatures are still on the map, they should be transferred to the army of a specific hero. I know that something similar was implemented in the first mission of Frida's campaign, but unfortunately, I don't understand how it was done there.
Okay, I don't know what your general knowledge of scripts is, so I'll try to explain it simply:
First, you need to assign script names to the required units in the editor and configure them so that they reliably join the heroes of the player you need (the necessary items are highlighted in the screenshot).
Then, in the script, for convenience, create a table through which the presence of units on the map will be determined:
stacks = {'script_name_of_unit_1', 'script_name_of_unit_2'... and so on
Then, use a new day trigger to check for the existence of units daily:
function NewDay() if GetDate(DAY) == 'day when the check needs to be performed' then -- then check for the existence of units and transfer them to the desired hero for i, stack in stacks do if IsObjectExists(stack) then MakeHeroInteractWithObject('Script_name_of_the_desired_hero', stack) end end end end
Okay, I don't know what your general knowledge of scripts is, so I'll try to explain it simply:
First, you need to assign script names to the desired units in the editor and configure them so that they are guaranteed to join the heroes of the player you want (the relevant items are highlighted in the screenshot).
Then, in the script, for convenience, create a table through which it will determine the presence of units on the map:
stacks = {'script_name_of_unit_1', 'script_name_of_unit_2'... and so on
Then, use a new day trigger to check daily for the existence of units:
function NewDay() if GetDate(DAY) == 'day when the check needs to be performed' then -- further check for the existence of units and transfer to the desired hero for i, stack in stacks do if IsObjectExists(stack) then MakeHeroInteractWithObject('Script_name_of_the_desired_hero', stack) end end end end
Trigger(NEW_DAY_TRIGGER, 'NewDay')
Thank you for the answer. I didn't know that it is possible to set different attitudes of a creature towards different players. I created the table of creatures shown above, but the specified creatures may be destroyed before the specified time, according to the quest, which means, as I understand it with my poor mind, I still need a function to check for the existence of these creatures in principle, in order to complete the task before the specified day
well, it's simple, you create a check thread:
```
function CheckStacks()
while 1 do
local x
for i, stack in stacks do
if IsObjectExists(stack) then
x = not nil
end
end
if not x then
SetObjectiveState('desired_quest', OBJECTIVE_COMPLETED)
break
end
if GetDate(DAY) == desired_day then
break
end
sleep()
end
end
startThread(CheckStacks)
function CheckStacks() while 1 do local x for i, stack in stacks do if IsObjectExists(stack) then x = not nil end end if not x then SetObjectiveState('desired_objective', OBJECTIVE_COMPLETED) break end if GetDate(DAY) == desired_day then break end sleep() end end