diff --git a/src/scripts/common/eobj/HousingEstateEntrance.cpp b/src/scripts/common/eobj/HousingEstateEntrance.cpp index 8f1b8298..0267323e 100644 --- a/src/scripts/common/eobj/HousingEstateEntrance.cpp +++ b/src/scripts/common/eobj/HousingEstateEntrance.cpp @@ -56,7 +56,7 @@ public: Common::FFXIVARR_POSITION3 pos; - auto land = zone->getLand( eobj.getHousingLink() >> 8 ); + auto land = zone->getLand( eobj.getHousingLink() ); if( !land ) return; diff --git a/src/scripts/common/warptaxi/HousingWarpTaxiExitEstate.cpp b/src/scripts/common/warptaxi/HousingWarpTaxiExitEstate.cpp index d35fdcd3..d0149236 100644 --- a/src/scripts/common/warptaxi/HousingWarpTaxiExitEstate.cpp +++ b/src/scripts/common/warptaxi/HousingWarpTaxiExitEstate.cpp @@ -1,6 +1,15 @@ #include #include +#include +#include +#include +#include + +#include "Territory/InstanceObjectCache.h" +#include "Territory/Territory.h" +#include "Territory/Housing/HousingInteriorTerritory.h" + using namespace Sapphire; class HousingWarpTaxiExitEstate : public Sapphire::ScriptAPI::EventScript @@ -17,8 +26,35 @@ public: { if( result.getResult( 0 ) == 1 ) { - eventMgr().eventFinish( player, result.eventId, 1 ); - player.exitInstance(); + auto& terriMgr = Common::Service< Sapphire::World::Manager::TerritoryMgr >::ref(); + auto pHZone = terriMgr.getTerritoryByGuId( player.getTerritoryId() ); + if( !pHZone ) + return; + auto zone = std::dynamic_pointer_cast< World::Territory::Housing::HousingInteriorTerritory >( pHZone ); + if( !zone ) + return; + + auto landIdent = zone->getLandIdent(); + + int housingIndex; + if( landIdent.territoryTypeId == 339 ) + housingIndex = 0; + else if( landIdent.territoryTypeId == 340 ) + housingIndex = 1; + else if( landIdent.territoryTypeId == 341 ) + housingIndex = 2; + + auto& exdData = Common::Service< Data::ExdData >::ref(); + auto info = exdData.getRow< Excel::HousingLandSet >( housingIndex ); + + auto landInfo = info->_data.Lands[ landIdent.landId ]; + auto& instanceObjectCache = Common::Service< InstanceObjectCache >::ref(); + auto exitRange = instanceObjectCache.getPopRange( landInfo.ExitPopRange ); + + Common::FFXIVARR_POSITION3 pos{ exitRange->data.transform.translation.x, exitRange->data.transform.translation.y, exitRange->data.transform.translation.z }; + float rot = Common::Util::eulerToDirection( { exitRange->data.transform.rotation.x, exitRange->data.transform.rotation.y, exitRange->data.transform.rotation.z } ); + + warpMgr().requestMoveTerritory( player, Common::WarpType::WARP_TYPE_NORMAL, landIdent.territoryTypeId << 16 | landIdent.wardNum, pos, rot ); } } ); } diff --git a/src/world/Manager/WarpMgr.cpp b/src/world/Manager/WarpMgr.cpp index 92defc4c..f8baf892 100644 --- a/src/world/Manager/WarpMgr.cpp +++ b/src/world/Manager/WarpMgr.cpp @@ -5,6 +5,7 @@ #include "TerritoryMgr.h" #include +#include #include "Task/MoveTerritoryTask.h" #include "Task/WarpTask.h" @@ -30,7 +31,10 @@ void WarpMgr::requestMoveTerritory( Entity::Player& player, Common::WarpType war auto pTeri = teriMgr.getTerritoryByGuId( targetTerritoryId ); if( !pTeri ) + { + Logger::error( "Unable to find target territory instance {}", targetTerritoryId ); return; + } m_entityIdToWarpInfoMap[ player.getId() ] = { targetTerritoryId, warpType, targetPos, targetRot };