mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-06 18:57:45 +00:00
somewhat working gilshops
This commit is contained in:
parent
18a1ab79d6
commit
9ab7d5c68a
6 changed files with 39 additions and 14 deletions
|
@ -65,6 +65,8 @@ struct FFXIVIpcEventHandlerReturn : FFXIVIpcBasePacket< ReturnEventHandler >
|
|||
/* 0008 */ uint16_t param2;
|
||||
/* 000A */ char pad_000A[2];
|
||||
/* 000C */ uint16_t param3;
|
||||
/* 000E */ char pad_000E[2];
|
||||
/* 0010 */ uint16_t tradeQuantity;
|
||||
};
|
||||
|
||||
struct FFXIVIpcEnterTerritoryHandler : FFXIVIpcBasePacket< EnterTeriEventHandler >
|
||||
|
|
|
@ -7,13 +7,33 @@ public:
|
|||
GilShop() : EventScript( 0x00041 )
|
||||
{}
|
||||
|
||||
constexpr static auto SCENE_FLAGS = HIDE_HOTBAR | NO_DEFAULT_CAMERA;
|
||||
|
||||
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 );
|
||||
|
||||
player.sendDebug("got tradeQuantity: " + std::to_string( result.tradeQuantity ) );
|
||||
player.playScene( result.eventId, 10, SCENE_FLAGS, 0, 0, shopInteractionCallback );
|
||||
return;
|
||||
}
|
||||
|
||||
// exit
|
||||
player.playScene( result.eventId, 255, SCENE_FLAGS );
|
||||
}
|
||||
|
||||
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
|
||||
{
|
||||
auto callback = [actorId]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
player.playGilShop( actorId, result.eventId, HIDE_HOTBAR | NO_DEFAULT_CAMERA );
|
||||
};
|
||||
|
||||
player.playScene( eventId, 0, HIDE_HOTBAR | NO_DEFAULT_CAMERA, 0, 2, callback );
|
||||
player.playScene( eventId, 0, SCENE_FLAGS, 0, 2, shopCallback );
|
||||
}
|
||||
};
|
|
@ -58,7 +58,8 @@ public:
|
|||
/*! play a subevent */
|
||||
void playScene( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam2, uint32_t eventParam3 );
|
||||
|
||||
void playGilShop( uint64_t actorId, uint32_t eventId, uint32_t flags );
|
||||
void playGilShop( uint32_t eventId, uint32_t flags,
|
||||
Event::EventHandler::SceneReturnCallback eventCallback );
|
||||
|
||||
void directorPlayScene( uint32_t eventId, uint32_t scene, uint32_t flags, uint32_t eventParam3, uint32_t eventParam4, uint32_t eventParam5 = 0 );
|
||||
|
||||
|
|
|
@ -133,20 +133,19 @@ void Core::Entity::Player::playScene( uint32_t eventId, uint32_t scene,
|
|||
playScene( eventId, scene, flags, eventParam2, eventParam3, 0, eventCallback );
|
||||
}
|
||||
|
||||
void Core::Entity::Player::playGilShop( uint64_t actorId, uint32_t eventId, uint32_t flags )
|
||||
void Core::Entity::Player::playGilShop( uint32_t eventId, uint32_t flags,
|
||||
Event::EventHandler::SceneReturnCallback eventCallback )
|
||||
{
|
||||
auto pEvent = getEvent( eventId );
|
||||
auto pEvent = bootstrapSceneEvent( eventId, flags );
|
||||
if( !pEvent )
|
||||
{
|
||||
auto pLog = g_fw.get< Logger >();
|
||||
pLog->error( "Could not find event " + std::to_string( eventId ) + ", event has not been started!" );
|
||||
return;
|
||||
}
|
||||
|
||||
pEvent->setEventReturnCallback( eventCallback );
|
||||
|
||||
auto openGilShopPacket = makeZonePacket< Server::FFXIVIpcEventOpenGilShop >( getId() );
|
||||
openGilShopPacket->data().eventId = eventId;
|
||||
openGilShopPacket->data().sceneFlags = flags;
|
||||
openGilShopPacket->data().actorId = actorId;
|
||||
openGilShopPacket->data().actorId = getId();
|
||||
|
||||
openGilShopPacket->data().scene = 10;
|
||||
|
||||
|
|
|
@ -12,6 +12,7 @@ namespace Core {
|
|||
uint16_t param1;
|
||||
uint16_t param2;
|
||||
uint16_t param3;
|
||||
uint16_t tradeQuantity;
|
||||
};
|
||||
|
||||
class EventHandler
|
||||
|
|
|
@ -203,6 +203,7 @@ void Core::Network::GameConnection::eventHandlerReturn( const Packets::FFXIVARR_
|
|||
const auto& param1 = packet.data().param1;
|
||||
const auto& param2 = packet.data().param2;
|
||||
const auto& param3 = packet.data().param3;
|
||||
const auto& tradeQuantity = packet.data().tradeQuantity;
|
||||
|
||||
std::string eventName = Event::getEventName( eventId );
|
||||
|
||||
|
@ -228,6 +229,7 @@ void Core::Network::GameConnection::eventHandlerReturn( const Packets::FFXIVARR_
|
|||
result.param1 = param1;
|
||||
result.param2 = param2;
|
||||
result.param3 = param3;
|
||||
result.tradeQuantity = tradeQuantity;
|
||||
eventCallback( player, result );
|
||||
}
|
||||
// we might have a scene chain callback instead so check for that too
|
||||
|
|
Loading…
Add table
Reference in a new issue