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

55 lines
1.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"
2022-02-10 18:50:44 +01:00
#include "Territory/Territory.h"
2019-10-28 22:18:23 +01:00
#include <Exd/ExdData.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() :
2022-02-10 18:50:44 +01:00
Sapphire::ScriptAPI::EventScript( 0x00020000 )
{
}
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
{
2022-02-10 18:50:44 +01:00
auto& exdData = Common::Service< Sapphire::Data::ExdData >::ref();
2022-01-27 21:24:54 +01:00
auto warp = exdData.getRow< Excel::Warp >( eventId );
if( !warp )
return;
2022-02-10 18:50:44 +01:00
auto qualifiedPreResult = [ this ]( Entity::Player& player, const Event::SceneResult& result )
{
//eventMgr().playScene( player, result.eventId, 1, HIDE_HOTBAR, { 1 }, nullptr );
if( result.getResult( 0 ) == 1 && result.errorCode != Common::EventSceneError::EVENT_SCENE_ERROR_LUA_ERRRUN )
{
auto warp = this->exdData().getRow< Excel::Warp >( result.eventId );
if( warp )
{
auto popRangeInfo = instanceObjectCache().getPopRangeInfo( warp->data().PopRange );
if( popRangeInfo )
{
auto pTeri = teriMgr().getZoneByTerritoryTypeId( popRangeInfo->m_territoryTypeId );
warpMgr().requestMoveTerritory( player, Sapphire::Common::WARP_TYPE_TOWN_TRANSLATE,
pTeri->getGuId(), popRangeInfo->m_pos, popRangeInfo->m_rotation );
}
}
}
};
eventMgr().playScene( player, eventId, 0, HIDE_HOTBAR, { 1 }, qualifiedPreResult );
}
};
EXPOSE_SCRIPT( WarpTaxi );