mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
More BNpc work, close to actual spawning
This commit is contained in:
parent
772c63dd8a
commit
01a147b561
8 changed files with 45 additions and 26 deletions
|
@ -187,6 +187,13 @@ void Core::Entity::Actor::addInRangeActor( ActorPtr pActor )
|
||||||
// if actor is a player, add it to the in range player set
|
// if actor is a player, add it to the in range player set
|
||||||
m_inRangePlayers.insert( pPlayer );
|
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() )
|
if( actor.isPlayer() )
|
||||||
m_inRangePlayers.erase( actor.getAsPlayer() );
|
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 */
|
/*! \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_inRangeActor.clear();
|
||||||
m_inRangePlayers.clear();
|
m_inRangePlayers.clear();
|
||||||
|
m_inRangeBNpc.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/*!
|
/*!
|
||||||
|
|
|
@ -37,6 +37,7 @@ protected:
|
||||||
/*! list of various actors in range */
|
/*! list of various actors in range */
|
||||||
std::set< ActorPtr > m_inRangeActor;
|
std::set< ActorPtr > m_inRangeActor;
|
||||||
std::set< PlayerPtr > m_inRangePlayers;
|
std::set< PlayerPtr > m_inRangePlayers;
|
||||||
|
std::set< BNpcPtr > m_inRangeBNpc;
|
||||||
|
|
||||||
/*! Parent cell in the zone */
|
/*! Parent cell in the zone */
|
||||||
Core::Cell* m_pCell;
|
Core::Cell* m_pCell;
|
||||||
|
@ -85,9 +86,7 @@ public:
|
||||||
bool isAetheryte() const;
|
bool isAetheryte() const;
|
||||||
|
|
||||||
///// IN RANGE LOGIC ///////////////////////////////
|
///// IN RANGE LOGIC ///////////////////////////////
|
||||||
virtual void onRemoveInRangeActor( Actor& pActor )
|
virtual void onRemoveInRangeActor( Actor& pActor ) {}
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
// check if another actor is in the actors in range set
|
// check if another actor is in the actors in range set
|
||||||
bool isInRangeSet( ActorPtr pActor ) const;
|
bool isInRangeSet( ActorPtr pActor ) const;
|
||||||
|
|
|
@ -25,6 +25,7 @@
|
||||||
#include "Chara.h"
|
#include "Chara.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
#include "BNpc.h"
|
#include "BNpc.h"
|
||||||
|
#include "BNpcTemplate.h"
|
||||||
#include "Zone/TerritoryMgr.h"
|
#include "Zone/TerritoryMgr.h"
|
||||||
#include "Framework.h"
|
#include "Framework.h"
|
||||||
#include "Common.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()
|
Core::Entity::BNpc::~BNpc()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
|
@ -19,12 +19,12 @@ namespace Entity {
|
||||||
\brief Base class for all BNpcs
|
\brief Base class for all BNpcs
|
||||||
|
|
||||||
*/
|
*/
|
||||||
class BNpc :
|
class BNpc : public Npc
|
||||||
public Npc
|
|
||||||
{
|
{
|
||||||
|
|
||||||
public:
|
public:
|
||||||
BNpc();
|
BNpc();
|
||||||
|
BNpc( BNpcTemplatePtr pTemplate );
|
||||||
|
|
||||||
virtual ~BNpc() override;
|
virtual ~BNpc() override;
|
||||||
|
|
||||||
|
|
|
@ -662,6 +662,11 @@ std::map< uint8_t, Core::StatusEffect::StatusEffectPtr > Core::Entity::Chara::ge
|
||||||
return m_statusEffectMap;
|
return m_statusEffectMap;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
uint32_t* Core::Entity::Chara::getModels()
|
||||||
|
{
|
||||||
|
return m_modelEquip;
|
||||||
|
}
|
||||||
|
|
||||||
void Core::Entity::Chara::sendStatusEffectUpdate()
|
void Core::Entity::Chara::sendStatusEffectUpdate()
|
||||||
{
|
{
|
||||||
uint64_t currentTimeMs = Util::getTimeMs();
|
uint64_t currentTimeMs = Util::getTimeMs();
|
||||||
|
|
|
@ -93,6 +93,8 @@ protected:
|
||||||
uint16_t m_gp;
|
uint16_t m_gp;
|
||||||
/*! Additional look info of the actor */
|
/*! Additional look info of the actor */
|
||||||
uint8_t m_customize[26];
|
uint8_t m_customize[26];
|
||||||
|
/*! Additional model info */
|
||||||
|
uint32_t m_modelEquip[10];
|
||||||
/*! Current class of the actor */
|
/*! Current class of the actor */
|
||||||
Common::ClassJob m_class;
|
Common::ClassJob m_class;
|
||||||
/*! Id of the currently selected target actor */
|
/*! Id of the currently selected target actor */
|
||||||
|
@ -115,9 +117,7 @@ public:
|
||||||
|
|
||||||
virtual ~Chara() override;
|
virtual ~Chara() override;
|
||||||
|
|
||||||
virtual void calculateStats()
|
virtual void calculateStats() {};
|
||||||
{
|
|
||||||
};
|
|
||||||
|
|
||||||
/// Status effect functions
|
/// Status effect functions
|
||||||
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
void addStatusEffect( StatusEffect::StatusEffectPtr pEffect );
|
||||||
|
@ -138,6 +138,8 @@ public:
|
||||||
|
|
||||||
void sendStatusEffectUpdate();
|
void sendStatusEffectUpdate();
|
||||||
|
|
||||||
|
uint32_t* getModels();
|
||||||
|
|
||||||
// add a status effect by id
|
// add a status effect by id
|
||||||
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param = 0 );
|
void addStatusEffectById( uint32_t id, int32_t duration, Entity::Chara& source, uint16_t param = 0 );
|
||||||
|
|
||||||
|
|
|
@ -933,8 +933,6 @@ private:
|
||||||
uint64_t m_modelSubWeapon;
|
uint64_t m_modelSubWeapon;
|
||||||
uint64_t m_modelSystemWeapon;
|
uint64_t m_modelSystemWeapon;
|
||||||
|
|
||||||
uint32_t m_modelEquip[10];
|
|
||||||
|
|
||||||
bool m_bNewGame;
|
bool m_bNewGame;
|
||||||
|
|
||||||
uint8_t m_guardianDeity;
|
uint8_t m_guardianDeity;
|
||||||
|
|
|
@ -51,6 +51,7 @@ private:
|
||||||
// m_data.mainWeaponModel = item->getModelId1();
|
// m_data.mainWeaponModel = item->getModelId1();
|
||||||
//m_data.secWeaponModel = player.getModelSubWeapon();
|
//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[ 0 ] = bnpc.getModelForSlot( Common::GearSetSlot::Head );
|
||||||
m_data.models[ 1 ] = bnpc.getModelForSlot( Common::GearSetSlot::Body );
|
m_data.models[ 1 ] = bnpc.getModelForSlot( Common::GearSetSlot::Body );
|
||||||
m_data.models[ 2 ] = bnpc.getModelForSlot( Common::GearSetSlot::Hands );
|
m_data.models[ 2 ] = bnpc.getModelForSlot( Common::GearSetSlot::Hands );
|
||||||
|
@ -87,31 +88,16 @@ private:
|
||||||
// 0x20 == spawn hidden to be displayed by the spawneffect control
|
// 0x20 == spawn hidden to be displayed by the spawneffect control
|
||||||
m_data.displayFlags = bnpc.getStance();
|
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 );
|
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 )
|
if( bnpc.getEquipDisplayFlags() & Core::Common::EquipDisplayFlags::Visor )
|
||||||
{
|
{
|
||||||
m_data.displayFlags |= static_cast< uint16_t >( Common::DisplayFlags::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.currentMount = bnpc.getCurrentMount();
|
||||||
m_data.persistentEmote = bnpc.getPersistentEmote();
|
m_data.persistentEmote = bnpc.getPersistentEmote();
|
||||||
|
|
||||||
|
@ -122,6 +108,7 @@ private:
|
||||||
//m_data.unknown_60 = 3;
|
//m_data.unknown_60 = 3;
|
||||||
//m_data.unknown_61 = 7;
|
//m_data.unknown_61 = 7;
|
||||||
|
|
||||||
|
|
||||||
uint64_t currentTimeMs = Core::Util::getTimeMs();
|
uint64_t currentTimeMs = Core::Util::getTimeMs();
|
||||||
|
|
||||||
for( auto const& effect : bnpc.getStatusEffectMap() )
|
for( auto const& effect : bnpc.getStatusEffectMap() )
|
||||||
|
|
Loading…
Add table
Reference in a new issue