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:
parent
1621b9fd20
commit
ad4d8049e0
3 changed files with 22 additions and 1 deletions
|
@ -247,7 +247,6 @@ bool Sapphire::Entity::BNpc::moveTo( const Entity::Chara& targetChara )
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
void Sapphire::Entity::BNpc::sendPositionUpdate()
|
void Sapphire::Entity::BNpc::sendPositionUpdate()
|
||||||
{
|
{
|
||||||
uint8_t unk1 = 0x3a;
|
uint8_t unk1 = 0x3a;
|
||||||
|
@ -478,6 +477,8 @@ void Sapphire::Entity::BNpc::update( uint64_t tickCount )
|
||||||
if( !pHatedActor )
|
if( !pHatedActor )
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
pNaviProvider->updateAgentParameters( *this );
|
||||||
|
|
||||||
auto distanceOrig = Util::distance( getPos().x, getPos().y, getPos().z,
|
auto distanceOrig = Util::distance( getPos().x, getPos().y, getPos().z,
|
||||||
m_spawnPos.x, m_spawnPos.y, m_spawnPos.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 );
|
setStance( Stance::Passive );
|
||||||
//setOwner( nullptr );
|
//setOwner( nullptr );
|
||||||
m_state = BNpcState::Retreat;
|
m_state = BNpcState::Retreat;
|
||||||
|
pNaviProvider->updateAgentParameters( *this );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -6,6 +6,7 @@
|
||||||
|
|
||||||
#include "Actor/Actor.h"
|
#include "Actor/Actor.h"
|
||||||
#include "Actor/Chara.h"
|
#include "Actor/Chara.h"
|
||||||
|
#include "Actor/BNpc.h"
|
||||||
|
|
||||||
#include <Manager/RNGMgr.h>
|
#include <Manager/RNGMgr.h>
|
||||||
|
|
||||||
|
@ -582,6 +583,22 @@ int32_t Sapphire::World::Navi::NaviProvider::addAgent( Entity::Chara& chara )
|
||||||
return m_pCrowd->addAgent( position, ¶ms );
|
return m_pCrowd->addAgent( position, ¶ms );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Sapphire::World::Navi::NaviProvider::updateAgentParameters( Entity::BNpc& bnpc )
|
||||||
|
{
|
||||||
|
dtCrowdAgentParams params;
|
||||||
|
std::memset( ¶ms, 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(), ¶ms );
|
||||||
|
}
|
||||||
|
|
||||||
void Sapphire::World::Navi::NaviProvider::updateCrowd( float timeInSeconds )
|
void Sapphire::World::Navi::NaviProvider::updateCrowd( float timeInSeconds )
|
||||||
{
|
{
|
||||||
dtCrowdAgentDebugInfo info;
|
dtCrowdAgentDebugInfo info;
|
||||||
|
|
|
@ -72,6 +72,8 @@ namespace Sapphire::World::Navi
|
||||||
void addAgentUpdateFlag( Entity::Chara& chara, uint8_t flags );
|
void addAgentUpdateFlag( Entity::Chara& chara, uint8_t flags );
|
||||||
void removeAgentUpdateFlag( Entity::Chara& chara, uint8_t flags );
|
void removeAgentUpdateFlag( Entity::Chara& chara, uint8_t flags );
|
||||||
|
|
||||||
|
void updateAgentParameters( Entity::BNpc& bnpc );
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
std::string m_internalName;
|
std::string m_internalName;
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue