1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-03 09:17:47 +00:00
sapphire/src/servers/Scripts/common/GilShop.cpp

59 lines
1.7 KiB
C++
Raw Normal View History

#include <ScriptObject.h>
#include <Actor/Player.h>
2018-11-24 15:17:18 +11:00
#include <Framework.h>
#include <Manager/ShopMgr.h>
2018-10-28 21:53:21 +01:00
using namespace Core;
class GilShop :
public Sapphire::ScriptAPI::EventScript
{
public:
GilShop() :
Sapphire::ScriptAPI::EventScript( 0x00040000 )
{
}
constexpr static auto SCENE_FLAGS = HIDE_HOTBAR | NO_DEFAULT_CAMERA;
2018-07-22 23:20:12 +10:00
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
{
2018-11-24 15:17:18 +11:00
player.playScene( eventId, 0, SCENE_FLAGS, 0, 2, std::bind( &GilShop::shopCallback, this, std::placeholders::_1, std::placeholders::_2 ) );
}
private:
2018-11-24 15:17:18 +11:00
void shopInteractionCallback( Entity::Player& player, const Event::SceneResult& result )
{
// item purchase
if( result.param1 == 768 )
{
// buy
if( result.param2 == 1 )
{
2018-11-24 15:17:18 +11:00
auto shopMgr = getFramework()->get< Sapphire::World::Manager::ShopMgr >();
2018-11-24 15:17:18 +11:00
shopMgr->purchaseGilShopItem( player, result.eventId, result.param3, result.param4 );
}
2018-07-22 23:20:12 +10:00
2018-11-24 15:17:18 +11:00
// sell
else if( result.param2 == 2 )
{
2018-11-24 15:17:18 +11:00
// so apparently shops will always show a sell window
// BUT won't always let you sell stuff (eg, housing permit menu)
// there doesn't seem to be anything in gilshop exd for that, so maybe it's some shitty server hack?
2018-07-22 23:20:12 +10:00
}
2018-11-24 15:17:18 +11:00
player.playGilShop( result.eventId, SCENE_FLAGS, std::bind( &GilShop::shopInteractionCallback, this, std::placeholders::_1, std::placeholders::_2 ) );
return;
}
// exit
player.playScene( result.eventId, 255, SCENE_FLAGS );
}
2018-11-24 15:17:18 +11:00
void shopCallback( Entity::Player& player, const Event::SceneResult& result )
{
2018-11-24 15:17:18 +11:00
player.playGilShop( result.eventId, SCENE_FLAGS, std::bind( &GilShop::shopInteractionCallback, this, std::placeholders::_1, std::placeholders::_2 ) );
}
};