Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Implement Aetheryte Tickets #955

Merged
merged 3 commits into from
Jun 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/common/Common.h
Original file line number Diff line number Diff line change
Expand Up @@ -1790,6 +1790,7 @@ namespace Sapphire::Common
{
uint16_t targetAetheryte;
uint16_t cost;
bool useAetheryteTicket{ false };
};

enum EventSceneError : uint8_t
Expand Down
1 change: 1 addition & 0 deletions src/scripts/action/common/ActionTeleport5.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ class ActionTeleport5 : public Sapphire::ScriptAPI::ActionScript
auto teleportQuery = pPlayer->getTeleportQuery();

if( pPlayer->getCurrency( Common::CurrencyType::Gil ) < teleportQuery.cost ||
teleportQuery.useAetheryteTicket && !pPlayer->removeItem( 7569 ) ||
teleportQuery.targetAetheryte == 0 )
{
action.interrupt();
Expand Down
14 changes: 11 additions & 3 deletions src/scripts/common/aethernet/Aetheryte.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,10 +62,18 @@ class Aetheryte :
// eventParam4 (or params[1] if using EventPlay8, which is actually used on retail) anything bigger than 1 will show select instance menu item
eventMgr().playScene( player, eventId, 0, 1, { 1, 2 }, [ this ]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.numOfResults == 1 ) // set homepoint
if( result.numOfResults == 1 )
{
player.setHomepoint( result.eventId & 0xFFFF );
eventMgr().sendEventNotice( player, result.eventId, 2, 0xEA, 0, 0 );
auto cmd = result.getResult( 0 );
if( cmd == 1 ) // set homepoint
{
player.setHomepoint( result.eventId & 0xFFFF );
eventMgr().sendEventNotice( player, result.eventId, 2, 0xEA, 0, 0 );
}
else if( cmd == 5 )
{
//TODO: Housing teleport selection
}
}
else if( result.numOfResults == 2 ) // aethernet access
{
Expand Down
8 changes: 5 additions & 3 deletions src/world/Actor/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1367,7 +1367,7 @@ bool Player::isDirectorInitialized() const
return m_directorInitialized;
}

void Player::teleportQuery( uint16_t aetheryteId )
void Player::teleportQuery( uint16_t aetheryteId, bool useAetheryteTicket )
{
auto& exdData = Common::Service< Data::ExdData >::ref();
// TODO: only register this action if enough gil is in possession
Expand All @@ -1378,8 +1378,9 @@ void Player::teleportQuery( uint16_t aetheryteId )

auto fromAetheryte = exdData.getRow< Excel::Aetheryte >( exdData.getRow< Excel::TerritoryType >( getTerritoryTypeId() )->data().Aetheryte );

// calculate cost - does not apply for favorite points or homepoints neither checks for aether tickets
auto cost = static_cast< uint16_t > (
// calculate cost - does not apply for favorite points or homepoints
// if using aetheryte ticket, cost is 0
auto cost = useAetheryteTicket ? 0 : static_cast< uint16_t > (
( std::sqrt( std::pow( fromAetheryte->data().CostPosX - targetAetheryte->data().CostPosX, 2 ) +
std::pow( fromAetheryte->data().CostPosY - targetAetheryte->data().CostPosY, 2 ) ) / 2 ) + 100 );

Expand All @@ -1393,6 +1394,7 @@ void Player::teleportQuery( uint16_t aetheryteId )
{
m_teleportQuery.targetAetheryte = aetheryteId;
m_teleportQuery.cost = cost;
m_teleportQuery.useAetheryteTicket = useAetheryteTicket;
}
else
{
Expand Down
2 changes: 1 addition & 1 deletion src/world/Actor/Player.h
Original file line number Diff line number Diff line change
Expand Up @@ -339,7 +339,7 @@ namespace Sapphire::Entity
uint64_t getFullOnlineStatusMask() const;

/*! query teleport of a specified type */
void teleportQuery( uint16_t aetheryteId );
void teleportQuery( uint16_t aetheryteId, bool useAetheryteTicket );

Common::PlayerTeleportQuery getTeleportQuery() const;

Expand Down
5 changes: 3 additions & 2 deletions src/world/Network/Handlers/PacketCommandHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -607,8 +607,9 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
}
case PacketCommand::TELEPO_INQUIRY: // Teleport
{

player.teleportQuery( static_cast< uint16_t >( data.Arg0 ) );
// data.Arg0 = aetheryte id
// data.Arg1 = confirm or cancel if using aetheryte ticket
player.teleportQuery( static_cast< uint16_t >( data.Arg0 ), data.Arg1 == 1 );
break;
}
case PacketCommand::DYE_ITEM: // Dye item
Expand Down
Loading