1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-26 06:27:45 +00:00

More groundwork for questbattles

This commit is contained in:
Mordred 2019-03-31 11:27:11 +02:00
parent 1b86b87503
commit d55ae2c8c0
9 changed files with 239 additions and 179 deletions

View file

@ -102,12 +102,12 @@ uint32_t Sapphire::Entity::EventObject::getHousingLink() const
return m_housingLink; return m_housingLink;
} }
void Sapphire::Entity::EventObject::setParentInstance( Sapphire::InstanceContentPtr instance ) void Sapphire::Entity::EventObject::setParentInstance( Sapphire::ZonePtr instance )
{ {
m_parentInstance = instance; m_parentInstance = instance;
} }
Sapphire::InstanceContentPtr Sapphire::Entity::EventObject::getParentInstance() const Sapphire::ZonePtr Sapphire::Entity::EventObject::getParentInstance() const
{ {
return m_parentInstance; return m_parentInstance;
} }

View file

@ -13,7 +13,7 @@ namespace Sapphire::Entity
Common::FFXIVARR_POSITION3 pos, float rotation, const std::string& givenName = "none" ); Common::FFXIVARR_POSITION3 pos, float rotation, const std::string& givenName = "none" );
using OnTalkEventHandler = std::function< void( Entity::Player&, Entity::EventObjectPtr, using OnTalkEventHandler = std::function< void( Entity::Player&, Entity::EventObjectPtr,
InstanceContentPtr, uint64_t ) >; ZonePtr, uint64_t ) >;
uint32_t getGimmickId() const; uint32_t getGimmickId() const;
@ -35,9 +35,9 @@ namespace Sapphire::Entity
const std::string& getName() const; const std::string& getName() const;
InstanceContentPtr getParentInstance() const; ZonePtr getParentInstance() const;
void setParentInstance( InstanceContentPtr instance ); void setParentInstance( ZonePtr instance );
void spawn( PlayerPtr pTarget ) override; void spawn( PlayerPtr pTarget ) override;
@ -56,7 +56,7 @@ namespace Sapphire::Entity
uint8_t m_state; uint8_t m_state;
float m_scale; float m_scale;
std::string m_name; std::string m_name;
InstanceContentPtr m_parentInstance; ZonePtr m_parentInstance;
OnTalkEventHandler m_onTalkEventHandler; OnTalkEventHandler m_onTalkEventHandler;

View file

@ -5,6 +5,7 @@
#include "Territory/Zone.h" #include "Territory/Zone.h"
#include "Territory/InstanceContent.h" #include "Territory/InstanceContent.h"
#include "Territory/QuestBattle.h"
#include "Actor/Player.h" #include "Actor/Player.h"
#include "Actor/EventObject.h" #include "Actor/EventObject.h"
#include "ServerMgr.h" #include "ServerMgr.h"
@ -461,6 +462,44 @@ bool Sapphire::Scripting::ScriptMgr::onInstanceEnterTerritory( InstanceContentPt
return false; return false;
} }
bool Sapphire::Scripting::ScriptMgr::onInstanceInit( QuestBattlePtr instance )
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance->getDirectorId() );
if( script )
{
script->onInit( *instance );
return true;
}
return false;
}
bool Sapphire::Scripting::ScriptMgr::onInstanceUpdate( QuestBattlePtr instance, uint32_t currTime )
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance->getDirectorId() );
if( script )
{
script->onUpdate( *instance, currTime );
return true;
}
return false;
}
bool Sapphire::Scripting::ScriptMgr::onInstanceEnterTerritory( QuestBattlePtr instance, Entity::Player& player,
uint32_t eventId, uint16_t param1, uint16_t param2 )
{
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestBattleScript >( instance->getDirectorId() );
if( script )
{
script->onEnterTerritory( *instance, player, eventId, param1, param2 );
return true;
}
return false;
}
Sapphire::Scripting::NativeScriptMgr& Sapphire::Scripting::ScriptMgr::getNativeScriptHandler() Sapphire::Scripting::NativeScriptMgr& Sapphire::Scripting::ScriptMgr::getNativeScriptHandler()
{ {
return *m_nativeScriptMgr; return *m_nativeScriptMgr;

View file

@ -100,6 +100,13 @@ namespace Sapphire::Scripting
onInstanceEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1, onInstanceEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
uint16_t param2 ); uint16_t param2 );
bool onInstanceInit( QuestBattlePtr instance );
bool onInstanceUpdate( QuestBattlePtr instance, uint32_t currTime );
bool onInstanceEnterTerritory( QuestBattlePtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
uint16_t param2 );
bool loadDir( const std::string& dirname, std::set< std::string >& files, const std::string& ext ); bool loadDir( const std::string& dirname, std::set< std::string >& files, const std::string& ext );
NativeScriptMgr& getNativeScriptHandler(); NativeScriptMgr& getNativeScriptHandler();

View file

@ -5,13 +5,16 @@
#include "Event/Director.h" #include "Event/Director.h"
#include "Forwards.h" #include "Forwards.h"
namespace Sapphire { namespace Sapphire::Data
namespace Data {
struct InstanceContent;
}
class InstanceContent : public Event::Director, public Zone
{ {
public: struct InstanceContent;
}
namespace Sapphire
{
class InstanceContent : public Event::Director, public Zone
{
public:
enum InstanceContentState enum InstanceContentState
{ {
Created, Created,
@ -97,7 +100,7 @@ public:
/*! 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;
private: private:
std::shared_ptr< Sapphire::Data::InstanceContent > m_instanceConfiguration; std::shared_ptr< Sapphire::Data::InstanceContent > m_instanceConfiguration;
uint32_t m_instanceContentId; uint32_t m_instanceContentId;
InstanceContentState m_state; InstanceContentState m_state;
@ -114,7 +117,7 @@ private:
// the players which are bound to the instance, regardless of inside or offline // the players which are bound to the instance, regardless of inside or offline
std::set< uint32_t > m_boundPlayerIds; std::set< uint32_t > m_boundPlayerIds;
}; };
} }
#endif //SAPPHIRE_INSTANCECONTENT_H #endif //SAPPHIRE_INSTANCECONTENT_H

View file

@ -48,7 +48,7 @@ Sapphire::QuestBattle::QuestBattle( std::shared_ptr< Sapphire::Data::QuestBattle
bool Sapphire::QuestBattle::init() bool Sapphire::QuestBattle::init()
{ {
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >(); auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
pScriptMgr->onInstanceInit( getAsInstanceContent() ); pScriptMgr->onInstanceInit( getAsQuestBattle() );
return true; return true;
} }
@ -152,7 +152,7 @@ void Sapphire::QuestBattle::onUpdate( uint32_t currTime )
} }
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >(); auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
pScriptMgr->onInstanceUpdate( getAsInstanceContent(), currTime ); pScriptMgr->onInstanceUpdate( getAsQuestBattle(), currTime );
} }
void Sapphire::QuestBattle::onFinishLoading( Entity::Player& player ) void Sapphire::QuestBattle::onFinishLoading( Entity::Player& player )
@ -348,8 +348,8 @@ void Sapphire::QuestBattle::onTalk( Sapphire::Entity::Player& player, uint32_t e
if( it == m_eventIdToObjectMap.end() ) if( it == m_eventIdToObjectMap.end() )
return; return;
if( auto onTalk = it->second->getOnTalkHandler() ) if( auto onTalkHandler = it->second->getOnTalkHandler() )
onTalk( player, it->second, getAsInstanceContent(), actorId ); onTalkHandler( player, it->second, getAsQuestBattle(), actorId );
else else
player.sendDebug( "No onTalk handler found for interactable eobj with EObjID#{0}, eventId#{1} ", player.sendDebug( "No onTalk handler found for interactable eobj with EObjID#{0}, eventId#{1} ",
it->second->getObjectId(), eventId ); it->second->getObjectId(), eventId );
@ -359,7 +359,7 @@ void
Sapphire::QuestBattle::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 ) Sapphire::QuestBattle::onEnterTerritory( Entity::Player& player, uint32_t eventId, uint16_t param1, uint16_t param2 )
{ {
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >(); auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
pScriptMgr->onInstanceEnterTerritory( getAsInstanceContent(), player, eventId, param1, param2 ); pScriptMgr->onInstanceEnterTerritory( getAsQuestBattle(), player, eventId, param1, param2 );
// TODO: this may or may not be correct for questbattles // TODO: this may or may not be correct for questbattles
player.directorPlayScene( getDirectorId(), 1, NO_DEFAULT_CAMERA | CONDITION_CUTSCENE | SILENT_ENTER_TERRI_ENV | player.directorPlayScene( getDirectorId(), 1, NO_DEFAULT_CAMERA | CONDITION_CUTSCENE | SILENT_ENTER_TERRI_ENV |

View file

@ -5,13 +5,16 @@
#include "Event/Director.h" #include "Event/Director.h"
#include "Forwards.h" #include "Forwards.h"
namespace Sapphire { namespace Sapphire::Data
namespace Data { {
struct QuestBattle; struct QuestBattle;
} }
class QuestBattle : public Event::Director, public Zone
namespace Sapphire
{ {
public: class QuestBattle : public Event::Director, public Zone
{
public:
QuestBattle( std::shared_ptr< Sapphire::Data::QuestBattle > pBattleDetails, QuestBattle( std::shared_ptr< Sapphire::Data::QuestBattle > pBattleDetails,
uint16_t territoryType, uint16_t territoryType,
uint32_t guId, uint32_t guId,
@ -87,7 +90,7 @@ public:
/*! 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;
private: private:
std::shared_ptr< Sapphire::Data::QuestBattle > m_pBattleDetails; std::shared_ptr< Sapphire::Data::QuestBattle > m_pBattleDetails;
uint32_t m_questBattleId; uint32_t m_questBattleId;
Event::Director::DirectorState m_state; Event::Director::DirectorState m_state;
@ -102,7 +105,7 @@ private:
// the players which are bound to the instance, regardless of inside or offline // the players which are bound to the instance, regardless of inside or offline
std::set< uint32_t > m_boundPlayerIds; std::set< uint32_t > m_boundPlayerIds;
}; };
} }
#endif #endif

View file

@ -17,6 +17,7 @@
#include "Zone.h" #include "Zone.h"
#include "InstanceContent.h" #include "InstanceContent.h"
#include "QuestBattle.h"
#include "Manager/TerritoryMgr.h" #include "Manager/TerritoryMgr.h"
#include "Session.h" #include "Session.h"
@ -749,6 +750,11 @@ Sapphire::InstanceContentPtr Sapphire::Zone::getAsInstanceContent()
return std::dynamic_pointer_cast< InstanceContent, Zone >( shared_from_this() ); return std::dynamic_pointer_cast< InstanceContent, Zone >( shared_from_this() );
} }
Sapphire::QuestBattlePtr Sapphire::Zone::getAsQuestBattle()
{
return std::dynamic_pointer_cast< QuestBattle, Zone >( shared_from_this() );
}
uint32_t Sapphire::Zone::getNextEObjId() uint32_t Sapphire::Zone::getNextEObjId()
{ {
return ++m_nextEObjId; return ++m_nextEObjId;

View file

@ -161,6 +161,8 @@ namespace Sapphire
InstanceContentPtr getAsInstanceContent(); InstanceContentPtr getAsInstanceContent();
QuestBattlePtr getAsQuestBattle();
void updateSpawnPoints(); void updateSpawnPoints();
uint32_t getNextEffectSequence(); uint32_t getNextEffectSequence();