1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 14:07:46 +00:00

Movement speed of BNpcs will double when in combat or retreat mode

This commit is contained in:
Mordred 2019-04-22 23:30:43 +02:00
parent 1621b9fd20
commit ad4d8049e0
3 changed files with 22 additions and 1 deletions

View file

@ -247,7 +247,6 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara )
return false;
}
void Sapphire::Entity::BNpc::sendPositionUpdate()
{
uint8_t unk1 = 0x3a;
@ -478,6 +477,8 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
if( !pHatedActor )
return;
pNaviProvider->updateAgentParameters( *this );
auto distanceOrig = Util::distance( getPos().x, getPos().y, getPos().z,
m_spawnPos.x, m_spawnPos.y, m_spawnPos.z );
@ -531,6 +532,7 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
setStance( Stance::Passive );
//setOwner( nullptr );
m_state = BNpcState::Retreat;
pNaviProvider->updateAgentParameters( *this );
}
}
}

View file

@ -6,6 +6,7 @@
#include "Actor/Actor.h"
#include "Actor/Chara.h"
#include "Actor/BNpc.h"
#include <Manager/RNGMgr.h>
@ -582,6 +583,22 @@ int32_t Sapphire::World::Navi::NaviProvider::addAgent( Entity::Chara& chara )
return m_pCrowd->addAgent( position, &params );
}
void Sapphire::World::Navi::NaviProvider::updateAgentParameters( Entity::BNpc& bnpc )
{
dtCrowdAgentParams params;
std::memset( &params, 0, sizeof( params ) );
params.height = 3.f;
params.maxAcceleration = 25.f;
params.maxSpeed = std::pow( 2, bnpc.getRadius() * 0.35f ) + 1.f;
if( bnpc.getState() == Entity::BNpcState::Combat || bnpc.getState() == Entity::BNpcState::Retreat )
params.maxSpeed *= 2;
params.radius = ( bnpc.getRadius() ) * 0.75f;
params.collisionQueryRange = params.radius * 12.0f;
params.pathOptimizationRange = params.radius * 20.0f;
params.updateFlags = 0;
m_pCrowd->updateAgentParameters( bnpc.getAgentId(), &params );
}
void Sapphire::World::Navi::NaviProvider::updateCrowd( float timeInSeconds )
{
dtCrowdAgentDebugInfo info;

View file

@ -72,6 +72,8 @@ namespace Sapphire::World::Navi
void addAgentUpdateFlag( Entity::Chara& chara, uint8_t flags );
void removeAgentUpdateFlag( Entity::Chara& chara, uint8_t flags );
void updateAgentParameters( Entity::BNpc& bnpc );
protected:
std::string m_internalName;