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

More BNpc work, close to actual spawning

This commit is contained in:
Mordred 2018-09-10 23:57:14 +02:00
parent 772c63dd8a
commit 01a147b561
8 changed files with 45 additions and 26 deletions

View file

@ -187,6 +187,13 @@ void Core::Entity::Actor::addInRangeActor( ActorPtr pActor )
// if actor is a player, add it to the in range player set
m_inRangePlayers.insert( pPlayer );
}
else if( pActor->isBattleNpc() )
{
auto pBNpc = pActor->getAsBNpc();
// if actor is a player, add it to the in range player set
m_inRangeBNpc.insert( pBNpc );
}
}
/*!
@ -210,6 +217,9 @@ void Core::Entity::Actor::removeInRangeActor( Actor& actor )
if( actor.isPlayer() )
m_inRangePlayers.erase( actor.getAsPlayer() );
if( actor.isBattleNpc() )
m_inRangeBNpc.erase( actor.getAsBNpc() );
}
/*! \return true if there is at least one actor in the in range set */
@ -280,6 +290,7 @@ void Core::Entity::Actor::clearInRangeSet()
{
m_inRangeActor.clear();
m_inRangePlayers.clear();
m_inRangeBNpc.clear();
}
/*!

View file

@ -37,6 +37,7 @@ protected:
/*! list of various actors in range */
std::set< ActorPtr > m_inRangeActor;
std::set< PlayerPtr > m_inRangePlayers;
std::set< BNpcPtr > m_inRangeBNpc;
/*! Parent cell in the zone */
Core::Cell* m_pCell;
@ -85,9 +86,7 @@ public:
bool isAetheryte() const;
///// IN RANGE LOGIC ///////////////////////////////
virtual void onRemoveInRangeActor( Actor& pActor )
{
}
virtual void onRemoveInRangeActor( Actor& pActor ) {}
// check if another actor is in the actors in range set
bool isInRangeSet( ActorPtr pActor ) const;

View file

@ -25,6 +25,7 @@
#include "Chara.h"
#include "Player.h"
#include "BNpc.h"
#include "BNpcTemplate.h"
#include "Zone/TerritoryMgr.h"
#include "Framework.h"
#include "Common.h"
@ -40,6 +41,22 @@ Core::Entity::BNpc::BNpc() : Npc( ObjKind::BattleNpc )
{
}
Core::Entity::BNpc::BNpc( BNpcTemplatePtr pTemplate ) : Npc( ObjKind::BattleNpc )
{
m_modelChara = pTemplate->getModelChara();
m_displayFlags = pTemplate->getDisplayFlags();
m_pose = pTemplate->getPose();
m_aggressionMode = pTemplate->getAggressionMode();
m_weaponMain = pTemplate->getWeaponMain();
m_weaponSub = pTemplate->getWeaponSub();
m_bNpcNameId = pTemplate->getBNpcNameId();
m_bNpcBaseId = pTemplate->getBNpcBaseId();
memcpy( m_customize, pTemplate->getCustomize(), sizeof( m_customize ) );
memcpy( m_modelEquip, pTemplate->getModelEquip(), sizeof( m_modelEquip ) );
}
Core::Entity::BNpc::~BNpc()
{
}

View file

@ -19,12 +19,12 @@ namespace Entity {
\brief Base class for all BNpcs
*/
class BNpc :
public Npc
class BNpc : public Npc
{
public:
BNpc();
BNpc( BNpcTemplatePtr pTemplate );
virtual ~BNpc() override;

View file

@ -662,6 +662,11 @@ std::map< uint8_t, Core::StatusEffect::StatusEffectPtr > Core::Entity::Chara::ge
return m_statusEffectMap;
}
uint32_t* Core::Entity::Chara::getModels()
{
return m_modelEquip;
}
void Core::Entity::Chara::sendStatusEffectUpdate()
{
uint64_t currentTimeMs = Util::getTimeMs();

View file

@ -93,6 +93,8 @@ protected:
uint16_t m_gp;
/*! Additional look info of the actor */
uint8_t m_customize[26];
/*! Additional model info */
uint32_t m_modelEquip[10];
/*! Current class of the actor */
Common::ClassJob m_class;
/*! Id of the currently selected target actor */
@ -115,9 +117,7 @@ public:
virtual ~Chara() override;
virtual void calculateStats()
{
};
virtual void calculateStats() {};
/// Status effect functions
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
@ -138,6 +138,8 @@ public:
void sendStatusEffectUpdate();
uint32_t* getModels();
// add a status effect by id
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param = 0 );

View file

@ -933,8 +933,6 @@ private:
uint64_t m_modelSubWeapon;
uint64_t m_modelSystemWeapon;
uint32_t m_modelEquip[10];
bool m_bNewGame;
uint8_t m_guardianDeity;

View file

@ -51,6 +51,7 @@ private:
// m_data.mainWeaponModel = item->getModelId1();
//m_data.secWeaponModel = player.getModelSubWeapon();
memcpy( m_data.models, bnpc.getModels(), sizeof( m_data.models ) );
m_data.models[ 0 ] = bnpc.getModelForSlot( Common::GearSetSlot::Head );
m_data.models[ 1 ] = bnpc.getModelForSlot( Common::GearSetSlot::Body );
m_data.models[ 2 ] = bnpc.getModelForSlot( Common::GearSetSlot::Hands );
@ -87,31 +88,16 @@ private:
// 0x20 == spawn hidden to be displayed by the spawneffect control
m_data.displayFlags = bnpc.getStance();
if( bnpc.getZoningType() != Common::ZoneingType::None || bnpc.getGmInvis() == true )
if( bnpc.getZoningType() != Common::ZoneingType::None )
{
m_data.displayFlags |= static_cast< uint16_t >( Common::DisplayFlags::Invisible );
}
if( bnpc.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideHead )
{
m_data.displayFlags |= static_cast< uint16_t >( Common::DisplayFlags::HideHead );
}
if( bnpc.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideWeapon )
{
m_data.displayFlags |= static_cast< uint16_t >( Common::DisplayFlags::HideWeapon );
}
if( bnpc.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::Visor )
{
m_data.displayFlags |= static_cast< uint16_t >( Common::DisplayFlags::Visor );
}
if( !( bnpc.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::HideLegacyMark ) )
{
m_data.look[ 0xC ] = m_data.look[ 0xC ] | 1 << 7;
}
m_data.currentMount = bnpc.getCurrentMount();
m_data.persistentEmote = bnpc.getPersistentEmote();
@ -122,6 +108,7 @@ private:
//m_data.unknown_60 = 3;
//m_data.unknown_61 = 7;
uint64_t currentTimeMs = Core::Util::getTimeMs();
for( auto const& effect : bnpc.getStatusEffectMap() )