From 511ddb39c0c57b701e58ec5396d7975bdccd24cc Mon Sep 17 00:00:00 2001 From: Karrz1 <127596890+Karrz1@users.noreply.github.com> Date: Mon, 16 Nov 2026 20:37:15 +0000 Subject: [PATCH] Units: SIN's collision height fix as he wrote it SIN's fix for creature models whose client data stores a negative 'unset' collision height (-20000000, model 34 and others): such a model now gets the default collision height (2.03128), and a mount height that is not set is ignored. Some raptors' melee swings failed the line of sight check because of it. This replaces our fix for the same bug, which took the top of the model's bounding box instead (CreatureModelDataEntry::GetCollisionHeight, removed). For those 68 models the height is now the default, not the model's own. Code by SIN (1amcoff1n), Invalid creature collision heights for 0.1.35. Applied as written; only the hunk position differs in our Unit.cpp. To build, the bot module's collisionprobe command now prints the raw model height (it called the removed helper). --- src/server/game/DataStores/DB2Structure.h | 10 ---------- src/server/game/Entities/Unit/Unit.cpp | 23 +++++++++++------------ 2 files changed, 11 insertions(+), 22 deletions(-) diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h index 74eedef72d..3bb92d8af8 100644 --- a/src/server/game/DataStores/DB2Structure.h +++ b/src/server/game/DataStores/DB2Structure.h @@ -1183,16 +1183,6 @@ struct CreatureModelDataEntry EnumFlag GetFlags() const { return static_cast(Flags); } - // Classic 1.60 client data: 67 models (142 displays, for example the Deviate Creeper's) carry -20000000 in CollisionHeight and - // CollisionWidth, a "not set" mark the client fills from the model's own bounds. Taken as a height it put those creatures' head - // 14 million yards under the ground, so nothing could see them (bots 0.1 y from a Deviate Creeper read "out of line of sight", - // Discord 2026-11-09). The top of the model's bounding box (GeoBox[5]) is the height then; 0 when that is not above the feet. - float GetCollisionHeight() const - { - if (CollisionHeight >= 0.0f) - return CollisionHeight; - return GeoBox[5] > 0.0f ? GeoBox[5] : 0.0f; - } }; struct CreatureTypeEntry diff --git a/src/server/game/Entities/Unit/Unit.cpp b/src/server/game/Entities/Unit/Unit.cpp index 9be10b0d61..0ceb71c560 100644 --- a/src/server/game/Entities/Unit/Unit.cpp +++ b/src/server/game/Entities/Unit/Unit.cpp @@ -15329,31 +15329,30 @@ bool Unit::VisibleAuraSlotCompare::operator()(AuraApplication* left, AuraApplica return left->GetSlot() < right->GetSlot(); } -// Returns collisionheight of the unit. If it is 0, it returns DEFAULT_COLLISION_HEIGHT. float Unit::GetCollisionHeight() const { - float scaleMod = GetObjectScale(); // 99% sure about this + CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.AssertEntry(GetNativeDisplayId()); + CreatureModelDataEntry const* modelData = sCreatureModelDataStore.AssertEntry(displayInfo->ModelID); + // Client models can store a negative sentinel for an unset collision height. + if (!std::isfinite(modelData->CollisionHeight) || modelData->CollisionHeight <= 0.0f) + return DEFAULT_COLLISION_HEIGHT; + + float const scaleMod = GetObjectScale(); + float collisionHeight = scaleMod * modelData->CollisionHeight * modelData->ModelScale * displayInfo->CreatureModelScale; if (IsMounted()) { if (CreatureDisplayInfoEntry const* mountDisplayInfo = sCreatureDisplayInfoStore.LookupEntry(GetMountDisplayId())) { if (CreatureModelDataEntry const* mountModelData = sCreatureModelDataStore.LookupEntry(mountDisplayInfo->ModelID)) { - CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.AssertEntry(GetNativeDisplayId()); - CreatureModelDataEntry const* modelData = sCreatureModelDataStore.AssertEntry(displayInfo->ModelID); - float const collisionHeight = scaleMod * ((mountModelData->MountHeight * mountDisplayInfo->CreatureModelScale) + (modelData->GetCollisionHeight() * modelData->ModelScale * displayInfo->CreatureModelScale * 0.5f)); - return collisionHeight == 0.0f ? DEFAULT_COLLISION_HEIGHT : collisionHeight; + if (std::isfinite(mountModelData->MountHeight) && mountModelData->MountHeight >= 0.0f) + collisionHeight = scaleMod * ((mountModelData->MountHeight * mountDisplayInfo->CreatureModelScale) + (modelData->CollisionHeight * modelData->ModelScale * displayInfo->CreatureModelScale * 0.5f)); } } } - //! Dismounting case - use basic default model data - CreatureDisplayInfoEntry const* displayInfo = sCreatureDisplayInfoStore.AssertEntry(GetNativeDisplayId()); - CreatureModelDataEntry const* modelData = sCreatureModelDataStore.AssertEntry(displayInfo->ModelID); - - float const collisionHeight = scaleMod * modelData->GetCollisionHeight() * modelData->ModelScale * displayInfo->CreatureModelScale; - return collisionHeight == 0.0f ? DEFAULT_COLLISION_HEIGHT : collisionHeight; + return std::isfinite(collisionHeight) && collisionHeight > 0.0f ? collisionHeight : DEFAULT_COLLISION_HEIGHT; } void Unit::AddWorldEffect(int32 worldEffectId)