Of course, this is only half of the script — for the attacker — I decided not to clutter the forum and your feed with extra unreadable scripts. I'll make the defender's one based on the attacker's template.
Added 1 hour 31 minutes later
Something isn't working.
MapScript is complaining (Script) ERROR: Parameter lost: function name.
path = '/'..GetMapDataPath()
main_hero = 'Raelag'
print("Main Hero named");
SetHeroCombatScript('Raelag', path.."CombatScript.xdb#xpointer(/Script)");
print("Combat script launched");
LevR = GetHeroLevel('Raelag');
print("LevR set as Raelag's level determiner");
function HeroLevelSaveF()
SetGameVar("LevR", GetGameVar("LevR")+1); --Increment the hero level variable by 1
print("Set that LevR is SetGameVar");
end
SetGameVar("LevR", 1)
Trigger(HERO_LEVELUP_TRIGGER, "Raelag")I tried changing the function name — nothing changes.
I tried removing LevR = GetHeroLevel('Raelag'); (it seemed to me that Trigger(HERO_LEVELUP_TRIGGER, "Raelag") is quite sufficient, and maybe that's the case. Should I remove LevR = GetHeroLevel('Raelag') or not?) — nothing changed either, (Script) ERROR: Parameter lost: function name.
The combat script seems correct, but Raelag still casts Rock, and the game doesn't see that he is level 20. Here is the script, just in case:
function Start()
Level_R = GetGameVar("LevR") + 0;
print("Level_R óñòàíîâëåí êàê îïðåäåëèòåëü óðîâíÿ Ðàèëàãà ìàòü åãî â áîþ è çàâèñèò îò LevR");
if GetHeroName(GetAttackerHero()) == 'Raelag' then
print("åñëè ÃÃ àãðåññîð");
local mana = GetUnitManaPoints(GetAttackerHero());
SetUnitManaPoints(GetAttackerHero(), 200);
repeat sleep(1) until GetUnitManaPoints(GetAttackerHero())==200;
sleep(1);
if Level_R < 20 then
print("åñëè óðîâåíü ìåíüøå 20, òî");
for i, creature in GetDefenderCreatures() do
startThread(UnitCastAimedSpell, GetAttackerHero(), 4, creature);
print("êàñòóåì ãëûáó");
end;
SetUnitManaPoints(GetAttackerHero(), mana);
print("âîçâðàùàåì ìàíó");
else
print("åñëè óðîâåíü 20 è áîëüøå, òî");
for i, creature in GetDefenderCreatures() do
startThread(UnitCastAimedSpell, GetAttackerHero(), 5, creature);
print("êàñòóåì øàð");
end
SetUnitManaPoints(GetAttackerHero(), mana);
print("âîçâðàùàåì ìàíó");
end
else
if GetHeroName(GetDefenderHero()) == 'Raelag' then
print("åñëè ÃÃ àãðåññîð");
local mana = GetUnitManaPoints(GetDefenderHero())
SetUnitManaPoints(GetDefenderHero(), 200);
repeat sleep(1) until GetUnitManaPoints(GetDefenderHero())==200
sleep(1);
if Level_R < 20 then
print("åñëè óðîâåíü ìåíüøå 20, òî");
for i, creature in GetAttackerCreatures() do
startThread(UnitCastAimedSpell, GetDefenderHero(), 4, creature);
print("êàñòóåì ãëûáó");
end;
SetUnitManaPoints(GetDefenderHero(), mana);
else
print("åñëè óðîâåíü 20 è áîëüøå, òî");
for i, creature in GetAttackerCreatures() do
startThread(UnitCastAimedSpell, GetDefenderHero(), 5, creature);
print("êàñòóåì øàð");
end;
SetUnitManaPoints(GetDefenderHero(), mana);
print("âîçâðàùàåì ìàíó");
end
end;
end;
end;Sorry if the Russian text doesn't display, but everything seems clear anyway.Added 3 minutes later
Maybe there's a mistake in the Map script here? Or some extra brackets or quotes?
SetGameVar("LevR", GetGameVar("LevR")+1);