1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 00:27:44 +00:00

Merge pull request #519 from NotAdam/develop

fix bnpc callback name inconsistency, add companion spawning
This commit is contained in:
Adam 2019-02-02 23:53:06 +11:00 committed by GitHub
commit c2163032f5
11 changed files with 44 additions and 13 deletions

View file

@ -122,9 +122,9 @@ enum ActorControlType : uint16_t
ActorFadeOut = 0x10A,
ActorFadeIn = 0x10B,
WithdrawMsg = 0x10C,
OrderMinion = 0x10D,
ToggleMinion = 0x10E,
LearnMinion = 0x10F,
OrderCompanion = 0x10D,
ToggleCompanion = 0x10E,
LearnCompanion = 0x10F,
ActorFateOut1 = 0x110,
Emote = 0x122,
@ -278,7 +278,7 @@ enum ActorControlType : uint16_t
ChangeTarget = 0x03,
DismountReq = 0x65,
SpawnCompanionReq = 0x66,
RemoveStatusEffect = 0x68,
CastCancel = 0x69,

View file

@ -68,7 +68,7 @@ public:
Scene00001( player );
}
void onNpcKill( uint32_t npcId, Entity::Player& player ) override
void onBNpcKill( uint32_t npcId, Entity::Player& player ) override
{
if( npcId != ENEMY0 )
return;

View file

@ -1133,7 +1133,7 @@ void Sapphire::Entity::Player::update( int64_t currTime )
void Sapphire::Entity::Player::onMobKill( uint16_t nameId )
{
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
pScriptMgr->onMobKill( *getAsPlayer(), nameId );
pScriptMgr->onBNpcKill( *getAsPlayer(), nameId );
}
void Sapphire::Entity::Player::freePlayerSpawnId( uint32_t actorId )
@ -1504,6 +1504,24 @@ void Sapphire::Entity::Player::dismount()
m_mount = 0;
}
void Sapphire::Entity::Player::spawnCompanion( uint16_t id )
{
auto exdData = m_pFw->get< Data::ExdDataGenerated >();
assert( exdData );
auto companion = exdData->get< Data::Companion >( id );
if( !id )
return;
m_companionId = id;
sendToInRangeSet( makeActorControl142( getId(), ActorControlType::ToggleCompanion, id ), true );
}
uint16_t Sapphire::Entity::Player::getCurrentCompanion() const
{
return m_companionId;
}
uint8_t Sapphire::Entity::Player::getCurrentMount() const
{
return m_mount;

View file

@ -565,6 +565,11 @@ namespace Sapphire::Entity
/*! dismount the current mount and send the packets */
void dismount();
void spawnCompanion( uint16_t id );
void despawnCompanion();
uint16_t getCurrentCompanion() const;
/*! get the current mount */
uint8_t getCurrentMount() const;
@ -1076,6 +1081,7 @@ namespace Sapphire::Entity
// content finder info
uint32_t m_cfPenaltyUntil; // unix time
uint16_t m_companionId;
uint32_t m_mount;
uint32_t m_emoteMode;

View file

@ -126,6 +126,11 @@ void Sapphire::Network::GameConnection::clientTriggerHandler( FrameworkPtr pFw,
player.dismount();
break;
}
case ClientTriggerType::SpawnCompanionReq:
{
player.spawnCompanion( param1 );
break;
}
case ClientTriggerType::RemoveStatusEffect: // Remove status (clicking it off)
{
// todo: check if status can be removed by client from exd

View file

@ -84,6 +84,7 @@ namespace Sapphire::Network::Packets::Server
memset( m_data.unlockedPvp, 0xFF, sizeof( m_data.unlockedPvp ) );
memset( m_data.unlockedRaids, 0xFF, sizeof( m_data.unlockedRaids ) );
memset( m_data.unlockedTrials, 0xFF, sizeof( m_data.unlockedTrials ) );
memset( m_data.minions, 0xFF, sizeof( m_data.minions ) );
};
};

View file

@ -71,6 +71,7 @@ namespace Sapphire::Network::Packets::Server
m_data.title = player.getTitle();
m_data.voice = player.getVoiceId();
m_data.currentMount = player.getCurrentMount();
m_data.activeMinion = player.getCurrentCompanion();
m_data.onlineStatus = static_cast< uint8_t >( player.getOnlineStatus() );

View file

@ -111,7 +111,7 @@ namespace Sapphire::ScriptAPI
{
}
void EventScript::onNpcKill( uint32_t npcId, Entity::Player& player )
void EventScript::onBNpcKill( uint32_t nameId, Entity::Player& player )
{
}

View file

@ -165,7 +165,7 @@ namespace Sapphire::ScriptAPI
virtual void onTalk( uint32_t eventId, Sapphire::Entity::Player& player, uint64_t actorId );
virtual void onNpcKill( uint32_t npcId, Sapphire::Entity::Player& player );
virtual void onBNpcKill( uint32_t nameId, Sapphire::Entity::Player& player );
virtual void onEmote( uint64_t actorId, uint32_t eventId, uint32_t emoteId, Sapphire::Entity::Player& player );

View file

@ -272,20 +272,20 @@ bool Sapphire::Scripting::ScriptMgr::onEventItem( Entity::Player& player, uint32
return false;
}
bool Sapphire::Scripting::ScriptMgr::onMobKill( Entity::Player& player, uint16_t nameId )
bool Sapphire::Scripting::ScriptMgr::onBNpcKill( Entity::Player& player, uint16_t nameId )
{
auto pEventMgr = framework()->get< World::Manager::EventMgr >();
std::string eventName = "onBnpcKill_" + std::to_string( nameId );
// loop through all active quests and try to call available onMobKill callbacks
// loop through all active quests and try to call available onBNpcKill callbacks
for( size_t i = 0; i < 30; i++ )
{
auto activeQuests = player.getQuestActive( static_cast< uint16_t >( i ) );
if( !activeQuests )
continue;
uint32_t questId = activeQuests->c.questId | 0x00010000;
uint32_t questId = activeQuests->c.questId | Event::EventHandler::EventHandlerType::Quest << 16;
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( questId );
if( script )
@ -294,7 +294,7 @@ bool Sapphire::Scripting::ScriptMgr::onMobKill( Entity::Player& player, uint16_t
player.sendDebug( "Calling: {0}.{1}", objName, eventName );
script->onNpcKill( nameId, player );
script->onBNpcKill( nameId, player );
}
}

View file

@ -68,7 +68,7 @@ namespace Sapphire::Scripting
bool onEventItem( Entity::Player& player, uint32_t eventItemId, uint32_t eventId, uint32_t castTime,
uint64_t targetId );
bool onMobKill( Entity::Player& player, uint16_t nameId );
bool onBNpcKill( Entity::Player& player, uint16_t nameId );
bool onCastFinish( Entity::Player& pPlayer, Entity::CharaPtr pTarget, uint32_t actionId );