1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-07 11:17:46 +00:00
sapphire/src/scripts/common/aethernet/Aetheryte.cpp

126 lines
3.9 KiB
C++
Raw Normal View History

2018-06-18 13:14:11 +00:00
#include <ScriptObject.h>
2018-03-07 08:14:42 +01:00
#include <Actor/Player.h>
#include <Framework.h>
#include <Exd/ExdDataGenerated.h>
2018-03-07 08:14:42 +01:00
using namespace Sapphire;
2018-10-28 21:53:21 +01:00
class Aetheryte :
public Sapphire::ScriptAPI::EventScript
2018-03-07 08:14:42 +01:00
{
private:
constexpr static auto ACTION_ATTUNE = 0x13;
constexpr static auto ACTION_TELEPORT = 0x4;
constexpr static auto AETHERYTE_MENU_AETHERNET = 1;
constexpr static auto AETHERYTE_MENU_HOUSING = 2;
constexpr static auto AETHERYTE_MENU_HOME_POINT = 3;
constexpr static auto AETHERYTE_MENU_FAVORITE_POINT = 4;
constexpr static auto AETHERYTE_MENU_FAVORITE_POINT_SECURITY_TOKEN = 5;
2018-03-07 08:14:42 +01:00
public:
Aetheryte() :
Sapphire::ScriptAPI::EventScript( 0x00050000 )
{
}
2018-03-07 08:14:42 +01:00
void aethernet( uint32_t eventId, Entity::Player& player, uint64_t actorId )
{
if( player.isAetheryteRegistered( eventId & 0xFFFF ) )
{
player.playScene( eventId, 2, 0, [this]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param1 == 256 )
{
player.teleport( result.param2, 2 );
}
} );
}
else
{
player.eventActionStart( eventId, ACTION_ATTUNE,
[]( Entity::Player& player, uint32_t eventId, uint64_t additional )
{
player.registerAetheryte( eventId & 0xFFFF );
player.playScene( eventId, 3, 0, 0, 0 );
},
[]( Entity::Player& ply, uint32_t evntId, uint64_t additional )
{
}, 0 );
}
}
void aetheryte( uint32_t eventId, Entity::Player& player, uint64_t actorId )
{
if( player.isAetheryteRegistered( eventId & 0xFFFF ) )
{
player.playScene( eventId, 0, 1, [this]( Entity::Player& player, const Event::SceneResult& result )
2018-03-07 08:14:42 +01:00
{
if( result.param1 == 256 ) // set homepoint
{
player.setHomepoint( result.eventId & 0xFFFF );
player.sendQuestMessage( result.eventId, 2, 0xEA, 0, 0 );
}
else if( result.param1 == 512 ) // aethernet access
{
if( result.param2 == 4 )
{
player.teleport( result.param3, 2 );
}
else if( result.param2 == 2 ) // register favored destination
{
2018-03-07 08:14:42 +01:00
}
2018-03-07 08:14:42 +01:00
// else if( param2 == 0xC3E1 ) // register free destination
// {
//
// }
}
} );
}
else
{
player.eventActionStart( eventId, ACTION_ATTUNE,
[this]( Entity::Player& player, uint32_t eventId, uint64_t additional )
{
player.registerAetheryte( eventId & 0xFFFF );
2018-03-07 08:14:42 +01:00
if( player.isActionLearned( ACTION_TELEPORT ) )
{
player.sendQuestMessage( eventId, 0, 2, 0, 0 );
}
else
{
player.sendQuestMessage( eventId, 0, 1, 1, 0 );
player.learnAction( ACTION_TELEPORT );
}
},
[]( Entity::Player& player, uint32_t eventId, uint64_t additional )
{}, 0 );
}
}
void onTalk( uint32_t eventId, Entity::Player& player, uint64_t actorId ) override
{
auto pExdData = framework()->get< Sapphire::Data::ExdDataGenerated >();
if( !pExdData )
return;
auto aetherInfo = pExdData->get< Sapphire::Data::Aetheryte >( eventId & 0xFFFF );
if( !aetherInfo )
return;
if( aetherInfo->isAetheryte )
aetheryte( eventId, player, actorId );
else
aethernet( eventId, player, actorId );
}
};
EXPOSE_SCRIPT( Aetheryte );