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.
function artifact_objective() while 1 do * if HasArtefact("Brem", 13) then * * SetObjectiveState("dopzadanie1", OBJECTIVE_COMPLETED); * * break * end; sleep (2); end; end;
function newday() if GetDate(DAY)==2 then MessageBox(path.."day2.txt"); sleep(5); MessageBox(path.."day2-2.txt"); end
if GetDate(DAY)==3 then MessageBox(path.."day3.txt"); end
if GetDate(DAY)==4 then MessageBox(path.."day4.txt"); end
if GetDate(DAY)==5 then MessageBox(path.."day5.txt"); SetObjectiveState("zadanie4", OBJECTIVE_ACTIVE, 1); if GetObjectOwner("ditana")==PLAYER_1 then SetObjectiveState("zadanie4", OBJECTIVE_COMPLETED, 1); TeachHeroSpell("Brem", 18); end; end
if GetDate(DAY)==6 then MessageBox(path.."day6.txt"); SetObjectiveState("dopzadanie1", OBJECTIVE_ACTIVE, 1); startThread(artifact_objective) end; end
if GetDate(DAY)==7 then MessageBox(path.."day7.txt"); end; Trigger(NEW_DAY_TRIGGER, "newday");
There is another persistent problem with the town that has the quest name "ditana": the quest to capture it appears, but nothing happens when the quest is completed. At the same time, I searched for it by name in the map itself, and the game finds such an object.
I have one large script. qwert(1, 2, and 3) are quests. Next, I defined 2 variables with the values of identifiers (monks and angels). gar_(1, 2, 3, and 4) are garrisons. Calid and Nymus are 2 demons. Next, I have a check: if the garrison belongs to player 4 (demons), then they will move to the Castle located at coordinates 41, 14. Then, if the quest qwert3 is completed, the variables that are responsible for the angel and monk identifiers will be incremented by one, and they will become upgraded creatures. Next, if the day of the week is 6 and the quest qwert1 is completed, then 15 monks should arrive in all 4 garrisons, and if the quest qwert3 is completed, they will be inquisitors, and if the quest qwert2 is completed and the day of the week is 5, then angels will arrive in the garrisons, also, if quest 3 is completed, they will be upgraded. Next, the second part of the function: If the day is 7, then a demon appears on the map, it moves towards the garrison, and also on day 14, Nymus appears, who also moves towards the garrison, but to a different one, the one closest to him. The script worked perfectly at the initial stage, but when I added the script that is at the beginning, which is responsible for the priority point of the demons, everything broke down (First, they should appear initially and run to the garrison, capture it, stand in the garrison for 1 day, and on the new day, their priority point becomes the Castle, and they run to it). I would be very grateful to anyone who can help me figure it out.
function demon()
local p1 = GetObjectiveState('qwert1', PLAYER_1);
local p = GetObjectiveState('qwert2', PLAYER_1);
local opr = 9
local opr3 = 13
local p2 = GetObjectiveState('qwert3', 1);
local ggg = GetObjectOwner('gar_1');
local ggg1 = GetObjectOwner('gar_2');
local ggg2 = GetObjectOwner('gar_3');
local ggg3 = GetObjectOwner('gar_4');
if ggg = 4 then
MoveHero('Calid', 41, 14, 0);
MoveHero('Nymus', 41, 14, 0);
elseif ggg1 = 4 then
MoveHero('Calid', 41, 14, 0);
MoveHero('Nymus', 41, 14, 0);
elseif ggg2 = 4 then
MoveHero('Calid', 41, 14, 0);
MoveHero('Nymus', 41, 14, 0);
elseif ggg3 < 4 then
MoveHero('Calid', 41, 14, 0);
MoveHero('Nymus', 41, 14, 0);
end;
end;
local p2 = GetObjectiveState('qwert3', 1);
if p2 == OBJECTIVE_COMPLETED then opr = opr + 1
if p2 == OBJECTIVE_COMPLETED then opr = opr3 + 1
if p1 == OBJECTIVE_COMPLETED and GetDate(DAY_OF_WEEK) == 6
then
AddObjectCreatures('gar_1', opr, 15);
AddObjectCreatures('gar_2', opr, 15);
AddObjectCreatures('gar_3', opr, 15);
AddObjectCreatures('gar_4', opr, 15);
elseif p == OBJECTIVE_COMPLETED and GetDate(DAY_OF_WEEK) == 5
then
AddObjectCreatures('gar_1', opr3, 3);
AddObjectCreatures('gar_2', opr3, 3);
AddObjectCreatures('gar_3', opr3, 3);
AddObjectCreatures('gar_4', opr3, 3);
elseif GetDate(0) == 7 then
DeployReserveHero('Calid', 2, 16, 0, 0);
sleep(5);
MoveHero('Calid', 7, 15, 0);
elseif GetDate(0) == 14 then
DeployReserveHero('Nymus', 5, 1, 0, 0);
sleep(5);
MoveHero('Nymus', 5, 4, 0);
Also, regarding the previous script that I asked about. In one of the Heroes 5 campaigns, in the mission for the League of Shadows, there was a quest: The player has a dragon in their army, and it must not die; if it died in any battle, the player would lose. I want to make a similar script: 4 peasants appear in my army, then I have to go with them to one place, and when I get there, they should disappear (I can do everything I wrote). But how do I make it so that after any of the battles, if they die, the quest fails?
Navkratis you have the `newday` function, then `if` statements for days two through six, then you closed the function with `end`, and then there's an `if` statement for the seventh day. Obviously, the last `if` statement should also be inside the function, not outside of it.
Navkratis You have the `newday` function, then `if` statements for days two through six, then you closed the function with `end`, and then there's an `if` statement for the seventh day. Obviously, the last `if` statement should also be inside the function, not outside of it.
Thank you very much, it helped. I added that extra `end` on day 6 for the `startThread`, but it seems it was unnecessary. Now I need to figure out the city problem, but I'll probably leave it for later, after I finish working on the scripts.
Loli Nikita,
please also check your end statements; something is clearly wrong there. Judging by the end statements, your function ends before the line:
local p2 = GetObjectiveState ('qwert3', 1);
So, what's the point of declaring all those local variables then?
Also, I'm not sure, but is it true that if you write an if statement on one line, like you do:
if p2 == OBJECTIVE_COMPLETED then opr= opr+1
then the end after that is not needed?
In any case, an end is required after the last elseif, specifically at the end of the code. This is not counting the end that closes the entire function, and it is currently in the wrong place.
As a recommendation, it is better to name variables more clearly; this will not only make it easier for us on the forum, but you will also avoid getting confused yourself. A longer name is better; you might lose a little time typing, but you will gain a lot of time when debugging.
The same goes for spaces. If it displays correctly on the forum (with the exception that the forum adds asterisks), I highly recommend following proper indentation. Otherwise, you have complete chaos, and it is clear that you will not be able to place these end statements intuitively without a detailed count.
Is it possible to set a priority for a hero so that he moves through obstacles? I simply use * MoveHero, but my hero appears behind the garrison and doesn't go to the priority target – the castle. He just stands in one place and doesn't want to move until I take the army out of the garrison, and only then does he go through it to the castle.
A garrison with an army is an impassable object for the MoveHero function; you can create a "great attractor" for the hero's companion using the SetAIHeroAttractor(sObjectName, sHeroName, nPriority) function, where priority is the priority level, ranging from -1 to 2. 0 removes the priority.
function tainiki() while 1 do * if HasArtefact("Brem", 23) and if HasArtefact("Brem", 28) and if HasArtefact("Brem", 68) then * * SetObjectiveState("dopzadanie2", OBJECTIVE_COMPLETED); * * break * end; sleep (2); end; end;
if GetDate(DAY)==8 then MessageBox(path.."day8.txt"); SetObjectiveState("dopzadanie2", OBJECTIVE_ACTIVE, 1); startThread(tainiki) end;
the MapScriptEditor program reports an unexpected character near the if statement (in the tainiki function). The condition for completing the task should be the presence of three artifacts with the hero. What is wrong here? :o
Added 5 hours 30 minutes ago However... While running the script above (i.e., on day 8), the console displays a message stating that the object dopzadanie 2 was not found and the quest is not issued.
In the task parameters, KIND_MANUAL should be set, the script name should be the same as in the script, and Is Initially Active should be set to true. Is everything set up that way for you?
The task parameters should have KIND_MANUAL, the same script name as in the script, and Is Initially Active = true. Is everything set up that way for you?
One of the guides states that "Is Initially Active - if true, the task is active at the start of the map," but I need it to activate only on the eighth day, so it's set to false. Interestingly, there's a completely identical task, dopzadanie1, which activates and completes. For dopzadanie2, I set all the items from Map Properties Free in the same way, but the result is different.
Added 30 minutes later An unexpected idea appeared about what the reason might be; I’m checking it now.
Added 17 minutes later In general, this issue is resolved; it turned out that I made a mistake in Map Properties Free with the nesting level, and dopzadanie 2 was for the second player:o For now, the task has started, and I hope its completion will also be recorded.