From 6ebdad3855893cf1dab31d596f3fcc54836cb14a Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 21 Apr 2019 23:52:41 +1000 Subject: [PATCH 1/2] make larger enemies stack further away from the player --- src/world/Actor/BNpc.cpp | 13 +++++++------ src/world/Actor/Chara.cpp | 6 +++--- src/world/Actor/Chara.h | 4 ++-- src/world/Actor/Player.cpp | 2 +- src/world/Navi/NaviProvider.cpp | 4 ++-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index e14b0f4b..49ced95d 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -98,14 +98,14 @@ Sapphire::Entity::BNpc::BNpc( uint32_t id, BNpcTemplatePtr pTemplate, float posX auto bNpcBaseData = exdData->get< Data::BNpcBase >( m_bNpcBaseId ); assert( bNpcBaseData ); - m_scale = bNpcBaseData->scale; + m_radius = bNpcBaseData->scale; auto modelChara = exdData->get< Data::ModelChara >( bNpcBaseData->modelChara ); if( modelChara ) { auto modelSkeleton = exdData->get< Data::ModelSkeleton >( modelChara->model ); if( modelSkeleton ) - m_scale *= modelSkeleton->scaleFactor; + m_radius *= modelSkeleton->scaleFactor; } // todo: is this actually good? @@ -242,7 +242,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos ) auto pos1 = pNaviProvider->getMovePos( *this ); - if( Util::distance( pos1, pos ) < getScale() ) + if( Util::distance( pos1, pos ) < getRadius() + 3.f ) { // Reached destination face( pos ); @@ -278,7 +278,7 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara ) auto pos1 = pNaviProvider->getMovePos( *this ); - if( Util::distance( pos1, targetChara.getPos() ) <= ( getScale() + targetChara.getScale() ) + 0.25f ) + if( Util::distance( pos1, targetChara.getPos() ) <= ( getRadius() + targetChara.getRadius() ) + 3.f ) { // Reached destination face( targetChara.getPos() ); @@ -560,7 +560,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount ) break; } - if( distance > ( getScale() + pHatedActor->getScale() ) ) + if( distance > ( getRadius() + pHatedActor->getRadius() ) ) { if( hasFlag( Immobile ) ) break; @@ -572,10 +572,11 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount ) moveTo( *pHatedActor ); } - if( ( distance - getScale() ) < 5 ) + if( distance < ( getRadius() + pHatedActor->getRadius() + 3.f ) ) { if( !hasFlag( TurningDisabled ) && face( pHatedActor->getPos() ) ) sendPositionUpdate(); + // in combat range. ATTACK! autoAttack( pHatedActor ); } diff --git a/src/world/Actor/Chara.cpp b/src/world/Actor/Chara.cpp index 6eba77f9..b4e9303d 100644 --- a/src/world/Actor/Chara.cpp +++ b/src/world/Actor/Chara.cpp @@ -39,7 +39,7 @@ Sapphire::Entity::Chara::Chara( ObjKind type, FrameworkPtr pFw ) : m_targetId( INVALID_GAME_OBJECT_ID64 ), m_pFw( std::move( std::move( pFw ) ) ), m_directorId( 0 ), - m_scale( 2.f ) + m_radius( 1.f ) { m_lastTickTime = 0; @@ -715,7 +715,7 @@ void Sapphire::Entity::Chara::setAgentId( uint32_t agentId ) } -float Sapphire::Entity::Chara::getScale() const +float Sapphire::Entity::Chara::getRadius() const { - return m_scale; + return m_radius; } \ No newline at end of file diff --git a/src/world/Actor/Chara.h b/src/world/Actor/Chara.h index 56638255..d882a18a 100644 --- a/src/world/Actor/Chara.h +++ b/src/world/Actor/Chara.h @@ -132,7 +132,7 @@ namespace Sapphire::Entity uint32_t m_agentId; /*! Detour Crowd actor scale */ - float m_scale; + float m_radius; public: Chara( Common::ObjKind type, FrameworkPtr pFw ); @@ -278,7 +278,7 @@ namespace Sapphire::Entity uint32_t getAgentId() const; void setAgentId( uint32_t agentId ); - float getScale() const; + float getRadius() const; }; diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index 84b1be39..f6d32053 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -84,7 +84,7 @@ Sapphire::Entity::Player::Player( FrameworkPtr pFw ) : m_queuedZoneing = nullptr; m_status = ActorStatus::Idle; m_invincibilityType = InvincibilityType::InvincibilityNone; - m_scale = 1.f; + m_radius = 1.f; memset( m_questTracking, 0, sizeof( m_questTracking ) ); memset( m_name, 0, sizeof( m_name ) ); diff --git a/src/world/Navi/NaviProvider.cpp b/src/world/Navi/NaviProvider.cpp index 7a0d728a..99cb7079 100644 --- a/src/world/Navi/NaviProvider.cpp +++ b/src/world/Navi/NaviProvider.cpp @@ -572,8 +572,8 @@ int32_t Sapphire::World::Navi::NaviProvider::addAgent( Entity::Chara& chara ) std::memset( ¶ms, 0, sizeof( params ) ); params.height = 3.f; params.maxAcceleration = 25.f; - params.maxSpeed = std::pow( 2, chara.getScale() * 0.35f ) + 1.f; - params.radius = ( chara.getScale() ) * 0.75f; + params.maxSpeed = std::pow( 2, chara.getRadius() * 0.35f ) + 1.f; + params.radius = ( chara.getRadius() ) * 0.75f; params.collisionQueryRange = params.radius * 12.0f; params.pathOptimizationRange = params.radius * 20.0f; params.updateFlags = 0; From cb7a91d9d8d62e181b9d9e121e61aa5cc591bb2f Mon Sep 17 00:00:00 2001 From: NotAdam Date: Mon, 22 Apr 2019 00:05:04 +1000 Subject: [PATCH 2/2] fix bnpcs not being pushed --- src/world/Actor/BNpc.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index 49ced95d..1b211251 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -238,7 +238,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos ) return false; } - pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE ); +// pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE ); auto pos1 = pNaviProvider->getMovePos( *this ); @@ -250,7 +250,7 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos ) sendPositionUpdate(); //pNaviProvider->resetMoveTarget( *this ); pNaviProvider->updateAgentPosition( *this ); - pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE ); +// pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE ); return true; } @@ -274,7 +274,7 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara ) return false; } - pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE ); +// pNaviProvider->addAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE ); auto pos1 = pNaviProvider->getMovePos( *this ); @@ -286,7 +286,7 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara ) sendPositionUpdate(); //pNaviProvider->resetMoveTarget( *this ); pNaviProvider->updateAgentPosition( *this ); - pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE ); +// pNaviProvider->removeAgentUpdateFlag( *this, DT_CROWD_OBSTACLE_AVOIDANCE ); return true; }