2019-02-03 19:38:04 +11:00
|
|
|
#include "ActionMgr.h"
|
|
|
|
|
2019-02-09 14:45:22 +11:00
|
|
|
#include "Action/Action.h"
|
|
|
|
#include "Script/ScriptMgr.h"
|
|
|
|
|
|
|
|
#include "Actor/Player.h"
|
|
|
|
|
|
|
|
#include <Exd/ExdDataGenerated.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
|
|
|
}
|
|
|
|
|
|
|
|
void World::Manager::ActionMgr::handleAoEPlayerAction( Entity::Player& player, uint8_t type,
|
2019-02-09 15:39:05 +11:00
|
|
|
uint32_t actionId, Data::ActionPtr actionData,
|
|
|
|
Common::FFXIVARR_POSITION3 pos )
|
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-03 19:57:04 +11:00
|
|
|
}
|
|
|
|
|
|
|
|
void World::Manager::ActionMgr::handleTargetedPlayerAction( Entity::Player& player, uint8_t type,
|
2019-02-09 15:39:05 +11:00
|
|
|
uint32_t actionId, Data::ActionPtr actionData, uint64_t targetId )
|
2019-02-03 19:57:04 +11:00
|
|
|
{
|
2019-02-09 15:39:05 +11:00
|
|
|
player.sendDebug( "got act: {0}", actionData->name );
|
|
|
|
|
2019-02-09 15:45:02 +11:00
|
|
|
auto action = Action::make_Action( player.getAsPlayer(), actionId, actionData, framework() );
|
2019-02-09 17:07:53 +11:00
|
|
|
action->setType( static_cast< Common::HandleActionType >( type ) );
|
2019-02-09 15:39:05 +11:00
|
|
|
|
|
|
|
bootstrapAction( player, action, *actionData );
|
|
|
|
}
|
|
|
|
|
|
|
|
void World::Manager::ActionMgr::bootstrapAction( Entity::Player& player,
|
|
|
|
Action::ActionPtr currentAction,
|
|
|
|
Data::Action& actionData )
|
|
|
|
{
|
|
|
|
if( !canPlayerUseAction( player, *currentAction, actionData ) )
|
|
|
|
return;
|
|
|
|
|
|
|
|
// instantly cast and finish actions that have no cast time
|
|
|
|
// not worth adding it to the player
|
|
|
|
// todo: what do in cases of swiftcast/etc? script callback?
|
|
|
|
if( !currentAction->isCastedAction() )
|
|
|
|
{
|
|
|
|
currentAction->start();
|
|
|
|
currentAction->onFinish();
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
// otherwise, set the action on the player and start it
|
|
|
|
player.setCurrentAction( currentAction );
|
|
|
|
currentAction->start();
|
|
|
|
}
|
|
|
|
|
|
|
|
bool World::Manager::ActionMgr::canPlayerUseAction( Entity::Player& player,
|
|
|
|
Action::Action& currentAction,
|
|
|
|
Data::Action& actionData )
|
|
|
|
{
|
|
|
|
// lol
|
|
|
|
if( !player.isAlive() )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// npc actions/non player actions
|
|
|
|
if( actionData.classJob == -1 )
|
|
|
|
return false;
|
|
|
|
|
|
|
|
// todo: check class/job reqs
|
|
|
|
|
|
|
|
// todo: min tp
|
|
|
|
// todo: min mp
|
|
|
|
|
|
|
|
// todo: script callback for action conditionals?
|
|
|
|
|
|
|
|
return true;
|
2019-02-03 19:38:04 +11:00
|
|
|
}
|