1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +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 uint8_t
{ {
No = 0x00, No = 0x00,
Land = 0x02, LeaveCollision = 0x01,
Fall = 0x04, EnterCollision = 0x02,
StartFalling = 0x04,
}; };
enum MoveSpeed : enum MoveSpeed :

View file

@ -36,6 +36,7 @@
#include "Framework.h" #include "Framework.h"
#include <Logging/Logger.h> #include <Logging/Logger.h>
#include <Manager/NaviMgr.h> #include <Manager/NaviMgr.h>
#include <Manager/TerritoryMgr.h>
using namespace Sapphire::Common; using namespace Sapphire::Common;
using namespace Sapphire::Network::Packets; using namespace Sapphire::Network::Packets;
@ -521,7 +522,12 @@ void Sapphire::Entity::BNpc::update( int64_t currTime )
} }
if( distance > minActorDistance ) 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() ); moveTo( pHatedActor->getPos() );
}
else else
{ {
if( face( pHatedActor->getPos() ) ) if( face( pHatedActor->getPos() ) )

View file

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