diff --git a/src/servers/Scripts/common/GilShop.cpp b/src/servers/Scripts/common/GilShop.cpp index f496074d..8ff007f4 100644 --- a/src/servers/Scripts/common/GilShop.cpp +++ b/src/servers/Scripts/common/GilShop.cpp @@ -4,20 +4,36 @@ class GilShop : public EventScript { public: - GilShop() : EventScript( 0x00041 ) + GilShop() : EventScript( 0x00040001 ) {} constexpr static auto SCENE_FLAGS = HIDE_HOTBAR | NO_DEFAULT_CAMERA; + void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override + { + player.playScene( eventId, 0, SCENE_FLAGS, 0, 2, shopCallback ); + } + +private: static void shopInteractionCallback( Entity::Player& player, const Event::SceneResult& result ) { // item purchase if( result.param1 == 768 ) { - //player.playGilShop( result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA, shopInteractionCallback ); + // buy + if( result.param2 == 1 ) + { - player.sendDebug("got tradeQuantity: " + std::to_string( result.param4 ) ); - player.playScene( result.eventId, 10, SCENE_FLAGS, 0, 0, shopInteractionCallback ); + } + + // sell + else if( result.param2 == 2 ) + { + + } + + player.sendDebug( "got tradeQuantity: " + std::to_string( result.param4 ) ); + player.playGilShop( result.eventId, SCENE_FLAGS, shopInteractionCallback ); return; } @@ -27,13 +43,6 @@ public: static void shopCallback( Entity::Player& player, const Event::SceneResult& result ) { - //player.playGilShop( result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA, shopInteractionCallback ); - - player.playScene( result.eventId, 10, SCENE_FLAGS, 0, 0, shopInteractionCallback ); - } - - void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override - { - player.playScene( eventId, 0, SCENE_FLAGS, 0, 2, shopCallback ); + player.playGilShop( result.eventId, SCENE_FLAGS, shopInteractionCallback ); } }; \ No newline at end of file diff --git a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp index d8cbf1f7..61d7e06c 100644 --- a/src/servers/sapphire_zone/Actor/PlayerEvent.cpp +++ b/src/servers/sapphire_zone/Actor/PlayerEvent.cpp @@ -140,7 +140,9 @@ void Core::Entity::Player::playGilShop( uint32_t eventId, uint32_t flags, if( !pEvent ) return; + pEvent->setPlayedScene( true ); pEvent->setEventReturnCallback( eventCallback ); + pEvent->setSceneChainCallback( nullptr ); auto openGilShopPacket = makeZonePacket< Server::FFXIVIpcEventOpenGilShop >( getId() ); openGilShopPacket->data().eventId = eventId; diff --git a/src/servers/sapphire_zone/Script/ScriptMgr.cpp b/src/servers/sapphire_zone/Script/ScriptMgr.cpp index fe87b6a4..f9ca9890 100644 --- a/src/servers/sapphire_zone/Script/ScriptMgr.cpp +++ b/src/servers/sapphire_zone/Script/ScriptMgr.cpp @@ -174,6 +174,7 @@ bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorI uint16_t eventType = eventId >> 16; uint32_t scriptId = eventId; + // todo: replace this shit with something more flexible allowing for handlers for an entire type without a bunch of if statements // aethernet/aetherytes need to be handled separately if( eventType == Event::EventHandler::EventHandlerType::Aetheryte ) { @@ -184,7 +185,7 @@ bool Core::Scripting::ScriptMgr::onTalk( Entity::Player& player, uint64_t actorI } else if( eventType == Event::EventHandler::EventHandlerType::Shop ) { - scriptId = 0x00041; + scriptId = 0x00040001; } auto script = m_nativeScriptMgr->getScript< EventScript >( scriptId );