From 9daf224019198f3445374a9edfacffeec1a36521 Mon Sep 17 00:00:00 2001 From: Lucy <44952533+Skyliegirl33@users.noreply.github.com> Date: Wed, 8 Mar 2023 18:13:29 +0100 Subject: [PATCH] Add option for scripts to enable the generic/lut handler --- src/world/Action/Action.cpp | 13 +++++++++++-- src/world/Action/Action.h | 3 +++ 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 02c8c8d4..190965eb 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -517,8 +517,9 @@ void Action::Action::handleAction() auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); auto hasLutEntry = hasValidLutEntry(); + auto hasScript = scriptMgr.onExecute( *this ); - if( !scriptMgr.onExecute( *this ) && !hasLutEntry ) + if( !hasScript && !hasLutEntry ) { if( auto player = m_pSource->getAsPlayer() ) { @@ -528,9 +529,12 @@ void Action::Action::handleAction() return; } + if( !hasScript ) + m_enableGenericHandler = true; + Network::Util::Player::sendHudParam( *m_pSource->getAsPlayer() ); - if( !hasLutEntry || m_hitActors.empty() ) + if( !m_enableGenericHandler || !hasLutEntry || m_hitActors.empty() ) { // send any effect packet added by script or an empty one just to play animation for other players m_effectBuilder->buildAndSendPackets( m_hitActors ); @@ -962,3 +966,8 @@ uint64_t Action::Action::getCastTimeRest() const { return m_castTimeRestMs; } + +void Action::Action::enableGenericHandler() +{ + m_enableGenericHandler = true; +} \ No newline at end of file diff --git a/src/world/Action/Action.h b/src/world/Action/Action.h index 081be92e..66a680f9 100644 --- a/src/world/Action/Action.h +++ b/src/world/Action/Action.h @@ -53,6 +53,8 @@ namespace Sapphire::World::Action uint64_t getCastTimeRest() const; + void enableGenericHandler(); + /*! * @brief Checks if a chara has enough resources available to cast the action (tp/mp/etc) * @return true if they have the required resources @@ -207,6 +209,7 @@ namespace Sapphire::World::Action bool m_canTargetFriendly{}; bool m_canTargetHostile{}; bool m_canTargetDead{}; + bool m_enableGenericHandler{}; Common::ActionInterruptType m_interruptType;