mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-01 08:27:46 +00:00
add encounter to instancecontent; basic status handling;
This commit is contained in:
parent
5217a474a5
commit
e3a140da40
4 changed files with 54 additions and 5 deletions
|
@ -58,6 +58,7 @@ namespace Sapphire
|
|||
|
||||
virtual void addState( EncounterState::EncounterStatePtr pState, bool initState = true ) = 0;
|
||||
virtual void addBNpc( Entity::BNpcPtr pBNpc ) = 0;
|
||||
virtual void removeBNpc( uint32_t layoutId ) = 0;
|
||||
virtual Entity::BNpcPtr getBNpc( uint32_t layoutId ) = 0;
|
||||
|
||||
virtual EncounterFightStatus getEncounterFightStatus() const = 0;
|
||||
|
|
|
@ -95,6 +95,20 @@ namespace Sapphire
|
|||
|
||||
void update( double deltaTime ) override
|
||||
{
|
||||
// todo: better way to start fights here..
|
||||
|
||||
auto ifrit = getBNpc( IfritNormalData::IFRIT );
|
||||
|
||||
if( ifrit; ifrit->hateListGetHighestValue() != 0 && m_status == EncounterFightStatus::IDLE )
|
||||
{
|
||||
start();
|
||||
}
|
||||
|
||||
if( m_status == EncounterFightStatus::ACTIVE && ifrit && !ifrit->hateListGetHighest()->isAlive() )
|
||||
{
|
||||
m_status = EncounterFightStatus::FAIL;
|
||||
}
|
||||
|
||||
if( m_stateStack; !m_stateStack->empty() )
|
||||
{
|
||||
if( m_stateStack->top()->shouldFinish() )
|
||||
|
@ -110,8 +124,14 @@ namespace Sapphire
|
|||
void reset() override
|
||||
{
|
||||
auto boss = m_pInstance->getActiveBNpcByLayoutId( IfritNormalData::IFRIT );
|
||||
if( boss )
|
||||
{
|
||||
removeBNpc( IfritNormalData::IFRIT );
|
||||
m_pInstance->removeActor( boss );
|
||||
|
||||
}
|
||||
|
||||
|
||||
init();
|
||||
}
|
||||
|
||||
|
@ -131,5 +151,10 @@ namespace Sapphire
|
|||
if( bnpc != std::end( m_bnpcs ) )
|
||||
return bnpc->second;
|
||||
}
|
||||
|
||||
void removeBNpc( uint32_t layoutId ) override
|
||||
{
|
||||
m_bnpcs.erase( layoutId );
|
||||
}
|
||||
};
|
||||
}
|
|
@ -28,6 +28,8 @@
|
|||
#include "InstanceContent.h"
|
||||
#include "InstanceObjectCache.h"
|
||||
|
||||
#include <Encounter/InstanceContent/IfritNormal.h>
|
||||
|
||||
|
||||
using namespace Sapphire::Common;
|
||||
using namespace Sapphire::Network::Packets;
|
||||
|
@ -67,6 +69,11 @@ bool Sapphire::InstanceContent::init()
|
|||
auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref();
|
||||
scriptMgr.onInstanceInit( *this );
|
||||
|
||||
// todo: every fight is now ifrit
|
||||
m_pEncounter = std::make_shared< IfritEncounterFight >( std::dynamic_pointer_cast< InstanceContent, Territory >( shared_from_this() ) );
|
||||
|
||||
m_pEncounter->init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -137,10 +144,10 @@ void Sapphire::InstanceContent::onUpdate( uint64_t tickCount )
|
|||
if( it == m_playerMap.end() )
|
||||
return;
|
||||
|
||||
auto player = it->second;
|
||||
if( !player->isLoadingComplete() ||
|
||||
!player->isDirectorInitialized() ||
|
||||
player->hasCondition( PlayerCondition::WatchingCutscene ) )
|
||||
auto pPlayer = it->second;
|
||||
if( !pPlayer->isLoadingComplete() ||
|
||||
!pPlayer->isDirectorInitialized() ||
|
||||
pPlayer->hasCondition( PlayerCondition::WatchingCutscene ) )
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -158,12 +165,20 @@ void Sapphire::InstanceContent::onUpdate( uint64_t tickCount )
|
|||
if( m_pEntranceEObj )
|
||||
m_pEntranceEObj->setPermissionInvisibility( 1 );
|
||||
m_state = DutyInProgress;
|
||||
|
||||
// todo: also yucky, should be init
|
||||
m_pEncounter->reset();
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
case DutyReset:
|
||||
{
|
||||
// todo: revive players if trial/enclosed raid arena, add reset timer
|
||||
m_instanceCommenceTime = 0;
|
||||
m_state = Created;
|
||||
break;
|
||||
}
|
||||
|
||||
case DutyInProgress:
|
||||
{
|
||||
|
@ -178,6 +193,9 @@ void Sapphire::InstanceContent::onUpdate( uint64_t tickCount )
|
|||
m_instanceTerminate = true;
|
||||
|
||||
updateBNpcs( tickCount );
|
||||
|
||||
if( m_pEncounter->getEncounterFightStatus() == EncounterFightStatus::FAIL )
|
||||
m_state = DutyReset;
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -215,6 +233,8 @@ void Sapphire::InstanceContent::onUpdate( uint64_t tickCount )
|
|||
auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref();
|
||||
scriptMgr.onInstanceUpdate( *this, tickCount );
|
||||
|
||||
m_pEncounter->update( tickCount );
|
||||
|
||||
m_lastUpdate = tickCount;
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@
|
|||
#include "Event/Director.h"
|
||||
#include "Forwards.h"
|
||||
#include <Exd/Structs.h>
|
||||
#include <memory>
|
||||
|
||||
namespace Sapphire
|
||||
{
|
||||
|
@ -214,6 +215,8 @@ namespace Sapphire
|
|||
|
||||
// the players which are bound to the instance, regardless of inside or offline
|
||||
std::set< uint32_t > m_boundPlayerIds;
|
||||
|
||||
EncounterFightPtr m_pEncounter;
|
||||
};
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue