From 448d7914485177bc256b5994b437dcc14f6d3893 Mon Sep 17 00:00:00 2001 From: roeming Date: Thu, 7 Sep 2023 14:37:02 -0400 Subject: [PATCH] Match setNearestBridge --- src/plugProjectNishimuraU/Ujia.cpp | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/src/plugProjectNishimuraU/Ujia.cpp b/src/plugProjectNishimuraU/Ujia.cpp index 1cc65027a..fab52f8f5 100644 --- a/src/plugProjectNishimuraU/Ujia.cpp +++ b/src/plugProjectNishimuraU/Ujia.cpp @@ -271,6 +271,33 @@ void Obj::setBridgeSearch() */ void Obj::setNearestBridge() { + this->mBridge = nullptr; + this->_2CC = 0.0f; + this->_2D0 = 0.0f; + + if(ItemBridge::mgr) + { + f32 radius = C_PARMS->mGeneral.mTerritoryRadius.mValue; + radius = SQUARE(radius); + Iterator i(ItemBridge::mgr); + CI_LOOP(i) + { + ItemBridge::Item* cBridge = static_cast(*i); + Vector3f v = (cBridge)->getStartPos(); + float newRad = sqrDistanceXZ(mPosition, v); + if(newRad < radius) + { + mBridge = cBridge; + radius = newRad; + } + } + } + + if (mBridge) + { + f32 width = mBridge->getStageWidth() - 20.0f; + _2CC = -(0.5f*width - (rand() * width / RAND_MAX)); + } /* stwu r1, -0x50(r1) mflr r0