Skip to content

Posts from Scripts

4.8 (8 ratings)
In reply to Победитель
Auto-translated
Winner
The trigger didn't work...
Actually, it's a bit different:
I didn't use a trigger; instead, I launched the 'lost_PL_4' function in a separate thread, starting from the moment the task to kill PLAYER_4 was issued, with an interval of 5 sleeps. I did this so that the check would also run during the opponent's turn.
In reply to JonnyP
User Avatar
Auto-translated
JonnyP
Basically, it's not quite right:
I didn't use a trigger; instead, I ran the 'lost_PL_4' function in a separate thread, starting from the moment the task to kill PLAYER_4 was given, with an interval of 5 sleeps. I did it so that the check would also run during the opponent's turn.
Could you explain it in a bit more detail? :o

I replaced "~1" with "2," but nothing still happens. Then I did this: when one city is captured, it checks if the second city is also captured. Now, when two cities are captured, the game crashes :D. I also don't understand that quest... I guess I'll have to redo it.
Карты для Heroes of Might and Magic V
Цикл "Закадычные враги": "Особенное гостеприимство, "Супероружие", "Меж молотом и наковальней"
"Падение Шантири"

Кампания для "Кодекса Войны"
"Выбор Сагиттеля"
In reply to Победитель
Auto-translated
Winner
Could you please explain in a bit more detail? :o

I replaced "~1" with "2," but nothing happens. Then, I tried this: when capturing one city, it checks if the second city has also been captured. Now, when capturing two cities, the game crashes :D. I also don't understand that quest... I guess I'll have to redo it.
So, here's how I'm running the loop: (I also have a check here to see if a monster is on the map; if not, the mission fails).

while 1 do
if atonce_5==1 then
startThread (lost_PL4);
if IsObjectExists('Lelliana')==nil then
SetObjectiveState ('obj_7',OBJECTIVE_FAILED);
startThread(gameover);
end;
end;
sleep (5);
end;

This function checks the state of player 4; i.e., here, if PL_4 is not participating in the game, then the 'obj_7' objective is completed.
function lost_PL4()
if GetPlayerState(PLAYER_4)~=1 then
atonce_5=99;
SetObjectiveState ('obj_7',OBJECTIVE_COMPLETED);
end;
end;

And when the objective is activated, you need to assign
atonce_5=1; and after the objective is completed, atonce_5=99; so that the loop doesn't slow down the game.
Try creating a new objective in the Objectives tab without changing the parameters (just set the name, description, and OBJECTIVE_KIND_MANUAL), and check how it behaves when completed (will the mission be won immediately, without completing other objectives?)
In reply to Победитель
User Avatar
Auto-translated
Winner
A question arose. Is there a trigger that activates if a player has no towns and heroes = the player has lost?
According to the game's design, they will lose anyway.
Winner
And regarding completing a task when another player is defeated?
If you need to complete one task when one enemy opponent is defeated, here's how:
GetPlayerState(PLAYER_4) == PLAYER_LOST then ....
In principle, it's the same as what JonnyP wrote. :) But without numerical IDs.

What prevents you from attaching it to a new day trigger?

Because if an enemy town remains without a hero and is captured, your trigger (Trigger (PLAYER_REMOVE_HERO_TRIGGER,PLAYER_4,'lost_PL4')) will not activate.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

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

What prevents attaching it to a trigger for a new day?

After all, if the enemy town remains without a hero and is captured, your trigger (Trigger (PLAYER_REMOVE_HERO_TRIGGER,PLAYER_4,'lost_PL4')) will not work.
for a new day - the win will naturally only be for a new day, and not after the death of PL_4. (this is also possible)

regarding the trigger - yes, but if you have 4 players, and only one of them dies, and a hero is needed - that's why a loop is used instead of a trigger.
In reply to JonnyP
User Avatar
Auto-translated
JonnyP
on a new day, the win will naturally only be on a new day, and not after the death of PL_4. (this is also possible)

regarding the trigger - yes, but if you have 4 players, and only one of them dies, and a hero is also needed - that's why a loop is used instead of a trigger.
I don't know how it is with you and your computer (I had a laptop). But loops significantly slow down the game. I abandoned it in favor of a daily trigger on one map.

There is, of course, another way to do it. There is a way: when the ownership of an enemy city changes to a non-enemy one, check if there are any other of its cities or heroes on the map. If there are, proceed to the trigger for losing heroes.

There is a more reliable way: check if there are cities and heroes on the map when each trigger is activated. This will protect against different delays and possible incorrect sleeps. Otherwise, if the timeout is not completed, the turn will end, and the game may even crash.

You can hang two triggers on 1 function. It's simple.
Etc. The algorithm can be composed in any way.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
In reply to Dyrman
Auto-translated
Dyrman
I don't know how it is for you with a computer (I had a laptop). But loops significantly slow down the game. On one map, I gave up on it in favor of a trigger that runs daily.
A loop with 300 lines and about 20 conditions doesn't slow things down too much; everything is within reason. Without loops, you simply can't do many interesting things :cool:
In reply to JonnyP
User Avatar
Auto-translated
JonnyP
A loop of 300 lines, with about 20 conditions – it doesn't slow things down too much; everything is in moderation. Without loops, you simply can't do many interesting things:cool:
What other examples are there?
Well, this task can be easily done, even using scripts, and ideally, it should already be in the standard settings (in the object properties, or something like that). I'll create it using scripts when I get home – it's more interesting;)
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
In reply to Dyrman
Auto-translated
Dyrman
What other examples are there?
Well, for example, if you equip the 'bag of gold' artifact, it gives you a discount when hiring units, but if you remove it, you no longer get the discount. And this effect lasts for the entire day.
In reply to JonnyP
User Avatar
Auto-translated
JonnyP
For example, you equip the 'bag of gold' artifact, and it gives you a discount when hiring, you take it off – no discount. And all of this lasts for the entire day.
Hiring from an object?
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
In reply to Dyrman
Auto-translated
Dyrman
Hiring from an object?
of course. You can't do it without a mod when hiring from a town.
In reply to JonnyP
User Avatar
Auto-translated
JonnyP
Of course. You can't do without a mod when playing in a city.
Well, a mod isn't just scripts. But some mods affect other maps and the game itself, which is definitely not good. I'm all for keeping things clean. :D
In September, I wrote a script to allow you to view information about potions, artifacts, etc., directly from the hero, but I couldn't finish the map, even though there wasn't much left to do (I was terribly busy, and then I just got bored, I'll finish it someday).
I wonder, what other ways are there to view additional information entered by the map creator from the hero? Naturally, without a mod that changes the game's checksum. Does anyone know?
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
User Avatar
Auto-translated
I don't understand what you're talking about, Dyrman. What information are you referring to?
 

К А
Стикеры GBF в Telegram
In reply to Dyrman
Auto-translated
Dyrman

wrote a script so that you can view information about potions, rates, etc. directly from the hero, but he couldn't finish the map, even though there was only a little left to do (he was terribly busy, and then it just became boring, he'll finish it someday).
It would be interesting to see how you managed to do this with scripts? :confused:

Added 2 minutes later
Dyrman
Some mods affect other maps and the game itself - this is, of course, not good.
But playing on such maps is more interesting.
In reply to Ment
User Avatar
Auto-translated
Ment
I don't understand what you're talking about, Dyrman. What information are you referring to?
Well, for example:
I want to view the hero rating that I entered, but I want to see it through the hero's interface.

Added 1 minute ago
JonnyP
It would be interesting to see how you managed to do this with scripts? :confused:

Added 2 minutes ago

but the game is more interesting on such maps.

You use an empty reserved slot for a global spell, and when it's called, you launch a message with variables - it's simple ;) By the way, this is how loyalty is displayed. If you need the code, I'll post it upon request.

I'm conservative when it comes to changing the game (unit stats, races, overall gameplay). All of this should either be a separate mod for the player to choose, or not exist at all, which is why I don't like such maps.

Has anyone done anything similar with changing the interface or redrawing it? It shouldn't even affect the checksum, but it would increase convenience.
Моды для HeroesV:
NHF 0.90 : NHF - группа в VK

Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...

Statistics

Welcome our newest member: Emil