From b1bbfe3acd04406eddbbee71fc54b617574c6406 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sat, 26 Jan 2019 11:39:25 +1100 Subject: [PATCH] set correct bnpc animation when aggro'd/passive --- src/common/Network/PacketDef/Zone/ServerZoneDef.h | 2 +- src/world/Actor/BNpc.cpp | 13 ++++++++++--- src/world/Network/PacketWrappers/MoveActorPacket.h | 8 ++++---- 3 files changed, 15 insertions(+), 8 deletions(-) diff --git a/src/common/Network/PacketDef/Zone/ServerZoneDef.h b/src/common/Network/PacketDef/Zone/ServerZoneDef.h index ef70853c..65de5804 100644 --- a/src/common/Network/PacketDef/Zone/ServerZoneDef.h +++ b/src/common/Network/PacketDef/Zone/ServerZoneDef.h @@ -666,7 +666,7 @@ struct FFXIVIpcActorMove : { /* 0000 */ uint8_t rotation; /* 0001 */ uint8_t unknown_1; - /* 0002 */ uint8_t unknown_2; + /* 0002 */ uint8_t animationType; /* 0003 */ uint8_t unknown_3; /* 0004 */ uint16_t unknown_4; /* 0006 */ uint16_t posX; diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index da046a07..2179e591 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -174,9 +174,9 @@ void Sapphire::Entity::BNpc::step() // This is probably not a good way to do it but works fine for now float angle = Util::calcAngFrom( getPos().x, getPos().z, stepPos.x, stepPos.z ) + PI; - auto x = ( cosf( angle ) * 1.7f ); + auto x = ( cosf( angle ) * .5f ); auto y = stepPos.y; - auto z = ( sinf( angle ) * 1.7f ); + auto z = ( sinf( angle ) * .5f ); face( stepPos ); setPos( { getPos().x + x, y, getPos().z + z } ); @@ -229,7 +229,14 @@ bool Sapphire::Entity::BNpc::moveTo( const FFXIVARR_POSITION3& pos ) void Sapphire::Entity::BNpc::sendPositionUpdate() { - auto movePacket = std::make_shared< MoveActorPacket >( *getAsChara(), 0x3A, 0, 0, 0x5A ); + uint8_t unk1 = 0x3a; + uint8_t animationType = 2; + + if( m_state == BNpcState::Combat ) + animationType = 0; + + + auto movePacket = std::make_shared< MoveActorPacket >( *getAsChara(), unk1, animationType, 0, 0x5A ); sendToInRangeSet( movePacket ); } diff --git a/src/world/Network/PacketWrappers/MoveActorPacket.h b/src/world/Network/PacketWrappers/MoveActorPacket.h index a3e09ddb..f4a4f589 100644 --- a/src/world/Network/PacketWrappers/MoveActorPacket.h +++ b/src/world/Network/PacketWrappers/MoveActorPacket.h @@ -19,19 +19,19 @@ namespace Sapphire::Network::Packets::Server public ZoneChannelPacket< FFXIVIpcActorMove > { public: - MoveActorPacket( Entity::Chara& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 ) : + MoveActorPacket( Entity::Chara& actor, uint8_t unk1, uint8_t animationType, uint8_t unk3, uint16_t unk4 ) : ZoneChannelPacket< FFXIVIpcActorMove >( actor.getId(), actor.getId() ) { - initialize( actor, unk1, unk2, unk3, unk4 ); + initialize( actor, unk1, animationType, unk3, unk4 ); }; private: - void initialize( Entity::Chara& actor, uint8_t unk1, uint8_t unk2, uint8_t unk3, uint16_t unk4 ) + void initialize( Entity::Chara& actor, uint8_t unk1, uint8_t animationType, uint8_t unk3, uint16_t unk4 ) { m_data.rotation = Util::floatToUInt8Rot( actor.getRot() ); m_data.unknown_1 = unk1; - m_data.unknown_2 = unk2; + m_data.animationType = animationType; m_data.unknown_3 = unk3; m_data.unknown_4 = unk4; m_data.posX = Util::floatToUInt16( actor.getPos().x );