1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-03 17:27:47 +00:00
sapphire/src/scripts/common/warptaxi/WarpTaxi.cpp

90 lines
2.7 KiB
C++
Raw Normal View History

#include <ScriptObject.h>
#include <Actor/Player.h>
2019-10-28 22:18:23 +01:00
#include <datReader/DatCategories/bg/LgbTypes.h>
2020-01-06 20:19:42 +11:00
#include <datReader/DatCategories/bg/lgb.h>
2019-10-28 22:18:23 +01:00
#include "Territory/InstanceObjectCache.h"
#include <Exd/ExdDataGenerated.h>
#include <Manager/PlayerMgr.h>
2020-03-01 01:00:57 +11:00
#include <Service.h>
using namespace Sapphire;
class WarpTaxi : public Sapphire::ScriptAPI::EventScript
{
public:
WarpTaxi() :
Sapphire::ScriptAPI::EventScript( 0x0002005a )
{
}
void inner( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param1 == 256 ) // exit
{
player.eventFinish( 1310721, 0 );
player.eventFinish( getId(), 1 );
}
else if( result.param1 == 768 ) // teleport to ward
{
player.eventFinish( 1310721, 0 );
player.eventFinish( getId(), 1 );
2020-03-01 01:00:57 +11:00
auto& exdData = Common::Service< Data::ExdDataGenerated >::ref();
auto& popRange = Common::Service< Sapphire::InstanceObjectCache >::ref();
2019-10-28 22:18:23 +01:00
2020-03-01 01:00:57 +11:00
auto warp = exdData.get< Sapphire::Data::Warp >( getId() );
if( !warp )
return;
2020-03-01 01:00:57 +11:00
auto& playerMgr = Common::Service< Sapphire::World::Manager::PlayerMgr >::ref();
2019-10-28 22:18:23 +01:00
2020-03-01 01:00:57 +11:00
auto pPop = popRange.getPopRange( warp->territoryType, warp->popRange );
2019-10-28 22:18:23 +01:00
if( !pPop )
{
std::cout << "not found...";
}
else
{
std::cout << "found!!";
}
2020-03-01 01:00:57 +11:00
playerMgr.movePlayerToLandDestination( player, warp->popRange, result.param3 );
}
else
{
player.playScene( 1310721, 0, HIDE_HOTBAR, 0, 1, 341,
std::bind( &WarpTaxi::inner, this, std::placeholders::_1, std::placeholders::_2 ) );
}
}
void inner2( Entity::Player& player, uint64_t actorId )
{
player.playScene( getId(), 0, HIDE_HOTBAR, 0, 0, 32529,
[this, actorId]( Entity::Player& player, const Event::SceneResult& result )
{
player.eventStart( actorId, 1310721, Event::EventHandler::Nest, 1, 0 );
player.playScene( 1310721, 0, HIDE_HOTBAR, 0, 1, 341,
std::bind( &WarpTaxi::inner, this, std::placeholders::_1, std::placeholders::_2 ) );
} );
}
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
{
2020-03-01 01:00:57 +11:00
auto exdData = Common::Service< Sapphire::Data::ExdDataGenerated >::ref();
2020-03-01 01:00:57 +11:00
auto warp = exdData.get< Sapphire::Data::Warp >( eventId );
if( !warp )
return;
player.eventStart( actorId, warp->conditionSuccessEvent, Event::EventHandler::Nest, 0, 0,
std::bind( &WarpTaxi::inner2, this, std::placeholders::_1, std::placeholders::_2 ) );
player.playScene( warp->conditionSuccessEvent, 0, HIDE_HOTBAR, 0, 0, 7, nullptr );
}
};
EXPOSE_SCRIPT( WarpTaxi );