mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 07:37:45 +00:00
OnWithin and OnOutside range have been adjusted to include Quest object, minor fix to onEmote function quest updates
This commit is contained in:
parent
27b218fd78
commit
3eb5fbf6fa
4 changed files with 60 additions and 13 deletions
|
@ -524,7 +524,7 @@ void Sapphire::Network::GameConnection::handlePackets( const Sapphire::Network::
|
||||||
|
|
||||||
auto pe4 = std::make_shared< FFXIVRawPacket >( 0x08, 0x18, 0, 0 );
|
auto pe4 = std::make_shared< FFXIVRawPacket >( 0x08, 0x18, 0, 0 );
|
||||||
*reinterpret_cast< unsigned int* >( &pe4->data()[ 0 ] ) = id;
|
*reinterpret_cast< unsigned int* >( &pe4->data()[ 0 ] ) = id;
|
||||||
*reinterpret_cast< unsigned int* >( &pe4->data()[ 4 ] ) = timeStamp;
|
*reinterpret_cast< unsigned int* >( &pe4->data()[ 4 ] ) = Util::getTimeSeconds();
|
||||||
sendSinglePacket( pe4 );
|
sendSinglePacket( pe4 );
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
|
|
@ -158,11 +158,11 @@ namespace Sapphire::ScriptAPI
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuestScript::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
void QuestScript::onWithinRange( World::Quest& quest, Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
void QuestScript::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
void QuestScript::onOutsideRange( World::Quest& quest, Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -223,9 +223,9 @@ namespace Sapphire::ScriptAPI
|
||||||
|
|
||||||
virtual void onEnterTerritory( World::Quest& quest, Sapphire::Entity::Player& player, uint16_t param1, uint16_t param2 );
|
virtual void onEnterTerritory( World::Quest& quest, Sapphire::Entity::Player& player, uint16_t param1, uint16_t param2 );
|
||||||
|
|
||||||
virtual void onWithinRange( Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
virtual void onWithinRange( World::Quest& quest, Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
||||||
|
|
||||||
virtual void onOutsideRange( Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
virtual void onOutsideRange( World::Quest& quest, Sapphire::Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z );
|
||||||
|
|
||||||
virtual void onEventHandlerTradeReturn( Sapphire::Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
|
virtual void onEventHandlerTradeReturn( Sapphire::Entity::Player& player, uint32_t eventId, uint16_t subEvent, uint16_t param,
|
||||||
uint32_t catalogId );
|
uint32_t catalogId );
|
||||||
|
|
|
@ -263,20 +263,64 @@ bool Sapphire::Scripting::ScriptMgr::onEnterTerritory( Entity::Player& player, u
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::Scripting::ScriptMgr::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
bool Sapphire::Scripting::ScriptMgr::onWithinRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
||||||
|
{
|
||||||
|
const auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
||||||
|
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
||||||
|
|
||||||
|
if( eventType == Event::EventHandler::EventHandlerType::Quest )
|
||||||
|
{
|
||||||
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId );
|
||||||
|
if( !script )
|
||||||
|
return false;
|
||||||
|
if( player.hasQuest( eventId ) )
|
||||||
|
{
|
||||||
|
auto idx = player.getQuestIndex( eventId );
|
||||||
|
auto& quest = player.getQuestByIndex( idx );
|
||||||
|
World::Quest preQ = quest;
|
||||||
|
script->onWithinRange( quest, player, eventId, param1, x, y, z );
|
||||||
|
if( quest != preQ )
|
||||||
|
player.updateQuest( quest );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
||||||
if( !script )
|
if( !script )
|
||||||
return false;
|
return false;
|
||||||
script->onWithinRange( player, eventId, param1, x, y, z );
|
script->onWithinRange( player, eventId, param1, x, y, z );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Sapphire::Scripting::ScriptMgr::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
bool Sapphire::Scripting::ScriptMgr::onOutsideRange( Entity::Player& player, uint32_t eventId, uint32_t param1, float x, float y, float z )
|
||||||
|
{
|
||||||
|
const auto eventType = static_cast< uint16_t >( eventId >> 16 );
|
||||||
|
auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref();
|
||||||
|
|
||||||
|
if( eventType == Event::EventHandler::EventHandlerType::Quest )
|
||||||
|
{
|
||||||
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId );
|
||||||
|
if( !script )
|
||||||
|
return false;
|
||||||
|
if( player.hasQuest( eventId ) )
|
||||||
|
{
|
||||||
|
auto idx = player.getQuestIndex( eventId );
|
||||||
|
auto& quest = player.getQuestByIndex( idx );
|
||||||
|
World::Quest preQ = quest;
|
||||||
|
script->onOutsideRange( quest, player, eventId, param1, x, y, z );
|
||||||
|
if( quest != preQ )
|
||||||
|
player.updateQuest( quest );
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId );
|
||||||
if( !script )
|
if( !script )
|
||||||
return false;
|
return false;
|
||||||
script->onOutsideRange( player, eventId, param1, x, y, z );
|
script->onOutsideRange( player, eventId, param1, x, y, z );
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -295,7 +339,10 @@ bool Sapphire::Scripting::ScriptMgr::onEmote( Entity::Player& player, uint64_t a
|
||||||
{
|
{
|
||||||
auto idx = player.getQuestIndex( eventId );
|
auto idx = player.getQuestIndex( eventId );
|
||||||
auto& quest = player.getQuestByIndex( idx );
|
auto& quest = player.getQuestByIndex( idx );
|
||||||
|
World::Quest preQ = quest;
|
||||||
script->onEmote( quest, actor, emoteId, player );
|
script->onEmote( quest, actor, emoteId, player );
|
||||||
|
if( quest != preQ )
|
||||||
|
player.updateQuest( quest );
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
|
Loading…
Add table
Reference in a new issue