Skip to content

Fix #3855: Add opt-in dimension/interior matching for colshapes - #5384

Open
iManGaaX wants to merge 3 commits into
multitheftauto:masterfrom
iManGaaX:resolve/issue-3855
Open

iManGaaX wants to merge 3 commits into
multitheftauto:masterfrom
iManGaaX:resolve/issue-3855

Conversation

@iManGaaX

Copy link
Copy Markdown
Contributor

Summary

Colshape hit detection never checked dimension or interior, so a colshape in dimension 1 would still fire onClientColShapeHit/onColShapeHit (and isElementWithinColShape would return true) for an element standing in dimension 0. setElementDimension also never re-evaluated an existing collision, so a stale collision stayed registered until the element moved out of the shape

Both checks are now available as opt-in per colshape flags, so nothing changes for existing servers or scripts

Closes #3855.

New functions

setColShapeCheckDimension(colshape, boolean)
getColShapeCheckDimension(colshape)

setColShapeCheckInterior(colshape, boolean)
getColShapeCheckInterior(colshape)

-- OOP
colshape:setCheckDimension(boolean)
colshape:getCheckInterior()

Both default to false, which keeps the current (documented) behaviour exactly as it is today

Event parameters

onColShapeHit/onColShapeLeave and onElementColShapeHi/onElementColShapeLeave (plus their client versions) now pass two additional arguments so scripts no longer have to resolve them manually:

addEventHandler("onColShapeHit", colshape, function(hitElement, matchingDimension, dimension, interior)
    outputChatBox(("%s dim=%d interior=%d"):format(getElementType(hitElement), dimension, interior))
end)

The extra arguments are appended at the end; the existing two keep their position, so current handlers are unaffected

Test plan

Set setColShapeCheckDimension/setColShapeCheckInterior on a colshape in another dimension, then walk in and out with diffrent dimensions and confirm that onColShapeHit/onColShapeLeave no longer fire for the mismatching dimension/interior, and that the new event arguments report the element's dimension and interior

Checklist

  • Your code should follow the coding guidelines.
  • Smaller pull requests are easier to review. If your pull request is beefy, your pull request should be reviewable commit-by-commit.

@FileEX FileEX added the enhancement New feature or request label Sep 23, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

setElementDimension doesn't work with colshapes

2 participants