Skip to content

Posts from Scripts for beginners.

4.5 (2 ratings)
User Avatar
#211
Auto-translated
A. Well, it seems that point number 3 did have an effect. I'm afraid I'll have to make the script more complex – the gaz task should be placed in the objectives tab, as a general task, but initially invisible. It should be triggered by OBJECT_TOUCH_TRIGGER with a house, and the house should have its standard functions disabled (first, display a message, then – the task).
But first, I need to check – if I set gaz as a general and accessible task from the very beginning, will it work?
 

К А
Стикеры GBF в Telegram
#212
Auto-translated
Hello everyone. A simple question about MessageBox. Where should I put the text file?
User Avatar
#213
Auto-translated
Somewhere in the archive with the map. The path to the text file in the map archive is the same path you write in the scripts. Usually, it is placed where map.xdb, terrain.bin, and other files related to that specific map are located.
 

К А
Стикеры GBF в Telegram
#214
Auto-translated
I'm just being slow and can't find the archive. In my Maps directory, there's just the map itself.
User Avatar
#215
Auto-translated
That's exactly what it is. When the map editor starts, this archive (which is actually a zip file, even if it's labeled differently) is unpacked. After closing the editor, all changes are packed back into it.
 

К А
Стикеры GBF в Telegram
#216
Auto-translated
So, when I open a map in the editor, do I need to put the text file into the Maps directory?
User Avatar
#217
Auto-translated
No, there's some other directory... I don't remember exactly, something like Editor -> H5mMods -> the folder with the map's name. But to avoid messing things up, it's better to close the editor and open the map archive using WinRAR. And put it there.
 

К А
Стикеры GBF в Telegram
#218
Auto-translated
Hello, I'm back to working on the game. I still haven't figured out how MessageBox works. Also, it won't open the zip file. Could you provide a couple of screenshots or explain everything step by step again?
User Avatar
#219
Auto-translated
You are opening a file with the .h5m extension, right?
 

К А
Стикеры GBF в Telegram
#220
Auto-translated
Yes, I'm trying to extract the contents of map_name.h5m. But it just won't work. Could you describe another method in more detail?
User Avatar
#221
Auto-translated
Hello, could you please give me some advice? I have a building on the map where I want to recruit troops using script functions. How can I make these functions execute sequentially, without interrupting each other? According to the Manuals, there should be an if condition in the second function, but what should it be? Here are the functions: --Start-- --Naim1-- function Naim1(hero) Naim1_hero = hero MessageBox("/Maps/SingleMissions/Time of Troubles1/Naim1MB.txt") QuestionBox("/Maps/SingleMissions/Time of Troubles1/Naim1QB.txt", "Naim1_ok"); end function Naim1_ok() local gold = GetPlayerResource(PLAYER_1, GOLD) if gold >= 3000 then Trigger(OBJECT_TOUCH_TRIGGER, "Tavern", nil) SetPlayerResource(PLAYER_1, GOLD, gold - 3000) AddHeroCreatures(Naim1_hero, 4, 30) else MessageBox("/Maps/SingleMissions/Time of Troubles1/Naim2MB.txt") end end Trigger(OBJECT_TOUCH_TRIGGER, "Tavern", "Naim1") --Naim2-- function Naim2(hero) Naim2_hero = hero MessageBox("/Maps/SingleMissions/Time of Troubles1/Naim3MB.txt") QuestionBox("/Maps/SingleMissions/Time of Troubles1/Naim2QB.txt", "Naim2_ok"); end function Naim2_ok() local gold = GetPlayerResource(PLAYER_1, GOLD) if gold >= 7000 then Trigger(OBJECT_TOUCH_TRIGGER, "Tavern", nil) SetPlayerResource(PLAYER_1, GOLD, gold - 7000) AddHeroCreatures(Naim1_hero, 11, 3) else MessageBox("/Maps/SingleMissions/Time of Troubles1/Naim4MB.txt") end end Trigger(OBJECT_TOUCH_TRIGGER, "Tavern", "Naim2") --End--
In reply to Vladislav A-V
User Avatar
#222
Auto-translated
If you need the second function to execute only after the first creatures have been hired, you can replace "nil" with "Naim2" in the trigger under the condition "if gold >= 3000 then". This is how it would look:

...
if gold >= 3000 then
Trigger(OBJECT_TOUCH_TRIGGER, "Tavern", "Naim2")
SetPlayerResource(PLAYER_1, GOLD, gold - 3000)
AddHeroCreatures(Naim1_hero, 4, 30)
else ...
And remove Trigger(OBJECT_TOUCH_TRIGGER, "Tavern", "Naim2") at the very end.
In this case, the trigger for "Naim1" will be activated at the beginning, and after hiring, it will be replaced with "Naim2", and after hiring the second set of creatures, it will be reset.
User Avatar
#223
Auto-translated
Thank you very much, it helped. Could you please give me another piece of advice? How can I implement the following idea: initially, a certain building cannot be constructed in a town, but it can be unlocked and upgraded by completing a side quest. I have already created the initial dialogue window with the NPC and configured the quest (destroying a group of neutral creatures). However, I have some questions: how can I, upon completing the quest and returning to the NPC, disable the initial function with dialogue #1 and activate the function with dialogue #2 in the same region, and unlock the building as a reward?
----
Function for the introduction, with dialogue #1
----
function Barracks_build(hero) Barracks_hero = hero MessageBox("/Maps/SingleMissions/Time of Troubles1/Barracks_building.txt",nil) QuestionBox("/Maps/SingleMissions/Time of Troubles1/Barracks_buildingQB.txt", "Barracks_build_ok",nil); end Trigger(REGION_ENTER_AND_STOP_TRIGGER, "QuestSword", "Barracks_build",nil)
----
Function for agreement, with dialogue #2
----
function Barracks_build_ok() MessageBox("/Maps/SingleMissions/Time of Troubles1/Barracks_building1.txt"); SetObjectiveState("zadanie1", OBJECTIVE_ACTIVE,1); Trigger(REGION_ENTER_AND_STOP_TRIGGER, "QuestSword", "Barracks_build",nil) end
----
User Avatar
#224
Auto-translated
As an alternative, you can write the following in the Barracks_build_ok function: ``` function Barracks_build_ok() MessageBox("/Maps/SingleMissions/Time of Troubles1/Barracks_building1.txt"); SetObjectiveState("zadanie1", OBJECTIVE_ACTIVE,1); Trigger(REGION_ENTER_AND_STOP_TRIGGER, "QuestSword", nil) startThread( _Barracks_build_mob_monitor); end ``` And here is the _Barracks_build_mob_monitor function itself: ``` function _Barracks_build_mob_monitor () while 1 do sleep(2); if not Exists("Neutral") then Trigger(REGION_ENTER_AND_STOP_TRIGGER, "QuestSword", "Barracks_build_2"); break end; end; end; ``` It checks in a separate thread whether the 'Neutral' unit exists (Exists("Neutral")). If it is defeated at some point, the trigger for the region changes to "Barracks_build_2" - a function with dialogue #2. The completion of the quest depends on its type (kind). If it is OBJECTIVE_KIND_MANUAL, it can be completed with the following line: ``` SetObjectiveState('zadanie1', OBJECTIVE_COMPLETED); ``` Place it under the condition if not Exists("Neutral") then, before the trigger. If it is not OBJECTIVE_KIND_MANUAL, but is set to destroy a unit, it should complete automatically. I haven't encountered any issues with unlocking buildings, but SetTownBuildingLimitLevel will likely help in this case.
User Avatar
#225
Auto-translated
Thank you very much, the main condition works perfectly. Now I need to find a script that unlocks buildings. I encountered something similar in the second mission for the Necromancer in the ToE campaign, something related to vampires.

Statistics

Welcome our newest member: Emil