2018-07-22 16:54:01 +10:00
|
|
|
#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-15 12:40:02 +01:00
|
|
|
#include <Zone/HousingMgr.h>
|
2018-11-10 23:47:19 +01:00
|
|
|
#include <Network/PacketWrappers/ActorControlPacket143.h>
|
|
|
|
#include <Network/CommonActorControl.h>
|
2018-11-15 12:40:02 +01:00
|
|
|
#include "Framework.h"
|
2018-11-10 23:47:19 +01:00
|
|
|
|
2018-07-22 16:54:01 +10:00
|
|
|
|
2018-10-28 21:53:21 +01:00
|
|
|
using namespace Core;
|
2018-11-11 12:10:57 +01:00
|
|
|
using namespace Network;
|
|
|
|
using namespace Packets;
|
|
|
|
using namespace Server;
|
2018-10-28 21:53:21 +01:00
|
|
|
|
2018-11-13 21:34:44 +11:00
|
|
|
class CmnDefHousingSignboard : public Sapphire::ScriptAPI::EventScript
|
2018-07-22 16:54:01 +10:00
|
|
|
{
|
|
|
|
public:
|
2018-11-13 21:34:44 +11:00
|
|
|
CmnDefHousingSignboard() : Sapphire::ScriptAPI::EventScript( 721031 )
|
2018-08-29 21:40:59 +02:00
|
|
|
{
|
|
|
|
}
|
2018-07-22 16:54:01 +10:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
void Scene00000( Entity::Player& player )
|
|
|
|
{
|
2018-11-10 19:00:13 +01:00
|
|
|
auto callback = [ this ]( Entity::Player& player, const Event::SceneResult& result )
|
|
|
|
{
|
2018-11-15 12:40:02 +01:00
|
|
|
auto pFw = getFramework();
|
|
|
|
if( !pFw )
|
|
|
|
return LandPurchaseResult::ERR_INTERNAL;
|
2018-11-10 19:00:13 +01:00
|
|
|
// 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-16 17:07:22 +01:00
|
|
|
auto pHouMgr = pFw->get< Core::HousingMgr >();
|
2018-11-10 19:11:43 +01:00
|
|
|
|
2018-11-19 09:40:44 +01:00
|
|
|
LandPurchaseResult res = pHouMgr->purchaseLand( player, activeLand.plot,
|
2018-11-17 01:16:44 +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
|
|
|
{
|
2018-11-11 12:10:57 +01:00
|
|
|
auto screenMsgPkt = makeActorControl143( player.getId(), ActorControl::DutyQuestScreenMsg, m_id, 0x98 );
|
2018-11-10 23:47:19 +01:00
|
|
|
player.queuePacket( screenMsgPkt );
|
2018-11-11 23:55:34 +01:00
|
|
|
auto screenMsgPkt2 = makeActorControl143( player.getId(), ActorControl::LogMsg, 0x0D16, 0x1AA,
|
|
|
|
activeLand.ward + 1, activeLand.plot + 1 );
|
|
|
|
player.queuePacket( screenMsgPkt2 );
|
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
|
|
|
{
|
2018-11-11 17:20:47 +01:00
|
|
|
auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 3314 );
|
2018-11-10 23:47:19 +01:00
|
|
|
player.queuePacket( errorMsg );
|
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:
|
|
|
|
{
|
|
|
|
auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 3312 );
|
|
|
|
player.queuePacket( errorMsg );
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
|
|
|
case LandPurchaseResult::ERR_NO_MORE_LANDS_FOR_CHAR:
|
|
|
|
{
|
|
|
|
auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 3313 );
|
|
|
|
player.queuePacket( errorMsg );
|
2018-11-11 12:10:57 +01:00
|
|
|
break;
|
2018-11-11 17:20:47 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
case LandPurchaseResult::ERR_INTERNAL:
|
|
|
|
{
|
|
|
|
auto errorMsg = makeActorControl143( player.getId(), ActorControl::LogMsg, 1995 );
|
|
|
|
player.queuePacket( errorMsg );
|
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
|
|
|
}
|
|
|
|
};
|
|
|
|
|
|
|
|
player.playScene( getId(), 0, HIDE_HOTBAR, 0, 0, callback );
|
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
}
|
2018-07-22 16:54:01 +10:00
|
|
|
|
2018-08-29 21:40:59 +02:00
|
|
|
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
|
|
|
|
{
|
|
|
|
Scene00000( player );
|
|
|
|
}
|
2018-11-15 12:40:02 +01:00
|
|
|
};
|