Posts from Current questions and answers regarding the map editor.
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).
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!
How else can I trigger a battle?
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.
Ah, my mistake, I got it mixed up with another function. Yes, the attacking unit should be a human.
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
How else can you trigger a battle?
Trigger a battle? Do you mean within the battle itself or after it?
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
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.
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!