mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
Cleanup cleanup cleanup
This commit is contained in:
parent
33463f45a9
commit
fe9a2ef974
4 changed files with 29 additions and 29 deletions
|
@ -18,20 +18,19 @@ namespace Sapphire::World::AI
|
||||||
class GambitTargetCondition
|
class GambitTargetCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
GambitTargetCondition( GambitTargetType targetType ) : m_targetType( targetType ) {};
|
GambitTargetCondition() = default;
|
||||||
virtual ~GambitTargetCondition() = default;
|
virtual ~GambitTargetCondition() = default;
|
||||||
|
|
||||||
virtual bool isConditionMet( Sapphire::Entity::BNpc& src ) { return false; };
|
virtual bool isConditionMet( Sapphire::Entity::BNpc& src ) { return false; };
|
||||||
Sapphire::Entity::CharaPtr getTarget() const { return m_pTarget; };
|
Sapphire::Entity::CharaPtr getTarget() const { return m_pTarget; };
|
||||||
protected:
|
protected:
|
||||||
GambitTargetType m_targetType;
|
|
||||||
Sapphire::Entity::CharaPtr m_pTarget;
|
Sapphire::Entity::CharaPtr m_pTarget;
|
||||||
};
|
};
|
||||||
|
|
||||||
class TopHateTargetCondition : public GambitTargetCondition
|
class TopHateTargetCondition : public GambitTargetCondition
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
TopHateTargetCondition() : GambitTargetCondition( PlayerAndAlly ) {};
|
TopHateTargetCondition() = default;
|
||||||
|
|
||||||
bool isConditionMet( Sapphire::Entity::BNpc& src ) override
|
bool isConditionMet( Sapphire::Entity::BNpc& src ) override
|
||||||
{
|
{
|
||||||
|
@ -45,12 +44,12 @@ namespace Sapphire::World::AI
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
|
||||||
class HPSelfPctLessThan : public GambitTargetCondition
|
class HPSelfPctLessThanTargetCondition : public GambitTargetCondition
|
||||||
{
|
{
|
||||||
public:
|
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 )
|
if( src.getHpPercent() < m_HpPct )
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,6 +10,7 @@
|
||||||
#include "StatusEffect/StatusEffect.h"
|
#include "StatusEffect/StatusEffect.h"
|
||||||
|
|
||||||
using namespace Sapphire;
|
using namespace Sapphire;
|
||||||
|
using namespace Sapphire::Common;
|
||||||
using namespace Sapphire::World::Action;
|
using namespace Sapphire::World::Action;
|
||||||
|
|
||||||
|
|
||||||
|
@ -20,8 +21,8 @@ ActionResult::ActionResult( Entity::CharaPtr target ) :
|
||||||
m_result.Arg1 = 0;
|
m_result.Arg1 = 0;
|
||||||
m_result.Arg2 = 0;
|
m_result.Arg2 = 0;
|
||||||
m_result.Value = 0;
|
m_result.Value = 0;
|
||||||
m_result.Flag = static_cast< uint8_t >( Common::ActionResultFlag::None );
|
m_result.Flag = static_cast< uint8_t >( ActionResultFlag::None );
|
||||||
m_result.Type = Common::CalcResultType::TypeNone;
|
m_result.Type = CalcResultType::TypeNone;
|
||||||
}
|
}
|
||||||
|
|
||||||
Entity::CharaPtr ActionResult::getTarget() const
|
Entity::CharaPtr ActionResult::getTarget() const
|
||||||
|
@ -29,7 +30,7 @@ Entity::CharaPtr ActionResult::getTarget() const
|
||||||
return m_target;
|
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.Arg0 = hitEffect;
|
||||||
m_result.Value = static_cast< int16_t >( amount );
|
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;
|
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.Arg0 = hitEffect;
|
||||||
m_result.Value = static_cast< int16_t >( amount );
|
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;
|
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.Value = static_cast< int16_t >( amount );
|
||||||
m_result.Flag = static_cast< uint8_t >( flag );
|
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 )
|
void ActionResult::startCombo( uint16_t actionId )
|
||||||
{
|
{
|
||||||
m_result.Value = static_cast< int16_t >( actionId );
|
m_result.Value = static_cast< int16_t >( actionId );
|
||||||
m_result.Flag = static_cast< uint8_t >( Common::ActionResultFlag::EffectOnSource );
|
m_result.Flag = static_cast< uint8_t >( ActionResultFlag::EffectOnSource );
|
||||||
m_result.Type = Common::CalcResultType::TypeCombo;
|
m_result.Type = CalcResultType::TypeCombo;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ActionResult::comboSucceed()
|
void ActionResult::comboSucceed()
|
||||||
{
|
{
|
||||||
// no EffectOnSource flag on this
|
// 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 )
|
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.Value = static_cast< int16_t >( id );
|
||||||
m_result.Arg2 = param;
|
m_result.Arg2 = param;
|
||||||
m_result.Type = Common::CalcResultType::TypeSetStatus;
|
m_result.Type = CalcResultType::TypeSetStatus;
|
||||||
|
|
||||||
m_bOverrideStatus = shouldOverride;
|
m_bOverrideStatus = shouldOverride;
|
||||||
m_pStatus = StatusEffect::make_StatusEffect( id, source.getAsChara(), m_target, duration, 3000 );
|
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.Value = static_cast< int16_t >( id );
|
||||||
m_result.Arg2 = param;
|
m_result.Arg2 = param;
|
||||||
m_result.Type = Common::CalcResultType::TypeSetStatusMe;
|
m_result.Type = CalcResultType::TypeSetStatusMe;
|
||||||
m_result.Flag = static_cast< uint8_t >( Common::ActionResultFlag::EffectOnSource );
|
m_result.Flag = static_cast< uint8_t >( ActionResultFlag::EffectOnSource );
|
||||||
|
|
||||||
m_bOverrideStatus = shouldOverride;
|
m_bOverrideStatus = shouldOverride;
|
||||||
m_pStatus = StatusEffect::make_StatusEffect( id, m_target, m_target, duration, 3000 );
|
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.Value = static_cast< int16_t >( mountId );
|
||||||
m_result.Arg0 = 1;
|
m_result.Arg0 = 1;
|
||||||
m_result.Type = Common::CalcResultType::TypeMount;
|
m_result.Type = CalcResultType::TypeMount;
|
||||||
}
|
}
|
||||||
|
|
||||||
const Common::CalcResultParam& ActionResult::getCalcResultParam() const
|
const Common::CalcResultParam& ActionResult::getCalcResultParam() const
|
||||||
|
@ -112,28 +113,28 @@ void ActionResult::execute()
|
||||||
|
|
||||||
switch( m_result.Type )
|
switch( m_result.Type )
|
||||||
{
|
{
|
||||||
case Common::CalcResultType::TypeDamageHp:
|
case CalcResultType::TypeDamageHp:
|
||||||
case Common::CalcResultType::TypeCriticalDamageHp:
|
case CalcResultType::TypeCriticalDamageHp:
|
||||||
{
|
{
|
||||||
m_target->takeDamage( m_result.Value );
|
m_target->takeDamage( m_result.Value );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Common::CalcResultType::TypeRecoverHp:
|
case CalcResultType::TypeRecoverHp:
|
||||||
case Common::CalcResultType::TypeCriticalRecoverHp:
|
case CalcResultType::TypeCriticalRecoverHp:
|
||||||
{
|
{
|
||||||
m_target->heal( m_result.Value );
|
m_target->heal( m_result.Value );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Common::CalcResultType::TypeRecoverMp:
|
case CalcResultType::TypeRecoverMp:
|
||||||
{
|
{
|
||||||
m_target->restoreMP( m_result.Value );
|
m_target->restoreMP( m_result.Value );
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Common::CalcResultType::TypeSetStatus:
|
case CalcResultType::TypeSetStatus:
|
||||||
case Common::CalcResultType::TypeSetStatusMe:
|
case CalcResultType::TypeSetStatusMe:
|
||||||
{
|
{
|
||||||
if( !m_bOverrideStatus )
|
if( !m_bOverrideStatus )
|
||||||
m_target->addStatusEffectByIdIfNotExist( m_pStatus );
|
m_target->addStatusEffectByIdIfNotExist( m_pStatus );
|
||||||
|
@ -142,7 +143,7 @@ void ActionResult::execute()
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
case Common::CalcResultType::TypeMount:
|
case CalcResultType::TypeMount:
|
||||||
{
|
{
|
||||||
auto pPlayer = m_target->getAsPlayer();
|
auto pPlayer = m_target->getAsPlayer();
|
||||||
pPlayer->setMount( m_result.Value );
|
pPlayer->setMount( m_result.Value );
|
||||||
|
|
|
@ -1056,7 +1056,7 @@ void BNpc::init()
|
||||||
|
|
||||||
//setup a test gambit
|
//setup a test gambit
|
||||||
auto testGambitRule = AI::make_GambitRule( AI::make_TopHateTargetCondition(), Action::make_Action( getAsChara(), 88, 0 ), 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 );
|
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( testGambitRule );
|
||||||
m_gambits.push_back( testGambitRule1 );
|
m_gambits.push_back( testGambitRule1 );
|
||||||
|
|
|
@ -51,7 +51,7 @@ namespace World::AI
|
||||||
{
|
{
|
||||||
TYPE_FORWARD( GambitTargetCondition );
|
TYPE_FORWARD( GambitTargetCondition );
|
||||||
TYPE_FORWARD( TopHateTargetCondition );
|
TYPE_FORWARD( TopHateTargetCondition );
|
||||||
TYPE_FORWARD( HPSelfPctLessThan );
|
TYPE_FORWARD( HPSelfPctLessThanTargetCondition );
|
||||||
|
|
||||||
TYPE_FORWARD( GambitRule );
|
TYPE_FORWARD( GambitRule );
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue