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.
Error Details:
Share Link
Posts from Current questions and answers regarding the map editor.Auto-translated
1. I don't know if there's a mod for this, but it's quite easy to create. In Shared, you need to replace the animation set link with the version that includes the arena.
2. In the daytime function, an if check is needed based on the GetObjectCreatures type, and if it returns 0, then the daytime resource increase from the mine should be subtracted from the total amount.
2. Can you provide a sample script that would work automatically for any mine? For example, if you add a gold mine, the script would automatically apply its effect.
2. Can you write a sample script that works automatically for any mines? That is, if you add a gold mine, the effect is automatically applied to it.
I don't claim this is the absolute truth; there may be errors (I haven't tested it), but the prototype turned out something like this. There is also an option to disable the mine using a trigger and temporarily enable it upon interaction, but I don't know what happens first: resource generation or custom triggers. Regarding the code. The array can be created manually; it is constant, meaning it will be the same from map to map, unless the map does not contain mines of the required type, in which case the loop will execute 0 times, and this will not cause any errors. Ah yes, and you need to assign names to all the mines, but they don't necessarily have to be meaningful; you can use any names. As long as the script knows that the mine has a unique name.
minesArray = { {type = "BUILDING_SAWMILL",res = <resource ID>,dailyValue = <how much the mine produces>} ... {type = <mine type (see types.xml base tables)>,res = <resource ID>,dailyValue = <how much the mine produces>} } function checkMines() local weekMultiplier = 1; if(GetCurrentMoonWeek() == <union week ID>) then weekMultiplier = 3; end; if(GetCurrentMoonWeek() == <idleness week ID (or whatever it is)>) then weekMultiplier = 0.5; end for i,minesType in minesArray do local allMines = GetObjectNamesByType(minesType.type); for ind, mine in allMines do local owner = GetObjectOwner(mine); if(owner ~= 0) then if(GetObjectCreatures(mine,<creature ID>) < value) then local currentRes = GetPlayerResource(owner,minesType.res) SetPlayerResource(owner,minesType.res, currentRes - minesType.dailyValue * weekMultiplier); end; end; end; end; end; Trigger(NEW_DAY_TRIGGER,"checkMines");
Не уходи безропотно во тьму, Будь яростней пред ночью всех ночей, Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму Во мгле словами не зажжёшь лучей – Не уходи безропотно во тьму.
Oh, and yes. There's no need to name the mines; GetObjectNamesByType creates them all automatically.
Jewill, I asked our friend Dolgiy to write a script because I know it's not just a couple of lines, and the advice "just filter resources in a trigger for a new day" might not help someone who's not familiar with it.
Ah, and yes. You don't need to name the mines; GetObjectNamesByType creates them all without any issues.
Jewill, I asked our friend Dolgiy to write a script only because I know it's not just a couple of lines, and the advice "just select resources in the trigger for a new day" might not help someone who's not familiar with it.
Thanks for the tip about the names – I didn't know that, and I've been struggling to name objects on the map myself . Well, let Dolgiy write a script too – the person who asked the question will have a whole zoo of options to choose from! And it's true, it's definitely not just a couple of lines. Although I perfectly understand that sometimes people want to show off their knowledge, but they don't want to spend too much time on it.
Added 1 minute ago }{0TT@6bI4
Everything looks good. I can suggest a simplification: Create a table with resource coefficients based on the weeks:
multiplies={[UNION_WEEK_ID]=3, [IDLE_WEEK_ID]=0.5} weekMultiplier=multiplies[GetCurrentMoonWeek()] or 1
That's a good improvement; it's generally better to avoid these silly checks. Going back to my small comment: do you know which triggers run "first"? Nival's triggers, or custom ones?
Не уходи безропотно во тьму, Будь яростней пред ночью всех ночей, Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму Во мгле словами не зажжёшь лучей – Не уходи безропотно во тьму.
Disabling the standard operation of the mine shouldn't cancel the resource income (if the mine is captured). Otherwise, resources are definitely added before the trigger for a new day is activated.
Disabling the standard operation of the mine shouldn't prevent resource generation (if it's captured). And indeed, resources are calculated before the trigger for a new day activates.
It's a shame, although it makes sense. I just don't think these manipulations involving resource removal are the right solution. However, based on my personal experience and the experience of everyone in this thread, sometimes there isn't a correct solution, or rather, there is one, but it's not feasible. In any case, thank you; I won't waste time trying to bypass the Nival events.
Не уходи безропотно во тьму, Будь яростней пред ночью всех ночей, Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму Во мгле словами не зажжёшь лучей – Не уходи безропотно во тьму.
I don't remember being asked to write a script, but my idea is generally similar to Jewill's script. Only, I'm not much of a programmer (I don't really understand tables; 2D arrays are closer to my understanding). It should be taken into account that there are also weeks of mining 2x (wood + ore), as well as the same for Sulfur + Mercury and Crystals + Gems, the names of which I don't remember. And another week for gold.
Added 3 hours 6 minutes ago Jewill
This is sad, although logical. I just think that these manipulations with subtraction are not the right solution. Although, based on my personal experience and the experience of this entire thread, sometimes there is no right solution, or rather, there is, but it is not feasible. In any case, thank you, I won't waste time trying to bypass the Nival events.
You can also do this with a while 1 do loop. Where mines that don't pass the check for the presence of creatures become neutral.
Added 18 minutes ago
--Name all mines with the same name plus a number starting from 1 and onwards: For example, mine1, mine2, mine3, mine4, etc.
while 1 do sleep(10); for i = 1,"number of mines on the map" do --Replace "number of mines on the map" with the number if GetObjectCreatures("mine"..i,"creature ID") == 0 and GetObjectOwner("mine"..i) ~= 0 then --Replace "creature ID" with the desired creature ID SetObjectOwner("mine"..i,0); end; end; end;
Added 1 hour 2 minutes ago However, something is needed to stop the mine from becoming neutral when a hero captures it and places creatures in the garrison. Otherwise, the mine will become neutral, and you will have to fight these creatures. Something like a region around the active tile of the mine and a condition that if there is no hero in the region, then SetObjectOwner("mine"..i,0) is executed. But I think there is a better idea, but it doesn't come to mind yet.
I don't remember being asked to write a script, but my idea is generally similar to Jewill's script. Only, I'm not a very good programmer (I don't really understand tables; 2D arrays are closer to me). It should be taken into account that there are also weeks of mining 2x (wood + ore), as well as the same for Sulfur + Mercury and Crystals + Gems, the names of which I don't remember. And another week for gold.
Added 3 hours 6 minutes ago
You can also do this using a while 1 do loop. Where mines that don't pass the check for the presence of creatures become neutral.
Added 18 minutes ago
--Name all mines with the same name plus a number starting from 1 and onwards: For example, mine1, mine2, mine3, mine4, etc.
while 1 do sleep(10); for i = 1,"number of mines on the map" do --"number of mines on the map" replace with the number if GetObjectCreatures("mine"..i,"creature ID") == 0 and GetObjectOwner("mine"..i) ~= 0 then --replace "creature ID" with the desired creature ID SetObjectOwner("mine"..i,0); end; end; end;
Added 1 hour 2 minutes ago However, something is needed to stop the mine from becoming neutral when a hero captures it and places creatures in the garrison. Otherwise, the mine will become neutral, and you will have to fight these creatures. Something like a region around the active tile of the mine and a condition that if there is no hero in the region, then SetObjectOwner("mine"..i,0) is executed. But I think there is a better idea, but it doesn't come to mind yet.
Perhaps a multithreaded approach is an option, but I don't quite understand how to implement it here. Besides, for some reason, I think that any script with a dozen threads is monstrous. If the person who asked the question doesn't have knowledge of scripts, a multithreaded approach (which needs to be stopped and started at the right time) will ruin all desire to work on the map, in my opinion. In your example, it would be great to implement stopping the thread and checks based on interaction with the mine, but there is no event for completing the interaction, i.e., closing the modal window with the garrison.
Added 20 hours 7 minutes ago Hello everyone! I have repeatedly read that TalkBoxForPlayers breaks saves in Multiplayer. And just as many times I have read that it does not break them. Is there any truth to this? And if it does break them, does anyone know the approximate reason? I'm not hoping for a solution :) Because it's a great tool.
Не уходи безропотно во тьму, Будь яростней пред ночью всех ночей, Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму Во мгле словами не зажжёшь лучей – Не уходи безропотно во тьму.
Hello everyone! I've read many times that TalkBoxForPlayers corrupts save files in Multiplayer. And just as many times, I've read that it doesn't. Is there any truth to this? And if it does, does anyone know the approximate reason? I'm not really hoping for a solution Because it's a great tool.
Every time I've used TalkBoxForPlayers, I haven't had any problems. The only thing I can say is that the game version should be 3.1. The player ID is not counted as 1, 2, 3, 4, 5, 6, 7, 8, but as 1, 2, 4, 8, 16, 32, 64, 128, and the two arguments: IconTooltipRef and AddTextRef should contain only quotes without a link "", because the link text is not displayed anyway (a bug, etc.). You can see examples of TalkBoxForPlayers working stably on my map "White Temple". And yes, I advise you to edit the .lua code only in the HoMM5MapScriptsEditor program.
I just checked the map in online mode. The first time it worked normally, and the second time it crashed. Hmm
I haven't had any problems with TalkBoxForPlayers. The only thing I can say is that the game version should be 3.1. The player ID is not counted as 1, 2, 3, 4, 5, 6, 7, 8, but as 1, 2, 4, 8, 16, 32, 64, 128, and the two arguments: IconTooltipRef and AddTextRef should only contain quotes without a link "", as the link text is not displayed anyway (a bug, etc.). You can see examples of TalkBoxForPlayers working stably on my map "White Temple". And yes, I recommend editing the .lua code only in the HoMM5MapScriptsEditor program.
I just checked the map in online mode. The first time it worked normally, but the second time it crashed. Hmm.
Thank you for the clarification. I have been working with this function for some time, and there are no problems with its use, but there is a problem with the potential for corrupting saves. I am testing it in hot-seat mode (because I can't run two clients on one PC), and I haven't noticed any crashes, and the saves seem to be working fine. But I'm afraid to continue working, as if I'm sitting on a powder keg. I will take a look at your map, thank you.
Не уходи безропотно во тьму, Будь яростней пред ночью всех ночей, Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму Во мгле словами не зажжёшь лучей – Не уходи безропотно во тьму.
Dolgy, "can you write a script" – that was the request. Of course, you didn't notice.
Your version with checks is extremely inefficient in terms of execution time. It turns out that a cycle is constantly running throughout the game, and within it, another cycle runs N times per tick. At the same time, you need to strictly track the number of mines and number each one. Yes, such a script might be easier for a beginner than tables (by the way, they are still two-dimensional, in Jewill's version), but then, in the end, the user will solve everything in this brute-force way, and in more complex situations, they will reach a dead end.
Moreover, the automatic reset of the owner from the mine will occur... immediately after it is captured! Unless the player manages to quickly click on the mine and place the required garrison (and it's not easy to carry it around)... Plus, the computer will lose the ability to keep these mines under control in principle.
So, despite all due respect for your experience with Multiplayer, which still delights the eye, the script you proposed in its current form is simply not working.
Jewill, I won't definitively say that they can't cause crashes, but I haven't encountered this personally, just like Dolgy.
P.S. Since we're talking about advice, I recommend looking at how talkboxes are structured in the "Path of the Hero" map (in the talkbox.lia scripts) or in MCCS
Dolgy, "can you write a script" was the request. You clearly didn't notice.
Your version with checks is extremely inefficient in terms of execution time. It results in a constant cycle running throughout the game, with another N iterations per tick. At the same time, you need to strictly track the number of mines and number each one. Yes, such a script might be easier for a beginner than tables (by the way, they are still two-dimensional, in Jewill's version), but then the user will end up solving everything in a brute-force manner and will hit a dead end in more complex situations. Moreover, the automatic reset of the mine's owner will trigger... immediately after it is captured! Unless the player manages to quickly click on the mine and assign the desired garrison (and it's not easy to carry it around)... Plus, the computer will lose the ability to control these mines at all. So, despite all due respect for your experience with Multiplayer, which still delights the eye, the script you proposed in its current form is simply not working.
Jewill, I can't definitively say whether they can cause crashes, but I haven't encountered such a problem myself, just like Dolgy.
P.S. Since we're talking about advice, I recommend looking at how talkboxes are structured in the "Path of the Hero" map (in the talkbox.lia scripts) or in MCCS
Thank you for the advice. "Path of the Hero" has been thoroughly explored, though not completely, but quite extensively... the respected author knows his stuff. If you haven't encountered any issues, I might be tempted to use talkboxes. If I disappear, it means they are corrupting saves and I need to rewrite 1000+ lines Which I really don't want to do... P.S. And now, I'll continue my fascinating song "1000 and 1 questions to Hottabych and Co. about the fun dance of scripts in Heroes": Attention, question (let's say - for thought). There is a function called CanShowPlayer(), or something similar, it is undocumented, but it checks the possibility of showing a message window to the player. My tests have shown that the function works strangely, that is, it does not always give a clearly expected result. However, it seems that when standard modal (and not so modal) windows, such as garrison, level-up, etc., are open, it returns nil, and after the window is closed, it returns not nil. Do you think that, in combination with triggers on touching any object and a stream that checks for the player's ability to show the window, it is possible to create a trigger to close the window? That is, in the example of the script discussed above, to catch the moment when the player interacts with an object, then record x1 - the moment when showing the window became impossible (and we take the beginning of the stream in segments as the starting point), then x2 - the moment when showing the window became possible again. And accordingly, at this moment x2, we consider that the trigger has been activated - we give an event. In the case of our own window, we can also send a "signal" to this stream in the form of a name, for example, so that it performs a specific action. It's a bit of a mess, but I'm somehow not at peace with these mines... P.S. P.S.
All this song is only because, as far as I understand from the documentation, it is not possible to pass arguments through the standard callback parameter for windows (I will be happy if I am wrong again). And so, it would be possible to pass my own, which would eliminate the use of criminal arrays-buffers of data.
Не уходи безропотно во тьму, Будь яростней пред ночью всех ночей, Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму Во мгле словами не зажжёшь лучей – Не уходи безропотно во тьму.
Hello! Does anyone know how to create weather effects? For example, I would like to add rain, snowfall, or a sandstorm to the game. I saw rain on the last map in Unicorn Empire, but unfortunately, I don't know how it all works.