1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-25 11:07:45 +00:00

Merge branch 'develop_5.5x' of https://github.com/collett8192/Sapphire into develop_5.5x

This commit is contained in:
Rey 2021-08-17 08:55:06 -05:00
commit 71a6d30c03
2 changed files with 404 additions and 55 deletions

View file

@ -24,10 +24,9 @@ public:
0: current time 0: current time
1: main actor 1 id 1: main actor 1 id
2: main actor 2 id 2: main actor 2 id
3: seq 3 start time 3: internal sequence start time
4: seq 3 internal sequence 4: internal sequence
5: seq 3 remaining unfinished player count 5: remaining unfinished player count
6: seq 4 internal sequence
101: questBL 101: questBL
102: questBH 102: questBH
103: questCL 103: questCL
@ -45,10 +44,9 @@ public:
}; };
auto mainBookHandler = [ & ]( Entity::Player& player, Entity::EventObjectPtr eobj, TerritoryPtr terri, uint32_t eventId, uint64_t actorId ) auto mainBookHandler = [ & ]( Entity::Player& player, Entity::EventObjectPtr eobj, TerritoryPtr terri, uint32_t eventId, uint64_t actorId )
{
if( instance.getSequence() == 1 )
{ {
auto v1 = instance.getCustomVar( 1 ); auto v1 = instance.getCustomVar( 1 );
auto v2 = instance.getCustomVar( 2 );
if( v1 == 0 ) if( v1 == 0 )
{ {
player.sendUrgent( "The host of this ceremony is not determined yet, become the host as the first one to join the instance with quest 67114 at seq 12." ); player.sendUrgent( "The host of this ceremony is not determined yet, become the host as the first one to join the instance with quest 67114 at seq 12." );
@ -59,7 +57,8 @@ public:
player.sendUrgent( "You are not the host of this ceremony." ); player.sendUrgent( "You are not the host of this ceremony." );
return; return;
} }
auto v2 = instance.getCustomVar( 2 ); if( instance.getSequence() == 1 )
{
if( v2 > 0 ) if( v2 > 0 )
{ {
auto p1 = instance.getPlayer( v1 ); auto p1 = instance.getPlayer( v1 );
@ -96,7 +95,64 @@ public:
} }
else if( instance.getSequence() == 4 ) else if( instance.getSequence() == 4 )
{ {
player.sendUrgent( "WIP..." ); if( instance.getCustomVar( 4 ) == 5 )
{
auto p1 = instance.getPlayer( v1 );
auto p2 = instance.getPlayer( v2 );
if( p1 && p2 )
{
auto seq4Callback = [ & ]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param1 != 512 || result.param2 != 0 )
return;
instance.setCustomVar( 3, 0 );
instance.setCustomVar( 4, 0 );
instance.setSequence( 5 );
instance.foreachPlayer( [ &instance ]( auto p )
{
p->queuePacket( makeActorControlSelf( p->getId(), DirectorUpdate, instance.getDirectorId(), 0x80000001, 1 ) );
});
};
// event item workaround
player.eventFinish( eventId, 1 );
player.eventStart( player.getId(), instance.getDirectorId(), Event::EventHandler::Item, 0, 2001464 );
player.playScene( instance.getDirectorId(), 32, 134225921, 0, 1, 1086, seq4Callback );
}
else
{
player.sendUrgent( "Two main characters must be in the instance to continue the ceremony." );
}
}
else
player.sendUrgent( "Waiting for the cutscene and popup messages to finish..." );
}
else if( instance.getSequence() == 5 )
{
player.sendUrgent( "Waiting for the cutscene and popup messages to finish..." );
}
else if( instance.getSequence() == 6 )
{
auto p1 = instance.getPlayer( v1 );
auto p2 = instance.getPlayer( v2 );
if( p1 && p2 )
{
auto seq4Callback = [ & ]( Entity::Player& player, const Event::SceneResult& result )
{
if( result.param1 != 512 || result.param2 != 0 )
return;
instance.setCustomVar( 3, 0 );
instance.setCustomVar( 4, 0 );
instance.setSequence( 7 );
};
// event item workaround
player.eventFinish( eventId, 1 );
player.eventStart( player.getId(), instance.getDirectorId(), Event::EventHandler::Item, 0, 2001464 );
player.playScene( instance.getDirectorId(), 32, 134225921, 0, 1, 1087, seq4Callback );
}
else
{
player.sendUrgent( "Two main characters must be in the instance to continue the ceremony." );
}
} }
}; };
@ -120,22 +176,22 @@ public:
} }
void onUpdate( PublicContent& instance, uint64_t tickCount ) override void onUpdate( PublicContent& instance, uint64_t tickCount ) override
{
switch( instance.getSequence() )
{
case 3:
{ {
if( instance.getCustomVar( 3 ) == 0 ) if( instance.getCustomVar( 3 ) == 0 )
instance.setCustomVar( 3, tickCount ); instance.setCustomVar( 3, tickCount );
auto dt = std::difftime( tickCount, instance.getCustomVar( 3 ) ) / 1000.f; auto dt = std::difftime( tickCount, instance.getCustomVar( 3 ) ) / 1000.f;
auto v4 = instance.getCustomVar( 4 ); auto v4 = instance.getCustomVar( 4 );
switch( instance.getSequence() )
{
case 3:
{
switch( v4 ) switch( v4 )
{ {
case 0: case 0:
case 1: case 1:
case 2: case 2:
{ {
if( dt >= 1 + v4 * 6 ) if( dt >= 1 + v4 * 7 )
{ {
instance.setCustomVar( 4, v4 + 1 ); instance.setCustomVar( 4, v4 + 1 );
FFXIVIpcDirectorPopUp packetData = {}; FFXIVIpcDirectorPopUp packetData = {};
@ -158,15 +214,14 @@ public:
} }
case 3: case 3:
{ {
if( dt < 20 ) if( dt < 23 )
return; return;
instance.setCustomVar( 4, 255 );
auto p1 = instance.getPlayer( instance.getCustomVar( 1 ) ); auto p1 = instance.getPlayer( instance.getCustomVar( 1 ) );
auto p2 = instance.getPlayer( instance.getCustomVar( 2 ) ); auto p2 = instance.getPlayer( instance.getCustomVar( 2 ) );
if( !p1 || !p2 ) if( !p1 || !p2 )
{ {
instance.setSequence( 1 ); instance.setSequence( 1 );
instance.foreachPlayer( [ &instance ]( auto p ) instance.foreachPlayer( []( auto p )
{ {
p->sendUrgent( "Failed to start the scene, missing main actors." ); p->sendUrgent( "Failed to start the scene, missing main actors." );
}); });
@ -258,21 +313,315 @@ public:
instance.setCustomVar( 5, v5 ); instance.setCustomVar( 5, v5 );
if( v5 == 0 ) if( v5 == 0 )
{ {
player.sendDebug( "all players finished scene" ); instance.setCustomVar( 3, 0 );
instance.setCustomVar( 4, 1 );
} }
}; };
p->playScene16( instance.getDirectorId(), 3, 9219, 0, paramList, seq3Callback ); p->playScene16( instance.getDirectorId(), 3, 139469827, 0, paramList, seq3Callback );
}); });
instance.setCustomVar( 3, 0 );
instance.setCustomVar( 4, 0 );
instance.setCustomVar( 5, instance.getPopCount() ); instance.setCustomVar( 5, instance.getPopCount() );
instance.setCustomVar( 6, 0 );
instance.setSequence( 4 ); instance.setSequence( 4 );
break; break;
} }
} }
break;
}
case 4:
{
switch( v4 )
{
case 1:
case 2:
case 3:
{
if( dt >= 6 + ( v4 - 1 ) * 7 )
{
instance.setCustomVar( 4, v4 + 1 );
FFXIVIpcDirectorPopUp packetData = {};
packetData.directorId = instance.getDirectorId();
packetData.flags = 3;
packetData.bNPCName = 1010505;
packetData.textId = v4 == 1 ? 1008: ( v4 == 2 ? 1091 : 1097 );
packetData.popupTimeMs = 6000;
packetData.param[ 0 ] = 1024;
packetData.param[ 1 ] = instance.getCustomVar( 1 );
packetData.param[ 2 ] = instance.getCustomVar( 2 );
instance.foreachPlayer( [ &instance, &packetData ]( auto p )
{
auto packet = makeZonePacket< FFXIVIpcDirectorPopUp >( p->getId() );
memcpy( &packet->data(), &packetData, sizeof( packetData ) );
p->queuePacket( packet );
});
} }
break; break;
} }
case 4:
{
if( dt >= 28 )
{
instance.setCustomVar( 4, 5 );
instance.foreachPlayer( [ &instance ]( auto p )
{
auto packet = makeZonePacket< FFXIVDirectorUnk4 >( p->getId() );
packet->data().param[0] = instance.getDirectorId();
packet->data().param[1] = 4353;
packet->data().param[2] = 1;
packet->data().param[3] = 0;
p->queuePacket( packet );
});
}
break;
}
}
break;
}
case 5:
{
//first half of sec5
switch( v4 )
{
case 0:
case 1:
case 2:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
case 9:
case 10:
{
if( dt >= 1 + v4 * 7 )
{
instance.setCustomVar( 4, v4 + 1 );
FFXIVIpcDirectorPopUp packetData = {};
packetData.directorId = instance.getDirectorId();
packetData.flags = 3;
packetData.bNPCName = 1010505;
packetData.textId = v4 == 0 ? 1010 :
( v4 == 1 ? 1011 :
( v4 == 2 ? 1015 :
( v4 == 3 ? 1103 :
( v4 == 4 ? 1019 :
( v4 == 5 ? 1107 :
( v4 == 6 ? 1020 :
( v4 == 7 ? 1021 :
( v4 == 8 ? 1125 :
( v4 == 9 ? 1126 : 1127 ) ) ) ) ) ) ) ) ); //FIX THIS SHIT BEFORE PR
packetData.popupTimeMs = 6000;
packetData.param[ 0 ] = 1024;
packetData.param[ 1 ] = instance.getCustomVar( 1 );
packetData.param[ 2 ] = instance.getCustomVar( 2 );
instance.foreachPlayer( [ &instance, &packetData ]( auto p )
{
auto packet = makeZonePacket< FFXIVIpcDirectorPopUp >( p->getId() );
memcpy( &packet->data(), &packetData, sizeof( packetData ) );
p->queuePacket( packet );
});
}
break;
}
case 11:
{
if( dt >= 78 )
{
instance.foreachPlayer( [ &instance ]( auto p )
{
p->eventStart( p->getId(), instance.getDirectorId(), Event::EventHandler::GameProgress, 1, 1 );
std::vector< uint32_t > paramList;
paramList.push_back( 671 );
auto seq5Callback = [ & ]( Entity::Player& player, const Event::SceneResult& result )
{
auto seq5Callback2 = [ & ]( Entity::Player& player, const Event::SceneResult& result )
{
auto v5 = instance.getCustomVar( 5 );
v5--;
instance.setCustomVar( 5, v5 );
if( v5 == 0 )
{
instance.setCustomVar( 3, 0 );
instance.setCustomVar( 4, 101 );
}
};
std::vector< uint32_t > paramList;
paramList.push_back( 665 + instance.getCustomVar( 102 ) );
player.playScene16( instance.getDirectorId(), 3, 139469827, 0, paramList, seq5Callback2 );
};
p->playScene16( instance.getDirectorId(), 3, 139469827, 0, paramList, seq5Callback );
});
instance.setCustomVar( 4, 100 );
instance.setCustomVar( 5, instance.getPopCount() );
}
break;
}
}
//second half of seq5
const uint16_t textIds[ 4 ] = { 1022, 1023, 1131, 1025 };
switch( v4 )
{
case 101:
case 102:
case 103:
case 104:
{
if( dt >= 6 + ( v4 - 101 ) * 7 )
{
instance.setCustomVar( 4, v4 + 1 );
FFXIVIpcDirectorPopUp packetData = {};
packetData.directorId = instance.getDirectorId();
packetData.flags = 3;
packetData.bNPCName = 1010505;
packetData.textId = textIds[ v4 - 101 ];
packetData.popupTimeMs = 6000;
packetData.param[ 0 ] = 1024;
packetData.param[ 1 ] = instance.getCustomVar( 1 );
packetData.param[ 2 ] = instance.getCustomVar( 2 );
instance.foreachPlayer( [ &instance, &packetData ]( auto p )
{
auto packet = makeZonePacket< FFXIVIpcDirectorPopUp >( p->getId() );
memcpy( &packet->data(), &packetData, sizeof( packetData ) );
p->queuePacket( packet );
});
}
break;
}
case 105:
{
if( dt >= 34 )
{
instance.setCustomVar( 4, 106 );
instance.foreachPlayer( [ &instance ]( auto p )
{
auto packet = makeZonePacket< FFXIVDirectorUnk4 >( p->getId() );
packet->data().param[0] = instance.getDirectorId();
packet->data().param[1] = 4363;
packet->data().param[2] = 1;
packet->data().param[3] = 0;
p->queuePacket( packet );
});
}
break;
}
case 106:
{
if( dt >= 40 )
{
instance.setCustomVar( 4, 107 );
instance.foreachPlayer( [ &instance ]( auto p )
{
auto packet = makeZonePacket< FFXIVDirectorUnk4 >( p->getId() );
packet->data().param[0] = instance.getDirectorId();
packet->data().param[1] = 4373;
packet->data().param[2] = 25591553;
packet->data().param[3] = 0;
p->queuePacket( packet );
});
}
break;
}
case 107:
{
if( dt >= 46 )
{
// quest update here on retail
// set invisible wall state to 7
instance.foreachPlayer( [ &instance ]( auto p )
{
p->queuePacket( makeActorControlSelf( p->getId(), DirectorUpdate, instance.getDirectorId(), 0x80000001, 89 ) ); // bgm, how to map id from questDH?
});
instance.setCustomVar( 3, 0 );
instance.setCustomVar( 4, 0 );
instance.setSequence( 6 );
}
break;
}
}
break;
}
case 7:
{
const uint16_t textIds[ 5 ] = { 1026, 1027, 1141, 1028, 1134 };
switch( v4 )
{
case 0:
case 1:
case 2:
case 3:
case 4:
{
if( dt >= 1 + v4 * 7 )
{
instance.setCustomVar( 4, v4 + 1 );
FFXIVIpcDirectorPopUp packetData = {};
packetData.directorId = instance.getDirectorId();
packetData.flags = 3;
packetData.bNPCName = 1010505;
packetData.textId = textIds[ v4 ];
packetData.popupTimeMs = 6000;
packetData.param[ 0 ] = 1024;
packetData.param[ 1 ] = instance.getCustomVar( 1 );
packetData.param[ 2 ] = instance.getCustomVar( 2 );
instance.foreachPlayer( [ &instance, &packetData ]( auto p )
{
auto packet = makeZonePacket< FFXIVIpcDirectorPopUp >( p->getId() );
memcpy( &packet->data(), &packetData, sizeof( packetData ) );
p->queuePacket( packet );
});
}
break;
}
case 5:
{
if( dt >= 35 )
{
instance.setCustomVar( 4, 6 );
instance.foreachPlayer( [ &instance ]( auto p )
{
auto packet = makeZonePacket< FFXIVDirectorUnk4 >( p->getId() );
packet->data().param[0] = instance.getDirectorId();
packet->data().param[1] = 4360;
packet->data().param[2] = 1;
packet->data().param[3] = 0;
p->queuePacket( packet );
});
}
break;
}
case 6:
{
if( dt >= 41 )
{
instance.foreachPlayer( [ &instance ]( auto p )
{
p->eventStart( p->getId(), instance.getDirectorId(), Event::EventHandler::GameProgress, 1, 1 );
std::vector< uint32_t > paramList;
paramList.push_back( 50006 );
auto seq5Callback = [ & ]( Entity::Player& player, const Event::SceneResult& result )
{
player.prepareZoning( 152, true, 1, 0, 0, 1, 8 );
player.queuePacket( makeActorControlSelf( player.getId(), DirectorUpdate, instance.getDirectorId(), 0x80000001, 1 ) );
if( player.getId() == instance.getCustomVar( 1 ) || player.getId() == instance.getCustomVar( 2 ) )
{
player.updateQuest( 67114, 255 );
}
player.eventFinish( instance.getDirectorId(), 1 );
player.exitInstance();
};
p->playScene16( instance.getDirectorId(), 3, 139469827, 0, paramList, seq5Callback );
});
instance.setCustomVar( 4, 255 );
}
break;
}
}
break;
}
}
instance.setCustomVar( 0, tickCount ); instance.setCustomVar( 0, tickCount );
} }
@ -337,7 +686,7 @@ public:
{ {
player.setPosAndNotifyClient( 0, 750, -50, -3.14f ); player.setPosAndNotifyClient( 0, 750, -50, -3.14f );
} }
//player.queuePacket( makeActorControlSelf( getId(), DirectorUpdate, instance.getDirectorId(), 0x80000003, 1200 ) ); // timer //player.queuePacket( makeActorControlSelf( getId(), DirectorUpdate, instance.getDirectorId(), 0x80000003, 1200 ) ); // timer, we dont need it for now
player.playScene( instance.getDirectorId(), 1, HIDE_HOTBAR, 0, 2, 4, callback ); player.playScene( instance.getDirectorId(), 1, HIDE_HOTBAR, 0, 2, 4, callback );
} }

View file

@ -538,8 +538,8 @@ bool Sapphire::Entity::Player::exitInstance()
{ {
auto& teriMgr = Common::Service< TerritoryMgr >::ref(); auto& teriMgr = Common::Service< TerritoryMgr >::ref();
if( auto d = getCurrentTerritory()->getAsDirector() ) auto d = getCurrentTerritory()->getAsDirector();
if( d->getContentFinderConditionId() > 0 ) if( d && d->getContentFinderConditionId() > 0 )
{ {
auto p = makeZonePacket< FFXIVDirectorUnk4 >( getId() ); auto p = makeZonePacket< FFXIVDirectorUnk4 >( getId() );
p->data().param[0] = d->getDirectorId(); p->data().param[0] = d->getDirectorId();