Posts from Scripts
Auto-translated
once again, does the hero block the only possible path to the desired cell?
then everything works according to the mechanics; CanHeroMove considers the hero an impassable obstacle. You could add a check for this situation, and if it occurs, move Erling to your hero's location, for example.
more precisely, something like this
if(CanMoveHero(Erling, 15, 9, 0)) then
MoveHero(Erling, 15, 9, 0)
else
MoveHeroRealTime(Erling, 15, 9, 0)
end
try replacing MoveHero with MoveHeroRealTime, and remove the CanHeroMove check
more precisely, something like thisif(CanMoveHero(Erling, 15, 9, 0)) then
MoveHero(Erling, 15, 9, 0)
else
MoveHeroRealTime(Erling, 15, 9, 0)
end
No, that won't work. I have a task to defend the castle, so MoveHeroRealTime won't be suitable. 15,9 is the entry point to the castle; this might help.
You can perform a series of MoveHero actions, each moving the hero one step, with a check for success after each step. Store the coordinates of each step in an array.
y={9,9,10,10}
for i=1 to n
if IsHeroAlive("Erling") then
MoveHero("Erling",x,y,0)
end
end
So, hypothetically speaking. In reality, I see a couple of weak points in the code (for example, in the event of a battle and victory in it, Erling will most likely not continue moving, as the script has already completed its execution while the battle was in progress), but the logic is generally like this.
x={15,16,17,18}
y={9,9,10,10}
for i=1 to n
if IsHeroAlive("Erling") then
MoveHero("Erling",x,y,0)
end
end
So, hypothetically speaking. In reality, I see a couple of weak points in the code here (for example, in the event of a battle and victory in it, Erling will most likely not continue moving, as by the time the battle is over, the script will have already finished executing), but the logic is generally like this.
The console displays an error (see screenshot). Here is the code:
x={15,16,17,18}
y={9,9,10,10}
for i=1,n do
if IsHeroAlive(Erling) then
MoveHero(Erling,x,y,0)
end
end
x={15,16,17,18}
y={9,9,10,10}
n=4
for i=1,n do
if IsHeroAlive(Erling) then
MoveHero(Erling,x,y,0)
end
end
The size of the coordinate array should be passed to n.
well, if the problem is only in this specific location, you can simply move to it if the desired one is unavailable.
So the answer is no; if the function doesn't complete for some reason, then that's it.