I found my mistake in the script, but it still doesn't work, although the editor has stopped complaining.
I'm writing in the combat script, as a second script, after Ilia's script for casting Ice Block in each battle:
function Nur_battle()
local defH, attH = GetDefenderHero(), GetAttackerHero()
if GetHeroName(defH) == "Nur" and GetHeroName(attH) == "Shadwyn" 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(defH) == "Shadwyn" and GetHeroName(attH) == "Nur" then
local mana = GetUnitManaPoints(GetAttackerHero())
SetUnitManaPoints(GetAttackerHero(), 200);
repeat sleep(1) until GetUnitManaPoints(GetAttackerHero())==200
for i, creature in GetDefenderCreatures() do
startThread(UnitCastAimedSpell, GetAttackerHero(), 3, creature)
end;
SetUnitManaPoints(GetAttackerHero(), mana);
end;
end;
end;
But when Ilia attacks Nazir, she still casts Ice Block, and Nazir doesn't cast Lightning on her.
What am I doing wrong?)
Maybe Nazir needs to be defined somewhere in the MapScript?
Added 2 minutes ago
That is, I'm writing a second function in the combat script, of course, and not a second script.
Added 4 hours 8 minutes ago
And here's a second question.
I'm trying to set up a Town Portal system, like in Heroes 3.
There are no problems with the main character; she teleports to the right place.
But I would like all the heroes of the first player to be able to teleport through this script.
And here arises the problem of how to identify them - SetObjectPosition(heroName, x, y, floor) requires the name of a specific hero.
But how do I know who will appear in the tavern?
Since I don't know how to identify a hero without a name, I've been trying to copy scripts from the forum, but it doesn't seem to work.
I wrote in the beginning of the MapScript:
kot_heroes={"Shadwyn", "Raelag", "Urunir", "Ohtarig"};
Then I wrote a function:
function Portal_HaladF (heroname)
local Portal_Hero
for key, name in kot_heroes do
if name == heroName then
Portal_Hero=1
SetObjectPosition(heroName, 56, 90, 0);
sleep(1);
end;
end;
if not Portal_Hero then
print("не тот герой");
end;
end;
But all of this doesn't work; the game continues to require the name of the person who will teleport.
How do I write that the hero who used the object should teleport, if this hero belongs to the first player?