mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-28 15:17:46 +00:00
VFX ItemAction handling
This commit is contained in:
parent
66f787ca0b
commit
458235685a
6 changed files with 78 additions and 5 deletions
|
@ -592,6 +592,11 @@ namespace Sapphire::Common
|
|||
CritDirectHitDamage = 3
|
||||
};
|
||||
|
||||
enum ItemActionType : uint16_t
|
||||
{
|
||||
ItemActionVFX = 944,
|
||||
};
|
||||
|
||||
enum ActionEffectDisplayType : uint8_t
|
||||
{
|
||||
HideActionName = 0,
|
||||
|
|
|
@ -113,6 +113,9 @@ void Sapphire::Action::Action::calculateMPCost()
|
|||
cost = 0.2313f * ( level * level ) - 26.98f * level + 875.21f;
|
||||
break;
|
||||
}
|
||||
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
// m_cost is the base cost, cost is the multiplier for the current player level
|
||||
|
@ -121,7 +124,24 @@ void Sapphire::Action::Action::calculateMPCost()
|
|||
|
||||
void Sapphire::Action::Action::subtractCostFromCaster()
|
||||
{
|
||||
if( !m_pSource->isPlayer() )
|
||||
return;
|
||||
|
||||
auto player = m_pSource->getAsPlayer();
|
||||
|
||||
switch( m_costType )
|
||||
{
|
||||
case Common::ActionCostType::MagicPoints:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
case Common::ActionCostType::TacticsPoints:
|
||||
{
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void Sapphire::Action::Action::setPos( Sapphire::Common::FFXIVARR_POSITION3 pos )
|
||||
|
|
|
@ -8,6 +8,8 @@
|
|||
#include <Exd/ExdDataGenerated.h>
|
||||
#include "Framework.h"
|
||||
|
||||
#include <Network/PacketWrappers/EffectPacket.h>
|
||||
|
||||
using namespace Sapphire;
|
||||
|
||||
World::Manager::ActionMgr::ActionMgr( Sapphire::FrameworkPtr pFw ) :
|
||||
|
@ -37,9 +39,22 @@ void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& play
|
|||
bootstrapAction( player, action, *actionData );
|
||||
}
|
||||
|
||||
void World::Manager::ActionMgr::handleItemAction( Sapphire::Entity::Player& player, uint32_t itemActionId )
|
||||
void World::Manager::ActionMgr::handleItemAction( Sapphire::Entity::Player& player, uint32_t itemId, Data::ItemActionPtr itemActionData )
|
||||
{
|
||||
player.sendDebug( "got item act: {0}", itemActionId );
|
||||
player.sendDebug( "got item act: {0}", itemId );
|
||||
|
||||
switch( itemActionData->type )
|
||||
{
|
||||
default:
|
||||
return;
|
||||
|
||||
case Common::ItemActionType::ItemActionVFX:
|
||||
{
|
||||
handleItemActionVFX( player, itemId, itemActionData->data[ 0 ] );
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
|
||||
|
@ -100,4 +115,21 @@ bool World::Manager::ActionMgr::canPlayerUseAction( Entity::Player& player,
|
|||
// todo: script callback for action conditionals?
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
void World::Manager::ActionMgr::handleItemActionVFX( Sapphire::Entity::Player& player, uint32_t itemId, uint16_t vfxId )
|
||||
{
|
||||
// todo: check we have item & remove item from inventory
|
||||
|
||||
Common::EffectEntry effect{};
|
||||
effect.effectType = Common::ActionEffectType::VFX;
|
||||
effect.value = vfxId;
|
||||
|
||||
auto effectPacket = std::make_shared< Network::Packets::Server::EffectPacket >( player.getId(), player.getId(), itemId );
|
||||
effectPacket->setTargetActor( player.getId() );
|
||||
effectPacket->setAnimationId( Common::ItemActionType::ItemActionVFX );
|
||||
effectPacket->setDisplayType( Common::ActionEffectDisplayType::ShowItemName );
|
||||
effectPacket->addEffect( effect );
|
||||
|
||||
player.sendToInRangeSet( effectPacket, true );
|
||||
}
|
|
@ -8,6 +8,9 @@ namespace Sapphire::Data
|
|||
{
|
||||
struct Action;
|
||||
using ActionPtr = std::shared_ptr< Action >;
|
||||
|
||||
struct ItemAction;
|
||||
using ItemActionPtr = std::shared_ptr< ItemAction >;
|
||||
}
|
||||
|
||||
namespace Sapphire::World::Manager
|
||||
|
@ -23,11 +26,14 @@ namespace Sapphire::World::Manager
|
|||
void handleAoEPlayerAction( Entity::Player& player, uint32_t actionId,
|
||||
Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos );
|
||||
|
||||
void handleItemAction( Entity::Player& player, uint32_t itemActionId );
|
||||
void handleItemAction( Entity::Player& player, uint32_t itemId, Data::ItemActionPtr itemActionData );
|
||||
|
||||
private:
|
||||
void bootstrapAction( Entity::Player& player, Action::ActionPtr currentAction, Data::Action& actionData );
|
||||
bool canPlayerUseAction( Entity::Player& player, Action::Action& currentAction, Data::Action& actionData );
|
||||
|
||||
// item action handlers
|
||||
void handleItemActionVFX( Entity::Player& player, uint32_t itemId, uint16_t vfxId );
|
||||
};
|
||||
}
|
||||
|
||||
|
|
|
@ -30,6 +30,8 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw,
|
|||
auto exdData = m_pFw->get< Data::ExdDataGenerated >();
|
||||
assert( exdData );
|
||||
|
||||
auto actionMgr = pFw->get< World::Manager::ActionMgr >();
|
||||
|
||||
switch( type )
|
||||
{
|
||||
default:
|
||||
|
@ -44,7 +46,6 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw,
|
|||
if( !action )
|
||||
return;
|
||||
|
||||
auto actionMgr = pFw->get< World::Manager::ActionMgr >();
|
||||
actionMgr->handleTargetedPlayerAction( player, actionId, action, targetId );
|
||||
break;
|
||||
}
|
||||
|
@ -58,7 +59,11 @@ void Sapphire::Network::GameConnection::actionHandler( FrameworkPtr pFw,
|
|||
if( item->itemAction == 0 )
|
||||
return;
|
||||
|
||||
player.sendDebug( "Got itemaction for act: {0}", item->itemAction );
|
||||
auto itemAction = exdData->get< Data::ItemAction >( item->itemAction );
|
||||
if( !itemAction )
|
||||
return;
|
||||
|
||||
actionMgr->handleItemAction( player, actionId, itemAction );
|
||||
|
||||
break;
|
||||
}
|
||||
|
|
|
@ -41,6 +41,11 @@ namespace Sapphire::Network::Packets::Server
|
|||
m_data.actionAnimationId = animationId;
|
||||
}
|
||||
|
||||
void setDisplayType( Common::ActionEffectDisplayType displayType )
|
||||
{
|
||||
m_data.effectDisplayType = displayType;
|
||||
}
|
||||
|
||||
void setEffectFlags( uint32_t effectFlags )
|
||||
{
|
||||
m_data.effectFlags = effectFlags;
|
||||
|
|
Loading…
Add table
Reference in a new issue