fix(Core/Unit): Improve vehicle exit safety checks and fallback logic#24612
fix(Core/Unit): Improve vehicle exit safety checks and fallback logic#24612sogladev wants to merge 3 commits intoazerothcore:masterfrom
Conversation
|
I've got vehicles to consistently drop players OOB, but admittedly that's not really hard to do: #24270 |
Adds line of sight and floor height validation to ensure unit exits occur at safe, reachable locations. Falls back to vehicle base position.
12dfd14 to
66a8dbd
Compare
I added a line of sight and floor check to fix seatAddon repositioning to invalid locations. This fixes your Gal'darah Impale issue too |
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 1 out of 1 changed files in this pull request and generated 2 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| else if (seatAddon->ExitParameter == VehicleExitParameters::VehicleExitParamDest) | ||
| pos.Relocate({ seatAddon->ExitParameterX, seatAddon->ExitParameterY, seatAddon->ExitParameterZ, seatAddon->ExitParameterO }); | ||
|
|
||
| bool isInLoS = GetMap()->isInLineOfSight(GetPositionX(), GetPositionY(), GetPositionZ(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), GetPhaseMask(), LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::Nothing); |
There was a problem hiding this comment.
The LoS check uses Map::isInLineOfSight with raw (x,y,z) from the unit and target position. Unlike WorldObject::IsWithinLOS/IsWithinLOSInMap, this does not account for collision height / hit-sphere points and can produce false negatives (e.g., ray intersecting terrain when both points are near the ground), causing the code to incorrectly fall back to the vehicle's position. Consider using the existing LOS helper on WorldObject/Unit (or at least adding collision-height offsets) for a more reliable check here.
| bool isInLoS = GetMap()->isInLineOfSight(GetPositionX(), GetPositionY(), GetPositionZ(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), GetPhaseMask(), LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::Nothing); | |
| bool isInLoS = IsWithinLOSInMap(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::Nothing); |
There was a problem hiding this comment.
This signature doesn't exist.
| pos.Relocate({ seatAddon->ExitParameterX, seatAddon->ExitParameterY, seatAddon->ExitParameterZ, seatAddon->ExitParameterO }); | ||
|
|
||
| bool isInLoS = GetMap()->isInLineOfSight(GetPositionX(), GetPositionY(), GetPositionZ(), pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ(), GetPhaseMask(), LINEOFSIGHT_ALL_CHECKS, VMAP::ModelIgnoreFlags::Nothing); | ||
| float floorZ = vehicleBase->GetMapHeight(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); |
There was a problem hiding this comment.
floorZ is computed via vehicleBase->GetMapHeight(...), but GetMapHeight internally offsets the provided Z by the caller object's collision height. Using the vehicle base (often much larger than the passenger) can change which surface is detected under (x,y), and may incorrectly trigger the fallback. Using the passenger (this->GetMapHeight) or calling Map::GetHeight with an explicit Z offset would avoid vehicle-size-dependent results.
| float floorZ = vehicleBase->GetMapHeight(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); | |
| float floorZ = GetMapHeight(pos.GetPositionX(), pos.GetPositionY(), pos.GetPositionZ()); |
Changes Proposed:
This PR proposes changes to:
AI-assisted Pull Requests
Important
While the use of AI tools when preparing pull requests is not prohibited, contributors must clearly disclose when such tools have been used and specify the model involved.
Contributors are also expected to fully understand the changes they are submitting and must be able to explain and justify those changes when requested by maintainers.
Issues Addressed:
#15831 (comment)
SOURCE:
The changes have been validated through:
Tests Performed:
This PR has been:
.go xyz 1919.7325 795.66583 135.66655 604 4.763204.go xyz 3320.7324 493.23688 74.50289 615 4.09756How to Test the Changes:
Known Issues and TODO List:
How to Test AzerothCore PRs
When a PR is ready to be tested, it will be marked as [WAITING TO BE TESTED].
You can help by testing PRs and writing your feedback here on the PR's page on GitHub. Follow the instructions here:
http://www.azerothcore.org/wiki/How-to-test-a-PR
REMEMBER: when testing a PR that changes something generic (i.e. a part of code that handles more than one specific thing), the tester should not only check that the PR does its job (e.g. fixing spell XXX) but especially check that the PR does not cause any regression (i.e. introducing new bugs).
For example: if a PR fixes spell X by changing a part of code that handles spells X, Y, and Z, we should not only test X, but we should test Y and Z as well.