Skip to content

Posts from Current questions and answers regarding the map editor.

5.0 (12 ratings)
User Avatar
Auto-translated
Using GetAttackerCreatures and GetDefenderCreatures (which return an array of attacker and defender creatures, respectively), as well as IsHuman(ATTACKER) (which returns true if the attacker is playing as a human).
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
Auto-translated
Ment
Using GetAttackerCreatures and GetDefenderCreatures (which return an array of attacker and defender creatures), as well as using IsHuman(ATTACKER) (which returns true if the attacker is playing as a human).
If you call StartCombat, does the attacker always have to be a human?
Мои карты:
Town
Готовится:Чума (40%), Сосиска(42%), Война Грааля
User Avatar
Auto-translated
There's no need to call StartCombat. Such things are only needed if you have specific victory conditions in a battle (for example, if all the enemy creatures are summoned, and you need to kill specifically the summoned creatures, as was the case in the original Heroes 5 and 6). If the victory conditions are standard (kill everyone except summoned creatures), this is not necessary!
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
Auto-translated
Ment
It's not necessary to call StartCombat. Such things are needed if you have specific victory conditions in a battle (for example, all enemy creatures are summoned, and you need to kill specifically summoned creatures; this was the case in Heroes of Might and Magic V). If the victory conditions are standard (kill everyone except summoned creatures), this is not needed!
And how else can you link a battle to a trigger?
Мои карты:
Town
Готовится:Чума (40%), Сосиска(42%), Война Грааля
User Avatar
Auto-translated
Oh, my mistake, I got it mixed up with another function. Yes, the attacking unit should be a human.
 

К А
Стикеры GBF в Telegram
In reply to Олегарх
Auto-translated
Oligarch
How else can I trigger a battle?
1st way: using 'StartCombatom' (as already suggested)
2nd way: You can also do it differently - make the script run regardless of whether the player is the attacker or the defender. No triggers are needed here; it's done by adding a few lines of script to the 'combat-common.lua' file - this file is launched by the game when any battle starts.
PS: The second method is more versatile for various battle situations. You can also add a check for specific heroes.
In reply to Ment
User Avatar
Auto-translated
Ment
Ah, my mistake, I got it mixed up with another function. Yes, the attacking unit should be a human.
A hero controlled by AI can also be an attacking unit in the StartCombat.
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
If it's the first argument in StartCombat, that should do it.
 

К А
Стикеры GBF в Telegram
In reply to Олегарх
User Avatar
Auto-translated
Yes
Oligarch
How else can you trigger a battle?

Trigger a battle? Do you mean within the battle itself or after it?
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
User Avatar
Auto-translated
This question is better phrased as: "What other way is there to trigger a battle, besides using StartCombat?"
 

К А
Стикеры GBF в Telegram
In reply to Ment
User Avatar
Auto-translated
There is a trigger with the ID COMBAT_RESULTS_TRIGGER, which is responsible for this (it calls a function after each battle ends).
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
In reply to Ment
Auto-translated
Please help! I want to make it so that when a hero enters a tent, they can buy different stats for different prices. However, I don't understand how to make it so that when the player chooses what they want to buy, the script checks the amount of gold they have, and if they don't have enough, the hero can't make the purchase. Here's how I started writing the script:

function tradeF
TalkBoxForPlayers(1, nil, nil, nil, nil, "snar", 0, "path/name.txt", "path/name.txt", 0, "path/name.txt", "path/name.txt", "path/name.txt.", "path/name.txt");
end;
Trigger(OBJECT_TOUCH_TRIGGER, "trade", "tradeF");

function snar(player_id, choice)

monet = GetPlayerResource(1, GOLD);

if choice == 1
then SetPlayerResource(1, GOLD, monet-2000);
ChangeHeroStat("hero name", STAT_ATTACK, 1);
elseif choice == 2
then SetPlayerResource(1, GOLD, monet-3000);
ChangeHeroStat("hero name", STAT_ATTACK, 2);
elseif choice == 3
then SetPlayerResource(1, GOLD, monet-2000);
ChangeHeroStat("hero name", STAT_DEFENCE, 1);
elseif choice == 4
then SetPlayerResource(1, GOLD, monet-6000);
ChangeHeroStat("hero name", STAT_DEFENCE, 2);
TeachHeroSpell("hero name", 25);
end;
end;

Here, "trade" is the name of the object where the trading takes place.
I tried writing "if A and B then C" to specify a second condition (the required amount of gold) after "and" for obtaining the desired stats, but it turned into a complete mess.
User Avatar
Auto-translated
No, that's how it's done, but then, at the very end, you also need to add an `else` statement, which displays a message about insufficient funds. Or, you could create a dialog box that doesn't display options that you don't have enough money for initially.
 

К А
Стикеры GBF в Telegram
In reply to Ment
Auto-translated
Ment
No, that's how it's done, but then, at the very end, you also need to add an "else" statement that displays a message about not having enough money. How else would you do it?
Or, you could create a dialog box that doesn't display options that you don't have enough money for in the first place.

I tried again - it really works. Hmm... I guess I just wasn't well-rested. Thank you!
User Avatar
Auto-translated
Does anyone know what function is activated when you click on a monster and the number 9 on the mini-keyboard while creating a map? (Specifically, a map, not a video). I had an Armageddon happen.

Whatever

Statistics

Welcome our newest member: Emil