mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-06-07 16:47:44 +00:00
added blind and deaf to bnpcs
This commit is contained in:
parent
412202cc0b
commit
2902948ff1
7 changed files with 64 additions and 2 deletions
|
@ -76,6 +76,9 @@ Sapphire::Entity::BNpc::BNpc( uint32_t id, BNpcTemplatePtr pTemplate, float posX
|
|||
m_timeOfDeath = 0;
|
||||
m_targetId = Common::INVALID_GAME_OBJECT_ID64;
|
||||
|
||||
m_isBlind = false;
|
||||
m_isDeaf = false;
|
||||
|
||||
m_maxHp = maxHp;
|
||||
m_maxMp = 200;
|
||||
m_hp = maxHp;
|
||||
|
@ -595,6 +598,26 @@ void Sapphire::Entity::BNpc::setTimeOfDeath( uint32_t timeOfDeath )
|
|||
m_timeOfDeath = timeOfDeath;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setDeaf( bool state )
|
||||
{
|
||||
m_isDeaf = state;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::setBlind( bool state )
|
||||
{
|
||||
m_isBlind = true;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::BNpc::isDeaf()
|
||||
{
|
||||
return m_isDeaf;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::BNpc::isBlind()
|
||||
{
|
||||
return m_isBlind;
|
||||
}
|
||||
|
||||
void Sapphire::Entity::BNpc::checkAggro()
|
||||
{
|
||||
// passive mobs should ignore players unless aggro'd
|
||||
|
@ -625,7 +648,8 @@ void Sapphire::Entity::BNpc::checkAggro()
|
|||
|
||||
if( distance < range )
|
||||
{
|
||||
aggro( pClosestChara );
|
||||
if(( !isBlind() && isDeaf() ) || ( isBlind() && isFacing( pClosestChara, 40 ) ) || ( isDeaf() && pClosestChara->getAsPlayer()->isRunning() ) )
|
||||
aggro( pClosestChara );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -94,6 +94,14 @@ namespace Sapphire::Entity
|
|||
uint32_t getTimeOfDeath() const;
|
||||
void setTimeOfDeath( uint32_t timeOfDeath );
|
||||
|
||||
void setDeaf( bool state );
|
||||
|
||||
void setBlind( bool state );
|
||||
|
||||
bool isDeaf();
|
||||
|
||||
bool isBlind();
|
||||
|
||||
void regainHp();
|
||||
|
||||
void checkAggro();
|
||||
|
@ -130,6 +138,9 @@ namespace Sapphire::Entity
|
|||
uint8_t m_naviPathStep;
|
||||
Common::FFXIVARR_POSITION3 m_naviTarget;
|
||||
|
||||
bool m_isBlind;
|
||||
bool m_isDeaf;
|
||||
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -60,6 +60,11 @@ std::string Sapphire::Entity::Chara::getName() const
|
|||
return std::string( m_name );
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Chara::isFacing( Entity::CharaPtr source, uint8_t coneAngel )
|
||||
{
|
||||
int32_t angle = Util::calcAngTo( getPos().x, getPos().y, source->getPos().x, source->getPos().y );
|
||||
return abs( int8_t( angle - getRot() ) ) < ( coneAngel >> 1 );
|
||||
}
|
||||
|
||||
/*! \return current stance of the actors */
|
||||
Sapphire::Common::Stance Sapphire::Entity::Chara::getStance() const
|
||||
|
|
|
@ -160,6 +160,8 @@ namespace Sapphire::Entity
|
|||
|
||||
std::string getName() const;
|
||||
|
||||
bool isFacing( Entity::CharaPtr source, uint8_t coneAngel );
|
||||
|
||||
bool face( const Common::FFXIVARR_POSITION3& p );
|
||||
|
||||
Common::Stance getStance() const;
|
||||
|
|
|
@ -77,7 +77,8 @@ Sapphire::Entity::Player::Player( FrameworkPtr pFw ) :
|
|||
m_mount( 0 ),
|
||||
m_emoteMode( 0 ),
|
||||
m_directorInitialized( false ),
|
||||
m_onEnterEventDone( false )
|
||||
m_onEnterEventDone( false ),
|
||||
m_isRunning( false )
|
||||
{
|
||||
m_id = 0;
|
||||
m_currentStance = Stance::Passive;
|
||||
|
@ -1423,6 +1424,16 @@ void Sapphire::Entity::Player::onMobDeaggro( BNpcPtr pBNpc )
|
|||
queuePacket( makeActorControl142( getId(), ToggleAggro ) );
|
||||
}
|
||||
|
||||
void Sapphire::Entity::Player::setRunning( bool state )
|
||||
{
|
||||
m_isRunning = state;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::isRunning()
|
||||
{
|
||||
return m_isRunning;
|
||||
}
|
||||
|
||||
bool Sapphire::Entity::Player::isLogin() const
|
||||
{
|
||||
return m_bIsLogin;
|
||||
|
|
|
@ -839,6 +839,9 @@ namespace Sapphire::Entity
|
|||
void onMobAggro( BNpcPtr pBNpc );
|
||||
void onMobDeaggro( BNpcPtr pBNpc );
|
||||
|
||||
void setRunning( bool state );
|
||||
bool isRunning();
|
||||
|
||||
// Content Finder handling
|
||||
//////////////////////////////////////////////////////////////////////////////////////////////////////
|
||||
/*! Get an unix time when the player can register into content finder again. */
|
||||
|
@ -1081,6 +1084,9 @@ namespace Sapphire::Entity
|
|||
|
||||
Util::SpawnIndexAllocator< uint8_t > m_objSpawnIndexAllocator;
|
||||
Util::SpawnIndexAllocator< uint8_t > m_actorSpawnIndexAllocator;
|
||||
|
||||
//movement
|
||||
bool m_isRunning;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
|
@ -256,6 +256,7 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
|
|||
unk1 = 0x7F;
|
||||
unk2 = 0x00;
|
||||
unk4 = 0x3C;
|
||||
player.setRunning( true );
|
||||
}
|
||||
|
||||
if( moveType & MoveType::Strafing )
|
||||
|
@ -267,6 +268,7 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
|
|||
//else
|
||||
// unk1 = 0x5f;
|
||||
unk4 = 0x3C;
|
||||
player.setRunning( false );
|
||||
}
|
||||
|
||||
if( moveType & MoveType::Walking )
|
||||
|
@ -275,6 +277,7 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
|
|||
unk2 = 0x02;
|
||||
unk3 = 0x00;
|
||||
unk4 = 0x18;
|
||||
player.setRunning( false );
|
||||
}
|
||||
|
||||
if( moveType & MoveType::Walking && moveType & MoveType::Strafing )
|
||||
|
|
Loading…
Add table
Reference in a new issue