mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 15:47:46 +00:00
Moved bnpc creation from level to zone, implicitly adding them to world aswell
This commit is contained in:
parent
8badc6e34d
commit
c712c747c6
5 changed files with 108 additions and 118 deletions
|
@ -64,9 +64,6 @@ public:
|
||||||
auto a3 = instance.createBNpcFromLevelEntry( INIT_POP_ENEMY_B_04, 10, 0, 1440, 938,
|
auto a3 = instance.createBNpcFromLevelEntry( INIT_POP_ENEMY_B_04, 10, 0, 1440, 938,
|
||||||
instance.getDirectorId(), Common::BNpcType::Enemy );
|
instance.getDirectorId(), Common::BNpcType::Enemy );
|
||||||
|
|
||||||
instance.pushActor( a2 );
|
|
||||||
instance.pushActor( a3 );
|
|
||||||
|
|
||||||
auto pPlayer = instance.getPlayerPtr();
|
auto pPlayer = instance.getPlayerPtr();
|
||||||
a2->hateListAdd( pPlayer, 1 );
|
a2->hateListAdd( pPlayer, 1 );
|
||||||
|
|
||||||
|
@ -105,12 +102,6 @@ public:
|
||||||
instance.getDirectorId(), Common::BNpcType::Friendly );
|
instance.getDirectorId(), Common::BNpcType::Friendly );
|
||||||
auto a5 = instance.createBNpcFromLevelEntry( INIT_P_POP_PAPARIMO, 50, 0, 27780, 1376,
|
auto a5 = instance.createBNpcFromLevelEntry( INIT_P_POP_PAPARIMO, 50, 0, 27780, 1376,
|
||||||
instance.getDirectorId(), Common::BNpcType::Friendly );
|
instance.getDirectorId(), Common::BNpcType::Friendly );
|
||||||
instance.pushActor( a1 );
|
|
||||||
instance.pushActor( a2 );
|
|
||||||
instance.pushActor( a3 );
|
|
||||||
instance.pushActor( a4 );
|
|
||||||
instance.pushActor( a5 );
|
|
||||||
|
|
||||||
a1->hateListAdd( a4, 10000 );
|
a1->hateListAdd( a4, 10000 );
|
||||||
a1->hateListAdd( a5, 10000 );
|
a1->hateListAdd( a5, 10000 );
|
||||||
|
|
||||||
|
|
|
@ -377,110 +377,6 @@ uint32_t Sapphire::QuestBattle::getQuestId() const
|
||||||
return m_pBattleDetails->quest;
|
return m_pBattleDetails->quest;
|
||||||
}
|
}
|
||||||
|
|
||||||
Sapphire::Entity::BNpcPtr
|
|
||||||
Sapphire::QuestBattle::createBNpcFromLevelEntry( uint32_t levelId, uint8_t level, uint8_t type,
|
|
||||||
uint32_t hp, uint16_t nameId, uint32_t directorId,
|
|
||||||
uint8_t bnpcType )
|
|
||||||
{
|
|
||||||
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
|
||||||
auto levelData = pExdData->get< Sapphire::Data::Level >( levelId );
|
|
||||||
if( !levelData )
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
if( levelData->type != 9 )
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
auto bnpcBaseId = levelData->object;
|
|
||||||
|
|
||||||
auto bnpcBaseData = pExdData->get< Sapphire::Data::BNpcBase >( bnpcBaseId );
|
|
||||||
if( !bnpcBaseData )
|
|
||||||
return nullptr;
|
|
||||||
|
|
||||||
//BNpcTemplate( uint32_t id, uint32_t baseId, uint32_t nameId, uint64_t weaponMain, uint64_t weaponSub,
|
|
||||||
// uint8_t aggressionMode, uint8_t enemyType, uint8_t onlineStatus, uint8_t pose,
|
|
||||||
// uint16_t modelChara, uint32_t displayFlags, uint32_t* modelEquip,
|
|
||||||
// uint8_t* customize )
|
|
||||||
|
|
||||||
std::vector< uint8_t > customize( 26 );
|
|
||||||
if( bnpcBaseData->bNpcCustomize != 0 )
|
|
||||||
{
|
|
||||||
auto bnpcCustomizeData = pExdData->get< Sapphire::Data::BNpcCustomize >( bnpcBaseData->bNpcCustomize );
|
|
||||||
if( bnpcCustomizeData )
|
|
||||||
{
|
|
||||||
customize[0] = bnpcCustomizeData->race;
|
|
||||||
customize[1] = bnpcCustomizeData->gender;
|
|
||||||
customize[2] = bnpcCustomizeData->bodyType;
|
|
||||||
customize[3] = bnpcCustomizeData->height;
|
|
||||||
customize[4] = bnpcCustomizeData->tribe;
|
|
||||||
customize[5] = bnpcCustomizeData->face;
|
|
||||||
customize[6] = bnpcCustomizeData->hairStyle;
|
|
||||||
customize[7] = bnpcCustomizeData->hairHighlight;
|
|
||||||
customize[8] = bnpcCustomizeData->skinColor;
|
|
||||||
customize[9] = bnpcCustomizeData->eyeHeterochromia;
|
|
||||||
customize[10] = bnpcCustomizeData->hairColor;
|
|
||||||
customize[11] = bnpcCustomizeData->hairHighlightColor;
|
|
||||||
customize[12] = bnpcCustomizeData->facialFeature;
|
|
||||||
customize[13] = bnpcCustomizeData->facialFeatureColor;
|
|
||||||
customize[14] = bnpcCustomizeData->eyebrows;
|
|
||||||
customize[15] = bnpcCustomizeData->eyeColor;
|
|
||||||
customize[16] = bnpcCustomizeData->eyeShape;
|
|
||||||
customize[17] = bnpcCustomizeData->nose;
|
|
||||||
customize[18] = bnpcCustomizeData->jaw;
|
|
||||||
customize[19] = bnpcCustomizeData->mouth;
|
|
||||||
customize[20] = bnpcCustomizeData->lipColor;
|
|
||||||
customize[21] = bnpcCustomizeData->bustOrTone1;
|
|
||||||
customize[22] = bnpcCustomizeData->extraFeature1;
|
|
||||||
customize[23] = bnpcCustomizeData->extraFeature2OrBust;
|
|
||||||
customize[24] = bnpcCustomizeData->facePaint;
|
|
||||||
customize[25] = bnpcCustomizeData->facePaintColor;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
std::vector< uint32_t > models( 10 );
|
|
||||||
uint64_t modelMain = 0;
|
|
||||||
uint64_t modeloff = 0;
|
|
||||||
if( bnpcBaseData->npcEquip != 0 )
|
|
||||||
{
|
|
||||||
auto npcEquipData = pExdData->get< Sapphire::Data::NpcEquip >( bnpcBaseData->npcEquip );
|
|
||||||
if( npcEquipData )
|
|
||||||
{
|
|
||||||
modelMain = npcEquipData->modelMainHand;
|
|
||||||
modeloff = npcEquipData->modelOffHand;
|
|
||||||
|
|
||||||
models[0] = npcEquipData->modelHead;
|
|
||||||
models[1] = npcEquipData->modelBody;
|
|
||||||
models[2] = npcEquipData->modelHands;
|
|
||||||
models[3] = npcEquipData->modelLegs;
|
|
||||||
models[4] = npcEquipData->modelFeet;
|
|
||||||
models[5] = npcEquipData->modelEars;
|
|
||||||
models[6] = npcEquipData->modelNeck;
|
|
||||||
models[7] = npcEquipData->modelWrists;
|
|
||||||
models[8] = npcEquipData->modelLeftRing;
|
|
||||||
models[9] = npcEquipData->modelRightRing;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
auto tmp = std::make_shared< Entity::BNpcTemplate >( 0, bnpcBaseId, nameId, modelMain, modeloff, 1, bnpcType, 0, 4,
|
|
||||||
bnpcBaseData->modelChara, 0, &models[0], &customize[0] );
|
|
||||||
|
|
||||||
auto bnpc = std::make_shared< Entity::BNpc >( getNextActorId(), tmp, levelData->x, levelData->y, levelData->z,
|
|
||||||
levelData->yaw, level, hp, shared_from_this(), m_pFw );
|
|
||||||
|
|
||||||
bnpc->setDirectorId( directorId );
|
|
||||||
bnpc->setLevelId( levelId );
|
|
||||||
return bnpc;
|
|
||||||
}
|
|
||||||
|
|
||||||
Sapphire::Entity::BNpcPtr Sapphire::QuestBattle::getActiveBNpcByLevelId( uint32_t levelId )
|
|
||||||
{
|
|
||||||
for( auto bnpcIt : m_bNpcMap )
|
|
||||||
{
|
|
||||||
if( bnpcIt.second->getLevelId() == levelId )
|
|
||||||
return bnpcIt.second;
|
|
||||||
}
|
|
||||||
return nullptr;
|
|
||||||
}
|
|
||||||
|
|
||||||
uint32_t Sapphire::QuestBattle::getCountEnemyBNpc()
|
uint32_t Sapphire::QuestBattle::getCountEnemyBNpc()
|
||||||
{
|
{
|
||||||
uint32_t count = 0;
|
uint32_t count = 0;
|
||||||
|
|
|
@ -66,7 +66,6 @@ namespace Sapphire
|
||||||
void fail();
|
void fail();
|
||||||
void success();
|
void success();
|
||||||
|
|
||||||
Entity::BNpcPtr getActiveBNpcByLevelId( uint32_t levelId );
|
|
||||||
uint32_t getCountEnemyBNpc();
|
uint32_t getCountEnemyBNpc();
|
||||||
|
|
||||||
void clearDirector( Entity::Player& player );
|
void clearDirector( Entity::Player& player );
|
||||||
|
@ -82,10 +81,6 @@ namespace Sapphire
|
||||||
/*! number of milliseconds after all players are ready for the instance to commence (spawn circle removed) */
|
/*! number of milliseconds after all players are ready for the instance to commence (spawn circle removed) */
|
||||||
const uint32_t instanceStartDelay = 1250;
|
const uint32_t instanceStartDelay = 1250;
|
||||||
|
|
||||||
Entity::BNpcPtr createBNpcFromLevelEntry( uint32_t levelId, uint8_t level, uint8_t type,
|
|
||||||
uint32_t hp, uint16_t nameId, uint32_t directorId,
|
|
||||||
uint8_t bnpcType );
|
|
||||||
|
|
||||||
Entity::PlayerPtr getPlayerPtr();
|
Entity::PlayerPtr getPlayerPtr();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -28,6 +28,7 @@
|
||||||
#include "Actor/EventObject.h"
|
#include "Actor/EventObject.h"
|
||||||
#include "Actor/SpawnGroup.h"
|
#include "Actor/SpawnGroup.h"
|
||||||
#include "Actor/SpawnPoint.h"
|
#include "Actor/SpawnPoint.h"
|
||||||
|
#include "Actor/BNpcTemplate.h"
|
||||||
|
|
||||||
#include "Network/GameConnection.h"
|
#include "Network/GameConnection.h"
|
||||||
|
|
||||||
|
@ -878,3 +879,107 @@ uint32_t Sapphire::Zone::getNextEffectSequence()
|
||||||
return m_effectCounter++;
|
return m_effectCounter++;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Sapphire::Entity::BNpcPtr
|
||||||
|
Sapphire::Zone::createBNpcFromLevelEntry( uint32_t levelId, uint8_t level, uint8_t type,
|
||||||
|
uint32_t hp, uint16_t nameId, uint32_t directorId,
|
||||||
|
uint8_t bnpcType )
|
||||||
|
{
|
||||||
|
auto pExdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||||
|
auto levelData = pExdData->get< Sapphire::Data::Level >( levelId );
|
||||||
|
if( !levelData )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
if( levelData->type != 9 )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
auto bnpcBaseId = levelData->object;
|
||||||
|
|
||||||
|
auto bnpcBaseData = pExdData->get< Sapphire::Data::BNpcBase >( bnpcBaseId );
|
||||||
|
if( !bnpcBaseData )
|
||||||
|
return nullptr;
|
||||||
|
|
||||||
|
//BNpcTemplate( uint32_t id, uint32_t baseId, uint32_t nameId, uint64_t weaponMain, uint64_t weaponSub,
|
||||||
|
// uint8_t aggressionMode, uint8_t enemyType, uint8_t onlineStatus, uint8_t pose,
|
||||||
|
// uint16_t modelChara, uint32_t displayFlags, uint32_t* modelEquip,
|
||||||
|
// uint8_t* customize )
|
||||||
|
|
||||||
|
std::vector< uint8_t > customize( 26 );
|
||||||
|
if( bnpcBaseData->bNpcCustomize != 0 )
|
||||||
|
{
|
||||||
|
auto bnpcCustomizeData = pExdData->get< Sapphire::Data::BNpcCustomize >( bnpcBaseData->bNpcCustomize );
|
||||||
|
if( bnpcCustomizeData )
|
||||||
|
{
|
||||||
|
customize[0] = bnpcCustomizeData->race;
|
||||||
|
customize[1] = bnpcCustomizeData->gender;
|
||||||
|
customize[2] = bnpcCustomizeData->bodyType;
|
||||||
|
customize[3] = bnpcCustomizeData->height;
|
||||||
|
customize[4] = bnpcCustomizeData->tribe;
|
||||||
|
customize[5] = bnpcCustomizeData->face;
|
||||||
|
customize[6] = bnpcCustomizeData->hairStyle;
|
||||||
|
customize[7] = bnpcCustomizeData->hairHighlight;
|
||||||
|
customize[8] = bnpcCustomizeData->skinColor;
|
||||||
|
customize[9] = bnpcCustomizeData->eyeHeterochromia;
|
||||||
|
customize[10] = bnpcCustomizeData->hairColor;
|
||||||
|
customize[11] = bnpcCustomizeData->hairHighlightColor;
|
||||||
|
customize[12] = bnpcCustomizeData->facialFeature;
|
||||||
|
customize[13] = bnpcCustomizeData->facialFeatureColor;
|
||||||
|
customize[14] = bnpcCustomizeData->eyebrows;
|
||||||
|
customize[15] = bnpcCustomizeData->eyeColor;
|
||||||
|
customize[16] = bnpcCustomizeData->eyeShape;
|
||||||
|
customize[17] = bnpcCustomizeData->nose;
|
||||||
|
customize[18] = bnpcCustomizeData->jaw;
|
||||||
|
customize[19] = bnpcCustomizeData->mouth;
|
||||||
|
customize[20] = bnpcCustomizeData->lipColor;
|
||||||
|
customize[21] = bnpcCustomizeData->bustOrTone1;
|
||||||
|
customize[22] = bnpcCustomizeData->extraFeature1;
|
||||||
|
customize[23] = bnpcCustomizeData->extraFeature2OrBust;
|
||||||
|
customize[24] = bnpcCustomizeData->facePaint;
|
||||||
|
customize[25] = bnpcCustomizeData->facePaintColor;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
std::vector< uint32_t > models( 10 );
|
||||||
|
uint64_t modelMain = 0;
|
||||||
|
uint64_t modeloff = 0;
|
||||||
|
if( bnpcBaseData->npcEquip != 0 )
|
||||||
|
{
|
||||||
|
auto npcEquipData = pExdData->get< Sapphire::Data::NpcEquip >( bnpcBaseData->npcEquip );
|
||||||
|
if( npcEquipData )
|
||||||
|
{
|
||||||
|
modelMain = npcEquipData->modelMainHand;
|
||||||
|
modeloff = npcEquipData->modelOffHand;
|
||||||
|
|
||||||
|
models[0] = npcEquipData->modelHead;
|
||||||
|
models[1] = npcEquipData->modelBody;
|
||||||
|
models[2] = npcEquipData->modelHands;
|
||||||
|
models[3] = npcEquipData->modelLegs;
|
||||||
|
models[4] = npcEquipData->modelFeet;
|
||||||
|
models[5] = npcEquipData->modelEars;
|
||||||
|
models[6] = npcEquipData->modelNeck;
|
||||||
|
models[7] = npcEquipData->modelWrists;
|
||||||
|
models[8] = npcEquipData->modelLeftRing;
|
||||||
|
models[9] = npcEquipData->modelRightRing;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
auto tmp = std::make_shared< Entity::BNpcTemplate >( 0, bnpcBaseId, nameId, modelMain, modeloff, 1, bnpcType, 0, 4,
|
||||||
|
bnpcBaseData->modelChara, 0, &models[0], &customize[0] );
|
||||||
|
|
||||||
|
auto bnpc = std::make_shared< Entity::BNpc >( getNextActorId(), tmp, levelData->x, levelData->y, levelData->z,
|
||||||
|
levelData->yaw, level, hp, shared_from_this(), m_pFw );
|
||||||
|
|
||||||
|
bnpc->setDirectorId( directorId );
|
||||||
|
bnpc->setLevelId( levelId );
|
||||||
|
pushActor( bnpc );
|
||||||
|
return bnpc;
|
||||||
|
}
|
||||||
|
|
||||||
|
Sapphire::Entity::BNpcPtr Sapphire::Zone::getActiveBNpcByLevelId( uint32_t levelId )
|
||||||
|
{
|
||||||
|
for( auto bnpcIt : m_bNpcMap )
|
||||||
|
{
|
||||||
|
if( bnpcIt.second->getLevelId() == levelId )
|
||||||
|
return bnpcIt.second;
|
||||||
|
}
|
||||||
|
return nullptr;
|
||||||
|
}
|
||||||
|
|
|
@ -158,6 +158,9 @@ namespace Sapphire
|
||||||
uint8_t state, Common::FFXIVARR_POSITION3 pos, float scale, float rotation );
|
uint8_t state, Common::FFXIVARR_POSITION3 pos, float scale, float rotation );
|
||||||
|
|
||||||
void registerEObj( Entity::EventObjectPtr object );
|
void registerEObj( Entity::EventObjectPtr object );
|
||||||
|
Entity::BNpcPtr createBNpcFromLevelEntry( uint32_t levelId, uint8_t level, uint8_t type,
|
||||||
|
uint32_t hp, uint16_t nameId, uint32_t directorId, uint8_t bnpcType );
|
||||||
|
Entity::BNpcPtr getActiveBNpcByLevelId( uint32_t levelId );
|
||||||
|
|
||||||
Entity::EventObjectPtr getEObj( uint32_t objId );
|
Entity::EventObjectPtr getEObj( uint32_t objId );
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue