I've written up a tutorial in which you will learn how to make an object test for another object inside an "arc of sight". The first thing that probably comes to your mind is the similarity to "line of sight". A line of sight is a line usually drawn from one object to another object to make sure nothing is in the way. For example, an enemy must shoot towards the player, but only if a wall is not between them.
There's collision_line() for that, and collision_* for other types of tests. But we want to use more of a circle sector shape. Essentially, an arc of sight.
This is very useful for effects such as a guard carrying around a flashlight; if the light shines on you, you're seen and the guard chases after you. But you can't get that effect without being a little creative.
I have included a partner gmk file, so you can see the effect visually. In this file you play as a little blue guy walking around trying to find the diamonds. Also in the area are red guys sauntering around, guarding these diamonds. If they see you, they chase after you and if they catch you, you die. Run out of their sight and they continue pacing around again.
First I'd like you to download and run this file to see the final effect.
Note: this tutorial assumes you have at least a basic knowledge of geometry. More specifically, you must know what a circle's radius is.
The partner file includes most of the direct info for a practical example, but on the GMC I posted a thread that will describe the concept behind this arc of sight. The basic theory is that we need a different shape than can be provided by Game Maker's functions. This is the circle sector. Check here for the full article.