1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-25 22:17: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;
}
void Sapphire::Entity::EventObject::setParentInstance( Sapphire::InstanceContentPtr instance )
void Sapphire::Entity::EventObject::setParentInstance( Sapphire::ZonePtr instance )
{
m_parentInstance = instance;
}
Sapphire::InstanceContentPtr Sapphire::Entity::EventObject::getParentInstance() const
Sapphire::ZonePtr Sapphire::Entity::EventObject::getParentInstance() const
{
return m_parentInstance;
}

View file

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

View file

@ -5,6 +5,7 @@
#include "Territory/Zone.h"
#include "Territory/InstanceContent.h"
#include "Territory/QuestBattle.h"
#include "Actor/Player.h"
#include "Actor/EventObject.h"
#include "ServerMgr.h"
@ -461,6 +462,44 @@ bool Sapphire::Scripting::ScriptMgr::onInstanceEnterTerritory( InstanceContentPt
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()
{
return *m_nativeScriptMgr;

View file

@ -100,6 +100,13 @@ namespace Sapphire::Scripting
onInstanceEnterTerritory( InstanceContentPtr instance, Entity::Player& player, uint32_t eventId, uint16_t param1,
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 );
NativeScriptMgr& getNativeScriptHandler();

View file

@ -5,10 +5,13 @@
#include "Event/Director.h"
#include "Forwards.h"
namespace Sapphire {
namespace Data {
namespace Sapphire::Data
{
struct InstanceContent;
}
namespace Sapphire
{
class InstanceContent : public Event::Director, public Zone
{
public:

View file

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

View file

@ -5,10 +5,13 @@
#include "Event/Director.h"
#include "Forwards.h"
namespace Sapphire {
namespace Data {
namespace Sapphire::Data
{
struct QuestBattle;
}
namespace Sapphire
{
class QuestBattle : public Event::Director, public Zone
{
public:

View file

@ -17,6 +17,7 @@
#include "Zone.h"
#include "InstanceContent.h"
#include "QuestBattle.h"
#include "Manager/TerritoryMgr.h"
#include "Session.h"
@ -749,6 +750,11 @@ Sapphire::InstanceContentPtr Sapphire::Zone::getAsInstanceContent()
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()
{
return ++m_nextEObjId;

View file

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