2019-02-03 19:38:04 +11:00
|
|
|
#include "ActionMgr.h"
|
|
|
|
|
2019-02-09 14:45:22 +11:00
|
|
|
#include "Action/Action.h"
|
2019-06-02 20:45:18 +10:00
|
|
|
#include "Action/ItemAction.h"
|
2019-02-09 14:45:22 +11:00
|
|
|
#include "Script/ScriptMgr.h"
|
|
|
|
#include "Actor/Player.h"
|
|
|
|
|
|
|
|
#include <Exd/ExdDataGenerated.h>
|
2019-02-09 18:02:11 +11:00
|
|
|
#include "Framework.h"
|
2019-02-09 14:45:22 +11:00
|
|
|
|
2019-02-09 21:48:42 +11:00
|
|
|
#include <Network/PacketWrappers/EffectPacket.h>
|
|
|
|
|
2019-02-03 19:38:04 +11:00
|
|
|
using namespace Sapphire;
|
|
|
|
|
|
|
|
World::Manager::ActionMgr::ActionMgr( Sapphire::FrameworkPtr pFw ) :
|
|
|
|
BaseManager( pFw )
|
|
|
|
{
|
|
|
|
|
2019-02-03 19:57:04 +11:00
|
|
|
}
|
|
|
|
|
2019-04-28 23:34:43 +02:00
|
|
|
void World::Manager::ActionMgr::handlePlacedPlayerAction( Entity::Player& player, uint32_t actionId,
|
2019-07-26 20:28:01 +10:00
|
|
|
Data::ActionPtr actionData, Common::FFXIVARR_POSITION3 pos,
|
|
|
|
uint16_t sequence )
|
2019-02-03 19:57:04 +11:00
|
|
|
{
|
2019-02-09 15:39:05 +11:00
|
|
|
player.sendDebug( "got aoe act: {0}", actionData->name );
|
2019-02-09 18:02:11 +11:00
|
|
|
|
2019-02-11 19:10:42 +11:00
|
|
|
|
2019-07-26 20:28:01 +10:00
|
|
|
auto action = Action::make_Action( player.getAsPlayer(), actionId, sequence, actionData, framework() );
|
2019-03-07 21:58:12 +11:00
|
|
|
|
2020-01-05 17:09:27 +09:00
|
|
|
action->setPos( pos );
|
|
|
|
|
2019-03-07 21:58:12 +11:00
|
|
|
if( !action->init() )
|
|
|
|
return;
|
2019-02-09 18:32:10 +11:00
|
|
|
|
2019-02-11 19:10:42 +11:00
|
|
|
if( !actionData->targetArea )
|
|
|
|
{
|
|
|
|
// not an action that has an aoe, cancel it
|
2019-03-07 20:33:14 +11:00
|
|
|
action->interrupt();
|
2019-02-11 19:10:42 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-09 18:32:10 +11:00
|
|
|
bootstrapAction( player, action, *actionData );
|
2019-02-03 19:57:04 +11:00
|
|
|
}
|
|
|
|
|
2019-02-09 19:26:31 +11:00
|
|
|
void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& player, uint32_t actionId,
|
2019-07-26 20:28:01 +10:00
|
|
|
Data::ActionPtr actionData, uint64_t targetId,
|
|
|
|
uint16_t sequence )
|
2019-02-03 19:57:04 +11:00
|
|
|
{
|
2019-07-26 20:28:01 +10:00
|
|
|
auto action = Action::make_Action( player.getAsPlayer(), actionId, sequence, actionData, framework() );
|
2019-02-09 15:39:05 +11:00
|
|
|
|
2019-04-07 16:04:36 +10:00
|
|
|
action->setTargetId( targetId );
|
|
|
|
|
2020-01-05 17:09:27 +09:00
|
|
|
action->setPos( player.getPos() );
|
|
|
|
|
2019-03-07 21:58:12 +11:00
|
|
|
if( !action->init() )
|
|
|
|
return;
|
|
|
|
|
2019-02-11 19:10:42 +11:00
|
|
|
// cancel any aoe actions casted with this packet
|
|
|
|
if( actionData->targetArea )
|
|
|
|
{
|
2019-03-07 20:33:14 +11:00
|
|
|
action->interrupt();
|
2019-02-11 19:10:42 +11:00
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2019-02-09 15:39:05 +11:00
|
|
|
bootstrapAction( player, action, *actionData );
|
|
|
|
}
|
|
|
|
|
2019-02-10 19:50:28 +11:00
|
|
|
void World::Manager::ActionMgr::handleItemAction( Sapphire::Entity::Player& player, uint32_t itemId,
|
|
|
|
Data::ItemActionPtr itemActionData,
|
|
|
|
uint16_t itemSourceSlot, uint16_t itemSourceContainer )
|
2019-02-09 19:26:31 +11:00
|
|
|
{
|
2019-02-10 19:50:28 +11:00
|
|
|
player.sendDebug( "got item act: {0}, slot: {1}, container: {2}", itemId, itemSourceSlot, itemSourceContainer );
|
|
|
|
|
2019-06-02 20:45:18 +10:00
|
|
|
auto action = Action::make_ItemAction( player.getAsChara(), itemId, itemActionData,
|
|
|
|
itemSourceSlot, itemSourceContainer, framework() );
|
2019-02-09 21:48:42 +11:00
|
|
|
|
2019-06-02 20:45:18 +10:00
|
|
|
// todo: item actions don't have cast times? if so we can just start it and we're good
|
|
|
|
action->start();
|
2019-02-09 19:26:31 +11:00
|
|
|
}
|
|
|
|
|
2019-02-09 15:39:05 +11:00
|
|
|
void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
|
|
|
|
Action::ActionPtr currentAction,
|
|
|
|
Data::Action& actionData )
|
|
|
|
{
|
2019-06-02 02:30:54 +10:00
|
|
|
if( !currentAction->preCheck() )
|
2019-02-11 00:40:00 +11:00
|
|
|
{
|
|
|
|
// forcefully interrupt the action and reset the cooldown
|
2019-03-07 20:33:14 +11:00
|
|
|
currentAction->interrupt();
|
2019-02-09 15:39:05 +11:00
|
|
|
return;
|
2019-02-11 00:40:00 +11:00
|
|
|
}
|
2019-02-09 15:39:05 +11:00
|
|
|
|
2020-01-05 17:09:27 +09:00
|
|
|
if( player.getCurrentAction() )
|
2019-02-09 15:39:05 +11:00
|
|
|
{
|
2020-01-05 17:09:27 +09:00
|
|
|
player.sendDebug( "Skill queued: {0}", currentAction->getId() );
|
|
|
|
player.setQueuedAction( currentAction );
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// if we have a cast time we want to associate the action with the player so update is called
|
|
|
|
if( currentAction->hasCastTime() )
|
|
|
|
{
|
|
|
|
player.setCurrentAction( currentAction );
|
|
|
|
}
|
|
|
|
|
|
|
|
// todo: what do in cases of swiftcast/etc? script callback?
|
|
|
|
currentAction->start();
|
2019-02-09 15:39:05 +11:00
|
|
|
}
|
2019-02-03 19:38:04 +11:00
|
|
|
}
|