diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index 47d1bcdf..df0bab07 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -240,7 +240,8 @@ bool Action::Action::update() player->setLastActionTick( tickCount ); uint32_t delayMs = 100 - lastTickMs; - castTime = ( m_castTimeMs + delayMs ) - 500; //subtract 500ms before the client begin to request actions while casting + castTime = ( m_castTimeMs + delayMs ); //subtract 500ms before the client begin to request actions while casting + m_castTimeRestMs = static_cast< uint64_t >( m_castTimeMs ) - std::difftime( static_cast< time_t >( tickCount ), static_cast< time_t >( m_startTime ) ); } if( !hasCastTime() || std::difftime( static_cast< time_t >( tickCount ), static_cast< time_t >( m_startTime ) ) > castTime ) @@ -872,3 +873,8 @@ void Action::Action::setActionKind( uint8_t actionKind ) { m_actionKind = actionKind; } + +uint64_t Action::Action::getCastTimeRest() const +{ + return m_castTimeRestMs; +} diff --git a/src/world/Action/Action.h b/src/world/Action/Action.h index b9967d8e..fd5d0190 100644 --- a/src/world/Action/Action.h +++ b/src/world/Action/Action.h @@ -49,6 +49,8 @@ namespace Sapphire::World::Action uint8_t getActionKind() const; void setActionKind( uint8_t actionKind ); + uint64_t getCastTimeRest() const; + /*! * @brief Checks if a chara has enough resources available to cast the action (tp/mp/etc) * @return true if they have the required resources @@ -161,6 +163,7 @@ namespace Sapphire::World::Action uint16_t m_primaryCost; uint64_t m_startTime; + uint64_t m_castTimeRestMs; uint32_t m_castTimeMs; uint32_t m_recastTimeMs; uint8_t m_cooldownGroup; diff --git a/src/world/Action/EventItemAction.cpp b/src/world/Action/EventItemAction.cpp index 1f562d76..6988e4a7 100644 --- a/src/world/Action/EventItemAction.cpp +++ b/src/world/Action/EventItemAction.cpp @@ -7,6 +7,8 @@ #include #include "Manager/PlayerMgr.h" +#include "Manager/EventMgr.h" + #include "Script/ScriptMgr.h" #include #include @@ -56,8 +58,13 @@ void EventItemAction::execute() { Manager::PlayerMgr::sendDebug( *getSourceChara()->getAsPlayer(), "EventItemAction type {0} execute called.", m_eventItemAction->data().Action ); auto& scriptMgr = Common::Service< Scripting::ScriptMgr >::ref(); + auto& eventMgr = Common::Service< World::Manager::EventMgr >::ref(); + + eventMgr.eventStart( *getSourceChara()->getAsPlayer(), m_targetId, m_eventItemAction->data().EventHandler, + Event::EventHandler::ActionResult, 0, 0 ); scriptMgr.onEventItem( *getSourceChara()->getAsPlayer(), m_eventItem, m_eventItemAction->data().EventHandler, m_targetId ); + eventMgr.checkEvent( *getSourceChara()->getAsPlayer(), m_eventItemAction->data().EventHandler ); } void EventItemAction::onStart() diff --git a/src/world/Network/Handlers/ActionHandler.cpp b/src/world/Network/Handlers/ActionHandler.cpp index 4b0ad7b0..33dc0465 100644 --- a/src/world/Network/Handlers/ActionHandler.cpp +++ b/src/world/Network/Handlers/ActionHandler.cpp @@ -75,9 +75,7 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P { auto action = exdData.getRow< Component::Excel::EventItem >( actionId ); assert( action ); - actionMgr.handleEventItemAction( player, actionId, action, sequence, targetId ); - break; } diff --git a/src/world/Network/Handlers/PacketHandlers.cpp b/src/world/Network/Handlers/PacketHandlers.cpp index 4d208b0c..5918d588 100644 --- a/src/world/Network/Handlers/PacketHandlers.cpp +++ b/src/world/Network/Handlers/PacketHandlers.cpp @@ -215,7 +215,7 @@ void Sapphire::Network::GameConnection::moveHandler( const Packets::FFXIVARR_PAC player.setRot( data.dir ); player.setPos( { data.pos.x, data.pos.y, data.pos.z } ); - if( player.getCurrentAction() && bPosChanged ) + if( player.getCurrentAction() && bPosChanged && player.getCurrentAction()->getCastTimeRest() > 500 ) player.getCurrentAction()->setInterrupted( Common::ActionInterruptType::RegularInterrupt ); auto clientAnimationType = data.flag; diff --git a/src/world/Script/ScriptMgr.cpp b/src/world/Script/ScriptMgr.cpp index 721451c8..e133a6aa 100644 --- a/src/world/Script/ScriptMgr.cpp +++ b/src/world/Script/ScriptMgr.cpp @@ -284,6 +284,8 @@ bool Sapphire::Scripting::ScriptMgr::onEmote( Entity::Player& player, uint64_t a { const auto eventType = static_cast< uint16_t >( eventId >> 16 ); + auto& pEventMgr = Common::Service< World::Manager::EventMgr >::ref(); + auto actor = pEventMgr.mapEventActorToRealActor( static_cast< uint32_t >( actorId ) ); if( eventType == Event::EventHandler::EventHandlerType::Quest ) { auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::QuestScript >( eventId ); @@ -293,7 +295,7 @@ bool Sapphire::Scripting::ScriptMgr::onEmote( Entity::Player& player, uint64_t a { auto idx = player.getQuestIndex( eventId ); auto& quest = player.getQuestByIndex( idx ); - script->onEmote( quest, actorId, emoteId, player ); + script->onEmote( quest, actor, emoteId, player ); } } else @@ -301,7 +303,7 @@ bool Sapphire::Scripting::ScriptMgr::onEmote( Entity::Player& player, uint64_t a auto script = m_nativeScriptMgr->getScript< Sapphire::ScriptAPI::EventScript >( eventId ); if( !script ) return false; - script->onEmote( actorId, eventId, emoteId, player ); + script->onEmote( actor, eventId, emoteId, player ); } return true;