Back to Main Page


This is a bit of info about what I consider to be an incredibly useful and powerful function in GTA V.

This is probably the last page of tips that I will ever post but I thought it was worth sharing this final page of info.

 

Angled Areas - Precision location checking.


Like most people, I used to use distance checking for every type of location check. Are we near a vehicle door, check the distance from the door. Are we near a specific location, check the distance from the location, etc... Most of the time this is fine but there are occasions when it can also be a pain.

Take this image for instance:

Imagine if you needed to check which door you were closest to. The fastest way to check distance, is with the distance-squared method, but that relies on X and Y checking alone. So in that instance, you are the same distance from every door, no matter which floor you are on. So then you have to start calculating the height, to know which level you're on. This is a prime example of a situation where Angled-Areas work really well.

You can see here how 3 angled areas detect you on the different floors with no problem.

This is because the checking area is very precisely defined. To define an angled area, you need three parameters.

1) The Origin - This is the point at the back of the angled area.

2) The Edge - This is the point at the front edge of the angled area.

3) The Angle (or width) - This defines the width of the base of the angled area.

The three parameters form a 3D Wedge shape and that is the area you are detected inside. The next two images show the definitions in a more relevant way. The first shows the parameters, the second shows the wedge area that these parameters define.

The game uses these checks a lot and on a scale that is quite simply vast at times. There is one check around the Alamo Sea area and the width is around 1200 metres wide and I think about 600 metres long, it was a huge area.

The real power of these checks is they are not confined to the axis limitations of a normal rectangle-area check. By that I mean that if you define a top-left corner and a bottom-right corner on a normal rectangle check, the sides run exactly East to West and North to South. Because these angled areas are simply defined by two points, they can check in any direction, as is shown in this next image. This is the telescope checking from my Players Extended mod and you can see how each area is aligned with the telescope prop direction, simply by setting the origin and edge at an offset from the prop.

So instead of checking a circular area, that could detect you too far to either side, you can define a very precise window, directly behind the prop... or vehicle.

This next image shows how extensively I use them in my Courier Services mod. To the left is the van pickup area, ahead at the top of the stairs is the office area and you can see the area attached to the back of the van, which is green because I am inside that area.

So how do you use them?

Function.Call<bool>(Hash.IS_ENTITY_IN_ANGLED_AREA, entity.Handle, origin.X, origin.Y, origin.Z, edge.X, edge.Y, edge.Z, angle, 0, true, 0);

That's all you need to do and that will return true if you are inside the detection area. There are several other very similar checks for a point being inside the area, for detecting bullets, clearing areas of vehicles, setting roads etc... The game uses them a lot and to be honest, it's no surprise.

So if you want an alternative to distance checking and you need it to check in a very specific area, give these a try.