mtasa-blue icon indicating copy to clipboard operation
mtasa-blue copied to clipboard

Add getVehicleEntryPoints

Open MegadreamsBE opened this issue 2 years ago • 5 comments

Fixes #2565

This PR adds a new function called getVehicleEntryPoints which returns a table containing the positions to 4 possible entry points to a vehicle. Note that this does not directly relate to the amount of doors a vehicle has as vehicles with two doors can have multiple entry points to the same door. This usually influences the type of animation that is being used which is most prominent with bikes (stepping onto the bike vs jumping onto it).

This function can be used alongside setPedEnterVehicle to make a ped enter a specific seat by first moving the ped to a entry point retrieved through getVehicleEntryPoints and then using setPedEnterVehicle to make them enter. At this time setPedEnterVehicle gives you no such control.

The non-OOP version returns a table containing 4 tables itself which hold the x, y, z coordinates of each entry point. The OOP version returns a table containing 4 Vector3's instead. When no entry points exist for a vehicle it will return false.

Test resources for both the non-OOP as OOP version of this function are provided on the bottom of this PR. These test resources display the entry points for each vehicle near you as seen in the screenshot below:

proxy_sa_2022-03-06_15-58-21

entrypoints.zip entrypoints-oop.zip

MegadreamsBE avatar Mar 06 '22 22:03 MegadreamsBE

are these points hardcoded or are they somehow affiliated with the seat or door dummy?

Einheit-101 avatar Mar 13 '22 00:03 Einheit-101

are these points hardcoded or are they somehow affiliated with the seat or door dummy?

Looking at the underlying logic of GetPositionToOpenCarDoor which is used by the game to figure out what point to get the ped to before making it enter the vehicle (it also causes the endless going around the vehicle as it tries to line up per the ALIGN task) it does seem to calculate these from some of the vehicle's dummies. Unfortunately I can't say for certain what these exact dummies are and how it derives these entry points from it.

MegadreamsBE avatar Mar 13 '22 00:03 MegadreamsBE