So far I have made a script that shoots out a sequence of 'invisible sight NPCs' the the west of the 'guard NPC.' For the sake of making my script easier to debug I have actually made these 'sight NPCs' visible in the game testing so I could see just exactly what's happening.
The problem I'm having:
I specifically made my script as a 'while' loop so that while the 'guard NPC' is facing in the west direction the Line of Sight will be carried out. You can see in the video provided that the 'guard NPC' starts out facing west and all goes well. But if the NPC is turned another direction and then back to the westward direction that the script does not continue to work. Can anyone tell me why this is? It may be important to note that this script is being run as an Autorun Script for the map.
Here's the script thus far:
Code:
global variable (0, x)
global variable (1, y)
#--------------------LINE OF SIGHT--------------------------
plotscript, Line Of Sight, begin
x := hero x (find hero (0))
y := hero y (find hero (0))
variable (xNPC, yNPC, z)
xNPC := NPC X (0)
yNPC := NPC Y (0)
z := 1
#Line of sight sweep for west-facing NPC
While (NPC direction (0) == west) do(
#Line of sight point west
#####
If (read zone (10, xNPC--1, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--1, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
If (read zone (10, xNPC--2, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--2, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
If (read zone (10, xNPC--3, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--3, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
If (read zone (10, xNPC--4, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--4, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
If (read zone (10, xNPC--5, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--5, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
#May need to add an additional break and/or wait here...
#wait (30)
#destroy NPC (1)
#wait (30)
)
end
global variable (0, x)
global variable (1, y)
#--------------------LINE OF SIGHT--------------------------
plotscript, Line Of Sight, begin
x := hero x (find hero (0))
y := hero y (find hero (0))
variable (xNPC, yNPC, z)
xNPC := NPC X (0)
yNPC := NPC Y (0)
z := 1
#Line of sight sweep for west-facing NPC
While (NPC direction (0) == west) do(
#Line of sight point west
#####
If (read zone (10, xNPC--1, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--1, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
If (read zone (10, xNPC--2, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--2, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
If (read zone (10, xNPC--3, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--3, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
If (read zone (10, xNPC--4, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--4, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
If (read zone (10, xNPC--5, yNPC) == true) then(
break
)
else (
create NPC (1, xNPC--5, yNPC, west)
wait (1)
destroy NPC (1)
wait (1)
)
#####
#May need to add an additional break and/or wait here...
#wait (30)
#destroy NPC (1)
#wait (30)
)
end
And the video of this issue can be seen here:
http://www.youtube.com/watch?v=A4DvThX7ui8&list=SP-ywmUILu1tgN7OJ_KDFM2wZOqoSoxvid
⊕ P E R S O N A L M U S I C: https://open.spotify.com/album/6fEo3fCm5C3XhtFRflfANr
⍠ C O L L A B M U S I C: https://dustpuppets.bandcamp.com/releases



