Skip to content

Conversation

@FileEX
Copy link
Member

@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
Member 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

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
Member 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
Member

@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

@Dutchman101
Copy link
Member

Thanks for addressing all code reviews, will merge now; please add it to wiki.

@Dutchman101 Dutchman101 merged commit aa90aa5 into multitheftauto:master Dec 21, 2024
6 checks passed
MTABot pushed a commit that referenced this pull request Dec 21, 2024
aa90aa5 Add new function testSphereAgainstWorld (Close #646) (#3787)
@FileEX FileEX deleted the feature/testSphereAgainstWorld branch December 22, 2024 01:01
@botder botder added this to the 1.6.1 milestone Dec 22, 2024
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

7 participants