Auto-translated
Hottabych, even though you haven't been here for a couple of months, maybe you'll answer.
(Or someone, please help, kind people).
You once taught me how to write a combat script for ГГ. Here it is, if you remember:
------------------------------------------------------------------------------------------------------
function Start()
Level_R = ceil(GetGameVar("LevR") + 0)
if GetHeroName(GetAttackerHero()) == 'Raelag' then
local mana = GetUnitManaPoints(GetAttackerHero());
SetUnitManaPoints(GetAttackerHero(), 200);
repeat sleep(1) until GetUnitManaPoints(GetAttackerHero())==200;
sleep(1);
if Level_R < 20 then
for i, creature in GetDefenderCreatures() do
startThread(UnitCastAimedSpell, GetAttackerHero(), 4, creature);
end;
SetUnitManaPoints(GetAttackerHero(), mana);
else
for i, creature in GetDefenderCreatures() do
startThread(UnitCastAimedSpell, GetAttackerHero(), 226, creature);
end
SetUnitManaPoints(GetAttackerHero(), mana);
end
else
if GetHeroName(GetDefenderHero()) == 'Raelag' then
local mana = GetUnitManaPoints(GetDefenderHero())
SetUnitManaPoints(GetDefenderHero(), 200);
repeat sleep(1) until GetUnitManaPoints(GetDefenderHero())==200
sleep(1);
if Level_R < 20 then
for i, creature in GetAttackerCreatures() do
startThread(UnitCastAimedSpell, GetDefenderHero(), 4, creature);
end;
SetUnitManaPoints(GetDefenderHero(), mana);
else
for i, creature in GetAttackerCreatures() do
startThread(UnitCastAimedSpell, GetDefenderHero(), 226, creature);
end;
SetUnitManaPoints(GetDefenderHero(), mana);
end
end;
end;
end;
------------------------------------------------------------------------------------------------------
How do I add another script to the combat script, for the enemy?
I've tried everything.
I tried writing something like:
------------------------------------------------------------------------------------------------------
if GetHeroName(GetAttackerHero()) == 'Shadwyn' then
if GetHeroName(GetDefenderHero()) == 'Nur' then
local mana = GetUnitManaPoints(GetDefenderHero())
SetUnitManaPoints(GetDefenderHero(), 200);
repeat sleep(1) until GetUnitManaPoints(GetDefenderHero())==200
for i, creature in GetAttackerCreatures() do
startThread(UnitCastAimedSpell, GetDefenderHero(), 3, creature)
end;
SetUnitManaPoints(GetDefenderHero(), mana);
else
if GetHeroName(GetAttackerHero()) == 'Shadwyn' then
local mana = GetUnitManaPoints(GetAttackerHero());
SetUnitManaPoints(GetAttackerHero(), 200);
repeat sleep(1) until GetUnitManaPoints(GetAttackerHero())==200;
sleep(1);
if Level_R < 20 then
for i, creature in GetDefenderCreatures() do
startThread(UnitCastAimedSpell, GetAttackerHero(), 4, creature);
end;
SetUnitManaPoints(GetAttackerHero(), mana);
else
for i, creature in GetDefenderCreatures() do
startThread(UnitCastAimedSpell, GetAttackerHero(), 279, creature);
end
SetUnitManaPoints(GetAttackerHero(), mana);
end
------------------------------------------------------------------------------------------------------
And so on, then for the defender - it still doesn't work. Although Nazir reliably casts lightning on my Illia, but in other battles she can't use Ice Block, it says "ERROR: Wrong type of argument 1, when calling function GetHeroName".
I tried changing the order of if GetHeroName(GetAttackerHero()) == 'Shadwyn' then and if GetHeroName(GetDefenderHero()) == 'Nur' then - it's the same.
I tried to specify Nazir together with Illia in MapScript:
path = '/'..GetMapDataPath()
main_hero = 'Shadwyn'
MagHero = 'Nur'
SetHeroCombatScript('Shadwyn', path.."CombatScript.xdb#xpointer(/Script)");
SetHeroCombatScript('Nur', path.."CombatScript.xdb#xpointer(/Script)");
- it doesn't help either.
I even tried to assign a separate CombatScript to Nazir - but it seems the game doesn't even see it.
In general, is it possible to assign combat scripts to multiple heroes, and how to do it?