Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add new function testSphereAgainstWorld (Close #646) #3787

Open
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

FileEX
Copy link
Contributor

@FileEX FileEX commented Oct 10, 2024

This PR adds a new function testSphereAgainstWorld, which allows checking if there are any obstacles within a given radius.

Syntax

bool hit, element hitElement, int modelID, float elementPositionX, float elementPositionY, float elementPositionZ, float elementRotationX, float elementRotationY, float elementRotationZ, int lodID, string type = testSphereAgainstWorld(float x, float y, float z, float radius [, element ignoredElement = nil, bool checkBuildings = true, checkVehicles = true, checkPeds = true, checkObjects = true, checkDummies = true, ignoreSomeObjectsForCamera = false ] )

hit - Indicates whether a collision was detected.
hitElement - The element that was detected. If it wasn't created in MTA, it will be nil.
elementPositionX, elementPositionY, elementPositionZ - World position of the detected element
elementRotationX, elementRotationY, elementRotationZ - World rotation of the element
modelID - The ID of the element.
lodID - The ID of the element's LOD (or 0).
entityType - The type of the element (building, vehicle, ped, object, dummy)

The modelID, lodID, and entityType parameters are returned even if hitElement is nil.

Closes #646

@FileEX FileEX changed the title Add new function testSphereAgainstWorld Add new function testSphereAgainstWorld (Close #646) Oct 10, 2024
@Einheit-101
Copy link

Would it be possible to return the XYZ where the hit got detected?

@FileEX
Copy link
Contributor Author

FileEX commented Oct 10, 2024

Would it be possible to return the XYZ where the hit got detected?

Yes, I'll add it tomorrow

@CrosRoad95
Copy link
Contributor

make 7 arguments in total: from, to, options "processLineOfSight" already has shown that using function with extensive amount of arguments is problematic, prune to errors, hard to extend.
Same with return value

@FileEX
Copy link
Contributor Author

FileEX commented Oct 11, 2024

Personally, I don’t see anything difficult in using functions like processLineOfSight, which return multiple values. You just need to familiarize yourself with the syntax and the example on the wiki. It doesn't cause any problems, errors, huge and difficult bugs, or any other made-up issues

@CrosRoad95

This comment was marked as abuse.

@FileEX

This comment was marked as outdated.

Copy link
Contributor

@Nico8340 Nico8340 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you solve TheNormalnij's request, then everything's fine

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

New function: testSphereAgainstWorld
5 participants