Posts from Scripts
Auto-translated
Added after 41 seconds
The only thing is that it needs to be reapplied when the hero dies.
Added 34 minutes later
And another question: how do I create a neutral hero? In the Unicorn Empire campaign, there was one in mission 4.
And another question - how do you make a neutral hero? In the Unicorn Empire campaign, there was one in mission 4.
SetObjectOwner('hero name', player number that is not on the map);
That is, if you have 2 players on your map, you place the hero in the editor and then write the line above, and instead of "player number that is not on the map," you write PLAYER_3.
1) How can I make the human player lose a battle in a standard way? That is, at the beginning, auto-win/lose is disabled and enabled only when all additional units are summoned. How can I make the human player lose, regardless of the "dwarf" or "atdwarf" variables, if all of their units are killed?
2) In the attacking script, the hero first casts a general speed-up spell. However, on the next turn, he doesn't cast the second spell. There are no errors in the console. The defensive script applies all spells as expected.
3) I noticed that the script throws an error if the hero cannot cast a spell (all creatures are immune to the spell). How can I fix this? That is, how can I prevent him from casting if there is no one to cast it on?
2) What spells does he cast in the defensive and attacking parts? It's clear that they are different, but which ones specifically? Perhaps the problem lies in the spell being inapplicable.
3) Wouldn't the spell not be cast anyway when an error occurs? What do you want to happen in the end?
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
2. In order of spells:
Attack
1) General Haste
2) General Blessing
3) Summon Phoenix
4) General Slow
5) Summon Elementals
6) Pause, doesn't cast anything for several turns
7) General Curse
8) Starts over
Defense
1) Summon Phoenix
2) Summon Elementals
3) General Haste
4) General Blessing
5) General Slow
6) Pause for several turns
7) General Curse
8) Starts over
3. Well, in principle, the AI stops using spells and gets stuck in this state. But in general, the chances that the player will have only elementals in their army are small.
Added 22 minutes later
I've tested the spells again. When defending, everything is perfect, but when attacking, it still doesn't work. And the spell is exactly the same. When defending, it easily casts General Blessing.
Added 2 hours 25 minutes later
Regarding point 2. I identified and fixed the bug. The condition check was being performed using an incorrect variable.
1. How will this look?
3. Well, basically, the AI stops casting spells and gets stuck in that state. But in general, the chances of the player having only elementals in their army are small.
function finish()
local human = IsHuman(ATTACKER) and ATTACKER or DEFENDER
local computer = 1 - human
while 1 do
local hum = GetCreatures(human)
local comp = GetCreatures(computer)
if length(hum) == 0 then
Finish(computer)
break
end
if length(computer) == 0 and (atdwarf == 6 or dwarf == 2) then
Finish(human)
break
end
sleep(20)
end
end
startThread(finish)
3. You can call spellcasting functions not directly, but through startThread; then, if an error occurs, the script will not crash but will continue to execute.
startThread(commandDoSpell, hero, spell, ...)
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
Rewrote the two initial finish conditions. Now something strange happens. When attacking Hagnar, the battle ends immediately because creatures disappear from both sides...
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
What do you mean? Create such a function and add it there?
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4