This should, in theory, prevent AI heroes from interacting with each other.
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
New here? I'm Roha — want a quick tour?
for x=66,67 do
for y=127,159 do
if IsTilePassable(x, y, 0)==1 then
CreateMonster ("name"..i, 32, 1, x, y, 0,1,2,270)
if x==67 and y==130 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
if x==67 and y==154 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
if x==66 and y==155 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
i=i+1
end
end
endI spawned monsters through a loop, so there is no need to get all the monster names, at least I think so.
Here is the script:for x=66,67 do
for y=127,159 do
if IsTilePassable(x, y, 0)==1 then
CreateMonster ("name"..i, 32, 1, x, y, 0,1,2,270)
if x==67 and y==130 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
if x==67 and y==154 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
if x==66 and y==155 then
PlayObjectAnimation ("name"..i, "death", ONESHOT_STILL)
end
i=i+1
end
end
end
That is, as a result, it should produce monsters standing in a rectangle, some of them dead. At the same time, the game does not play the death animation for creatures at the checked coordinates; the console says that a monster with the name name(...) was not found.
If I put sleep between CreateMonster and the checks, the monsters spawn not in a rectangle, but randomly according to some unclear principle. What could be the problem?
for x=66,67 do
for y=127,159 do
startThread(function(int)
local name="name"..int
CreateMonster(name, 32, 1, %x, %y, 0, 1, 2, -90)
sleep(1)
SetObjectPosition(name, %x, %y, 0)
if (%x==67 and %y==130) or (%x==67 and %y==154) or (%x==66 and %y==155) then
PlayObjectAnimation(name, "death", ONESHOT_STILL)
end
end, i)
i=i+1
end
end
Thank you! What is the difference between x and %x?
And I didn't know that you could write
startThread(function(int)
end, i)
Now I'll know. As I understand it, this is a call to a thread that is in the body of the function, passing the argument i as a number?
Is there a "bypass" where a script that produces an error simply skips the problematic function and continues?