Connection ErrorBad RequestSession 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.
Request Failed
We encountered an issue while processing your request.
Please check your internet connection and try again.
Knight of the Abyss, if you have one, please share a script guide. The last parameter of triggers is the name of the function that should be called when the trigger is activated. To clear it, you need to insert nil instead of the name: setting: Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1","Question"); deleting: Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1",nil);
A similar error exists in your first example with the message box.
Knight of the Abyss, if you have it, please refer to the script guide. The last parameter of triggers is the name of the function that should be called when the trigger is activated. To disable it, you need to insert "nil" instead of the name: setting: Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1","Question"); deleting: Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1",nil);
A similar error in your first example with the message box.
Thank you for pointing out the errors, I will take them into account. Apparently, either I wasn't reading carefully enough, or the trigger manual didn't catch my eye... I didn't know.
But in the second case, the trigger still doesn't want to be disabled; it constantly demands money when passed. I've tried everything, inserting Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1",nil); after QuestionBox, at the end of the "yes" function, and even tried creating a separate OBJECT_CAPTURE_TRIGGER so that when "gar1" is transferred to the first player, Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1",nil); would be executed along with this OBJECT_CAPTURE_TRIGGER, but nothing helps...
Added 6 minutes later Of course, there is an option to press "cancel" and calmly continue without paying, but this trigger that cannot be disabled is still very annoying...
Use the console, try simply typing this into it before entering the region: @Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1",nil); and check if the trigger activates. Perhaps some error will appear, for example, due to a typo.
Use the console, try simply typing this into it before entering the region: @Trigger(REGION_ENTER_AND_STOP_TRIGGER,"reg_1",nil); and check if the trigger activates. Perhaps some error will appear, for example, due to a typo.
Thank you very much for the advice. Strangely, neither the console nor the HOMM5 script editor reported any errors, but the reset didn't work. I placed sleep(5) after the question box and then the reset, and it started working, although I don't understand why sleep was needed there...
And one more question. How can I create a function that checks whether a player has visited a region? I don't want to write 5 different quests for 5 regions and do everything through REGION_ENTER_AND_STOP_TRIGGER. I would like to do everything through one quest... Thank you very much in advance.
-- initialization function function RegionInit() for i, region in region_table do Trigger(REGION_ENTER_AND_STOP_TRIGGER, region.name, 'RegionVisit'); end end
-- unified visit function function RegionVisit(hero) -- check which region we are in for i, region in region_table do if(IsObjectInRegion(hero, region.name)) then Trigger(REGION_ENTER_AND_STOP_TRIGGER, region.name, nil); region.visited = 1; -- here you can do what you need, depending on the region number (variable i is the number in the region_table table) end end end
-- returns true if the region with the name name has been visited function IsRegionVisited(name) for i, region in region_table do if((region.name == name) and (region.visited == 1)) then return true end end return nil end
-- initialization function function RegionInit() for i, region in region_table do Trigger(REGION_ENTER_AND_STOP_TRIGGER, region.name, 'RegionVisit'); end end
-- unified visit function function RegionVisit(hero) -- check which region we are in for i, region in region_table do if(IsObjectInRegion(hero, region.name)) then Trigger(REGION_ENTER_AND_STOP_TRIGGER, region.name, nil); region.visited = 1; -- here you can do what you need, depending on the region number (variable i is the number in the region_table table) end end end
-- returns true if the region with the name name has been visited function IsRegionVisited(name) for i, region in region_table do if((region.name == name) and (region.visited == 1)) then return true end end return nil end
I would never have come up with that myself, thank you so much!
I apologize, but what can I do, I'm just a newbie... My last question.
So, please tell me how to make it so that when all 5 regions from the table are visited, the quest to visit these regions is completed? I understand that this needs to be done using NEW_DAY_TRIGGER and startThread, but I don't have enough brainpower to figure out how to implement it all...
Jack_of_shadows Thanks!). Could you tell me how to make an event in NEW_DAY_TRIGGER happen once every two weeks? I understand how to make it happen once a week or once a month, but I think I need a formula to make it happen once every two weeks...
Hello! I'm a complete beginner and don't understand anything about scripts, so I would like to know... How can I make enemies automatically attack a town? That is, so that they don't gather resources, fight monsters, etc., but go straight to the town.
Hello! I'm a complete beginner, I don't understand anything about scripts, so I would like to know... How can I make enemies automatically attack a city? That is, so that they don't collect resources, don't fight with mobs, etc., but immediately go to the city.
Well, there are a few options.
You can paint over all the resources and mobs in the regions and prevent the computer from attacking these regions using the SetRegionBlocked script. This is time-consuming, but it guarantees 100% that it will not touch these resources, and it will have no choice but to run to the city. But there is no guarantee that it will 100% run to the city; if it is too dangerous for it, it will simply stand still or run around its territory. This is the most dubious option.
You can place a hero on the map and use EnableHeroAl and MoveHero to direct him to the city. This is a good option; the hero will not collect resources and will definitely attack the city, even if he has only 1 skeleton in his army, but it is not universal because after the hero dies, he will not attack again. This is a good option if you need to make an attack on your city at the start of the map.
You can place the hero in reserve and use NewDayTrigger, EnableHeroAl, and MoveHero to make the enemy's reserved hero attack your castle after a certain period of time (for example, attack every week). Pros: it will definitely attack the castle and will not collect resources along the way; it is a universal option; after the hero dies, the attack will be guaranteed to repeat after a certain period of time. Cons: it requires the most work.
Which option do you like best?
Added after 15 minutes RedHeavenHero
mod(GetDate(), 14) == 1
Thank you very much.
And could you also tell me:
1) Is it possible to make it so that when a hero's mana drops below 10, the player loses? (well, as if the hero is a Necromancer and needs to have 10 mana to sustain his life, otherwise he will die). There is a similar script in the campaign for Ilia, where the player loses when the black dragon is lost; maybe it is possible to do the same for a decrease in the amount of mana...
2) What script can be used to transfer all the AI's property to the player's control? For example, in the last mission for Frida, when you save Duncan, all the turquoise property is transferred to the blue. I searched through the manuals, but I didn't see anything about this. Thank you very much in advance!
function CheckMana() while GetHeroStat("hero_name", STAT_MANA_POINTS) >= 10 do sleep(5) end Loose() end
startThread(CheckMana)
2) You can see it in the map itself. It uses the functions GetObjectNamesByType and SetObjectOwner.
Added 2 hours 37 minutes ago
function change_all_owners() local types = {'BUILDING', 'TOWN', 'HERO', 'DWELLING'} for i, type in types do for j, object in GetObjectNamesByType(type) do if GetObjectOwner(object) == OLD_OWNER then SetObjectOwner(object, NEW_OWNER) end end end end
Knight of the Abyss,
In general, the third option seems to be the best, but I don't really understand scripts; I only started working with them a few days ago. The only thing I can do is create a script with the player's starting capital... So, could you write out exactly what the script would look like? I would be very grateful...
And also, here's another thing... If a hero (even an enemy hero) is without a castle, the player loses after a week. Is there a way to remove this function? So that there wouldn't be a mission like "Capture any town within a week."
And how do I make the AI attack on day 2, 3, 4, etc.? That is, not immediately.