mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-02 00:47:45 +00:00
Properly fade out dead mobs
This commit is contained in:
parent
f98747df64
commit
d00be5cd88
4 changed files with 75 additions and 2 deletions
|
@ -63,7 +63,7 @@ namespace Sapphire::Network::ActorControl
|
||||||
|
|
||||||
SpawnEffect = 0x25,
|
SpawnEffect = 0x25,
|
||||||
ToggleInvisible = 0x26,
|
ToggleInvisible = 0x26,
|
||||||
|
DeadFadeOut = 0x27,
|
||||||
SetSystemActionUnlocked = 0x29,
|
SetSystemActionUnlocked = 0x29,
|
||||||
|
|
||||||
UpdateUiExp = 0x2B,
|
UpdateUiExp = 0x2B,
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
#include <Manager/PlayerMgr.h>
|
#include <Manager/PlayerMgr.h>
|
||||||
#include <Manager/TaskMgr.h>
|
#include <Manager/TaskMgr.h>
|
||||||
#include <Task/RemoveBNpcTask.h>
|
#include <Task/RemoveBNpcTask.h>
|
||||||
|
#include <Task/FadeBNpcTask.h>
|
||||||
#include <Service.h>
|
#include <Service.h>
|
||||||
|
|
||||||
using namespace Sapphire::Common;
|
using namespace Sapphire::Common;
|
||||||
|
@ -777,7 +778,9 @@ void Sapphire::Entity::BNpc::onDeath()
|
||||||
setOwner( nullptr );
|
setOwner( nullptr );
|
||||||
|
|
||||||
auto& taskMgr = Common::Service< World::Manager::TaskMgr >::ref();
|
auto& taskMgr = Common::Service< World::Manager::TaskMgr >::ref();
|
||||||
auto removeTask = std::make_shared< Sapphire::World::RemoveBNpcTask >( 10000, getAsBNpc() );
|
auto fadeTask = std::make_shared< Sapphire::World::FadeBNpcTask >( 10000, getAsBNpc() );
|
||||||
|
auto removeTask = std::make_shared< Sapphire::World::RemoveBNpcTask >( 12000, getAsBNpc() );
|
||||||
|
taskMgr.queueTask( fadeTask );
|
||||||
taskMgr.queueTask( removeTask );
|
taskMgr.queueTask( removeTask );
|
||||||
|
|
||||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||||
|
|
47
src/world/Task/FadeBNpcTask.cpp
Normal file
47
src/world/Task/FadeBNpcTask.cpp
Normal file
|
@ -0,0 +1,47 @@
|
||||||
|
#include "FadeBNpcTask.h"
|
||||||
|
|
||||||
|
#include <Logging/Logger.h>
|
||||||
|
#include <Actor/BNpc.h>
|
||||||
|
#include <Manager/TerritoryMgr.h>
|
||||||
|
#include <Service.h>
|
||||||
|
|
||||||
|
#include <Territory/Territory.h>
|
||||||
|
#include <utility>
|
||||||
|
|
||||||
|
#include <Network/CommonActorControl.h>
|
||||||
|
#include <Network/PacketWrappers/ActorControlPacket.h>
|
||||||
|
|
||||||
|
using namespace Sapphire::World;
|
||||||
|
using namespace Sapphire::Network::ActorControl;
|
||||||
|
using namespace Sapphire::Network::Packets::WorldPackets::Server;
|
||||||
|
|
||||||
|
FadeBNpcTask::FadeBNpcTask( uint64_t delayTime, Entity::BNpcPtr bnpc ) :
|
||||||
|
Task( delayTime ),
|
||||||
|
m_pBNpc( std::move( bnpc ) )
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
|
void FadeBNpcTask::onQueue()
|
||||||
|
{
|
||||||
|
Logger::debug( { __FUNCTION__ } );
|
||||||
|
}
|
||||||
|
|
||||||
|
void FadeBNpcTask::execute()
|
||||||
|
{
|
||||||
|
|
||||||
|
auto teriMgr = Common::Service< World::Manager::TerritoryMgr >::ref();
|
||||||
|
auto pZone = teriMgr.getTerritoryByGuId( m_pBNpc->getTerritoryId() );
|
||||||
|
|
||||||
|
if( !pZone )
|
||||||
|
return;
|
||||||
|
|
||||||
|
m_pBNpc->sendToInRangeSet( makeActorControl( m_pBNpc->getId(), ActorControlType::DeadFadeOut, 0, 0, 0 ) );
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
std::string FadeBNpcTask::toString()
|
||||||
|
{
|
||||||
|
return fmt::format( "FadeBNpcTask: BNpc#{}, TerritoryId#{}, ElapsedTimeMs: {}", m_pBNpc->getId(), m_pBNpc->getTerritoryId(), getDelayTimeMs() );
|
||||||
|
}
|
||||||
|
|
||||||
|
|
23
src/world/Task/FadeBNpcTask.h
Normal file
23
src/world/Task/FadeBNpcTask.h
Normal file
|
@ -0,0 +1,23 @@
|
||||||
|
#pragma once
|
||||||
|
|
||||||
|
#include <cstdint>
|
||||||
|
#include <string>
|
||||||
|
#include <ForwardsZone.h>
|
||||||
|
#include "Task.h"
|
||||||
|
|
||||||
|
namespace Sapphire::World
|
||||||
|
{
|
||||||
|
|
||||||
|
class FadeBNpcTask : public Task
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
FadeBNpcTask( uint64_t delayTime, Entity::BNpcPtr bnpc );
|
||||||
|
|
||||||
|
void onQueue() override;
|
||||||
|
void execute() override;
|
||||||
|
std::string toString() override;
|
||||||
|
private:
|
||||||
|
Entity::BNpcPtr m_pBNpc;
|
||||||
|
};
|
||||||
|
|
||||||
|
}
|
Loading…
Add table
Reference in a new issue