Skip to content
User Avatar
#3432
Auto-translated
Good day, I haven't worked with combat scripts for a while. I wrote a short and seemingly simple code, but the spell cast doesn't work, and I can't figure out why (I tried it with all light spells, it only works with regeneration; in darkness, it only works with slow; the rest also give errors). I'm asking for help from experts. Example below:
Title
function Start()
local creaturesList = GetAttackerCreatures();
local manaSave = GetUnitManaPoints(GetAttackerHero());
sleep(5);
SetUnitManaPoints(GetAttackerHero(), 500);
for i, target in creaturesList do
UnitCastAimedSpell(GetAttackerHero(), SPELL_BLESS, target);
print("Unit"..GetAttackerHero().."casted".. SPELL_BLESS.." to target"..target);
end;
sleep(5);
SetUnitManaPoints(GetAttackerHero(), manaSave);
startThread(checkWinAttacker);
startThread(checkWinDefender);
sleep(5);
EnableAutoFinish(nil);
end;

function checkWinAttacker()
repeat sleep(1); until length(GetDefenderCreatures()) == 0;

sleep(30);
Finish(ATTACKER);
end;

function checkWinDefender()
repeat sleep(1); until length(GetAttackerCreatures()) == 0;

sleep(30);
Finish(DEFENDER);
end;
Карты для Heroes V: Повелители орды:
Multiplayer: Господство, Извечное противостояние, Война за Магию, Торговая империя, Анатомия войны, Эксперимент
SingleScenario: Последний Рубеж, Трон, Элиралис, Вернуться домой!, Лабиринты разума
Campaign: Колонизация