On the PuzzleScript home page, there is an example of an enemy (Eyeball
) which, when you (Player
) are directly in its line of sight, will move one square closer to you, using the rule
[ Eyeball | ... | Player ] -> [ > Eyeball | ... | Player ]
However, the Eyeball
will walk towards Player
even if it shouldn't be able to see you, for instance if there is a wall in the way. This is apparent in a level like
#########
#....O..#
#.......#
#########
#.......#
#..P....#
#########
where, if Player
passpasses below Eyeball
, Eyeball
will move one square down.
How do I make it so that the enemy can't see me through walls?
Inserting no Wall
into the rule above doesn't work, as that doesn't tell ...
to only match wall-free tiles, but rather checks whether there is at least one non-wall tile between Eyeball
and Player
. And adding the rule
[ > Eyeball | ... | Wall | ... | Player ] -> [ Eyeball | ... | Wall | ... | Player ]
in an attempt to correct the movement doesn't work as two ellipses in a single match pattern isn't allowed.