1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-03 01:07:47 +00:00
sapphire/src/scripts/common/GilShop.cpp

60 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>
using namespace Sapphire;
2018-10-28 21:53:21 +01:00
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 )
{
auto shopMgr = framework()->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
// can't sell if the vendor is yourself (eg, housing permit shop)
else if( result.param2 == 2 && result.actorId != player.getId() )
{
2018-07-22 23:20:12 +10:00
}
2020-01-08 18:21:30 +09:00
player.playGilShop( result.eventId, SCENE_FLAGS, result.param2, 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 )
{
player.playGilShop( result.eventId, SCENE_FLAGS, 0, std::bind( &GilShop::shopInteractionCallback, this, std::placeholders::_1, std::placeholders::_2 ) );
}
};
EXPOSE_SCRIPT( GilShop );