mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 07:37:45 +00:00
first batch of moving packet/logic out of player to playermgr;
This commit is contained in:
parent
6a9f5b683f
commit
2b57b73471
14 changed files with 170 additions and 131 deletions
|
@ -396,7 +396,7 @@ private:
|
||||||
{
|
{
|
||||||
eventMgr().sendEventNotice( player, getId(), 3, 0 );
|
eventMgr().sendEventNotice( player, getId(), 3, 0 );
|
||||||
quest.setSeq( Seq5 );
|
quest.setSeq( Seq5 );
|
||||||
player.setMount( Mount0 );
|
playerMgr().onMountUpdate( player, Mount0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -490,7 +490,7 @@ private:
|
||||||
|
|
||||||
void Scene00017Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result )
|
void Scene00017Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result )
|
||||||
{
|
{
|
||||||
player.setMount( Mount0 );
|
playerMgr().onMountUpdate( player, Mount0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -562,7 +562,7 @@ private:
|
||||||
|
|
||||||
void Scene00023Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result )
|
void Scene00023Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result )
|
||||||
{
|
{
|
||||||
player.setMount( Mount0 );
|
playerMgr().onMountUpdate( player, Mount0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
@ -611,7 +611,7 @@ private:
|
||||||
{
|
{
|
||||||
eventMgr().sendEventNotice( player, getId(), 6, 0 );
|
eventMgr().sendEventNotice( player, getId(), 6, 0 );
|
||||||
quest.setSeq( Seq8 );
|
quest.setSeq( Seq8 );
|
||||||
player.setMount( 0 );
|
playerMgr().onMountUpdate( player, 0 );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -646,7 +646,7 @@ private:
|
||||||
|
|
||||||
void Scene00030Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result )
|
void Scene00030Return( World::Quest& quest, Entity::Player& player, const Event::SceneResult& result )
|
||||||
{
|
{
|
||||||
player.setMount( Mount0 );
|
playerMgr().onMountUpdate( player, Mount0 );
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////
|
||||||
|
|
|
@ -320,7 +320,7 @@ void Action::Action::start()
|
||||||
|
|
||||||
if( player )
|
if( player )
|
||||||
{
|
{
|
||||||
player->setStateFlag( PlayerStateFlag::Casting );
|
Service< World::Manager::PlayerMgr >::ref().onSendStateFlags( *player, PlayerStateFlag::Casting );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -368,14 +368,14 @@ void Action::Action::interrupt()
|
||||||
// things that aren't players don't care about cooldowns and state flags
|
// things that aren't players don't care about cooldowns and state flags
|
||||||
if( m_pSource->isPlayer() )
|
if( m_pSource->isPlayer() )
|
||||||
{
|
{
|
||||||
auto player = m_pSource->getAsPlayer();
|
auto pPlayer = m_pSource->getAsPlayer();
|
||||||
|
|
||||||
// todo: reset cooldown for actual player
|
// todo: reset cooldown for actual player
|
||||||
|
|
||||||
// reset state flag
|
// reset state flag
|
||||||
//player->unsetStateFlag( PlayerStateFlag::Occupied1 );
|
//player->unsetStateFlag( PlayerStateFlag::Occupied1 );
|
||||||
player->setLastActionTick( 0 );
|
pPlayer->setLastActionTick( 0 );
|
||||||
player->unsetStateFlag( PlayerStateFlag::Casting );
|
Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( *pPlayer, PlayerStateFlag::Casting );
|
||||||
}
|
}
|
||||||
|
|
||||||
if( hasCastTime() )
|
if( hasCastTime() )
|
||||||
|
@ -424,10 +424,10 @@ void Action::Action::execute()
|
||||||
0x219, m_id, m_id, m_id, m_id );
|
0x219, m_id, m_id, m_id, m_id );
|
||||||
m_pSource->sendToInRangeSet( control, true );*/
|
m_pSource->sendToInRangeSet( control, true );*/
|
||||||
|
|
||||||
if( auto player = m_pSource->getAsPlayer() )
|
if( auto pPlayer = m_pSource->getAsPlayer(); pPlayer )
|
||||||
{
|
{
|
||||||
player->setLastActionTick( 0 );
|
pPlayer->setLastActionTick( 0 );
|
||||||
player->unsetStateFlag( PlayerStateFlag::Casting );
|
Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( *pPlayer, PlayerStateFlag::Casting );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,9 @@
|
||||||
|
|
||||||
#include <Util/Util.h>
|
#include <Util/Util.h>
|
||||||
|
|
||||||
|
#include <Service.h>
|
||||||
|
#include <Manager/PlayerMgr.h>
|
||||||
|
|
||||||
#include "Actor/Chara.h"
|
#include "Actor/Chara.h"
|
||||||
#include "Actor/Player.h"
|
#include "Actor/Player.h"
|
||||||
|
|
||||||
|
@ -133,7 +136,7 @@ void EffectResult::execute()
|
||||||
case Common::ActionEffectType::CALC_RESULT_TYPE_MOUNT:
|
case Common::ActionEffectType::CALC_RESULT_TYPE_MOUNT:
|
||||||
{
|
{
|
||||||
auto pPlayer = m_target->getAsPlayer();
|
auto pPlayer = m_target->getAsPlayer();
|
||||||
pPlayer->setMount( m_value );
|
Common::Service< World::Manager::PlayerMgr >::ref().onMountUpdate( *pPlayer, m_value );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -4,9 +4,12 @@
|
||||||
#include <Exd/Structs.h>
|
#include <Exd/Structs.h>
|
||||||
#include <Network/CommonActorControl.h>
|
#include <Network/CommonActorControl.h>
|
||||||
|
|
||||||
|
#include <Manager/PlayerMgr.h>
|
||||||
|
#include <Manager/EventMgr.h>
|
||||||
|
|
||||||
#include "Network/PacketWrappers/ActorControlPacket.h"
|
#include <Network/PacketWrappers/ActorControlPacket.h>
|
||||||
#include "Network/PacketWrappers/ActorControlSelfPacket.h"
|
#include <Network/PacketWrappers/ActorControlSelfPacket.h>
|
||||||
|
#include <Network/CommonActorControl.h>
|
||||||
|
|
||||||
#include "Actor/Player.h"
|
#include "Actor/Player.h"
|
||||||
|
|
||||||
|
@ -14,7 +17,6 @@
|
||||||
#include "WorldServer.h"
|
#include "WorldServer.h"
|
||||||
#include "Session.h"
|
#include "Session.h"
|
||||||
#include "Network/GameConnection.h"
|
#include "Network/GameConnection.h"
|
||||||
#include "Manager/EventMgr.h"
|
|
||||||
|
|
||||||
#include "EventAction.h"
|
#include "EventAction.h"
|
||||||
|
|
||||||
|
@ -54,9 +56,11 @@ void Action::EventAction::start()
|
||||||
|
|
||||||
if( m_pSource->isPlayer() )
|
if( m_pSource->isPlayer() )
|
||||||
{
|
{
|
||||||
|
auto pPlayer = m_pSource->getAsPlayer();
|
||||||
|
|
||||||
m_pSource->sendToInRangeSet( control, true );
|
m_pSource->sendToInRangeSet( control, true );
|
||||||
if( m_pSource->getAsPlayer()->hasStateFlag( PlayerStateFlag::InNpcEvent ) )
|
if( pPlayer->hasStateFlag( PlayerStateFlag::InNpcEvent ) )
|
||||||
m_pSource->getAsPlayer()->unsetStateFlag( PlayerStateFlag::InNpcEvent );
|
Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( *pPlayer, PlayerStateFlag::InNpcEvent );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
m_pSource->sendToInRangeSet( control );
|
m_pSource->sendToInRangeSet( control );
|
||||||
|
|
|
@ -2,17 +2,19 @@
|
||||||
|
|
||||||
#include <Exd/ExdData.h>
|
#include <Exd/ExdData.h>
|
||||||
|
|
||||||
#include "Actor/Player.h"
|
#include <Actor/Player.h>
|
||||||
|
|
||||||
|
#include <Manager/PlayerMgr.h>
|
||||||
|
|
||||||
|
#include <Network/GameConnection.h>
|
||||||
#include <Network/CommonActorControl.h>
|
#include <Network/CommonActorControl.h>
|
||||||
#include "Network/PacketWrappers/ActorControlSelfPacket.h"
|
#include <Network/PacketWrappers/ActorControlSelfPacket.h>
|
||||||
|
|
||||||
#include <Service.h>
|
#include <Service.h>
|
||||||
#include <Util/UtilMath.h>
|
#include <Util/UtilMath.h>
|
||||||
|
|
||||||
#include "WorldServer.h"
|
#include "WorldServer.h"
|
||||||
#include "Session.h"
|
#include "Session.h"
|
||||||
#include "Network/GameConnection.h"
|
|
||||||
|
|
||||||
using namespace Sapphire;
|
using namespace Sapphire;
|
||||||
using namespace Sapphire::Network::Packets;
|
using namespace Sapphire::Network::Packets;
|
||||||
|
@ -59,20 +61,19 @@ void MountAction::start()
|
||||||
|
|
||||||
m_pSource->sendToInRangeSet( castPacket, true );
|
m_pSource->sendToInRangeSet( castPacket, true );
|
||||||
|
|
||||||
player->setStateFlag( Common::PlayerStateFlag::Casting );
|
Common::Service< World::Manager::PlayerMgr >::ref().onSetStateFlag( *player, Common::PlayerStateFlag::Casting );
|
||||||
|
|
||||||
auto actionStartPkt = makeActorControlSelf( m_pSource->getId(), ActorControlType::ActionStart, 1, getId(), m_recastTimeMs / 10 );
|
auto actionStartPkt = makeActorControlSelf( m_pSource->getId(), ActorControlType::ActionStart, 1, getId(), m_recastTimeMs / 10 );
|
||||||
|
|
||||||
auto& server = Common::Service< World::WorldServer >::ref();
|
auto& server = Common::Service< World::WorldServer >::ref();
|
||||||
server.queueForPlayer( m_pSource->getAsPlayer()->getCharacterId(), actionStartPkt );
|
server.queueForPlayer( m_pSource->getAsPlayer()->getCharacterId(), actionStartPkt );
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void MountAction::execute()
|
void MountAction::execute()
|
||||||
{
|
{
|
||||||
assert( m_pSource );
|
assert( m_pSource );
|
||||||
|
|
||||||
m_pSource->getAsPlayer()->unsetStateFlag( Common::PlayerStateFlag::Casting );
|
Common::Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( *m_pSource->getAsPlayer(), Common::PlayerStateFlag::Casting );
|
||||||
m_effectBuilder->mount( m_pSource, m_mountId );
|
m_effectBuilder->mount( m_pSource, m_mountId );
|
||||||
m_effectBuilder->buildAndSendPackets( { m_pSource } );
|
m_effectBuilder->buildAndSendPackets( { m_pSource } );
|
||||||
}
|
}
|
|
@ -670,8 +670,6 @@ void Player::learnSong( uint8_t songId, uint32_t itemId )
|
||||||
Util::valueToFlagByteIndexValue( songId, value, index );
|
Util::valueToFlagByteIndexValue( songId, value, index );
|
||||||
|
|
||||||
m_orchestrion[ index ] |= value;
|
m_orchestrion[ index ] |= value;
|
||||||
|
|
||||||
Service< World::Manager::PlayerMgr >::ref().onUnlockOrchestrion( *this, songId, itemId );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Player::hasReward( Common::UnlockEntry unlockId ) const
|
bool Player::hasReward( Common::UnlockEntry unlockId ) const
|
||||||
|
@ -955,7 +953,6 @@ bool Player::hasStateFlag( Common::PlayerStateFlag flag ) const
|
||||||
|
|
||||||
void Player::setStateFlag( Common::PlayerStateFlag flag )
|
void Player::setStateFlag( Common::PlayerStateFlag flag )
|
||||||
{
|
{
|
||||||
auto prevOnlineStatus = getOnlineStatus();
|
|
||||||
auto iFlag = static_cast< int32_t >( flag );
|
auto iFlag = static_cast< int32_t >( flag );
|
||||||
|
|
||||||
uint16_t index;
|
uint16_t index;
|
||||||
|
@ -963,22 +960,6 @@ void Player::setStateFlag( Common::PlayerStateFlag flag )
|
||||||
Util::valueToFlagByteIndexValue( iFlag, value, index );
|
Util::valueToFlagByteIndexValue( iFlag, value, index );
|
||||||
|
|
||||||
m_stateFlags[ index ] |= value;
|
m_stateFlags[ index ] |= value;
|
||||||
|
|
||||||
auto newOnlineStatus = getOnlineStatus();
|
|
||||||
sendStateFlags( prevOnlineStatus != newOnlineStatus );
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::setStateFlags( std::vector< Common::PlayerStateFlag > flags )
|
|
||||||
{
|
|
||||||
for( const auto& flag : flags )
|
|
||||||
{
|
|
||||||
setStateFlag( flag );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
void Player::sendStateFlags( bool updateInRange )
|
|
||||||
{
|
|
||||||
Service< World::Manager::PlayerMgr >::ref().onSendStateFlags( *this, updateInRange );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::unsetStateFlag( Common::PlayerStateFlag flag )
|
void Player::unsetStateFlag( Common::PlayerStateFlag flag )
|
||||||
|
@ -986,8 +967,6 @@ void Player::unsetStateFlag( Common::PlayerStateFlag flag )
|
||||||
if( !hasStateFlag( flag ) )
|
if( !hasStateFlag( flag ) )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
auto prevOnlineStatus = getOnlineStatus();
|
|
||||||
|
|
||||||
auto iFlag = static_cast< int32_t >( flag );
|
auto iFlag = static_cast< int32_t >( flag );
|
||||||
|
|
||||||
uint16_t index;
|
uint16_t index;
|
||||||
|
@ -995,60 +974,21 @@ void Player::unsetStateFlag( Common::PlayerStateFlag flag )
|
||||||
Util::valueToFlagByteIndexValue( iFlag, value, index );
|
Util::valueToFlagByteIndexValue( iFlag, value, index );
|
||||||
|
|
||||||
m_stateFlags[ index ] ^= value;
|
m_stateFlags[ index ] ^= value;
|
||||||
|
|
||||||
auto newOnlineStatus = getOnlineStatus();
|
|
||||||
sendStateFlags( prevOnlineStatus != newOnlineStatus );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::update( uint64_t tickCount )
|
void Player::update( uint64_t tickCount )
|
||||||
{
|
{
|
||||||
if( m_hp <= 0 && m_status != ActorStatus::Dead )
|
// todo: better way to handle this override chara update
|
||||||
{
|
Service< World::Manager::PlayerMgr >::ref().onUpdate( *this, tickCount );
|
||||||
die();
|
|
||||||
Service< World::Manager::PlayerMgr >::ref().onDeath( *this );
|
|
||||||
}
|
|
||||||
|
|
||||||
if( !isAlive() )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_lastUpdate = tickCount;
|
|
||||||
|
|
||||||
if( !checkAction() )
|
|
||||||
{
|
|
||||||
if( m_targetId && m_currentStance == Common::Stance::Active && isAutoattackOn() )
|
|
||||||
{
|
|
||||||
auto mainWeap = getItemAt( Common::GearSet0, Common::GearSetSlot::MainHand );
|
|
||||||
|
|
||||||
// @TODO i dislike this, iterating over all in range actors when you already know the id of the actor you need...
|
|
||||||
for( const auto& actor : m_inRangeActor )
|
|
||||||
{
|
|
||||||
if( actor->getId() == m_targetId && actor->getAsChara()->isAlive() && mainWeap )
|
|
||||||
{
|
|
||||||
auto chara = actor->getAsChara();
|
|
||||||
|
|
||||||
// default autoattack range
|
|
||||||
float range = 3.f + chara->getRadius() + getRadius() * 0.5f;
|
|
||||||
|
|
||||||
// default autoattack range for ranged classes
|
|
||||||
if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer )
|
|
||||||
range = 25.f + chara->getRadius() + getRadius() * 0.5f;
|
|
||||||
|
|
||||||
if( Util::distance( getPos(), actor->getPos() ) <= range )
|
|
||||||
{
|
|
||||||
if( ( tickCount - m_lastAttack ) > mainWeap->getDelay() )
|
|
||||||
{
|
|
||||||
m_lastAttack = tickCount;
|
|
||||||
autoAttack( actor->getAsChara() );
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
Chara::update( tickCount );
|
Chara::update( tickCount );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint64_t Player::getLastAttack() const
|
||||||
|
{
|
||||||
|
return m_lastAttack;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::setLastAttack( uint64_t tickCount )
|
void Player::setLastAttack( uint64_t tickCount )
|
||||||
{
|
{
|
||||||
m_lastAttack = tickCount;
|
m_lastAttack = tickCount;
|
||||||
|
@ -1112,6 +1052,11 @@ const Player::OrchestrionList& Player::getOrchestrionBitmask() const
|
||||||
return m_orchestrion;
|
return m_orchestrion;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Player::setOrchestrionBitmask( const Player::OrchestrionList& orchestrion )
|
||||||
|
{
|
||||||
|
m_orchestrion = orchestrion;
|
||||||
|
}
|
||||||
|
|
||||||
void Player::unlockMount( uint32_t mountId )
|
void Player::unlockMount( uint32_t mountId )
|
||||||
{
|
{
|
||||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||||
|
@ -1373,21 +1318,11 @@ uint8_t Player::getEquipDisplayFlags() const
|
||||||
void Player::setMount( uint32_t mountId )
|
void Player::setMount( uint32_t mountId )
|
||||||
{
|
{
|
||||||
m_mount = mountId;
|
m_mount = mountId;
|
||||||
|
|
||||||
Service< World::Manager::PlayerMgr >::ref().onMountUpdate( *this, m_mount );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Player::setCompanion( uint8_t id )
|
void Player::setCompanion( uint8_t id )
|
||||||
{
|
{
|
||||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
|
||||||
|
|
||||||
auto companion = exdData.getRow< Excel::Companion >( id );
|
|
||||||
if( !id )
|
|
||||||
return;
|
|
||||||
|
|
||||||
m_companionId = id;
|
m_companionId = id;
|
||||||
|
|
||||||
Service< World::Manager::PlayerMgr >::ref().onCompanionUpdate( *this, m_companionId );
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t Player::getCurrentCompanion() const
|
uint8_t Player::getCurrentCompanion() const
|
||||||
|
|
|
@ -83,6 +83,10 @@ namespace Sapphire::Entity
|
||||||
/*! Event called on every session iteration */
|
/*! Event called on every session iteration */
|
||||||
void update( uint64_t tickCount ) override;
|
void update( uint64_t tickCount ) override;
|
||||||
|
|
||||||
|
/*! get last attack tick for player */
|
||||||
|
uint64_t getLastAttack() const;
|
||||||
|
|
||||||
|
/*! set last attack tick for player */
|
||||||
void setLastAttack( uint64_t tickCount );
|
void setLastAttack( uint64_t tickCount );
|
||||||
|
|
||||||
// Quest
|
// Quest
|
||||||
|
@ -418,7 +422,7 @@ namespace Sapphire::Entity
|
||||||
/*! check if aetheryte is already registered */
|
/*! check if aetheryte is already registered */
|
||||||
bool isAetheryteRegistered( uint8_t aetheryteId ) const;
|
bool isAetheryteRegistered( uint8_t aetheryteId ) const;
|
||||||
|
|
||||||
/*! return a const pointer to the aetheryte unlock bitmask array */
|
/*! return aetheryte mask */
|
||||||
uint8_t getAetheryteMaskAt( uint8_t index ) const;
|
uint8_t getAetheryteMaskAt( uint8_t index ) const;
|
||||||
|
|
||||||
/*! return a pointer to the aetheryte unlock bitmask array */
|
/*! return a pointer to the aetheryte unlock bitmask array */
|
||||||
|
@ -433,13 +437,13 @@ namespace Sapphire::Entity
|
||||||
/*! discover subarea subid fo map map_id, also send udpate packet */
|
/*! discover subarea subid fo map map_id, also send udpate packet */
|
||||||
void discover( int16_t map_id, int16_t sub_id );
|
void discover( int16_t map_id, int16_t sub_id );
|
||||||
|
|
||||||
/*! return a pointer to the discovery bitmask array */
|
/*! return a reference to the discovery bitmask array */
|
||||||
Discovery& getDiscoveryBitmask();
|
Discovery& getDiscoveryBitmask();
|
||||||
|
|
||||||
/*! helper/debug function to reset all discovered areas */
|
/*! helper/debug function to reset all discovered areas */
|
||||||
void resetDiscovery();
|
void resetDiscovery();
|
||||||
|
|
||||||
/*! get a pointer to the howto bitmask array */
|
/*! get a reference to the howto bitmask array */
|
||||||
HowToList& getHowToArray();
|
HowToList& getHowToArray();
|
||||||
|
|
||||||
/*! update bitmask for how-to's seen */
|
/*! update bitmask for how-to's seen */
|
||||||
|
@ -454,22 +458,25 @@ namespace Sapphire::Entity
|
||||||
/*! check if an action is already unlocked in the bitmask. */
|
/*! check if an action is already unlocked in the bitmask. */
|
||||||
bool hasReward( Common::UnlockEntry unlockId ) const;
|
bool hasReward( Common::UnlockEntry unlockId ) const;
|
||||||
|
|
||||||
/*! return a const pointer to the unlock bitmask array */
|
/*! return a const reference to the unlock bitmask array */
|
||||||
const UnlockList& getUnlockBitmask() const;
|
const UnlockList& getUnlockBitmask() const;
|
||||||
|
|
||||||
/*! return a const pointer to the orchestrion bitmask array */
|
/*! return a const reference to the orchestrion bitmask array */
|
||||||
const OrchestrionList& getOrchestrionBitmask() const;
|
const OrchestrionList& getOrchestrionBitmask() const;
|
||||||
|
|
||||||
|
/*! set orchestrion bitmask array */
|
||||||
|
void setOrchestrionBitmask( const OrchestrionList& orchestrion );
|
||||||
|
|
||||||
/*! unlock a mount */
|
/*! unlock a mount */
|
||||||
void unlockMount( uint32_t mountId );
|
void unlockMount( uint32_t mountId );
|
||||||
|
|
||||||
/*! unlock a companion */
|
/*! unlock a companion */
|
||||||
void unlockCompanion( uint32_t companionId );
|
void unlockCompanion( uint32_t companionId );
|
||||||
|
|
||||||
/*! return a const pointer to the minion guide bitmask array */
|
/*! return a reference to the minion guide bitmask array */
|
||||||
MinionList& getMinionGuideBitmask();
|
MinionList& getMinionGuideBitmask();
|
||||||
|
|
||||||
/*! return a const pointer to the setMount guide bitmask array */
|
/*! return a reference to the setMount guide bitmask array */
|
||||||
MountList& getMountGuideBitmask();
|
MountList& getMountGuideBitmask();
|
||||||
|
|
||||||
bool checkAction() override;
|
bool checkAction() override;
|
||||||
|
|
|
@ -269,8 +269,8 @@ void DebugCommandMgr::set( char* data, Entity::Player& player, std::shared_ptr<
|
||||||
int32_t id;
|
int32_t id;
|
||||||
sscanf( params.c_str(), "%d", &id );
|
sscanf( params.c_str(), "%d", &id );
|
||||||
|
|
||||||
player.setMount( 0 );
|
Common::Service< World::Manager::PlayerMgr >::ref().onMountUpdate( player, 0 );
|
||||||
player.setMount( static_cast< uint32_t >( id ));
|
Common::Service< World::Manager::PlayerMgr >::ref().onMountUpdate( player, id );
|
||||||
}
|
}
|
||||||
else if( subCommand == "weatheroverride" || subCommand == "wo" )
|
else if( subCommand == "weatheroverride" || subCommand == "wo" )
|
||||||
{
|
{
|
||||||
|
|
|
@ -555,12 +555,12 @@ void EventMgr::eventFinish( Sapphire::Entity::Player& player, uint32_t eventId,
|
||||||
}
|
}
|
||||||
|
|
||||||
if( player.hasStateFlag( Common::PlayerStateFlag::WatchingCutscene ) )
|
if( player.hasStateFlag( Common::PlayerStateFlag::WatchingCutscene ) )
|
||||||
player.unsetStateFlag( Common::PlayerStateFlag::WatchingCutscene );
|
Common::Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( player, Common::PlayerStateFlag::WatchingCutscene );
|
||||||
|
|
||||||
player.removeEvent( pEvent->getId() );
|
player.removeEvent( pEvent->getId() );
|
||||||
|
|
||||||
if( freePlayer == 1 )
|
if( freePlayer == 1 )
|
||||||
player.unsetStateFlag( Common::PlayerStateFlag::InNpcEvent );
|
Common::Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( player, Common::PlayerStateFlag::InNpcEvent );
|
||||||
}
|
}
|
||||||
|
|
||||||
void EventMgr::eventStart( Entity::Player& player, uint64_t actorId, uint32_t eventId, Event::EventHandler::EventType eventType, uint8_t eventParam1,
|
void EventMgr::eventStart( Entity::Player& player, uint64_t actorId, uint32_t eventId, Event::EventHandler::EventType eventType, uint8_t eventParam1,
|
||||||
|
@ -571,7 +571,7 @@ void EventMgr::eventStart( Entity::Player& player, uint64_t actorId, uint32_t ev
|
||||||
newEvent->setEventFinishCallback( std::move( callback ) );
|
newEvent->setEventFinishCallback( std::move( callback ) );
|
||||||
player.addEvent( newEvent );
|
player.addEvent( newEvent );
|
||||||
|
|
||||||
player.setStateFlag( Common::PlayerStateFlag::InNpcEvent );
|
Common::Service< World::Manager::PlayerMgr >::ref().onSetStateFlag( player, Common::PlayerStateFlag::InNpcEvent );
|
||||||
|
|
||||||
server.queueForPlayer( player.getCharacterId(), std::make_shared< EventStartPacket >( player.getId(), actorId,
|
server.queueForPlayer( player.getCharacterId(), std::make_shared< EventStartPacket >( player.getId(), actorId,
|
||||||
eventId, eventType, eventParam1, eventParam2 ) );
|
eventId, eventType, eventParam1, eventParam2 ) );
|
||||||
|
@ -836,7 +836,7 @@ Sapphire::Event::EventHandlerPtr EventMgr::bootstrapSceneEvent( Entity::Player&
|
||||||
}
|
}
|
||||||
|
|
||||||
if( flags & CONDITION_CUTSCENE )
|
if( flags & CONDITION_CUTSCENE )
|
||||||
player.setStateFlag( Common::PlayerStateFlag::WatchingCutscene );
|
Common::Service< World::Manager::PlayerMgr >::ref().onSetStateFlag( player, Common::PlayerStateFlag::WatchingCutscene );
|
||||||
|
|
||||||
return pEvent;
|
return pEvent;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,8 +13,8 @@
|
||||||
#include <Manager/HousingMgr.h>
|
#include <Manager/HousingMgr.h>
|
||||||
#include <Manager/FreeCompanyMgr.h>
|
#include <Manager/FreeCompanyMgr.h>
|
||||||
|
|
||||||
#include "Script/ScriptMgr.h"
|
#include <Script/ScriptMgr.h>
|
||||||
#include "WorldServer.h"
|
#include <WorldServer.h>
|
||||||
#include <Common.h>
|
#include <Common.h>
|
||||||
|
|
||||||
#include <Network/PacketContainer.h>
|
#include <Network/PacketContainer.h>
|
||||||
|
@ -23,19 +23,23 @@
|
||||||
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
#include <Network/PacketDef/Zone/ServerZoneDef.h>
|
||||||
#include <Network/PacketWrappers/ActorControlPacket.h>
|
#include <Network/PacketWrappers/ActorControlPacket.h>
|
||||||
#include <Network/PacketWrappers/ActorControlSelfPacket.h>
|
#include <Network/PacketWrappers/ActorControlSelfPacket.h>
|
||||||
#include "Network/PacketWrappers/ActorControlTargetPacket.h"
|
#include <Network/PacketWrappers/ActorControlTargetPacket.h>
|
||||||
#include "Network/PacketWrappers/InitZonePacket.h"
|
#include <Network/PacketWrappers/InitZonePacket.h>
|
||||||
#include <Network/PacketWrappers/ModelEquipPacket.h>
|
#include <Network/PacketWrappers/ModelEquipPacket.h>
|
||||||
#include "Network/PacketWrappers/PlayerSetupPacket.h"
|
#include <Network/PacketWrappers/PlayerSetupPacket.h>
|
||||||
#include <Network/PacketWrappers/PlayerStateFlagsPacket.h>
|
#include <Network/PacketWrappers/PlayerStateFlagsPacket.h>
|
||||||
#include <Network/PacketWrappers/UpdateHpMpTpPacket.h>
|
#include <Network/PacketWrappers/UpdateHpMpTpPacket.h>
|
||||||
#include "Network/PacketWrappers/ServerNoticePacket.h"
|
#include <Network/PacketWrappers/ServerNoticePacket.h>
|
||||||
#include "Network/PacketWrappers/ChatPacket.h"
|
#include <Network/PacketWrappers/ChatPacket.h>
|
||||||
#include "Network/PacketWrappers/HudParamPacket.h"
|
#include <Network/PacketWrappers/HudParamPacket.h>
|
||||||
|
|
||||||
#include <Actor/Player.h>
|
#include <Actor/Player.h>
|
||||||
#include <Actor/BNpc.h>
|
#include <Actor/BNpc.h>
|
||||||
|
|
||||||
|
#include <Inventory/Item.h>
|
||||||
|
|
||||||
|
#include <Util/UtilMath.h>
|
||||||
|
|
||||||
using namespace Sapphire;
|
using namespace Sapphire;
|
||||||
using namespace Sapphire::World::Manager;
|
using namespace Sapphire::World::Manager;
|
||||||
using namespace Sapphire::Network::Packets;
|
using namespace Sapphire::Network::Packets;
|
||||||
|
@ -213,6 +217,8 @@ void PlayerMgr::onGainExp( Entity::Player& player, uint32_t exp )
|
||||||
|
|
||||||
void PlayerMgr::onUnlockOrchestrion( Entity::Player& player, uint8_t songId, uint32_t itemId )
|
void PlayerMgr::onUnlockOrchestrion( Entity::Player& player, uint8_t songId, uint32_t itemId )
|
||||||
{
|
{
|
||||||
|
player.learnSong( songId, itemId );
|
||||||
|
|
||||||
auto& server = Common::Service< World::WorldServer >::ref();
|
auto& server = Common::Service< World::WorldServer >::ref();
|
||||||
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), ToggleOrchestrionUnlock, songId, 1, itemId ) );
|
server.queueForPlayer( player.getCharacterId(), makeActorControlSelf( player.getId(), ToggleOrchestrionUnlock, songId, 1, itemId ) );
|
||||||
}
|
}
|
||||||
|
@ -235,11 +241,21 @@ void PlayerMgr::onGcUpdate( Entity::Player& player )
|
||||||
|
|
||||||
void PlayerMgr::onCompanionUpdate( Entity::Player& player, uint8_t companionId )
|
void PlayerMgr::onCompanionUpdate( Entity::Player& player, uint8_t companionId )
|
||||||
{
|
{
|
||||||
|
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||||
|
|
||||||
|
auto companion = exdData.getRow< Excel::Companion >( companionId );
|
||||||
|
if( !companion )
|
||||||
|
return;
|
||||||
|
|
||||||
|
player.setCompanion( companionId );
|
||||||
|
|
||||||
player.sendToInRangeSet( makeActorControl( player.getId(), ActorControlType::ToggleCompanion, companionId ), true );
|
player.sendToInRangeSet( makeActorControl( player.getId(), ActorControlType::ToggleCompanion, companionId ), true );
|
||||||
}
|
}
|
||||||
|
|
||||||
void PlayerMgr::onMountUpdate( Entity::Player& player, uint32_t mountId )
|
void PlayerMgr::onMountUpdate( Entity::Player& player, uint32_t mountId )
|
||||||
{
|
{
|
||||||
|
Common::Service< World::Manager::PlayerMgr >::ref().onMountUpdate( player, mountId );
|
||||||
|
|
||||||
if( mountId != 0 )
|
if( mountId != 0 )
|
||||||
{
|
{
|
||||||
player.sendToInRangeSet( makeActorControl( player.getId(), ActorControlType::SetStatus,
|
player.sendToInRangeSet( makeActorControl( player.getId(), ActorControlType::SetStatus,
|
||||||
|
@ -427,6 +443,73 @@ void PlayerMgr::onZone( Sapphire::Entity::Player& player )
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::onUpdate( Entity::Player& player, uint64_t tickCount )
|
||||||
|
{
|
||||||
|
if( player.getHp() <= 0 && player.getStatus() != Common::ActorStatus::Dead )
|
||||||
|
{
|
||||||
|
player.die();
|
||||||
|
onDeath( player );
|
||||||
|
}
|
||||||
|
|
||||||
|
if( !player.isAlive() )
|
||||||
|
return;
|
||||||
|
|
||||||
|
if( !player.checkAction() )
|
||||||
|
{
|
||||||
|
if( player.getTargetId() && player.getStance() == Common::Stance::Active && player.isAutoattackOn() )
|
||||||
|
{
|
||||||
|
auto mainWeap = player.getItemAt( Common::GearSet0, Common::GearSetSlot::MainHand );
|
||||||
|
|
||||||
|
// @TODO i dislike this, iterating over all in range actors when you already know the id of the actor you need...
|
||||||
|
for( const auto& actor : player.getInRangeActors() )
|
||||||
|
{
|
||||||
|
if( actor->getId() == player.getTargetId() && actor->getAsChara()->isAlive() && mainWeap )
|
||||||
|
{
|
||||||
|
auto chara = actor->getAsChara();
|
||||||
|
|
||||||
|
// default autoattack range
|
||||||
|
float range = 3.f + chara->getRadius() + player.getRadius() * 0.5f;
|
||||||
|
|
||||||
|
// default autoattack range for ranged classes
|
||||||
|
auto classJob = player.getClass();
|
||||||
|
|
||||||
|
if( classJob == Common::ClassJob::Machinist || classJob == Common::ClassJob::Bard || classJob == Common::ClassJob::Archer )
|
||||||
|
range = 25.f + chara->getRadius() + player.getRadius() * 0.5f;
|
||||||
|
|
||||||
|
if( Common::Util::distance( player.getPos(), actor->getPos() ) <= range )
|
||||||
|
{
|
||||||
|
if( ( tickCount - player.getLastAttack() ) > mainWeap->getDelay() )
|
||||||
|
{
|
||||||
|
player.setLastAttack( tickCount );
|
||||||
|
player.autoAttack( actor->getAsChara() );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::onSetStateFlag( Sapphire::Entity::Player& player, Common::PlayerStateFlag flag )
|
||||||
|
{
|
||||||
|
auto prevOnlineStatus = player.getOnlineStatus();
|
||||||
|
|
||||||
|
player.setStateFlag( flag );
|
||||||
|
|
||||||
|
auto newOnlineStatus = player.getOnlineStatus();
|
||||||
|
onSendStateFlags( player, prevOnlineStatus != newOnlineStatus );
|
||||||
|
}
|
||||||
|
|
||||||
|
void PlayerMgr::onUnsetStateFlag( Sapphire::Entity::Player& player, Common::PlayerStateFlag flag )
|
||||||
|
{
|
||||||
|
auto prevOnlineStatus = player.getOnlineStatus();
|
||||||
|
|
||||||
|
player.unsetStateFlag( flag );
|
||||||
|
|
||||||
|
auto newOnlineStatus = player.getOnlineStatus();
|
||||||
|
onSendStateFlags( player, prevOnlineStatus != newOnlineStatus );
|
||||||
|
}
|
||||||
|
|
||||||
////////// Helper ///////////
|
////////// Helper ///////////
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -58,6 +58,12 @@ class PlayerMgr
|
||||||
|
|
||||||
void onZone( Sapphire::Entity::Player& player );
|
void onZone( Sapphire::Entity::Player& player );
|
||||||
|
|
||||||
|
void onUpdate( Sapphire::Entity::Player& player, uint64_t tickCount );
|
||||||
|
|
||||||
|
void onSetStateFlag( Sapphire::Entity::Player& player, Common::PlayerStateFlag flag );
|
||||||
|
|
||||||
|
void onUnsetStateFlag( Sapphire::Entity::Player& player, Common::PlayerStateFlag flag );
|
||||||
|
|
||||||
//////////// Helpers
|
//////////// Helpers
|
||||||
|
|
||||||
static void sendServerNotice( Sapphire::Entity::Player& player, const std::string& message );
|
static void sendServerNotice( Sapphire::Entity::Player& player, const std::string& message );
|
||||||
|
|
|
@ -327,13 +327,13 @@ void Sapphire::Network::GameConnection::gmCommandHandler( const Packets::FFXIVAR
|
||||||
if( param2 == 0 )
|
if( param2 == 0 )
|
||||||
{
|
{
|
||||||
for( uint8_t i = 0; i < 255; i++ )
|
for( uint8_t i = 0; i < 255; i++ )
|
||||||
targetActor->getAsPlayer()->learnSong( i, 0 );
|
Service< World::Manager::PlayerMgr >::ref().onUnlockOrchestrion( *targetPlayer, i, 0 );
|
||||||
|
|
||||||
PlayerMgr::sendServerNotice( player, "All Songs for {0} were turned on.", targetPlayer->getName() );
|
PlayerMgr::sendServerNotice( player, "All Songs for {0} were turned on.", targetPlayer->getName() );
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
targetActor->getAsPlayer()->learnSong( static_cast< uint8_t >( param2 ), 0 );
|
Service< World::Manager::PlayerMgr >::ref().onUnlockOrchestrion( *targetPlayer, static_cast< uint8_t >( param2 ), 0 );
|
||||||
PlayerMgr::sendServerNotice( player, "Song {0} for {1} was turned on.", param2, targetPlayer->getName() );
|
PlayerMgr::sendServerNotice( player, "Song {0} for {1} was turned on.", param2, targetPlayer->getName() );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -458,17 +458,17 @@ void Sapphire::Network::GameConnection::commandHandler( const Packets::FFXIVARR_
|
||||||
}
|
}
|
||||||
case PacketCommand::CANCEL_MOUNT:
|
case PacketCommand::CANCEL_MOUNT:
|
||||||
{
|
{
|
||||||
player.setMount( 0 );
|
Service< World::Manager::PlayerMgr >::ref().onMountUpdate( player, 0 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PacketCommand::COMPANION:
|
case PacketCommand::COMPANION:
|
||||||
{
|
{
|
||||||
player.setCompanion( static_cast< uint8_t >( param1 ) );
|
Common::Service< World::Manager::PlayerMgr >::ref().onCompanionUpdate( player, static_cast< uint8_t >( param1 ) );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PacketCommand::COMPANION_CANCEL:
|
case PacketCommand::COMPANION_CANCEL:
|
||||||
{
|
{
|
||||||
player.setCompanion( 0 );
|
Common::Service< World::Manager::PlayerMgr >::ref().onCompanionUpdate( player, 0 );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case PacketCommand::REQUEST_STATUS_RESET: // Remove status (clicking it off)
|
case PacketCommand::REQUEST_STATUS_RESET: // Remove status (clicking it off)
|
||||||
|
|
|
@ -99,7 +99,7 @@ void Sapphire::InstanceContent::onPlayerZoneIn( Entity::Player& player )
|
||||||
}
|
}
|
||||||
|
|
||||||
// mark player as "bound by duty"
|
// mark player as "bound by duty"
|
||||||
player.setStateFlag( PlayerStateFlag::BoundByDuty );
|
Common::Service< World::Manager::PlayerMgr >::ref().onSetStateFlag( player, PlayerStateFlag::BoundByDuty );
|
||||||
|
|
||||||
sendDirectorInit( player );
|
sendDirectorInit( player );
|
||||||
}
|
}
|
||||||
|
@ -614,7 +614,7 @@ void Sapphire::InstanceContent::clearDirector( Entity::Player& player )
|
||||||
|
|
||||||
player.setDirectorInitialized( false );
|
player.setDirectorInitialized( false );
|
||||||
// remove "bound by duty" state
|
// remove "bound by duty" state
|
||||||
player.unsetStateFlag( PlayerStateFlag::BoundByDuty );
|
Service< World::Manager::PlayerMgr >::ref().onUnsetStateFlag( player, PlayerStateFlag::BoundByDuty );
|
||||||
}
|
}
|
||||||
|
|
||||||
uint32_t Sapphire::InstanceContent::getExpireValue()
|
uint32_t Sapphire::InstanceContent::getExpireValue()
|
||||||
|
|
Loading…
Add table
Reference in a new issue