mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 07:07:45 +00:00
Changed the way players are being iterated for updating, some questbattle additions
This commit is contained in:
parent
ec84f7338f
commit
0079cba784
17 changed files with 112 additions and 24 deletions
|
@ -52,6 +52,12 @@ public:
|
|||
|
||||
}
|
||||
|
||||
void onDutyComplete( QuestBattle& instance, Entity::Player& player ) override
|
||||
{
|
||||
player.updateQuest( instance.getQuestId(), 2 );
|
||||
player.exitInstance();
|
||||
}
|
||||
|
||||
};
|
||||
|
||||
EXPOSE_SCRIPT( ChasingShadows );
|
|
@ -2102,3 +2102,8 @@ void Sapphire::Entity::Player::updateHuntingLog( uint16_t id )
|
|||
sendHuntingLog();
|
||||
}
|
||||
|
||||
Sapphire::World::SessionPtr Sapphire::Entity::Player::getSession()
|
||||
{
|
||||
return m_pSession;
|
||||
}
|
||||
|
||||
|
|
|
@ -972,6 +972,8 @@ namespace Sapphire::Entity
|
|||
|
||||
void updateHuntingLog( uint16_t id );
|
||||
|
||||
World::SessionPtr getSession();
|
||||
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
uint64_t m_lastMoveTime;
|
||||
|
@ -982,6 +984,8 @@ namespace Sapphire::Entity
|
|||
uint32_t m_lastWrite;
|
||||
uint32_t m_lastPing;
|
||||
|
||||
World::SessionPtr m_pSession;
|
||||
|
||||
bool m_bIsLogin;
|
||||
|
||||
uint64_t m_contentId; // This id will be the name of the folder for character settings in "My Games"
|
||||
|
|
|
@ -31,6 +31,7 @@ bool Sapphire::Entity::Player::load( uint32_t charId, World::SessionPtr pSession
|
|||
{
|
||||
auto pDb = m_pFw->get< Db::DbWorkerPool< Db::ZoneDbConnection > >();
|
||||
auto pTeriMgr = m_pFw->get< TerritoryMgr >();
|
||||
m_pSession = pSession;
|
||||
|
||||
const std::string char_id_str = std::to_string( charId );
|
||||
|
||||
|
|
|
@ -1030,6 +1030,26 @@ void Sapphire::World::Manager::DebugCommandMgr::questBattle( char* data, Entity:
|
|||
else
|
||||
player.sendDebug( "Failed to create instance with id#{0}", contentFinderConditionId );
|
||||
}
|
||||
else if( subCommand == "complete" )
|
||||
{
|
||||
|
||||
auto instance = std::dynamic_pointer_cast< QuestBattle >( player.getCurrentZone() );
|
||||
if( !instance )
|
||||
return;
|
||||
|
||||
instance->success();
|
||||
|
||||
}
|
||||
else if( subCommand == "fail" )
|
||||
{
|
||||
|
||||
auto instance = std::dynamic_pointer_cast< QuestBattle >( player.getCurrentZone() );
|
||||
if( !instance )
|
||||
return;
|
||||
|
||||
instance->fail();
|
||||
|
||||
}
|
||||
else if( subCommand == "createzone" || subCommand == "crz" )
|
||||
{
|
||||
uint32_t zoneId;
|
||||
|
|
|
@ -222,6 +222,7 @@ void Sapphire::Network::GameConnection::handleZonePacket( Sapphire::Network::Pac
|
|||
else
|
||||
{
|
||||
Logger::debug( "[{0}] Undefined Zone IPC : Unknown ( {1:04X} )", m_pSession->getId(), opcode );
|
||||
|
||||
Logger::debug( "Dump:\n{0}", Util::binaryToHexDump( const_cast< uint8_t* >( &pPacket.data[ 0 ] ),
|
||||
pPacket.segHdr.size ) );
|
||||
}
|
||||
|
|
|
@ -201,6 +201,11 @@ namespace Sapphire::ScriptAPI
|
|||
{
|
||||
}
|
||||
|
||||
void QuestBattleScript::onDutyComplete( Sapphire::QuestBattle& instance, Entity::Player& player )
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
void QuestBattleScript::onPlayerSetup( Sapphire::QuestBattle& instance, Entity::Player& player )
|
||||
{
|
||||
}
|
||||
|
|
|
@ -239,6 +239,8 @@ namespace Sapphire::ScriptAPI
|
|||
public:
|
||||
explicit QuestBattleScript( uint32_t questBattleId );
|
||||
|
||||
virtual void onDutyComplete( Sapphire::QuestBattle& instance, Entity::Player& player );
|
||||
|
||||
virtual void onPlayerSetup( Sapphire::QuestBattle& instance, Entity::Player& player );
|
||||
|
||||
virtual void onInit( Sapphire::QuestBattle& instance );
|
||||
|
|
|
@ -516,3 +516,16 @@ Sapphire::Scripting::NativeScriptMgr& Sapphire::Scripting::ScriptMgr::getNativeS
|
|||
{
|
||||
return *m_nativeScriptMgr;
|
||||
}
|
||||
|
||||
bool
|
||||
Sapphire::Scripting::ScriptMgr::onDutyComplete( Sapphire::QuestBattlePtr instance, Sapphire::Entity::Player& player )
|
||||
{
|
||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance->getDirectorId() );
|
||||
if( script )
|
||||
{
|
||||
script->onDutyComplete( *instance, player );
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -109,6 +109,8 @@ namespace Sapphire::Scripting
|
|||
bool onInstanceEnterTerritory( QuestBattlePtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
|
||||
uint16_t param2 );
|
||||
|
||||
bool onDutyComplete( QuestBattlePtr instance, Entity::Player& player );
|
||||
|
||||
bool loadDir( const std::string& dirname, std::set< std::string >& files, const std::string& ext );
|
||||
|
||||
NativeScriptMgr& getNativeScriptHandler();
|
||||
|
|
|
@ -39,7 +39,7 @@ void Sapphire::Cell::addActor( Entity::ActorPtr pAct )
|
|||
m_actors.insert( pAct );
|
||||
}
|
||||
|
||||
void Sapphire::Cell::removeActor( Entity::ActorPtr pAct )
|
||||
void Sapphire::Cell::removeActorFromCell( Entity::ActorPtr pAct )
|
||||
{
|
||||
if( pAct->isPlayer() )
|
||||
--m_playerCount;
|
||||
|
|
|
@ -36,7 +36,7 @@ public:
|
|||
|
||||
void addActor( Entity::ActorPtr pAct );
|
||||
|
||||
void removeActor( Entity::ActorPtr pAct );
|
||||
void removeActorFromCell( Entity::ActorPtr pAct );
|
||||
|
||||
bool hasActor( Entity::ActorPtr pAct )
|
||||
{
|
||||
|
|
|
@ -333,3 +333,33 @@ void Sapphire::QuestBattle::clearDirector( Entity::Player& player )
|
|||
// remove "bound by duty" state
|
||||
player.unsetStateFlag( PlayerStateFlag::BoundByDuty );
|
||||
}
|
||||
|
||||
void Sapphire::QuestBattle::success()
|
||||
{
|
||||
|
||||
m_pPlayer->eventStart( m_pPlayer->getId(), getDirectorId(), Event::EventHandler::GameProgress, 1, 0 );
|
||||
m_pPlayer->playScene( getDirectorId(), 60001, 0x40000,
|
||||
[ & ]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
player.eventFinish( getDirectorId(), 1 );
|
||||
player.eventStart( player.getId(), getDirectorId(), Event::EventHandler::GameProgress, 1, 0 );
|
||||
player.playScene( getDirectorId(), 6, HIDE_HOTBAR | NO_DEFAULT_CAMERA,
|
||||
[ & ]( Entity::Player& player, const Event::SceneResult& result )
|
||||
{
|
||||
player.eventFinish( getDirectorId(), 1 );
|
||||
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
|
||||
pScriptMgr->onDutyComplete( getAsQuestBattle(), *m_pPlayer );
|
||||
} );
|
||||
|
||||
} );
|
||||
}
|
||||
|
||||
void Sapphire::QuestBattle::fail()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
uint32_t Sapphire::QuestBattle::getQuestId() const
|
||||
{
|
||||
return m_pBattleDetails->quest;
|
||||
}
|
||||
|
|
|
@ -61,6 +61,11 @@ namespace Sapphire
|
|||
|
||||
void endEventCutscene();
|
||||
|
||||
uint32_t getQuestId() const;
|
||||
|
||||
void fail();
|
||||
void success();
|
||||
|
||||
void clearDirector( Entity::Player& player );
|
||||
|
||||
Event::Director::DirectorState getState() const;
|
||||
|
|
|
@ -234,9 +234,6 @@ void Sapphire::Zone::pushActor( Entity::ActorPtr pActor )
|
|||
auto pPlayer = pActor->getAsPlayer();
|
||||
|
||||
auto pServerZone = m_pFw->get< World::ServerMgr >();
|
||||
auto pSession = pServerZone->getSession( pPlayer->getId() );
|
||||
if( pSession )
|
||||
m_sessionSet.insert( pSession );
|
||||
m_playerMap[ pPlayer->getId() ] = pPlayer;
|
||||
updateCellActivity( cx, cy, 2 );
|
||||
}
|
||||
|
@ -259,7 +256,7 @@ void Sapphire::Zone::removeActor( Entity::ActorPtr pActor )
|
|||
|
||||
Cell* pCell = getCellPtr( cx, cy );
|
||||
if( pCell && pCell->hasActor( pActor ) )
|
||||
pCell->removeActor( pActor );
|
||||
pCell->removeActorFromCell( pActor );
|
||||
|
||||
if( pActor->isPlayer() )
|
||||
{
|
||||
|
@ -459,26 +456,22 @@ bool Sapphire::Zone::update( uint64_t tickCount )
|
|||
void Sapphire::Zone::updateSessions( uint64_t tickCount, bool changedWeather )
|
||||
{
|
||||
// update sessions in this zone
|
||||
for( auto it = m_sessionSet.begin(); it != m_sessionSet.end(); ++it )
|
||||
for( auto it = m_playerMap.begin(); it != m_playerMap.end(); ++it )
|
||||
{
|
||||
|
||||
auto pSession = *it;
|
||||
auto pPlayer = it->second;
|
||||
|
||||
if( !pSession )
|
||||
if( !pPlayer )
|
||||
{
|
||||
it = m_sessionSet.erase( it );
|
||||
continue;
|
||||
m_playerMap.erase( it );
|
||||
return;
|
||||
}
|
||||
|
||||
auto pPlayer = pSession->getPlayer();
|
||||
|
||||
// this session is not linked to this area anymore, remove it from zone session list
|
||||
if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) )
|
||||
{
|
||||
removeActor( pSession->getPlayer() );
|
||||
|
||||
it = m_sessionSet.erase( it );
|
||||
continue;
|
||||
removeActor( pPlayer );
|
||||
return;
|
||||
}
|
||||
|
||||
m_lastUpdate = tickCount;
|
||||
|
@ -488,11 +481,15 @@ void Sapphire::Zone::updateSessions( uint64_t tickCount, bool changedWeather )
|
|||
auto weatherChangePacket = makeZonePacket< FFXIVIpcWeatherChange >( pPlayer->getId() );
|
||||
weatherChangePacket->data().weatherId = static_cast< uint8_t >( m_currentWeather );
|
||||
weatherChangePacket->data().delay = 5.0f;
|
||||
pSession->getPlayer()->queuePacket( weatherChangePacket );
|
||||
pPlayer->queuePacket( weatherChangePacket );
|
||||
}
|
||||
|
||||
// perform session duties
|
||||
pSession->update();
|
||||
pPlayer->getSession()->update();
|
||||
|
||||
// this session is not linked to this area anymore, remove it from zone session list
|
||||
if( ( !pPlayer->getCurrentZone() ) || ( pPlayer->getCurrentZone() != shared_from_this() ) )
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -599,7 +596,7 @@ void Sapphire::Zone::updateActorPosition( Entity::Actor& actor )
|
|||
|
||||
if( pOldCell )
|
||||
{
|
||||
pOldCell->removeActor( actor.shared_from_this() );
|
||||
pOldCell->removeActorFromCell( actor.shared_from_this() );
|
||||
}
|
||||
|
||||
pCell->addActor( actor.shared_from_this() );
|
||||
|
|
|
@ -21,7 +21,6 @@ namespace Sapphire
|
|||
|
||||
class ZonePosition;
|
||||
|
||||
using SessionSet = std::set< World::SessionPtr >;
|
||||
using FestivalPair = std::pair< uint16_t, uint16_t >;
|
||||
|
||||
namespace Data
|
||||
|
@ -44,8 +43,6 @@ namespace Sapphire
|
|||
std::unordered_map< int32_t, Entity::BNpcPtr > m_bNpcMap;
|
||||
std::unordered_map< int32_t, Entity::EventObjectPtr > m_eventObjects;
|
||||
|
||||
SessionSet m_sessionSet;
|
||||
|
||||
Common::Weather m_currentWeather;
|
||||
Common::Weather m_weatherOverride;
|
||||
std::map< uint8_t, int32_t > m_weatherRateMap;
|
||||
|
|
|
@ -14,7 +14,7 @@ Sapphire::World::Util::ActorFilterInRange::ActorFilterInRange( Common::FFXIVARR_
|
|||
bool Sapphire::World::Util::ActorFilterInRange::conditionApplies( const Entity::Actor& actor )
|
||||
{
|
||||
return Sapphire::Util::distance( m_startPos.x, m_startPos.y, m_startPos.z,
|
||||
actor.getPos().x, actor.getPos().y, actor.getPos().z ) <= m_range;
|
||||
actor.getPos().x, actor.getPos().y, actor.getPos().z ) <= m_range;
|
||||
}
|
||||
|
||||
///////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
|
|
Loading…
Add table
Reference in a new issue