mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-29 07:37:45 +00:00
fix some timeline bugs, temporarily disable gambits
This commit is contained in:
parent
7b2ea407e9
commit
2f4efec34d
8 changed files with 66 additions and 33 deletions
|
@ -854,6 +854,8 @@ void Action::Action::addDefaultActorFilters()
|
|||
{
|
||||
switch( m_castType )
|
||||
{
|
||||
case( Common::CastType ) 5:
|
||||
case Common::CastType::RectangularAOE:
|
||||
case Common::CastType::SingleTarget:
|
||||
{
|
||||
auto filter = std::make_shared< World::Util::ActorFilterSingleTarget >( static_cast< uint32_t >( m_targetId ) );
|
||||
|
|
|
@ -929,15 +929,16 @@ void BNpc::init()
|
|||
|
||||
m_lastRoamTargetReachedTime = Common::Util::getTimeSeconds();
|
||||
|
||||
/*
|
||||
//setup a test gambit
|
||||
auto testGambitRule = AI::make_GambitRule( AI::make_TopHateTargetCondition(), Action::make_Action( getAsChara(), 88, 0 ), 5000 );
|
||||
auto testGambitRule1 = AI::make_GambitRule( AI::make_HPSelfPctLessThanTargetCondition( 50 ), Action::make_Action( getAsChara(), 120, 0 ), 5000 );
|
||||
/*
|
||||
|
||||
auto gambitPack = AI::make_GambitRuleSetPack();
|
||||
gambitPack->addRule( AI::make_TopHateTargetCondition(), Action::make_Action( getAsChara(), 88, 0 ), 5000 );
|
||||
gambitPack->addRule( AI::make_HPSelfPctLessThanTargetCondition( 50 ), Action::make_Action( getAsChara(), 120, 0 ), 10000 );
|
||||
m_pGambitPack = gambitPack;
|
||||
*/
|
||||
|
||||
|
||||
auto gambitPack = AI::make_GambitTimeLinePack( -1 );
|
||||
gambitPack->addTimeLine( AI::make_TopHateTargetCondition(), Action::make_Action( getAsChara(), 88, 0 ), 2 );
|
||||
|
@ -948,7 +949,7 @@ void BNpc::init()
|
|||
gambitPack->addTimeLine( AI::make_TopHateTargetCondition(), Action::make_Action( getAsChara(), 81, 0 ), 12 );
|
||||
gambitPack->addTimeLine( AI::make_TopHateTargetCondition(), Action::make_Action( getAsChara(), 82, 0 ), 14 );
|
||||
m_pGambitPack = gambitPack;
|
||||
|
||||
*/
|
||||
using namespace AI::Fsm;
|
||||
m_fsm = make_StateMachine();
|
||||
auto stateIdle = make_StateIdle();
|
||||
|
@ -980,6 +981,7 @@ void BNpc::init()
|
|||
void BNpc::processGambits( uint64_t tickCount )
|
||||
{
|
||||
m_tp = 1000;
|
||||
if( m_pGambitPack )
|
||||
m_pGambitPack->update( *this, tickCount );
|
||||
}
|
||||
|
||||
|
|
|
@ -22,6 +22,7 @@
|
|||
#include <Territory/QuestBattle.h>
|
||||
#include <Territory/InstanceContent.h>
|
||||
#include <Util/UtilMath.h>
|
||||
#include <Util/Util.h>
|
||||
|
||||
namespace Sapphire::Encounter
|
||||
{
|
||||
|
@ -348,7 +349,8 @@ namespace Sapphire::Encounter
|
|||
|
||||
void TimelinePack::update( TerritoryPtr pTeri, uint64_t time )
|
||||
{
|
||||
auto now = Common::Util::getTimeMs();
|
||||
for( auto& actor : m_actors )
|
||||
actor.update( pTeri, *this, time );
|
||||
actor.update( pTeri, *this, now );
|
||||
}
|
||||
}// namespace Sapphire::Encounter
|
|
@ -29,7 +29,7 @@ namespace Sapphire::Encounter
|
|||
case ConditionType::HpPctBetween:
|
||||
{
|
||||
auto hpPct = pBNpc->getHpPercent();
|
||||
return hpPct >= hp.min && hpPct <= hp.max;
|
||||
return hpPct > hp.min && hpPct < hp.max;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
|
@ -62,23 +62,26 @@ namespace Sapphire::Encounter
|
|||
|
||||
bool ConditionCombatState::isConditionMet( ConditionState& state, TimelinePack& pack, TerritoryPtr pTeri, uint64_t time ) const
|
||||
{
|
||||
auto pBattleNpc = pTeri->getActiveBNpcByLayoutId( this->layoutId );
|
||||
auto pBNpc = pTeri->getActiveBNpcByLayoutId( this->layoutId );
|
||||
|
||||
if( !pBNpc )
|
||||
return false;
|
||||
|
||||
// todo: these should really use callbacks when the state transitions or we could miss this tick
|
||||
switch( combatState )
|
||||
{
|
||||
case CombatStateType::Idle:
|
||||
return pBattleNpc->getState() == Entity::BNpcState::Idle;
|
||||
return pBNpc->getState() == Entity::BNpcState::Idle;
|
||||
case CombatStateType::Combat:
|
||||
return pBattleNpc->getState() == Entity::BNpcState::Combat;
|
||||
return pBNpc->getState() == Entity::BNpcState::Combat;
|
||||
case CombatStateType::Retreat:
|
||||
return pBattleNpc->getState() == Entity::BNpcState::Retreat;
|
||||
return pBNpc->getState() == Entity::BNpcState::Retreat;
|
||||
case CombatStateType::Roaming:
|
||||
return pBattleNpc->getState() == Entity::BNpcState::Roaming;
|
||||
return pBNpc->getState() == Entity::BNpcState::Roaming;
|
||||
case CombatStateType::JustDied:
|
||||
return pBattleNpc->getState() == Entity::BNpcState::JustDied;
|
||||
return pBNpc->getState() == Entity::BNpcState::JustDied;
|
||||
case CombatStateType::Dead:
|
||||
return pBattleNpc->getState() == Entity::BNpcState::Dead;
|
||||
return pBNpc->getState() == Entity::BNpcState::Dead;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
@ -219,9 +222,9 @@ namespace Sapphire::Encounter
|
|||
|
||||
if( state.m_phaseInfo.m_lastTimepointTime == 0 )
|
||||
{
|
||||
state.m_phaseInfo.m_lastTimepointTime = time;
|
||||
state.m_phaseInfo.m_timepointStates.clear();
|
||||
state.m_phaseInfo.m_timepointStates.resize( m_timepoints.size() );
|
||||
state.m_phaseInfo.m_lastTimepointTime = time;
|
||||
}
|
||||
|
||||
for( auto i = state.m_phaseInfo.m_lastTimepointIndex; i < m_timepoints.size(); )
|
||||
|
@ -244,17 +247,14 @@ namespace Sapphire::Encounter
|
|||
|
||||
if( timepoint.durationElapsed( timepointElapsed ) && timepoint.finished( tpState, timepointElapsed ) )
|
||||
{
|
||||
// timepoint.reset( tpState );
|
||||
timepoint.reset( tpState );
|
||||
// make sure this timepoint isnt run again unless phase loops
|
||||
++i;
|
||||
state.m_phaseInfo.m_lastTimepointIndex = i;
|
||||
|
||||
if( i == m_timepoints.size() )
|
||||
{
|
||||
state.m_phaseInfo.m_lastTimepointIndex++;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -79,7 +79,6 @@ namespace Sapphire::Encounter
|
|||
|
||||
void execute( ConditionState& state, TimelineActor& self, TimelinePack& pack, TerritoryPtr pTeri, uint64_t time ) const
|
||||
{
|
||||
state.m_startTime = time;
|
||||
m_phase.execute( state, self, pack, pTeri, time );
|
||||
};
|
||||
|
||||
|
@ -96,7 +95,6 @@ namespace Sapphire::Encounter
|
|||
void reset( ConditionState& state ) const
|
||||
{
|
||||
state.m_startTime = 0;
|
||||
state.m_enabled = isDefaultEnabled();
|
||||
m_phase.reset( state );
|
||||
}
|
||||
|
||||
|
|
|
@ -36,11 +36,14 @@ namespace Sapphire::Encounter
|
|||
pCondition->reset( state );
|
||||
}
|
||||
}
|
||||
else if( pCondition->inProgress( state ) )
|
||||
// update or execute
|
||||
else if( pCondition->isConditionMet( state, pack, pTeri, time ) )
|
||||
{
|
||||
if( pCondition->inProgress( state ) )
|
||||
{
|
||||
pCondition->update( state, *this, pack, pTeri, time );
|
||||
}
|
||||
else if( pCondition->isConditionMet( state, pack, pTeri, time ) )
|
||||
else
|
||||
{
|
||||
pCondition->execute( state, *this, pack, pTeri, time );
|
||||
|
||||
|
@ -49,6 +52,7 @@ namespace Sapphire::Encounter
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void TimelineActor::resetConditionState( uint32_t conditionId )
|
||||
{
|
||||
|
|
|
@ -66,6 +66,7 @@ namespace Sapphire::Encounter
|
|||
{ "spawnBNpc", TimepointDataType::SpawnBNpc },
|
||||
{ "bNpcFlags", TimepointDataType::SetBNpcFlags },
|
||||
{ "setEObjState", TimepointDataType::SetEObjState },
|
||||
{ "setBGM", TimepointDataType::SetBgm },
|
||||
|
||||
{ "setCondition", TimepointDataType::SetCondition },
|
||||
{ "snapshot", TimepointDataType::Snapshot }
|
||||
|
@ -112,6 +113,7 @@ namespace Sapphire::Encounter
|
|||
m_duration = json.at( "duration" ).get< uint64_t >();
|
||||
//m_overrideFlags = json.at( "overrideFlags" ).get< TimepointOverrideFlags >();
|
||||
m_description = json.at( "description" ).get< std::string >();
|
||||
m_type = tpType;
|
||||
|
||||
switch( tpType )
|
||||
{
|
||||
|
@ -292,7 +294,14 @@ namespace Sapphire::Encounter
|
|||
// todo: SetEObjState
|
||||
}
|
||||
break;
|
||||
case TimepointDataType::SetBgm:
|
||||
{
|
||||
auto& dataJ = json.at( "data" );
|
||||
auto bgmId = dataJ.at( "bgmId" ).get< uint32_t >();
|
||||
|
||||
m_pData = std::make_shared< TimepointDataBGM >( bgmId );
|
||||
}
|
||||
break;
|
||||
case TimepointDataType::SetCondition:
|
||||
{
|
||||
auto& dataJ = json.at( "data" );
|
||||
|
@ -322,6 +331,17 @@ namespace Sapphire::Encounter
|
|||
void Timepoint::execute( TimepointState& state, TimelineActor& self, TimelinePack& pack, TerritoryPtr pTeri, uint64_t time ) const
|
||||
{
|
||||
state.m_startTime = time;
|
||||
|
||||
const auto& players = pTeri->getPlayers();
|
||||
// send debug msg
|
||||
if( !m_description.empty() )
|
||||
{
|
||||
auto& playerMgr = Common::Service< Sapphire::World::Manager::PlayerMgr >::ref();
|
||||
|
||||
for( const auto& player : players )
|
||||
playerMgr.sendDebug( *player.second, m_description );
|
||||
}
|
||||
|
||||
update( state, self, pack, pTeri, time );
|
||||
}
|
||||
|
||||
|
@ -357,7 +377,6 @@ namespace Sapphire::Encounter
|
|||
break;
|
||||
case ActionTargetType::Selector:
|
||||
{
|
||||
// todo: selector
|
||||
const auto& results = pack.getSnapshotTargetIds( pActionData->m_selectorRef );
|
||||
if( pActionData->m_selectorIndex < results.size() )
|
||||
targetId = results[ pActionData->m_selectorIndex ];
|
||||
|
@ -369,8 +388,11 @@ namespace Sapphire::Encounter
|
|||
auto& actionMgr = Common::Service< Sapphire::World::Manager::ActionMgr >::ref();
|
||||
|
||||
// todo: this is probably wrong
|
||||
if( pBNpc->getCurrentAction() && pBNpc->getCurrentAction()->getId() != pActionData->m_actionId )
|
||||
actionMgr.handleTargetedAction( *pBNpc.get(), pActionData->m_actionId, targetId, 0 );
|
||||
if( !pBNpc->getCurrentAction() )
|
||||
{
|
||||
actionMgr.handleTargetedAction( *pBNpc, pActionData->m_actionId, targetId, 0 );
|
||||
state.m_finished = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -381,8 +403,9 @@ namespace Sapphire::Encounter
|
|||
|
||||
if( pBNpc )
|
||||
{
|
||||
pBNpc->setPos( pSetPosData->m_x, pSetPosData->m_y, pSetPosData->m_z );
|
||||
pBNpc->setRot( pSetPosData->m_rot );
|
||||
pBNpc->setPos( pSetPosData->m_x, pSetPosData->m_y, pSetPosData->m_z, true );
|
||||
state.m_finished = true;
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
@ -446,6 +469,7 @@ namespace Sapphire::Encounter
|
|||
auto handlerId = pHandler ? pHandler->getId() : 0xE0000000;
|
||||
auto talkerId = pTalker ? pTalker->getId() : 0xE0000000;
|
||||
|
||||
// todo: use Actrl EventBattleDialog = 0x39C maybe?,
|
||||
auto& playerMgr = Common::Service< Sapphire::World::Manager::PlayerMgr >::ref();
|
||||
for( auto& player : pTeri->getPlayers() )
|
||||
{
|
||||
|
@ -650,7 +674,7 @@ namespace Sapphire::Encounter
|
|||
break;
|
||||
}
|
||||
|
||||
if( m_type != TimepointDataType::SetPos && m_type != TimepointDataType::CastAction )
|
||||
if( m_type != TimepointDataType::CastAction )
|
||||
state.m_finished = true;
|
||||
|
||||
state.m_finished = state.m_finished || state.m_startTime + m_duration <= time;
|
||||
|
|
|
@ -150,7 +150,8 @@ namespace Sapphire::Encounter
|
|||
|
||||
uint32_t m_params[ 8 ]{ 0 };
|
||||
|
||||
TimepointDataBattleTalk( const std::vector< uint32_t >& params ) : TimepointData( TimepointDataType::BattleTalk )
|
||||
TimepointDataBattleTalk( const std::vector< uint32_t >& params ) :
|
||||
TimepointData( TimepointDataType::BattleTalk )
|
||||
{
|
||||
for( auto i = 0; i < params.size() && i < 8; ++i )
|
||||
m_params[ i ] = params[ i ];
|
||||
|
|
Loading…
Add table
Reference in a new issue