1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-01 16:37:45 +00:00

fix recast time truncated by field size, correctly send actionstart

This commit is contained in:
NotAdam 2019-03-08 00:26:41 +11:00
parent d9419b49b4
commit bcbbca056a
6 changed files with 63 additions and 18 deletions

View file

@ -36,13 +36,13 @@ enum ActorControlType : uint16_t
CastInterrupt = 0x0F, CastInterrupt = 0x0F,
/*! /*!
* @brief Sets the cooldown for an action * @brief Sent when a player uses an action
* *
* @param param1 Seems to be always 1 from what I've seen, needs more research * param1 Seems to be always 1 from what I've seen, needs more research
* @param param2 The actionid to set the cooldown for * param2 The actionid
* @param param3 The time in milliseconds to apply the cooldown for, 0 resets the cooldown * param3 The action cooldown in ms / 10
*/ */
SetActionCooldown = 0x11, ActionStart = 0x11,
StatusEffectGain = 0x14, StatusEffectGain = 0x14,
StatusEffectLose = 0x15, StatusEffectLose = 0x15,

View file

@ -0,0 +1,22 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionCure120 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionCure120() :
Sapphire::ScriptAPI::ActionScript( 120 )
{
}
void onExecute( Sapphire::Action::Action& action ) override
{
}
};
EXPOSE_SCRIPT( ActionCure120 );

View file

@ -0,0 +1,22 @@
#include <Script/NativeScriptApi.h>
#include <ScriptObject.h>
#include <Actor/Player.h>
#include <Action/Action.h>
class ActionAsylum3569 :
public Sapphire::ScriptAPI::ActionScript
{
public:
ActionAsylum3569() :
Sapphire::ScriptAPI::ActionScript( 3569 )
{
}
void onExecute( Sapphire::Action::Action& action ) override
{
}
};
EXPOSE_SCRIPT( ActionAsylum3569 );

View file

@ -62,8 +62,8 @@ bool Sapphire::Action::Action::init()
m_actionData = actionData; m_actionData = actionData;
} }
m_castTime = static_cast< uint32_t >( m_actionData->cast100ms * 100 ); m_castTimeMs = static_cast< uint32_t >( m_actionData->cast100ms * 100 );
m_recastTime = static_cast< uint16_t >( m_actionData->recast100ms * 100 ); m_recastTimeMs = static_cast< uint32_t >( m_actionData->recast100ms * 100 );
m_cooldownGroup = m_actionData->cooldownGroup; m_cooldownGroup = m_actionData->cooldownGroup;
m_range = m_actionData->range; m_range = m_actionData->range;
m_effectRange = m_actionData->effectRange; m_effectRange = m_actionData->effectRange;
@ -129,17 +129,17 @@ void Sapphire::Action::Action::setInterrupted( Common::ActionInterruptType type
uint32_t Sapphire::Action::Action::getCastTime() const uint32_t Sapphire::Action::Action::getCastTime() const
{ {
return m_castTime; return m_castTimeMs;
} }
void Sapphire::Action::Action::setCastTime( uint32_t castTime ) void Sapphire::Action::Action::setCastTime( uint32_t castTime )
{ {
m_castTime = castTime; m_castTimeMs = castTime;
} }
bool Sapphire::Action::Action::hasCastTime() const bool Sapphire::Action::Action::hasCastTime() const
{ {
return m_castTime > 0; return m_castTimeMs > 0;
} }
Sapphire::Entity::CharaPtr Sapphire::Action::Action::getSourceChara() const Sapphire::Entity::CharaPtr Sapphire::Action::Action::getSourceChara() const
@ -166,7 +166,7 @@ bool Sapphire::Action::Action::update()
uint64_t currTime = Util::getTimeMs(); uint64_t currTime = Util::getTimeMs();
if( !hasCastTime() || std::difftime( currTime, m_startTime ) > m_castTime ) if( !hasCastTime() || std::difftime( currTime, m_startTime ) > m_castTimeMs )
{ {
execute(); execute();
return true; return true;
@ -191,7 +191,7 @@ void Sapphire::Action::Action::start()
castPacket->data().skillType = Common::SkillType::Normal; castPacket->data().skillType = Common::SkillType::Normal;
castPacket->data().unknown_1 = m_id; castPacket->data().unknown_1 = m_id;
// This is used for the cast bar above the target bar of the caster. // This is used for the cast bar above the target bar of the caster.
castPacket->data().cast_time = m_castTime / 1000.f; castPacket->data().cast_time = m_castTimeMs / 1000.f;
castPacket->data().target_id = static_cast< uint32_t >( m_targetId ); castPacket->data().target_id = static_cast< uint32_t >( m_targetId );
m_pSource->sendToInRangeSet( castPacket, true ); m_pSource->sendToInRangeSet( castPacket, true );
@ -202,6 +202,10 @@ void Sapphire::Action::Action::start()
} }
} }
// todo: m_recastTimeMs needs to be adjusted for player sks/sps
auto actionStartPkt = makeActorControl143( m_pSource->getId(), ActorControlType::ActionStart, 1, getId(), m_recastTimeMs / 10 );
player->queuePacket( actionStartPkt );
auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >(); auto pScriptMgr = m_pFw->get< Scripting::ScriptMgr >();
if( !pScriptMgr->onStart( *this ) ) if( !pScriptMgr->onStart( *this ) )
{ {
@ -231,9 +235,6 @@ void Sapphire::Action::Action::interrupt()
{ {
auto player = m_pSource->getAsPlayer(); auto player = m_pSource->getAsPlayer();
auto resetCooldownPkt = makeActorControl143( m_pSource->getId(), ActorControlType::SetActionCooldown, 1, getId(), 0 );
player->queuePacket( resetCooldownPkt );
// todo: reset cooldown for actual player // todo: reset cooldown for actual player
// reset state flag // reset state flag

View file

@ -99,8 +99,8 @@ namespace Sapphire::Action
uint16_t m_primaryCost; uint16_t m_primaryCost;
uint64_t m_startTime; uint64_t m_startTime;
uint32_t m_castTime; uint32_t m_castTimeMs;
uint16_t m_recastTime; uint32_t m_recastTimeMs;
uint8_t m_cooldownGroup; uint8_t m_cooldownGroup;
int8_t m_range; int8_t m_range;
uint8_t m_effectRange; uint8_t m_effectRange;

View file

@ -26,7 +26,7 @@ Sapphire::Action::EventAction::EventAction( Entity::CharaPtr pActor, uint32_t ev
m_id = action; m_id = action;
m_pFw = pFw; m_pFw = pFw;
auto pExdData = pFw->get< Data::ExdDataGenerated >(); auto pExdData = pFw->get< Data::ExdDataGenerated >();
m_castTime = pExdData->get< Sapphire::Data::EventAction >( action )->castTime * 1000; // TODO: Add security checks. m_castTimeMs = pExdData->get< Sapphire::Data::EventAction >( action )->castTime * 1000; // TODO: Add security checks.
m_onActionFinishClb = std::move( finishRef ); m_onActionFinishClb = std::move( finishRef );
m_onActionInterruptClb = std::move( interruptRef ); m_onActionInterruptClb = std::move( interruptRef );
m_pSource = std::move( pActor ); m_pSource = std::move( pActor );