1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-28 15:17:46 +00:00

Merge pull request #523 from XeAri/develop

Mostly retail like movement + bnpcs auto attack move delay
This commit is contained in:
Adam 2019-02-07 10:04:17 +11:00 committed by GitHub
commit a55e4d91dc
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 26 additions and 15 deletions

View file

@ -419,8 +419,9 @@ namespace Sapphire::Common
uint8_t
{
No = 0x00,
Land = 0x02,
Fall = 0x04,
LeaveCollision = 0x01,
EnterCollision = 0x02,
StartFalling = 0x04,
};
enum MoveSpeed :

View file

@ -36,6 +36,7 @@
#include "Framework.h"
#include <Logging/Logger.h>
#include <Manager/NaviMgr.h>
#include <Manager/TerritoryMgr.h>
using namespace Sapphire::Common;
using namespace Sapphire::Network::Packets;
@ -521,7 +522,11 @@ void Sapphire::Entity::BNpc::update( int64_t currTime )
}
if( distance > minActorDistance )
moveTo( pHatedActor->getPos() );
{
//auto pTeriMgr = m_pFw->get< World::Manager::TerritoryMgr >();
//if ( ( currTime - m_lastAttack ) > 600 && pTeriMgr->isDefaultTerritory( getCurrentZone()->getTerritoryTypeId() ) )
moveTo( pHatedActor->getPos() );
}
else
{
if( face( pHatedActor->getPos() ) )

View file

@ -207,13 +207,12 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
auto animationState = updatePositionPacket.data().animationState;
auto animationType = updatePositionPacket.data().animationType;
auto headRotation = updatePositionPacket.data().headPosition;
uint8_t orgAnimationType = animationType;
uint8_t unknownRotation = 0;
uint16_t animationSpeed = MoveSpeed::Walk;
animationType |= clientAnimationType;
bool shouldSend = true;
if( animationType & MoveType::Strafing )
{
if( animationType & MoveType::Walking )
@ -230,13 +229,21 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
}
if( animationType & MoveType::Jumping )
{
if( animationState == MoveState::Fall )
if( animationState == MoveState::LeaveCollision )
{
if( orgAnimationType & clientAnimationType )
animationType += 0x10;
else
animationType += 0x04;
}
if( animationState == MoveState::StartFalling )
player.m_falling = true;
else
shouldSend = false;
if( animationState == MoveState::EnterCollision )
{
animationType = 2;
player.m_falling = false;
}
}
else
player.m_falling = false;
if( player.m_falling )
{
@ -244,16 +251,14 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
unknownRotation = 0x7F;
}
uint64_t currentTime = Util::getTimeMs();
player.m_lastMoveTime = currentTime;
player.m_lastMoveflag = animationType;
if( shouldSend )
{
auto movePacket = std::make_shared< MoveActorPacket >( player, headRotation, animationType, animationState, animationSpeed, unknownRotation );
player.sendToInRangeSet( movePacket );
}
auto movePacket = std::make_shared< MoveActorPacket >( player, headRotation, animationType, animationState, animationSpeed, unknownRotation );
player.sendToInRangeSet( movePacket );
}
void