1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 14:37:44 +00:00
sapphire/src/servers/Scripts/common/CmnDefHousingSignboard.cpp

64 lines
2 KiB
C++
Raw Normal View History

#include <ScriptObject.h>
#include <Actor/Player.h>
2018-11-10 19:00:13 +01:00
#include <Zone/Zone.h>
#include <Zone/HousingZone.h>
2018-11-10 23:47:19 +01:00
#include <Network/PacketWrappers/ActorControlPacket143.h>
#include <Network/CommonActorControl.h>
2018-10-28 21:53:21 +01:00
using namespace Core;
2018-11-10 19:00:13 +01:00
class CmnDefHousingSignboard : public EventScript
{
public:
2018-11-10 19:00:13 +01:00
CmnDefHousingSignboard() : EventScript( 721031 )
{
}
void Scene00000( Entity::Player& player )
{
2018-11-10 19:00:13 +01:00
auto callback = [ this ]( Entity::Player& player, const Event::SceneResult& result )
{
// Purchase Land
if( result.param2 == 2 )
{
auto activeLand = player.getActiveLand();
auto territoryId = player.getTerritoryId();
auto pTerritory = player.getCurrentZone();
auto pHousing = std::dynamic_pointer_cast< HousingZone >( pTerritory );
2018-11-10 19:11:43 +01:00
2018-11-10 23:47:19 +01:00
PurchaseResult res = pHousing->purchseLand( player, activeLand.plot,
static_cast< uint8_t >( result.param2 ) );
switch( res )
{
case PurchaseResult::SUCCESS:
{
auto screenMsgPkt = Network::Packets::Server::makeActorControl143( player.getId(),
Network::ActorControl::DutyQuestScreenMsg,
m_id, 0x98 );
player.queuePacket( screenMsgPkt );
}
case PurchaseResult::ERR_NOT_ENOUGH_GIL:
{
auto errorMsg = Network::Packets::Server::makeActorControl143( player.getId(),
Network::ActorControl::LogMsg,
4027 );
player.queuePacket( errorMsg );
}
}
2018-11-10 19:11:43 +01:00
2018-11-10 19:00:13 +01:00
}
};
player.playScene( getId(), 0, HIDE_HOTBAR, 0, 0, callback );
}
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
{
Scene00000( player );
}
};