mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
Merge branch 'master' of https://github.com/SapphireServer/Sapphire into actions-war
This commit is contained in:
commit
6e30be3be8
10 changed files with 41 additions and 63 deletions
|
@ -73,6 +73,11 @@ uint32_t Action::Action::getResultId() const
|
|||
return m_resultId;
|
||||
}
|
||||
|
||||
std::shared_ptr< Excel::ExcelStruct< Excel::Action > > Action::Action::getActionData() const
|
||||
{
|
||||
return m_actionData;
|
||||
}
|
||||
|
||||
bool Action::Action::init()
|
||||
{
|
||||
if( !m_actionData )
|
||||
|
|
|
@ -56,6 +56,8 @@ namespace Sapphire::World::Action
|
|||
uint64_t getCastTimeRest() const;
|
||||
|
||||
void enableGenericHandler();
|
||||
|
||||
std::shared_ptr< Excel::ExcelStruct< Excel::Action > > getActionData() const;
|
||||
|
||||
/*!
|
||||
* @brief Checks if a chara has enough resources available to cast the action (tp/mp/etc)
|
||||
|
|
|
@ -982,7 +982,7 @@ void BNpc::autoAttack( CharaPtr pTarget )
|
|||
pTarget->onActionHostile( getAsChara() );
|
||||
m_lastAttack = tick;
|
||||
srand( static_cast< uint32_t >( tick ) );
|
||||
actionMgr.handleTargetedAction( *this, 7, exdData.getRow< Excel::Action >( 7 ), pTarget->getId(), 0 );
|
||||
actionMgr.handleTargetedAction( *this, 7, pTarget->getId(), 0 );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1051,16 +1051,12 @@ uint32_t BNpc::getLayoutId() const
|
|||
|
||||
void BNpc::init()
|
||||
{
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
m_maxHp = Math::CalcStats::calculateMaxHp( *getAsChara() );
|
||||
m_hp = m_maxHp;
|
||||
|
||||
//setup a test gambit
|
||||
auto testGambitRule = std::make_shared< AI::GambitRule >( std::make_shared< AI::TopHateTargetCondition >(),
|
||||
Action::make_Action( getAsChara(), 88, 0, exdData.getRow< Excel::Action >( 88 ) ), 5000 );
|
||||
|
||||
auto testGambitRule1 = std::make_shared< AI::GambitRule >( std::make_shared< AI::HPSelfPctLessThan >( 50 ),
|
||||
Action::make_Action( getAsChara(), 120, 0, exdData.getRow< Excel::Action >( 120 ) ), 5000 );
|
||||
auto testGambitRule = AI::make_GambitRule( AI::make_TopHateTargetCondition(), Action::make_Action( getAsChara(), 88, 0 ), 5000 );
|
||||
auto testGambitRule1 = AI::make_GambitRule( AI::make_HPSelfPctLessThan( 50 ), Action::make_Action( getAsChara(), 120, 0 ), 5000 );
|
||||
|
||||
m_gambits.push_back( testGambitRule );
|
||||
m_gambits.push_back( testGambitRule1 );
|
||||
|
@ -1068,7 +1064,6 @@ void BNpc::init()
|
|||
|
||||
void BNpc::processGambits( uint64_t tickCount )
|
||||
{
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref();
|
||||
for( auto& gambitRule : m_gambits )
|
||||
{
|
||||
|
@ -1081,8 +1076,8 @@ void BNpc::processGambits( uint64_t tickCount )
|
|||
continue;
|
||||
|
||||
gambitRule->setLastExecutionMs( tickCount );
|
||||
actionMgr.handleTargetedAction( *this, gambitRule->getActionPtr()->getId(), exdData.getRow< Excel::Action >( gambitRule->getActionPtr()->getId() ),
|
||||
gambitRule->getGambitTargetCondition()->getTarget()->getId(), 0 );
|
||||
actionMgr.handleTargetedAction( *this, gambitRule->getActionPtr()->getId(), gambitRule->getGambitTargetCondition()->getTarget()->getId(), 0 );
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -365,7 +365,7 @@ Change the current target and propagate to in range players
|
|||
void Chara::changeTarget( uint64_t targetId )
|
||||
{
|
||||
setTargetId( targetId );
|
||||
Network::Util::Packet::sendActorControlTarget( getInRangePlayerIds(), getId(), ToggleWeapon, SetTarget, 0, 0, 0, 0, targetId );
|
||||
Network::Util::Packet::sendActorControlTarget( getInRangePlayerIds(), getId(), SetTarget, 0, 0, 0, 0, targetId );
|
||||
}
|
||||
|
||||
/*!
|
||||
|
|
|
@ -1302,33 +1302,8 @@ void Player::autoAttack( CharaPtr pTarget )
|
|||
auto& RNGMgr = Common::Service< World::Manager::RNGMgr >::ref();
|
||||
auto variation = static_cast< uint32_t >( RNGMgr.getRandGenerator< float >( 0, 3 ).next() );
|
||||
|
||||
actionMgr.handleTargetedAction( *this, 7, exdData.getRow< Excel::Action >( 7 ), pTarget->getId(), 0 );
|
||||
actionMgr.handleTargetedAction( *this, 7, pTarget->getId(), 0 );
|
||||
|
||||
/* auto damage = Math::CalcStats::calcAutoAttackDamage( *this );
|
||||
|
||||
auto effectPacket = std::make_shared< EffectPacket1 >( getId(), pTarget->getId(), 7 );
|
||||
|
||||
Common::CalcResultParam entry{};
|
||||
|
||||
entry.Value = static_cast< int16_t >( damage.first );
|
||||
entry.Type = Common::ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP;
|
||||
entry.Arg0 = 2;
|
||||
entry.Arg1 = 7;
|
||||
|
||||
if( getClass() == ClassJob::Machinist || getClass() == ClassJob::Bard || getClass() == ClassJob::Archer )
|
||||
effectPacket->setActionId( 8 );
|
||||
|
||||
auto resultId = pZone->getNextActionResultId();
|
||||
effectPacket->setResultId( resultId );
|
||||
effectPacket->setRotation( Util::floatToUInt16Rot( getRot() ) );
|
||||
effectPacket->addTargetEffect( entry );
|
||||
|
||||
server().queueForPlayers( getInRangePlayerIds( true ), effectPacket );
|
||||
|
||||
pTarget->takeDamage( static_cast< uint32_t >( damage.first ) );
|
||||
|
||||
auto& taskMgr = Common::Service< TaskMgr >::ref();*/
|
||||
//taskMgr.queueTask( Sapphire::World::makeActionIntegrityTask( resultId, pTarget, 500 ) );
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -50,6 +50,9 @@ TYPE_FORWARD( HousingInteriorTerritory );
|
|||
namespace World::AI
|
||||
{
|
||||
TYPE_FORWARD( GambitTargetCondition );
|
||||
TYPE_FORWARD( TopHateTargetCondition );
|
||||
TYPE_FORWARD( HPSelfPctLessThan );
|
||||
|
||||
TYPE_FORWARD( GambitRule );
|
||||
}
|
||||
|
||||
|
|
|
@ -23,19 +23,20 @@ bool ActionMgr::cacheActionLut()
|
|||
return Action::ActionLutData::cacheActions();
|
||||
}
|
||||
|
||||
void ActionMgr::handlePlacedPlayerAction( Entity::Player& player, uint32_t actionId,
|
||||
Excel::ExcelStructPtr< Excel::Action > actionData, Common::FFXIVARR_POSITION3 pos,
|
||||
uint16_t sequence )
|
||||
void ActionMgr::handlePlacedAction( Entity::Chara& chara, uint32_t actionId, Common::FFXIVARR_POSITION3 pos, uint16_t requestId )
|
||||
{
|
||||
PlayerMgr::sendDebug( player, "got aoe act: {0}", actionData->getString( actionData->data().Text.Name ) );
|
||||
|
||||
auto action = Action::make_Action( player.getAsPlayer(), actionId, sequence, actionData );
|
||||
auto action = Action::make_Action( chara.getAsChara(), actionId, requestId );
|
||||
|
||||
action->setPos( pos );
|
||||
|
||||
if( !action->init() )
|
||||
return;
|
||||
|
||||
auto actionData = action->getActionData();
|
||||
|
||||
if( chara.isPlayer() )
|
||||
PlayerMgr::sendDebug( *chara.getAsPlayer(), "got aoe act: {0}", actionData->getString( actionData->data().Text.Name ) );
|
||||
|
||||
if( !actionData->data().EffectRange )
|
||||
{
|
||||
// not an action that has an aoe, cancel it
|
||||
|
@ -43,13 +44,12 @@ void ActionMgr::handlePlacedPlayerAction( Entity::Player& player, uint32_t actio
|
|||
return;
|
||||
}
|
||||
|
||||
bootstrapAction( player, action, actionData );
|
||||
bootstrapAction( chara, action, actionData );
|
||||
}
|
||||
|
||||
void ActionMgr::handleItemManipulationAction( Entity::Player& player, uint32_t actionId,
|
||||
Excel::ExcelStructPtr< Excel::Action > actionData, uint16_t sequence )
|
||||
void ActionMgr::handleItemManipulationAction( Entity::Player& player, uint32_t actionId, uint16_t sequence )
|
||||
{
|
||||
auto action = Action::make_ItemManipulationAction( player.getAsPlayer(), actionId, sequence, actionData, 2500 ); // todo: maybe the delay can be retrieved from data
|
||||
auto action = Action::make_ItemManipulationAction( player.getAsPlayer(), actionId, sequence, nullptr, 2500 ); // todo: maybe the delay can be retrieved from data
|
||||
|
||||
player.setCurrentAction( action );
|
||||
|
||||
|
@ -59,10 +59,9 @@ void ActionMgr::handleItemManipulationAction( Entity::Player& player, uint32_t a
|
|||
action->start();
|
||||
}
|
||||
|
||||
void ActionMgr::handleTargetedAction( Entity::Chara& src, uint32_t actionId,
|
||||
Excel::ExcelStructPtr< Excel::Action > actionData, uint64_t targetId, uint16_t requestId )
|
||||
void ActionMgr::handleTargetedAction( Entity::Chara& src, uint32_t actionId, uint64_t targetId, uint16_t requestId )
|
||||
{
|
||||
auto action = Action::make_Action( src.getAsChara(), actionId, requestId, actionData );
|
||||
auto action = Action::make_Action( src.getAsChara(), actionId, requestId );
|
||||
|
||||
action->setTargetId( targetId );
|
||||
action->setPos( src.getPos() );
|
||||
|
@ -70,6 +69,8 @@ void ActionMgr::handleTargetedAction( Entity::Chara& src, uint32_t actionId,
|
|||
if( !action->init() )
|
||||
return;
|
||||
|
||||
auto actionData = action->getActionData();
|
||||
|
||||
bootstrapAction( src, action, actionData );
|
||||
}
|
||||
|
||||
|
|
|
@ -22,12 +22,9 @@ namespace Sapphire::World::Manager
|
|||
|
||||
bool cacheActionLut();
|
||||
|
||||
void handleItemManipulationAction( Entity::Player& player, uint32_t actionId, Excel::ExcelStructPtr< Excel::Action > actionData, uint16_t sequence );
|
||||
|
||||
void handleTargetedAction( Entity::Chara& chara, uint32_t actionId,
|
||||
std::shared_ptr< Excel::ExcelStruct< Excel::Action > > actionData, uint64_t targetId, uint16_t requestId );
|
||||
void handlePlacedPlayerAction( Entity::Player& player, uint32_t actionId,
|
||||
std::shared_ptr< Excel::ExcelStruct< Excel::Action > > actionData, Common::FFXIVARR_POSITION3 pos, uint16_t sequence );
|
||||
void handleItemManipulationAction( Entity::Player& player, uint32_t actionId, uint16_t requestId );
|
||||
void handleTargetedAction( Entity::Chara& chara, uint32_t actionId, uint64_t targetId, uint16_t requestId );
|
||||
void handlePlacedAction( Entity::Chara& chara, uint32_t actionId, Common::FFXIVARR_POSITION3 pos, uint16_t requestId );
|
||||
|
||||
void handleItemAction( Entity::Player& player, uint32_t itemId, std::shared_ptr< Excel::ExcelStruct< Excel::ItemAction > > itemActionData,
|
||||
uint16_t itemSourceSlot, uint16_t itemSourceContainer );
|
||||
|
|
|
@ -50,9 +50,9 @@ void Sapphire::Network::GameConnection::actionRequest( const Packets::FFXIVARR_P
|
|||
auto category = static_cast< Common::ActionCategory >( action->data().Category );
|
||||
|
||||
if( category == Common::ActionCategory::ItemManipulation )
|
||||
actionMgr.handleItemManipulationAction( player, actionId, action, requestId );
|
||||
actionMgr.handleItemManipulationAction( player, actionId, requestId );
|
||||
else
|
||||
actionMgr.handleTargetedAction( player, actionId, action, targetId, requestId );
|
||||
actionMgr.handleTargetedAction( player, actionId, targetId, requestId );
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -111,7 +111,7 @@ void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets
|
|||
return;
|
||||
}
|
||||
|
||||
PlayerMgr::sendDebug( player, "Skill type: {0}, sequence: {1}, actionId: {2}, x:{3}, y:{4}, z:{5}",
|
||||
PlayerMgr::sendDebug( player, "Skill type: {0}, requestId: {1}, actionId: {2}, x:{3}, y:{4}, z:{5}",
|
||||
type, requestId, actionId, pos.x, pos.y, pos.z );
|
||||
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
|
@ -123,5 +123,5 @@ void Sapphire::Network::GameConnection::selectGroundActionRequest( const Packets
|
|||
return;
|
||||
|
||||
auto& actionMgr = Common::Service< World::Manager::ActionMgr >::ref();
|
||||
actionMgr.handlePlacedPlayerAction( player, actionId, action, pos, requestId );
|
||||
actionMgr.handlePlacedAction( player, actionId, pos, requestId );
|
||||
}
|
||||
|
|
|
@ -49,6 +49,9 @@ void ActionIntegrityTask::execute()
|
|||
int statusIdx = 0;
|
||||
for( auto& actionResult : m_results )
|
||||
{
|
||||
if( actionResult && actionResult->getTarget() )
|
||||
actionResult->execute();
|
||||
|
||||
if( actionResult->getCalcResultParam().Type == Common::CALC_RESULT_TYPE_SET_STATUS || actionResult->getCalcResultParam().Type == Common::CALC_RESULT_TYPE_SET_STATUS_ME )
|
||||
{
|
||||
auto& status = data.Status[ statusIdx++ ];
|
||||
|
@ -59,9 +62,6 @@ void ActionIntegrityTask::execute()
|
|||
status.Slot = static_cast< uint8_t >( pEffect->getSlot() );
|
||||
status.SystemParam = static_cast< int16_t >( pEffect->getParam() );
|
||||
}
|
||||
|
||||
if( actionResult && actionResult->getTarget() )
|
||||
actionResult->execute();
|
||||
}
|
||||
|
||||
data.Hp = m_pTarget->getHp();
|
||||
|
|
Loading…
Add table
Reference in a new issue