I have a script that is mostly working the way I want. When the hero is walking the autorun loop will call a script which moves all the NPCs on the map in the hero's mirrored direction.
The problem is that sometime the NPCs are overlapping (occupying the same space). I don't want this to happen. If the space is already occupied by an NPC that can't move then no other NPC should be able to walk on to it. I'm not sure why this happens. My NPCs are set to "use" so they should not be able to step on each other. I've included a .gif to show the behaviour.
Here's my scripts so far:
Code: Select all
plotscript, Map Auto Run 0, begin
while(1 == 1) do(
if(check tag(3) == off) then(
if(hero is walking(me) == true) then(
set tag(3, on)
suspend player
# Perform all movements/actions
mirrorNPC 1
resume player
set tag(3, off)
)
)
wait
)
end
Code: Select all
script, mirrorNPC 1, begin
variable(copy, whichNPC)
for(copy, 0, 19) do(
whichNPC := NPC reference (1, copy)
if(whichNPC <> 0) then(
#Get hero direction
heroDir := hero direction(0)
# Move NPCs in mirror direction
if(heroDir == up) then(
mirrorHeroDir := up
) else if(heroDir == down) then(
mirrorHeroDir := down
) else if(heroDir == left) then(
mirrorHeroDir := right
) else if(heroDir == right) then(
mirrorHeroDir := left
)
show value(mirrorHeroDir)
if(check NPC wall (whichNPC, mirrorHeroDir) == false) then(
walk NPC(whichNPC, mirrorHeroDir, 1)
)
)
)
for(copy, 0, 19) do(
whichNPC := NPC reference (1, copy)
if(whichNPC <> 0) then(
wait for npc(whichNPC)
)
)
end