This is another method using a polygon as the line of sight feature instead of the inbuilt commands.
Its probably not functional in a larger scale game but it could be used in conjunction with some other code to be effective.
rem ----------------------------------------------------
rem
rem line of sight concept
rem indi
rem
rem original static concept
rem Pogrammer Holic [email protected]
rem ----------------------------------------------------
sync on
sync rate 0
make matrix 1,1000,1000,5,5
position matrix 1,-500,0,-500
make object sphere 1,10
position object 1,0,0,0
make object sphere 2,10
position object 2,0,0,100
make object triangle 3,0,0,0,-1,0,100,1,0,100
color object 3,rgb(255,0,0)
make object cube 4,10
position object 4,0,0,200
position camera 0,20,0
do
`Move object with up, down, left and right keys
move object 4,upkey()
move object 4,downkey()*-1
yrotate object 4,wrapvalue(object angle y(4)+leftkey()*-2)
yrotate object 4,wrapvalue(object angle y(4)+rightkey()*2)
`Move and rotate camera with mouse, click left to move forward, right to go back
yrotate camera wrapvalue(camera angle y()+mousemovex())
if mouseclick()=1 then move camera 2
if mouseclick()=2 then move camera -2
`Check monster 1's Line of sight vs Monster 2's body
if object collision(2,3)=1
text 10,10,"monster 1's Line of sight hits Monster 2's body"
endif
`Check Player body vs Monster 1's Line of sight
if object collision(3,4)=1
text 10,30,"monster 1's Line of sight hits Players Body"
else
y = wrapvalue(y + 1)
yrotate object 3,y
endif
`Check Player body and Monster 2's body vs Monster 1's line of sight
if object collision(2,3)=1 and object collision(3,4)=1
text 10,50,"monster 1's Line of sight cant see Monster 2"
endif
center text object screen x(1),object screen y(1),"monster 1"
center text object screen x(2),object screen y(2),"monster 2"
center text object screen x(4),object screen y(4),"player"
sync
loop