diff --git a/Source/Contents/Actors/SpriteDrawingPolicy.h b/Source/Contents/Actors/SpriteDrawingPolicy.h index 356bdbd2..19d0c9c5 100644 --- a/Source/Contents/Actors/SpriteDrawingPolicy.h +++ b/Source/Contents/Actors/SpriteDrawingPolicy.h @@ -8,6 +8,14 @@ struct SpriteFrameCell; struct SpriteRleImage; struct tagRECT; +struct AccessoryLayerDepth { + const int& bottomAccessory; + const int& topAccessory; + const int& middleAccessory; + + void OffsetLayerDepth(int layer, SpriteCellQuad& quad, float bottomDepth, float topDepth) const; +}; + struct SpriteDrawingPolicy { LuaScript& script; const unsigned char& newDrawOnTop; diff --git a/Source/Contents/SpriteLayerDepth.cpp b/Source/Contents/SpriteLayerDepth.cpp index 2d36a6d0..1373b038 100644 --- a/Source/Contents/SpriteLayerDepth.cpp +++ b/Source/Contents/SpriteLayerDepth.cpp @@ -9,14 +9,6 @@ constexpr float robeTopLayerThreshold = 320.0f; // GLOBAL: gl_24739 float g_cameraDistance = 300.0f; -struct AccessoryLayerDepth { - const int& bottomAccessory; - const int& topAccessory; - const int& middleAccessory; - - void OffsetLayerDepth(int layer, SpriteCellQuad& quad, float bottomDepth, float topDepth) const; -}; - // OFFSET: 0x0080DAA0 // FUNCTION: fn_10103 void SpriteDrawingPolicy::OffsetLayerDepth(int layer, SpriteCellQuad& quad, float bottomDepth, float topDepth) const { @@ -51,3 +43,147 @@ void SpriteDrawingPolicy::OffsetLayerDepth(int layer, SpriteCellQuad& quad, floa } // OFFSET: 0x0080E4D0 +// FUNCTION: fn_10107 +void AccessoryLayerDepth::OffsetLayerDepth(int layer, SpriteCellQuad& quad, float bottomDepth, float topDepth) const { + float bottom = bottomDepth; + float top = topDepth; + + switch (layer) { + case 1: + if (this->topAccessory == 1095) { + if (g_cameraDistance < 32.0f) { + bottom = bottomDepth - 0.000008f; + top = topDepth - 0.000008f; + } else { + bottom = bottomDepth - 0.0000005f; + top = topDepth - 0.0000005f; + } + } else if (g_cameraDistance < robeTopLayerThreshold) { + bottom = bottomDepth + 0.000025f; + top = topDepth + 0.000025f; + } + break; + case 2: + switch (this->bottomAccessory) { + case 1041: + case 1358: + case 1478: + case 1499: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = 0.0008f + bottomDepth; + top = 0.0008f + topDepth; + } else { + bottom = 0.00019f + bottomDepth; + top = 0.00019f + topDepth; + } + break; + case 1235: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = 0.0008f + bottomDepth; + top = 0.0008f + topDepth; + } else { + bottom = 0.00013f + bottomDepth; + top = 0.00013f + topDepth; + } + break; + case 1488: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = bottomDepth + 0.0008f; + top = topDepth + 0.0008f; + } else { + bottom = bottomDepth + 0.00019f; + top = topDepth + 0.00019f; + } + break; + default: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = bottomDepth + 0.000027f; + top = topDepth + 0.000027f; + } + break; + } + break; + case 3: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = bottomDepth + 0.00004f; + top = 0.0001f + topDepth; + } else { + top = 0.000045f + topDepth; + } + break; + case 4: + if (this->topAccessory == 1485) { + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = 0.00035f + bottomDepth; + top = 0.0006f + topDepth; + } else { + bottom = 0.00001f + bottomDepth; + top = 0.00015f + topDepth; + } + } else { + switch (this->middleAccessory) { + case 1318: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = 0.00025f + bottomDepth; + top = 0.0001f + topDepth; + } else { + bottom = 0.00005f + bottomDepth; + top = 0.00005f + topDepth; + } + break; + case 1354: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = bottomDepth + 0.00009f; + top = topDepth - 0.00005f; + } + break; + case 1363: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = bottomDepth + 0.000027f + 0.0004f; + top = topDepth + 0.000027f + 0.0007f; + } else { + bottom = bottomDepth + 0.00007f; + top = topDepth + 0.00017f; + } + break; + case 1582: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = bottomDepth + 0.0002f; + top = topDepth + 0.0002f; + } else { + bottom = bottomDepth + 0.00004f; + top = topDepth + 0.00006f; + } + break; + default: + if (g_cameraDistance < robeTopLayerThreshold) { + bottom = bottomDepth + 0.00003f; + top = topDepth + 0.00003f; + } + break; + } + } + break; + } + + quad.bottomDepth = bottom; + quad.topDepth = top; + + bool enabled = false; + double nearOffset = 0.0; + double farOffset = 0.0; + g_session.m_hotkeyScript->Call("OffsetItemPos_GetUppingBottomItem", "d>bll", this->bottomAccessory, &enabled, &nearOffset, &farOffset); + + if (layer == 2 && enabled) { + if (nearOffset == 0.0) { + nearOffset = 0.00025; + } + if (farOffset == 0.0) { + farOffset = 0.0001; + } + + const double offset = g_cameraDistance < robeTopLayerThreshold ? nearOffset : farOffset; + quad.bottomDepth = static_cast(static_cast(bottomDepth) + offset); + quad.topDepth = static_cast(static_cast(topDepth) + offset); + } +}