From fe9a2ef9746617de009993c2f44ace9b54071dfc Mon Sep 17 00:00:00 2001 From: Mordred Date: Thu, 16 Mar 2023 21:56:57 +0100 Subject: [PATCH] Cleanup cleanup cleanup --- src/world/AI/GambitTargetCondition.h | 11 ++++--- src/world/Action/ActionResult.cpp | 43 ++++++++++++++-------------- src/world/Actor/BNpc.cpp | 2 +- src/world/ForwardsZone.h | 2 +- 4 files changed, 29 insertions(+), 29 deletions(-) diff --git a/src/world/AI/GambitTargetCondition.h b/src/world/AI/GambitTargetCondition.h index ec0cd7ae..931b579d 100644 --- a/src/world/AI/GambitTargetCondition.h +++ b/src/world/AI/GambitTargetCondition.h @@ -18,20 +18,19 @@ namespace Sapphire::World::AI class GambitTargetCondition { public: - GambitTargetCondition( GambitTargetType targetType ) : m_targetType( targetType ) {}; + GambitTargetCondition() = default; virtual ~GambitTargetCondition() = default; virtual bool isConditionMet( Sapphire::Entity::BNpc& src ) { return false; }; Sapphire::Entity::CharaPtr getTarget() const { return m_pTarget; }; protected: - GambitTargetType m_targetType; Sapphire::Entity::CharaPtr m_pTarget; }; class TopHateTargetCondition : public GambitTargetCondition { public: - TopHateTargetCondition() : GambitTargetCondition( PlayerAndAlly ) {}; + TopHateTargetCondition() = default; bool isConditionMet( Sapphire::Entity::BNpc& src ) override { @@ -45,12 +44,12 @@ namespace Sapphire::World::AI }; }; - class HPSelfPctLessThan : public GambitTargetCondition + class HPSelfPctLessThanTargetCondition : public GambitTargetCondition { public: - HPSelfPctLessThan( uint8_t pct ) : GambitTargetCondition( Self ), m_HpPct( pct ) {}; + HPSelfPctLessThanTargetCondition( uint8_t pct ) : m_HpPct( pct ) {}; - virtual bool isConditionMet( Sapphire::Entity::BNpc& src ) + bool isConditionMet( Sapphire::Entity::BNpc& src ) override { if( src.getHpPercent() < m_HpPct ) { diff --git a/src/world/Action/ActionResult.cpp b/src/world/Action/ActionResult.cpp index e07c308c..31d82aed 100644 --- a/src/world/Action/ActionResult.cpp +++ b/src/world/Action/ActionResult.cpp @@ -10,6 +10,7 @@ #include "StatusEffect/StatusEffect.h" using namespace Sapphire; +using namespace Sapphire::Common; using namespace Sapphire::World::Action; @@ -20,8 +21,8 @@ ActionResult::ActionResult( Entity::CharaPtr target ) : m_result.Arg1 = 0; m_result.Arg2 = 0; m_result.Value = 0; - m_result.Flag = static_cast< uint8_t >( Common::ActionResultFlag::None ); - m_result.Type = Common::CalcResultType::TypeNone; + m_result.Flag = static_cast< uint8_t >( ActionResultFlag::None ); + m_result.Type = CalcResultType::TypeNone; } Entity::CharaPtr ActionResult::getTarget() const @@ -29,7 +30,7 @@ Entity::CharaPtr ActionResult::getTarget() const return m_target; } -void ActionResult::damage( uint32_t amount, Common::CalcResultType hitType, uint8_t hitEffect, Common::ActionResultFlag flag ) +void ActionResult::damage( uint32_t amount, CalcResultType hitType, uint8_t hitEffect, ActionResultFlag flag ) { m_result.Arg0 = hitEffect; m_result.Value = static_cast< int16_t >( amount ); @@ -37,7 +38,7 @@ void ActionResult::damage( uint32_t amount, Common::CalcResultType hitType, uint m_result.Type = hitType; } -void ActionResult::heal( uint32_t amount, Common::CalcResultType hitType, uint8_t hitEffect, Common::ActionResultFlag flag ) +void ActionResult::heal( uint32_t amount, CalcResultType hitType, uint8_t hitEffect, ActionResultFlag flag ) { m_result.Arg0 = hitEffect; m_result.Value = static_cast< int16_t >( amount ); @@ -45,31 +46,31 @@ void ActionResult::heal( uint32_t amount, Common::CalcResultType hitType, uint8_ m_result.Type = hitType; } -void ActionResult::restoreMP( uint32_t amount, Common::ActionResultFlag flag ) +void ActionResult::restoreMP( uint32_t amount, ActionResultFlag flag ) { m_result.Value = static_cast< int16_t >( amount ); m_result.Flag = static_cast< uint8_t >( flag ); - m_result.Type = Common::CalcResultType::TypeRecoverMp; + m_result.Type = CalcResultType::TypeRecoverMp; } void ActionResult::startCombo( uint16_t actionId ) { m_result.Value = static_cast< int16_t >( actionId ); - m_result.Flag = static_cast< uint8_t >( Common::ActionResultFlag::EffectOnSource ); - m_result.Type = Common::CalcResultType::TypeCombo; + m_result.Flag = static_cast< uint8_t >( ActionResultFlag::EffectOnSource ); + m_result.Type = CalcResultType::TypeCombo; } void ActionResult::comboSucceed() { // no EffectOnSource flag on this - m_result.Type = Common::CalcResultType::TypeComboHit; + m_result.Type = CalcResultType::TypeComboHit; } void ActionResult::applyStatusEffect( uint32_t id, int32_t duration, Entity::Chara& source, uint8_t param, bool shouldOverride ) { m_result.Value = static_cast< int16_t >( id ); m_result.Arg2 = param; - m_result.Type = Common::CalcResultType::TypeSetStatus; + m_result.Type = CalcResultType::TypeSetStatus; m_bOverrideStatus = shouldOverride; m_pStatus = StatusEffect::make_StatusEffect( id, source.getAsChara(), m_target, duration, 3000 ); @@ -80,8 +81,8 @@ void ActionResult::applyStatusEffectSelf( uint32_t id, int32_t duration, uint8_t { m_result.Value = static_cast< int16_t >( id ); m_result.Arg2 = param; - m_result.Type = Common::CalcResultType::TypeSetStatusMe; - m_result.Flag = static_cast< uint8_t >( Common::ActionResultFlag::EffectOnSource ); + m_result.Type = CalcResultType::TypeSetStatusMe; + m_result.Flag = static_cast< uint8_t >( ActionResultFlag::EffectOnSource ); m_bOverrideStatus = shouldOverride; m_pStatus = StatusEffect::make_StatusEffect( id, m_target, m_target, duration, 3000 ); @@ -92,7 +93,7 @@ void ActionResult::mount( uint16_t mountId ) { m_result.Value = static_cast< int16_t >( mountId ); m_result.Arg0 = 1; - m_result.Type = Common::CalcResultType::TypeMount; + m_result.Type = CalcResultType::TypeMount; } const Common::CalcResultParam& ActionResult::getCalcResultParam() const @@ -112,28 +113,28 @@ void ActionResult::execute() switch( m_result.Type ) { - case Common::CalcResultType::TypeDamageHp: - case Common::CalcResultType::TypeCriticalDamageHp: + case CalcResultType::TypeDamageHp: + case CalcResultType::TypeCriticalDamageHp: { m_target->takeDamage( m_result.Value ); break; } - case Common::CalcResultType::TypeRecoverHp: - case Common::CalcResultType::TypeCriticalRecoverHp: + case CalcResultType::TypeRecoverHp: + case CalcResultType::TypeCriticalRecoverHp: { m_target->heal( m_result.Value ); break; } - case Common::CalcResultType::TypeRecoverMp: + case CalcResultType::TypeRecoverMp: { m_target->restoreMP( m_result.Value ); break; } - case Common::CalcResultType::TypeSetStatus: - case Common::CalcResultType::TypeSetStatusMe: + case CalcResultType::TypeSetStatus: + case CalcResultType::TypeSetStatusMe: { if( !m_bOverrideStatus ) m_target->addStatusEffectByIdIfNotExist( m_pStatus ); @@ -142,7 +143,7 @@ void ActionResult::execute() break; } - case Common::CalcResultType::TypeMount: + case CalcResultType::TypeMount: { auto pPlayer = m_target->getAsPlayer(); pPlayer->setMount( m_result.Value ); diff --git a/src/world/Actor/BNpc.cpp b/src/world/Actor/BNpc.cpp index 4a9c95e6..30a3235c 100644 --- a/src/world/Actor/BNpc.cpp +++ b/src/world/Actor/BNpc.cpp @@ -1056,7 +1056,7 @@ void BNpc::init() //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_HPSelfPctLessThan( 50 ), Action::make_Action( getAsChara(), 120, 0 ), 5000 ); + auto testGambitRule1 = AI::make_GambitRule( AI::make_HPSelfPctLessThanTargetCondition( 50 ), Action::make_Action( getAsChara(), 120, 0 ), 5000 ); m_gambits.push_back( testGambitRule ); m_gambits.push_back( testGambitRule1 ); diff --git a/src/world/ForwardsZone.h b/src/world/ForwardsZone.h index 02bbc8a6..ef95ab0a 100644 --- a/src/world/ForwardsZone.h +++ b/src/world/ForwardsZone.h @@ -51,7 +51,7 @@ namespace World::AI { TYPE_FORWARD( GambitTargetCondition ); TYPE_FORWARD( TopHateTargetCondition ); - TYPE_FORWARD( HPSelfPctLessThan ); + TYPE_FORWARD( HPSelfPctLessThanTargetCondition ); TYPE_FORWARD( GambitRule ); }