1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-04-27 14:57:44 +00:00

Added quest to EObj hit event

This commit is contained in:
Mordred 2022-01-13 21:00:47 +01:00
parent be8d885e39
commit cefbdb6fac
3 changed files with 9 additions and 6 deletions

View file

@ -170,7 +170,7 @@ namespace Sapphire::ScriptAPI
{ {
} }
void QuestScript::onEObjHit( Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ) void QuestScript::onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId )
{ {
} }

View file

@ -223,7 +223,7 @@ namespace Sapphire::ScriptAPI
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 );
virtual void onEObjHit( Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId ); virtual void onEObjHit( World::Quest& quest, Sapphire::Entity::Player& player, uint64_t actorId, uint32_t actionId );
World::Manager::EventMgr& eventMgr() World::Manager::EventMgr& eventMgr()
{ {

View file

@ -365,7 +365,7 @@ bool Sapphire::Scripting::ScriptMgr::onBNpcKill( Entity::Player& player, uint16_
// loop through all active quests and try to call available onBNpcKill callbacks // loop through all active quests and try to call available onBNpcKill callbacks
for( size_t i = 0; i < 30; i++ ) for( size_t i = 0; i < 30; i++ )
{ {
auto quest = player.getQuestByIndex( static_cast< uint16_t >( i )); auto quest = player.getQuestByIndex( static_cast< uint16_t >( i ) );
if( quest.getId() == 0 ) if( quest.getId() == 0 )
continue; continue;
@ -402,15 +402,18 @@ bool Sapphire::Scripting::ScriptMgr::onEObjHit( Sapphire::Entity::Player& player
uint32_t questId = quest.getId() | Event::EventHandler::EventHandlerType::Quest << 16; uint32_t questId = quest.getId() | Event::EventHandler::EventHandlerType::Quest << 16;
auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( questId ); auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( questId );
if( script ) if( script )
{ {
didCallScript = true; didCallScript = true;
std::string objName = eventMgr.getEventName( questId ); std::string objName = eventMgr.getEventName( questId );
PlayerMgr::sendDebug( player, "Calling: {0}.onEObjHit actorId#{1}", objName, actorId ); PlayerMgr::sendDebug( player, "Calling: {0}.onEObjHit actorId#{1}, questId#", objName, actorId, quest.getId() );
script->onEObjHit( player, actorId, actionId ); World::Quest preQ = quest;
script->onEObjHit( quest, player, actorId, actionId );
if( quest != preQ )
player.updateQuest( quest );
} }
} }