2021-08-09 02:38:20 +09:00
# include <ScriptObject.h>
# include <Territory/InstanceContent.h>
# include "Actor/Player.h"
2021-08-15 05:04:10 +09:00
# include "Actor/EventObject.h"
2021-08-09 02:38:20 +09:00
# include "Territory/PublicContent.h"
2021-08-15 05:04:10 +09:00
# include <Util/UtilMath.h>
# include "Network/CommonActorControl.h"
# include "Network/PacketWrappers/ActorControlSelfPacket.h"
2021-08-15 08:49:13 +09:00
# include "Network/PacketDef/Zone/ServerZoneDef.h"
2021-08-09 02:38:20 +09:00
using namespace Sapphire ;
2021-08-15 05:04:10 +09:00
using namespace Sapphire : : Network : : ActorControl ;
using namespace Sapphire : : Network : : Packets ;
using namespace Sapphire : : Network : : Packets : : Server ;
2021-08-09 02:38:20 +09:00
class SanctumOfTheTwelve : public Sapphire : : ScriptAPI : : PublicContentScript
{
public :
SanctumOfTheTwelve ( ) : Sapphire : : ScriptAPI : : PublicContentScript ( 1 ) { }
2021-08-15 20:39:37 +09:00
/*
Custom var usage :
0 : current time
1 : main actor 1 id
2 : main actor 2 id
2021-08-15 23:56:10 +09:00
3 : internal sequence start time
4 : internal sequence
5 : remaining unfinished player count
2021-08-15 20:39:37 +09:00
101 : questBL
102 : questBH
103 : questCL
104 : questCH
105 : questDL
106 : questDH
*/
2021-08-09 02:38:20 +09:00
void onInit ( PublicContent & instance ) override
{
2021-08-15 05:04:10 +09:00
auto exitHandler = [ & ] ( Entity : : Player & player , Entity : : EventObjectPtr eobj , TerritoryPtr terri , uint32_t eventId , uint64_t actorId )
{
player . eventFinish ( eventId , 1 ) ;
player . exitInstance ( ) ;
} ;
2021-08-09 02:38:20 +09:00
2021-08-15 08:49:13 +09:00
auto mainBookHandler = [ & ] ( Entity : : Player & player , Entity : : EventObjectPtr eobj , TerritoryPtr terri , uint32_t eventId , uint64_t actorId )
{
2021-08-15 23:56:10 +09:00
auto v1 = instance . getCustomVar ( 1 ) ;
auto v2 = instance . getCustomVar ( 2 ) ;
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. " ) ;
return ;
}
if ( v1 ! = player . getId ( ) )
{
player . sendUrgent ( " You are not the host of this ceremony. " ) ;
return ;
}
2021-08-15 08:49:13 +09:00
if ( instance . getSequence ( ) = = 1 )
{
if ( v2 > 0 )
{
auto p1 = instance . getPlayer ( v1 ) ;
auto p2 = instance . getPlayer ( v2 ) ;
if ( p1 & & p2 )
{
2021-08-15 20:39:37 +09:00
auto seq1Callback = [ & ] ( Entity : : Player & player , const Event : : SceneResult & result )
{
if ( result . param1 ! = 512 | | result . param2 ! = 0 )
return ;
instance . setCustomVar ( 3 , 0 ) ;
instance . setCustomVar ( 4 , 0 ) ;
//skip 2 for now
instance . setSequence ( 3 ) ;
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 , 1077 , seq1Callback ) ;
}
else
{
player . sendUrgent ( " Two main characters must be in the instance to begin the ceremony. " ) ;
}
}
else
{
player . sendUrgent ( " Need another character with quest 67114 at seq 12 to begin the ceremony. " ) ;
}
}
else if ( instance . getSequence ( ) = = 4 )
{
2021-08-15 23:56:10 +09:00
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... " ) ;
}
2021-08-16 04:34:13 +09:00
else if ( instance . getSequence ( ) = = 5 )
{
player . sendUrgent ( " Waiting for the cutscene and popup messages to finish... " ) ;
}
2021-08-15 23:56:10 +09:00
else if ( instance . getSequence ( ) = = 6 )
2021-08-15 20:39:37 +09:00
{
2021-08-16 04:34:13 +09:00
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. " ) ;
}
2021-08-15 20:39:37 +09:00
}
} ;
auto subBookHandler = [ & ] ( Entity : : Player & player , Entity : : EventObjectPtr eobj , TerritoryPtr terri , uint32_t eventId , uint64_t actorId )
{
auto v2 = instance . getCustomVar ( 2 ) ;
if ( v2 = = player . getId ( ) )
{
player . sendUrgent ( " Wait for your partner to start the ceremony. " ) ;
}
} ;
instance . registerEObj ( " unknown_0 " , 2005027 , 0 , 0 , { 0.0f , 251.103f , - 60.39313f } , 1.0f , Common : : Util : : floatFromUInt16Rot ( 28453 ) ) - > setOnTalkHandler ( subBookHandler ) ;
instance . registerEObj ( " unknown_1 " , 2004902 , 0 , 1 , { - 0.1025963f , 2.902821f , - 125.97f } , 1.0f , Common : : Util : : floatFromUInt16Rot ( 32767 ) ) ;
instance . registerEObj ( " unknown_2 " , 2004786 , 0 , 0 , { 0.0f , 501.103f , - 60.39313f } , 1.0f , Common : : Util : : floatFromUInt16Rot ( 28453 ) ) - > setOnTalkHandler ( mainBookHandler ) ;
instance . registerEObj ( " unknown_3 " , 2004783 , 0 , 0 , { 0.0f , 0.5f , 19.0f } , 1.0f , Common : : Util : : floatFromUInt16Rot ( 32767 ) ) - > setOnTalkHandler ( exitHandler ) ;
instance . registerEObj ( " unknown_4 " , 2004783 , 0 , 0 , { 0.0f , 250.5515f , - 48.19313f } , 1.0f , Common : : Util : : floatFromUInt16Rot ( 32767 ) ) - > setOnTalkHandler ( exitHandler ) ;
instance . registerEObj ( " unknown_5 " , 2004783 , 0 , 0 , { - 0.01531982f , 500.5456f , - 48.20331 } , 0.9917603f , Common : : Util : : floatFromUInt16Rot ( 32767 ) ) - > setOnTalkHandler ( exitHandler ) ;
instance . registerEObj ( " unknown_6 " , 2004783 , 0 , 0 , { - 0.01531982f , 750.5475f , - 55.13086f } , 0.9917603f , Common : : Util : : floatFromUInt16Rot ( 32767 ) ) - > setOnTalkHandler ( exitHandler ) ;
instance . setCurrentFestival ( 237 , 0 ) ;
}
void onUpdate ( PublicContent & instance , uint64_t tickCount ) override
{
2021-08-16 04:34:13 +09:00
if ( instance . getCustomVar ( 3 ) = = 0 )
instance . setCustomVar ( 3 , tickCount ) ;
auto dt = std : : difftime ( tickCount , instance . getCustomVar ( 3 ) ) / 1000.f ;
auto v4 = instance . getCustomVar ( 4 ) ;
2021-08-15 20:39:37 +09:00
switch ( instance . getSequence ( ) )
{
case 3 :
{
switch ( v4 )
{
case 0 :
case 1 :
case 2 :
{
2021-08-15 23:56:10 +09:00
if ( dt > = 1 + v4 * 7 )
2021-08-15 20:39:37 +09:00
{
instance . setCustomVar ( 4 , v4 + 1 ) ;
FFXIVIpcDirectorPopUp packetData = { } ;
packetData . directorId = instance . getDirectorId ( ) ;
packetData . flags = 3 ;
packetData . bNPCName = 1010505 ;
packetData . textId = v4 = = 0 ? 1088 : ( v4 = = 1 ? 1006 : 1007 ) ;
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 3 :
{
2021-08-15 23:56:10 +09:00
if ( dt < 23 )
2021-08-15 20:39:37 +09:00
return ;
auto p1 = instance . getPlayer ( instance . getCustomVar ( 1 ) ) ;
auto p2 = instance . getPlayer ( instance . getCustomVar ( 2 ) ) ;
if ( ! p1 | | ! p2 )
{
instance . setSequence ( 1 ) ;
2021-08-16 04:34:13 +09:00
instance . foreachPlayer ( [ ] ( auto p )
2021-08-15 20:39:37 +09:00
{
p - > sendUrgent ( " Failed to start the scene, missing main actors. " ) ;
} ) ;
return ;
}
2021-08-15 08:49:13 +09:00
FFXIVCeremonySetActorAppearance packetData = { } ;
2021-08-15 20:39:37 +09:00
auto qBL = instance . getCustomVar ( 101 ) ;
packetData . questBL = qBL ;
2021-08-15 08:49:13 +09:00
packetData . u1 = 1 ;
if ( ! ( p1 - > getEquipDisplayFlags ( ) & Sapphire : : Common : : EquipDisplayFlags : : HideWeapon ) )
{
packetData . actors [ 0 ] . mainWeaponModel = p1 - > getModelMainWeapon ( ) ;
packetData . actors [ 0 ] . secWeaponModel = p1 - > getModelSubWeapon ( ) ;
}
packetData . actors [ 0 ] . charId = p1 - > getId ( ) ;
packetData . actors [ 0 ] . guardianDeity = p1 - > getGuardianDeity ( ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelHead ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) ;
2021-08-15 09:31:23 -05:00
if ( ( p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) & 0xFF ) = = 208 )
{
2022-02-08 10:11:52 -06:00
instance . foreachPlayer ( [ ] ( auto p )
{
p - > sendUrgent ( " Replacing p1 Model " ) ;
} ) ;
2021-08-15 09:31:23 -05:00
uint32_t gear = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) & 0xFFFFFF00 ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelHead ] = gear | 0xC7 ;
}
2021-08-15 08:49:13 +09:00
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelBody ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelBody ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelHands ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelHands ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelLegs ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelLegs ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelFeet ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelFeet ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelNeck ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelNeck ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelEar ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelEar ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelRing1 ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelRing1 ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelRing2 ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelRing2 ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelWrist ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelWrist ) ;
memcpy ( packetData . actors [ 0 ] . look , p1 - > getLookArray ( ) , sizeof ( packetData . actors [ 0 ] . look ) ) ;
if ( ! ( p2 - > getEquipDisplayFlags ( ) & Sapphire : : Common : : EquipDisplayFlags : : HideWeapon ) )
{
packetData . actors [ 1 ] . mainWeaponModel = p2 - > getModelMainWeapon ( ) ;
packetData . actors [ 1 ] . secWeaponModel = p2 - > getModelSubWeapon ( ) ;
}
packetData . actors [ 1 ] . charId = p2 - > getId ( ) ;
packetData . actors [ 1 ] . guardianDeity = p2 - > getGuardianDeity ( ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelHead ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) ;
2021-08-15 09:31:23 -05:00
if ( ( p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) & 0xFF ) = = 208 )
{
2022-02-08 10:11:52 -06:00
instance . foreachPlayer ( [ ] ( auto p )
{
p - > sendUrgent ( " Replacing p2 Model " ) ;
} ) ;
2021-08-15 09:31:23 -05:00
uint32_t gear = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) & 0xFFFFFF00 ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelHead ] = gear | 0xC7 ;
}
2021-08-15 08:49:13 +09:00
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelBody ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelBody ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelHands ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelHands ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelLegs ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelLegs ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelFeet ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelFeet ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelNeck ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelNeck ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelEar ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelEar ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelRing1 ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelRing1 ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelRing2 ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelRing2 ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelWrist ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelWrist ) ;
memcpy ( packetData . actors [ 1 ] . look , p2 - > getLookArray ( ) , sizeof ( packetData . actors [ 1 ] . look ) ) ;
2021-08-15 20:39:37 +09:00
instance . foreachPlayer ( [ & instance , & packetData , qBL ] ( auto p )
2021-08-15 08:49:13 +09:00
{
auto packet = makeZonePacket < FFXIVCeremonySetActorAppearance > ( p - > getId ( ) ) ;
memcpy ( & packet - > data ( ) , & packetData , sizeof ( packetData ) ) ;
p - > queuePacket ( packet ) ;
2021-08-15 20:39:37 +09:00
p - > eventStart ( p - > getId ( ) , instance . getDirectorId ( ) , Event : : EventHandler : : GameProgress , 1 , 1 ) ;
std : : vector < uint32_t > paramList ;
paramList . push_back ( qBL < 2 ? 664 : 665 ) ;
auto seq3Callback = [ & ] ( Entity : : Player & player , const Event : : SceneResult & result )
{
//keep everyone in their room for now
/*
if ( player . getId ( ) = = instance . getCustomVar ( 1 ) )
{
player . setPosAndNotifyClient ( 1.454 , 3.12581 , - 132.7992 , - 3.14 ) ;
}
else if ( player . getId ( ) = = instance . getCustomVar ( 2 ) )
{
player . setPosAndNotifyClient ( - 1.454 , 3.12581 , - 132.7992 , - 3.14 ) ;
}
else
{
player . setPosAndNotifyClient ( 0 , 2.64 , - 119 , - 3.14 ) ;
}
*/
auto v5 = instance . getCustomVar ( 5 ) ;
v5 - - ;
instance . setCustomVar ( 5 , v5 ) ;
if ( v5 = = 0 )
{
2021-08-15 23:56:10 +09:00
instance . setCustomVar ( 3 , 0 ) ;
instance . setCustomVar ( 4 , 1 ) ;
2021-08-15 20:39:37 +09:00
}
} ;
2021-08-16 04:34:13 +09:00
p - > playScene16 ( instance . getDirectorId ( ) , 3 , 139469827 , 0 , paramList , seq3Callback ) ;
2021-08-15 08:49:13 +09:00
} ) ;
2021-08-15 23:56:10 +09:00
instance . setCustomVar ( 3 , 0 ) ;
instance . setCustomVar ( 4 , 0 ) ;
2021-08-15 20:39:37 +09:00
instance . setCustomVar ( 5 , instance . getPopCount ( ) ) ;
instance . setSequence ( 4 ) ;
break ;
2021-08-15 08:49:13 +09:00
}
}
2021-08-15 23:56:10 +09:00
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 ;
}
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 ) ;
} ) ;
}
2021-08-16 04:34:13 +09:00
break ;
2021-08-15 23:56:10 +09:00
}
}
break ;
}
case 5 :
{
2021-08-16 04:34:13 +09:00
//first half of sec5
2021-08-15 23:56:10 +09:00
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 :
2021-08-16 02:20:43 +09:00
( v4 = = 9 ? 1126 : 1127 ) ) ) ) ) ) ) ) ) ; //FIX THIS SHIT BEFORE PR
2021-08-15 23:56:10 +09:00
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 )
{
2021-08-16 02:20:43 +09:00
instance . foreachPlayer ( [ & instance ] ( auto p )
2021-08-15 23:56:10 +09:00
{
p - > eventStart ( p - > getId ( ) , instance . getDirectorId ( ) , Event : : EventHandler : : GameProgress , 1 , 1 ) ;
std : : vector < uint32_t > paramList ;
2021-08-16 04:34:13 +09:00
paramList . push_back ( 671 ) ;
2021-08-15 23:56:10 +09:00
auto seq5Callback = [ & ] ( Entity : : Player & player , const Event : : SceneResult & result )
{
2021-08-16 04:34:13 +09:00
auto seq5Callback2 = [ & ] ( Entity : : Player & player , const Event : : SceneResult & result )
2021-08-15 23:56:10 +09:00
{
2021-08-16 04:34:13 +09:00
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 ) ;
2021-08-15 23:56:10 +09:00
} ;
2021-08-16 04:34:13 +09:00
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?
2021-08-15 23:56:10 +09:00
} ) ;
instance . setCustomVar ( 3 , 0 ) ;
instance . setCustomVar ( 4 , 0 ) ;
instance . setSequence ( 6 ) ;
}
break ;
}
}
break ;
2021-08-15 08:49:13 +09:00
}
2021-08-16 04:34:13 +09:00
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 ) ;
2021-08-16 04:39:51 +09:00
player . queuePacket ( makeActorControlSelf ( player . getId ( ) , DirectorUpdate , instance . getDirectorId ( ) , 0x80000001 , 1 ) ) ;
2021-08-16 04:34:13 +09:00
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 ;
2021-08-15 08:49:13 +09:00
}
2021-08-15 20:39:37 +09:00
}
instance . setCustomVar ( 0 , tickCount ) ;
2021-08-09 02:38:20 +09:00
}
void onPlayerZoneIn ( PublicContent & instance , Entity : : Player & player ) override
{
2021-08-09 06:55:56 +09:00
if ( instance . getCustomVar ( 1 ) = = 0 | | instance . getCustomVar ( 1 ) = = player . getId ( ) )
{
2021-08-15 08:49:13 +09:00
if ( player . hasQuest ( 67114 ) & & player . getQuestSeq ( 67114 ) = = 12 )
2021-08-09 06:55:56 +09:00
{
instance . setCustomVar ( 1 , player . getId ( ) ) ;
instance . setDirectorUI8AL ( player . getQuestUI8AH ( 67114 ) ) ;
instance . setDirectorUI8BL ( player . getQuestUI8AL ( 67114 ) ) ;
instance . setDirectorUI8CL ( player . getGuardianDeity ( ) ) ;
instance . setDirectorUI8DL ( player . getGuardianDeity ( ) ) ;
instance . setDirectorUI8EL ( player . getQuestUI8FH ( 67114 ) ) ;
instance . setDirectorUI8FL ( player . getQuestUI8FL ( 67114 ) ) ;
2021-08-15 20:39:37 +09:00
instance . setCustomVar ( 101 , player . getQuestUI8BL ( 67114 ) ) ;
instance . setCustomVar ( 102 , player . getQuestUI8BH ( 67114 ) ) ;
instance . setCustomVar ( 103 , player . getQuestUI8CL ( 67114 ) ) ;
instance . setCustomVar ( 104 , player . getQuestUI8CH ( 67114 ) ) ;
instance . setCustomVar ( 105 , player . getQuestUI8DL ( 67114 ) ) ;
instance . setCustomVar ( 106 , player . getQuestUI8DH ( 67114 ) ) ;
2021-08-09 06:55:56 +09:00
}
}
2021-08-15 08:49:13 +09:00
else if ( instance . getCustomVar ( 2 ) = = 0 | | instance . getCustomVar ( 2 ) = = player . getId ( ) )
{
if ( player . hasQuest ( 67114 ) & & player . getQuestSeq ( 67114 ) = = 12 )
{
instance . setCustomVar ( 2 , player . getId ( ) ) ;
auto p1 = instance . getPlayer ( instance . getCustomVar ( 1 ) ) ;
if ( p1 )
{
auto p = makeZonePacket < FFXIVDirectorUnk4 > ( getId ( ) ) ;
p - > data ( ) . param [ 0 ] = instance . getDirectorId ( ) ;
p - > data ( ) . param [ 1 ] = 4365 ;
p - > data ( ) . param [ 2 ] = 0 ;
p - > data ( ) . param [ 3 ] = 0 ;
p1 - > queuePacket ( p ) ;
}
}
}
2021-08-09 02:38:20 +09:00
}
void onLeaveTerritory ( PublicContent & instance , Entity : : Player & player ) override
{
}
void onEnterTerritory ( PublicContent & instance , Entity : : Player & player , uint32_t eventId , uint16_t param1 , uint16_t param2 ) override
{
2021-08-15 05:04:10 +09:00
auto callback = [ & ] ( Entity : : Player & player , const Event : : SceneResult & result )
{
} ;
2021-08-15 20:39:37 +09:00
if ( instance . getCustomVar ( 1 ) = = player . getId ( ) & & instance . getSequence ( ) = = 1 )
2021-08-15 08:49:13 +09:00
{
2021-08-15 20:39:37 +09:00
player . setPosAndNotifyClient ( 0 , 500 , - 50 , - 3.14f ) ;
2021-08-15 08:49:13 +09:00
}
2021-08-15 20:39:37 +09:00
else if ( instance . getCustomVar ( 2 ) = = player . getId ( ) & & instance . getSequence ( ) = = 1 )
2021-08-15 08:49:13 +09:00
{
2021-08-15 20:39:37 +09:00
player . setPosAndNotifyClient ( 0 , 250 , - 50 , - 3.14f ) ;
2021-08-15 08:49:13 +09:00
}
else
{
2021-08-15 20:39:37 +09:00
player . setPosAndNotifyClient ( 0 , 750 , - 50 , - 3.14f ) ;
2021-08-15 08:49:13 +09:00
}
2021-08-15 23:56:10 +09:00
//player.queuePacket( makeActorControlSelf( getId(), DirectorUpdate, instance.getDirectorId(), 0x80000003, 1200 ) ); // timer, we dont need it for now
2021-08-15 05:04:10 +09:00
player . playScene ( instance . getDirectorId ( ) , 1 , HIDE_HOTBAR , 0 , 2 , 4 , callback ) ;
2021-08-09 02:38:20 +09:00
}
void onDebug ( Entity : : Player & player , uint32_t param ) override
{
auto instance = player . getCurrentPublicContent ( ) ;
2022-02-11 20:42:25 -06:00
auto p1 = instance - > getPlayer ( instance - > getCustomVar ( 1 ) ) ;
auto p2 = instance - > getPlayer ( instance - > getCustomVar ( 2 ) ) ;
if ( ! p1 | | ! p2 )
{
instance - > setSequence ( 1 ) ;
instance - > foreachPlayer ( [ ] ( auto p )
{
p - > sendUrgent ( " Failed to start the scene, missing main actors. " ) ;
} ) ;
return ;
}
FFXIVCeremonySetActorAppearance packetData = { } ;
auto qBL = instance - > getCustomVar ( 101 ) ;
packetData . questBL = qBL ;
packetData . u1 = 1 ;
if ( ! ( p1 - > getEquipDisplayFlags ( ) & Sapphire : : Common : : EquipDisplayFlags : : HideWeapon ) )
{
packetData . actors [ 0 ] . mainWeaponModel = p1 - > getModelMainWeapon ( ) ;
packetData . actors [ 0 ] . secWeaponModel = p1 - > getModelSubWeapon ( ) ;
}
packetData . actors [ 0 ] . charId = p1 - > getId ( ) ;
packetData . actors [ 0 ] . guardianDeity = p1 - > getGuardianDeity ( ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelHead ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) ;
if ( ( p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) & 0xFF ) = = 208 )
{
instance - > foreachPlayer ( [ ] ( auto p )
{
p - > sendUrgent ( " Replacing p1 viel Model " ) ;
} ) ;
uint32_t gear = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) & 0xFFFFFF00 ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelHead ] = gear | 0xC7 ;
}
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelBody ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelBody ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelHands ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelHands ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelLegs ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelLegs ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelFeet ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelFeet ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelNeck ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelNeck ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelEar ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelEar ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelRing1 ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelRing1 ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelRing2 ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelRing2 ) ;
packetData . actors [ 0 ] . models [ Common : : GearModelSlot : : ModelWrist ] = p1 - > getModelForSlot ( Common : : GearModelSlot : : ModelWrist ) ;
memcpy ( packetData . actors [ 0 ] . look , p1 - > getLookArray ( ) , sizeof ( packetData . actors [ 0 ] . look ) ) ;
if ( ! ( p2 - > getEquipDisplayFlags ( ) & Sapphire : : Common : : EquipDisplayFlags : : HideWeapon ) )
{
packetData . actors [ 1 ] . mainWeaponModel = p2 - > getModelMainWeapon ( ) ;
packetData . actors [ 1 ] . secWeaponModel = p2 - > getModelSubWeapon ( ) ;
}
packetData . actors [ 1 ] . charId = p2 - > getId ( ) ;
packetData . actors [ 1 ] . guardianDeity = p2 - > getGuardianDeity ( ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelHead ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) ;
if ( ( p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) & 0xFF ) = = 208 )
{
instance - > foreachPlayer ( [ ] ( auto p )
{
p - > sendUrgent ( " Replacing p2 veil Model " ) ;
} ) ;
uint32_t gear = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelHead ) & 0xFFFFFF00 ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelHead ] = gear | 0xC7 ;
}
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelBody ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelBody ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelHands ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelHands ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelLegs ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelLegs ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelFeet ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelFeet ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelNeck ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelNeck ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelEar ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelEar ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelRing1 ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelRing1 ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelRing2 ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelRing2 ) ;
packetData . actors [ 1 ] . models [ Common : : GearModelSlot : : ModelWrist ] = p2 - > getModelForSlot ( Common : : GearModelSlot : : ModelWrist ) ;
memcpy ( packetData . actors [ 1 ] . look , p2 - > getLookArray ( ) , sizeof ( packetData . actors [ 1 ] . look ) ) ;
instance - > foreachPlayer ( [ & instance , & packetData , qBL , param ] ( auto p )
{
auto packet = makeZonePacket < FFXIVCeremonySetActorAppearance > ( p - > getId ( ) ) ;
memcpy ( & packet - > data ( ) , & packetData , sizeof ( packetData ) ) ;
p - > queuePacket ( packet ) ;
p - > eventStart ( p - > getId ( ) , instance - > getDirectorId ( ) , Event : : EventHandler : : GameProgress , 1 , 1 ) ;
std : : vector < uint32_t > paramList ;
paramList . push_back ( param ) ;
auto seq3Callback = [ & ] ( Entity : : Player & player , const Event : : SceneResult & result )
{
//keep everyone in their room for now
/*
if ( player . getId ( ) = = instance . getCustomVar ( 1 ) )
{
player . setPosAndNotifyClient ( 1.454 , 3.12581 , - 132.7992 , - 3.14 ) ;
}
else if ( player . getId ( ) = = instance . getCustomVar ( 2 ) )
{
player . setPosAndNotifyClient ( - 1.454 , 3.12581 , - 132.7992 , - 3.14 ) ;
}
else
{
player . setPosAndNotifyClient ( 0 , 2.64 , - 119 , - 3.14 ) ;
}
*/
auto v5 = instance - > getCustomVar ( 5 ) ;
v5 - - ;
instance - > setCustomVar ( 5 , v5 ) ;
if ( v5 = = 0 )
{
instance - > setCustomVar ( 3 , 0 ) ;
instance - > setCustomVar ( 4 , 1 ) ;
}
} ;
p - > playScene16 ( instance - > getDirectorId ( ) , 3 , 139469827 , 0 , paramList , seq3Callback ) ;
} ) ;
instance - > setCustomVar ( 3 , 0 ) ;
instance - > setCustomVar ( 4 , 0 ) ;
instance - > setCustomVar ( 5 , instance - > getPopCount ( ) ) ;
instance - > setSequence ( 4 ) ;
2021-08-09 02:38:20 +09:00
if ( ! instance | | instance - > getDirectorId ( ) ! = getId ( ) )
return ;
2022-02-11 20:42:25 -06:00
player . sendUrgent ( " SanctumOfTheTwelve: onDebug() Playing cutscene: {} " , param ) ;
2021-08-09 02:38:20 +09:00
2022-02-11 20:42:25 -06:00
//player.eventStart( player.getId(), instance->getDirectorId(), Event::EventHandler::EnterTerritory, 1, player.getZoneId() );
//player.directorPlayScene( instance->getDirectorId(), 3, FADE_OUT | CONDITION_CUTSCENE | HIDE_UI, 0, 1, param );
2021-08-09 02:38:20 +09:00
}
} ;
EXPOSE_SCRIPT ( SanctumOfTheTwelve ) ;