1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00

gilshops now work using the proper packet

This commit is contained in:
NotAdam 2018-07-23 00:05:44 +10:00
parent b8871519fe
commit 5ac4573bd3
3 changed files with 25 additions and 13 deletions

View file

@ -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 );
}
};

View file

@ -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;

View file

@ -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 );