mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 14:57:44 +00:00
support 3.x crit damage and remove direct hit
This commit is contained in:
parent
658d2fa7aa
commit
5fb62b75ec
3 changed files with 6 additions and 38 deletions
|
@ -37,18 +37,18 @@ uint64_t ActionResult::getDelay()
|
|||
|
||||
void ActionResult::damage( uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionResultFlag flag )
|
||||
{
|
||||
m_result.Arg0 = static_cast< uint8_t >( severity );
|
||||
//m_result.Arg0 = static_cast< uint8_t >( severity );
|
||||
m_result.Value = static_cast< int16_t >( amount );
|
||||
m_result.Flag = static_cast< uint8_t >( flag );
|
||||
m_result.Type = Common::ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP;
|
||||
m_result.Type = severity == Common::ActionHitSeverityType::CritDamage ? Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_DAMAGE_HP : Common::ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP;
|
||||
}
|
||||
|
||||
void ActionResult::heal( uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionResultFlag flag )
|
||||
{
|
||||
m_result.Arg1 = static_cast< uint8_t >( severity );
|
||||
//m_result.Arg1 = static_cast< uint8_t >( severity );
|
||||
m_result.Value = static_cast< int16_t >( amount );
|
||||
m_result.Flag = static_cast< uint8_t >( flag );
|
||||
m_result.Type = Common::ActionEffectType::CALC_RESULT_TYPE_RECOVER_HP;
|
||||
m_result.Type = severity == Common::ActionHitSeverityType::CritHeal ? Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_RECOVER_HP : Common::ActionEffectType::CALC_RESULT_TYPE_RECOVER_HP;
|
||||
}
|
||||
|
||||
void ActionResult::restoreMP( uint32_t amount, Common::ActionResultFlag flag )
|
||||
|
@ -119,12 +119,14 @@ void ActionResult::execute()
|
|||
switch( m_result.Type )
|
||||
{
|
||||
case Common::ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP:
|
||||
case Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_DAMAGE_HP:
|
||||
{
|
||||
m_target->takeDamage( m_result.Value );
|
||||
break;
|
||||
}
|
||||
|
||||
case Common::ActionEffectType::CALC_RESULT_TYPE_RECOVER_HP:
|
||||
case Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_RECOVER_HP:
|
||||
{
|
||||
m_target->heal( m_result.Value );
|
||||
break;
|
||||
|
|
|
@ -287,19 +287,6 @@ float CalcStats::blockProbability( const Chara& chara )
|
|||
return std::floor( ( 30 * blockRate ) / levelVal + 10 );
|
||||
}
|
||||
|
||||
float CalcStats::directHitProbability( const Chara& chara )
|
||||
{
|
||||
const auto& baseStats = chara.getStats();
|
||||
auto level = chara.getLevel();
|
||||
|
||||
auto dhRate = chara.getStatValueFloat( Common::BaseParam::Accuracy );
|
||||
|
||||
auto divVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::DIV ] );
|
||||
auto subVal = static_cast< float >( levelTable[ level ][ Common::LevelTableEntry::SUB ] );
|
||||
|
||||
return std::floor( 550.f * ( dhRate - subVal ) / divVal ) / 10.f;
|
||||
}
|
||||
|
||||
float CalcStats::criticalHitProbability( const Chara& chara )
|
||||
{
|
||||
const auto& baseStats = chara.getStats();
|
||||
|
@ -589,14 +576,6 @@ std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcAutoA
|
|||
hitType = Sapphire::Common::ActionHitSeverityType::CritDamage;
|
||||
}
|
||||
|
||||
if( directHitProbability( chara ) > range100( rng ) )
|
||||
{
|
||||
factor *= 1.25f;
|
||||
hitType = hitType == Sapphire::Common::ActionHitSeverityType::CritDamage ?
|
||||
Sapphire::Common::ActionHitSeverityType::CritDirectHitDamage :
|
||||
Sapphire::Common::ActionHitSeverityType::DirectHitDamage;
|
||||
}
|
||||
|
||||
factor *= 1.0f + ( ( range100( rng ) - 50.0f ) / 1000.0f );
|
||||
|
||||
// todo: buffs
|
||||
|
@ -634,14 +613,6 @@ std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcActio
|
|||
hitType = Sapphire::Common::ActionHitSeverityType::CritDamage;
|
||||
}
|
||||
|
||||
if( directHitProbability( chara ) > range100( rng ) )
|
||||
{
|
||||
factor *= 1.25f;
|
||||
hitType = hitType == Sapphire::Common::ActionHitSeverityType::CritDamage ?
|
||||
Sapphire::Common::ActionHitSeverityType::CritDirectHitDamage :
|
||||
Sapphire::Common::ActionHitSeverityType::DirectHitDamage;
|
||||
}
|
||||
|
||||
factor *= 1.0f + ( ( range100( rng ) - 50.0f ) / 1000.0f );
|
||||
|
||||
// todo: buffs
|
||||
|
|
|
@ -34,11 +34,6 @@ namespace Sapphire::Math
|
|||
*/
|
||||
static float blockProbability( const Sapphire::Entity::Chara& chara );
|
||||
|
||||
/*!
|
||||
* @brief Calculates the probability of a direct hit happening
|
||||
*/
|
||||
static float directHitProbability( const Sapphire::Entity::Chara& chara );
|
||||
|
||||
/*!
|
||||
* @brief Calculates the probability of a critical hit happening
|
||||
*/
|
||||
|
|
Loading…
Add table
Reference in a new issue