1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 06:47:45 +00:00

Mostly retial like movement + bnpcs auto attack move delay

This commit is contained in:
AriAvery 2019-02-06 18:51:51 +01:00
parent 87927b3713
commit 64c814157b
3 changed files with 31 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,12 @@ void Sapphire::Entity::BNpc::update( int64_t currTime )
}
if( distance > minActorDistance )
{
uint64_t tick = Util::getTimeMs();
auto pTeriMgr = m_pFw->get< World::Manager::TerritoryMgr >();
if ( ( tick - 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,25 @@ void Sapphire::Network::GameConnection::updatePositionHandler( FrameworkPtr pFw,
}
if( animationType & MoveType::Jumping )
{
if( animationState == MoveState::Fall )
player.m_falling = true;
if( animationState == MoveState::LeaveCollision )
{
if( orgAnimationType & clientAnimationType )
animationType += 0x10;
else
shouldSend = false;
animationType += 0x04;
}
else
if( animationState == MoveState::StartFalling )
{
player.m_falling = true;
animationType += 0x10;
unknownRotation = 0x7F;
}
if( animationState == MoveState::EnterCollision )
{
animationType = 2;
player.m_falling = false;
}
}
if( player.m_falling )
{
@ -244,16 +255,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 );
}
}
void