Skip to content

Posts from Scripts

4.8 (8 ratings)
User Avatar
Auto-translated
The word "function." Well, that's obvious, I think.
You'll laugh :D. I thought it was some special procedure :(. But the problems didn't go away. Now let's see what the console says.

Okay, it works :)! Thanks again for your help ;). The error was simple - the trigger had the wrong PlayerID.

And there's one last question. In the quest window, the map name is also displayed, and when you click on it, the map description is displayed. Instead, I have the English name and "Custom Map." Where is this edited?
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
User Avatar
Auto-translated
This is no longer funny. I added a couple of functions at the end, and the middle part (with the hero's death) stopped working. The console doesn't say anything, except for "Script Warning."
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
Auto-translated
What’s the problem? I’ll help in any way I can…
Дайте мне всего шесть строк, написанных рукой самого честного человека, и я найду, за что его можно повесить.
Весьма хороший попутчик... До первого перекрестка.
User Avatar
Auto-translated
That’s exactly the point – there is no problem. It just stops working from a certain point. I’ll try rebuilding the map again.
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
Auto-translated
Describe how the scripts are structured, i.e., list each function in order. After all, if the functions follow one after another, meaning one function must complete before the next one starts, then if even one function has an error and doesn't work, everything breaks down. Perhaps you missed an "end" or placed a trigger incorrectly. Or maybe a message isn't displaying.
Дайте мне всего шесть строк, написанных рукой самого честного человека, и я найду, за что его можно повесить.
Весьма хороший попутчик... До первого перекрестка.
User Avatar
Auto-translated
Sometimes, you come across scripted functions that take longer to execute than others (e.g., a message box). The game uses a clever trick: instead of finishing one function completely, it immediately starts the next, which causes the script to malfunction. In such cases, I often insert `sleep(3)` in suspicious places, and it usually helps.
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
Auto-translated
Ment
Sometimes, there are scripted functions that take longer to execute than others (e.g., a message box). The game uses a clever trick: it doesn't finish executing one function before starting the next, which causes the script to malfunction. In such cases, I insert `sleep(3)` in suspicious places, and it often helps.
Messages can also be loaded in a separate thread.
Winner
The console doesn't say anything other than "Script Warning."
"Script Warning" is still not an error. You didn't provide the description of the warning (or did you?).
If it's so complicated, it's better to connect through asynchronous programs. And the best thing to do is to share the map so we can take a look...
Everyone is a witness. I will share it :)
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
In reply to Dyrman
User Avatar
Auto-translated
Dyrman
Messages can also be uploaded in a separate thread.

"Script Warning" is still not an error. You didn't provide a description of the warning (or did you?).
If it's so complicated, it's better to connect through asynchronous programs. And the best thing is to share the map so we can take a look...
Everyone is a witness. I will share it :)
Thank you ;). But I figured it out. I just need to make the last function work.

I did it this way: instead of entering a region and starting a battle, I placed a garrison in the town and a script that triggers when it is captured :). So, it worked, thank you.
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
User Avatar
Auto-translated
Is it possible to make it so that when a hero enters a region for the first time, one function is executed, and upon subsequent entries, a different function is executed? And also, regarding this code: ``` if GetSavedCombatArmyHero(a1,0)=="Giovanni" then Loose(); end; if (GetSavedCombatArmyHero(a1,1)=="Giovanni") and (GetSavedCombatArmyHero(a1,0)=="Zehir") then MessageBox(GetMapDataPath().."talk_of_grigorio_6.txt"); SetObjectiveState("kill_pl5", OBJECTIVE_COMPLETED, PLAYER_1 ); SetPlayerResource(PLAYER_1 ,GOLD, GetPlayerResource(PLAYER_1 , GOLD)+20000); end; ``` What do (a1,0/1) represent here?
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
In reply to Победитель
User Avatar
Auto-translated
Winner
Is it possible to make it so that when a hero enters a region for the first time, one function is executed, and upon subsequent entries, another function is executed?

And also regarding this code:

if GetSavedCombatArmyHero(a1,0)=="Giovanni" then
Loose();
end;
if (GetSavedCombatArmyHero(a1,1)=="Giovanni") and (GetSavedCombatArmyHero(a1,0)=="Zehir") then
MessageBox(GetMapDataPath().."talk_of_grigorio_6.txt");
SetObjectiveState("kill_pl5", OBJECTIVE_COMPLETED, PLAYER_1 );
SetPlayerResource(PLAYER_1 ,GOLD, GetPlayerResource(PLAYER_1 , GOLD)+20000);
end;
What do (a1,0/1) mean here?
Loss/win.
When executing functions:
Set a counter for function execution or a variable that determines the function names.
But it is clearly easier for you to simply write 1 function with a condition for the first and second entry. A flag (variable) will determine the entry.
Like:
if f=1
first case, f is assigned 2
if f=2
second case
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
Auto-translated
Hey everyone, could you please help me out? I need to know how to write a script or find another way to achieve this! My friend and I are playing on the "Underground Treasures" map, and I want to create a trigger that gives "Player 4" +2 levels when their hero reaches level 23, specifically at the Prophet's Hut. I've tried several times and read a lot of guides, but I can't seem to get it to work. Could you explain it in simple terms, like you're talking to a beginner? Where do I go? What do I do? How do I do it?
User Avatar
Auto-translated
The code needs to be written in the top panel of the editor: Map Properties -> Map Script -> Edit. The script text is included in the message. I just made a mistake there: before 23, instead of ==, it should be >.
Attachments 1
1 file attached • Total size: 312 B
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
Ment
The code needs to be written in the top panel of the editor -> map properties -> map script -> edit. The script text is embedded in the message. I just made a mistake there: before 23, instead of ==, it should be >.


I did everything as you said, but it still doesn't work!!! When I enter the hut, it tells me that there is no one here!!! Please help!!! Here's how I write it:

function lev(hero)
if GetHeroLevel(hero)>1 and GetObjectOwner(hero)==4 then
LevelUpHero(hero);
sleep(4);
LevelUpHero(hero);
Trigger(OBJECT_TOUCH_TRIGGER,Seer,nil);
end;
end;
SetObjectEnabled(Seer,nil);
Trigger(OBJECT_TOUCH_TRIGGER,Seer,'lev');
User Avatar
Auto-translated
“Seer” needs to be enclosed in quotation marks or apostrophes. Also, it’s important that the capitalization matches.
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
Ment
Seer needs to be in quotes or apostrophes. And it's also important that the case matches.

Well, finally, I put everything in quotes, and it worked. I usually always do that, but I somehow missed it this time. THANK YOU so much, dude (+ for you!!!). I understood where my previous mistake was; in the second line, I simply wrote:
if GetHeroLevel(PLAYER_4)>23 (WITHOUT and GetObjectOwner(hero)==4 then).

And here's another question for you, if you don't mind:
So, if I'm editing the prophet's hut itself, when choosing the type of quest, let's say, to collect resources, it requires only one unit of wood in the game. Is there a way to edit this so that it requires a lot of everything, without using scripts?
And can quests be edited at all? If "YES," then how, please, in detail. Otherwise, thank you for your help!!!

Statistics