1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 06:27:45 +00:00
sapphire/src/scripts/common/housing/CmnDefHousingSignboard.cpp

91 lines
2.5 KiB
C++
Raw Normal View History

#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Territory/HousingZone.h>
#include <Manager/HousingMgr.h>
#include <Network/PacketWrappers/ActorControlSelfPacket.h>
2018-11-10 23:47:19 +01:00
#include <Network/CommonActorControl.h>
#include <Exd/ExdDataGenerated.h>
2020-03-01 01:00:57 +11:00
#include <Service.h>
2018-11-10 23:47:19 +01:00
using namespace Sapphire;
2018-11-11 12:10:57 +01:00
using namespace Network;
using namespace Packets;
using namespace Server;
using namespace Sapphire::World::Manager;
2018-10-28 21:53:21 +01:00
class CmnDefHousingSignboard : public Sapphire::ScriptAPI::EventScript
{
public:
CmnDefHousingSignboard() : Sapphire::ScriptAPI::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.getCurrentTerritory();
2018-11-10 19:00:13 +01:00
auto pHousing = std::dynamic_pointer_cast< HousingZone >( pTerritory );
2020-03-01 01:00:57 +11:00
auto& pHouMgr = Common::Service< HousingMgr >::ref();
2020-03-01 01:00:57 +11:00
LandPurchaseResult res = pHouMgr.purchaseLand( player, activeLand.plot,
2018-11-19 11:55:29 +01:00
static_cast< uint8_t >( result.param2 ) );
2018-11-10 23:47:19 +01:00
switch( res )
{
2018-11-11 17:20:47 +01:00
case LandPurchaseResult::SUCCESS:
2018-11-10 23:47:19 +01:00
{
2019-10-09 18:42:25 +02:00
auto screenMsgPkt = makeActorControlSelf( player.getId(), ActorControl::DutyQuestScreenMsg, m_id, 0x98 );
2018-11-10 23:47:19 +01:00
player.queuePacket( screenMsgPkt );
player.sendLogMessage( 0x0D16, pTerritory->getTerritoryTypeInfo()->placeName, activeLand.ward + 1, activeLand.plot + 1 );
2018-11-11 12:10:57 +01:00
break;
2018-11-10 23:47:19 +01:00
}
2018-11-11 12:10:57 +01:00
2018-11-11 17:20:47 +01:00
case LandPurchaseResult::ERR_NOT_ENOUGH_GIL:
2018-11-10 23:47:19 +01:00
{
player.sendLogMessage( 3314 );
2018-11-11 12:10:57 +01:00
break;
2018-11-10 23:47:19 +01:00
}
2018-11-11 12:10:57 +01:00
2018-11-11 17:20:47 +01:00
case LandPurchaseResult::ERR_NOT_AVAILABLE:
{
player.sendLogMessage( 3312 );
2018-11-11 17:20:47 +01:00
break;
}
case LandPurchaseResult::ERR_NO_MORE_LANDS_FOR_CHAR:
{
player.sendLogMessage( 3313 );
2018-11-11 12:10:57 +01:00
break;
2018-11-11 17:20:47 +01:00
}
case LandPurchaseResult::ERR_INTERNAL:
{
player.sendLogMessage( 1995 );
2018-11-11 12:10:57 +01:00
break;
2018-11-11 17:20:47 +01:00
}
2018-11-10 23:47:19 +01:00
}
2018-11-10 19:11:43 +01:00
2018-11-10 19:00:13 +01:00
}
2018-12-02 02:01:41 +01:00
return LandPurchaseResult::ERR_INTERNAL;
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 );
}
};
EXPOSE_SCRIPT( CmnDefHousingSignboard );