mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-05-04 17:57:47 +00:00
Use attack type for action hit effect, further simply action code.
This commit is contained in:
parent
9ba263da00
commit
aafb77ecbb
9 changed files with 48 additions and 51 deletions
1
deps/datReader/Exd/Structs.h
vendored
1
deps/datReader/Exd/Structs.h
vendored
|
@ -397,6 +397,7 @@ namespace Excel
|
|||
uint8_t UseClassJob;
|
||||
uint8_t Init;
|
||||
uint8_t Omen;
|
||||
uint8_t Unknown;
|
||||
int8_t Learn;
|
||||
int8_t SelectRange;
|
||||
int8_t SelectCorpse;
|
||||
|
|
|
@ -454,7 +454,7 @@ void Action::Action::execute()
|
|||
}
|
||||
}
|
||||
|
||||
std::pair< uint32_t, Common::ActionHitSeverityType > Action::Action::calcDamage( uint32_t potency )
|
||||
std::pair< uint32_t, Common::ActionEffectType > Action::Action::calcDamage( uint32_t potency )
|
||||
{
|
||||
// todo: what do for npcs?
|
||||
auto wepDmg = 1.f;
|
||||
|
@ -478,7 +478,7 @@ std::pair< uint32_t, Common::ActionHitSeverityType > Action::Action::calcDamage(
|
|||
return Math::CalcStats::calcActionDamage( *m_pSource, potency, wepDmg );
|
||||
}
|
||||
|
||||
std::pair< uint32_t, Common::ActionHitSeverityType > Action::Action::calcHealing( uint32_t potency )
|
||||
std::pair< uint32_t, Common::ActionEffectType > Action::Action::calcHealing( uint32_t potency )
|
||||
{
|
||||
auto wepDmg = 1.f;
|
||||
|
||||
|
|
|
@ -122,9 +122,9 @@ namespace Sapphire::World::Action
|
|||
*/
|
||||
void addDefaultActorFilters();
|
||||
|
||||
std::pair< uint32_t, Common::ActionHitSeverityType > calcDamage( uint32_t potency );
|
||||
std::pair< uint32_t, Common::ActionEffectType > calcDamage( uint32_t potency );
|
||||
|
||||
std::pair< uint32_t, Common::ActionHitSeverityType > calcHealing( uint32_t potency );
|
||||
std::pair< uint32_t, Common::ActionEffectType > calcHealing( uint32_t potency );
|
||||
|
||||
|
||||
std::vector< Entity::CharaPtr >& getHitCharas();
|
||||
|
|
|
@ -13,9 +13,8 @@ using namespace Sapphire;
|
|||
using namespace Sapphire::World::Action;
|
||||
|
||||
|
||||
ActionResult::ActionResult( Entity::CharaPtr target, uint64_t runAfter ) :
|
||||
m_target( std::move( target ) ),
|
||||
m_delayMs( runAfter )
|
||||
ActionResult::ActionResult( Entity::CharaPtr target ) :
|
||||
m_target( std::move( target ) )
|
||||
{
|
||||
m_result.Arg0 = 0;
|
||||
m_result.Arg1 = 0;
|
||||
|
@ -30,25 +29,20 @@ Entity::CharaPtr ActionResult::getTarget() const
|
|||
return m_target;
|
||||
}
|
||||
|
||||
uint64_t ActionResult::getDelay()
|
||||
void ActionResult::damage( uint32_t amount, Common::ActionEffectType hitType, uint8_t hitEffect, Common::ActionResultFlag flag )
|
||||
{
|
||||
return m_delayMs;
|
||||
}
|
||||
|
||||
void ActionResult::damage( uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionResultFlag flag )
|
||||
{
|
||||
//m_result.Arg0 = static_cast< uint8_t >( severity );
|
||||
m_result.Arg0 = hitEffect;
|
||||
m_result.Value = static_cast< int16_t >( amount );
|
||||
m_result.Flag = static_cast< uint8_t >( flag );
|
||||
m_result.Type = severity == Common::ActionHitSeverityType::CritDamage ? Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_DAMAGE_HP : Common::ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP;
|
||||
m_result.Type = hitType;
|
||||
}
|
||||
|
||||
void ActionResult::heal( uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionResultFlag flag )
|
||||
void ActionResult::heal( uint32_t amount, Common::ActionEffectType hitType, uint8_t hitEffect, Common::ActionResultFlag flag )
|
||||
{
|
||||
//m_result.Arg1 = static_cast< uint8_t >( severity );
|
||||
m_result.Arg0 = hitEffect;
|
||||
m_result.Value = static_cast< int16_t >( amount );
|
||||
m_result.Flag = static_cast< uint8_t >( flag );
|
||||
m_result.Type = severity == Common::ActionHitSeverityType::CritHeal ? Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_RECOVER_HP : Common::ActionEffectType::CALC_RESULT_TYPE_RECOVER_HP;
|
||||
m_result.Type = hitType;
|
||||
}
|
||||
|
||||
void ActionResult::restoreMP( uint32_t amount, Common::ActionResultFlag flag )
|
||||
|
|
|
@ -12,10 +12,10 @@ namespace Sapphire::World::Action
|
|||
class ActionResult
|
||||
{
|
||||
public:
|
||||
explicit ActionResult( Entity::CharaPtr target, uint64_t delayMs );
|
||||
explicit ActionResult( Entity::CharaPtr target );
|
||||
|
||||
void damage( uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionResultFlag flag = Common::ActionResultFlag::None );
|
||||
void heal( uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionResultFlag flag = Common::ActionResultFlag::None );
|
||||
void damage( uint32_t amount, Common::ActionEffectType hitType, uint8_t hitEffect, Common::ActionResultFlag flag = Common::ActionResultFlag::None );
|
||||
void heal( uint32_t amount, Common::ActionEffectType hitType, uint8_t hitEffect, Common::ActionResultFlag flag = Common::ActionResultFlag::None );
|
||||
void restoreMP( uint32_t amount, Common::ActionResultFlag flag = Common::ActionResultFlag::None );
|
||||
void startCombo( uint16_t actionId );
|
||||
void comboSucceed();
|
||||
|
@ -25,16 +25,12 @@ namespace Sapphire::World::Action
|
|||
|
||||
Entity::CharaPtr getTarget() const;
|
||||
|
||||
uint64_t getDelay();
|
||||
|
||||
const Common::CalcResultParam& getCalcResultParam() const;
|
||||
const Sapphire::StatusEffect::StatusEffectPtr getStatusEffect() const;
|
||||
|
||||
void execute();
|
||||
|
||||
private:
|
||||
uint64_t m_delayMs;
|
||||
|
||||
Entity::CharaPtr m_target;
|
||||
|
||||
Common::CalcResultParam m_result;
|
||||
|
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include <Util/Util.h>
|
||||
#include <Util/UtilMath.h>
|
||||
#include <Exd/ExdData.h>
|
||||
|
||||
#include <Logging/Logger.h>
|
||||
#include <Manager/TerritoryMgr.h>
|
||||
|
@ -46,58 +47,62 @@ void ActionResultBuilder::addResultToActor( Entity::CharaPtr& chara, ActionResul
|
|||
it->second.push_back( std::move( result ) );
|
||||
}
|
||||
|
||||
void ActionResultBuilder::heal( Entity::CharaPtr& effectTarget, Entity::CharaPtr& healingTarget, uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionResultFlag flag )
|
||||
void ActionResultBuilder::heal( Entity::CharaPtr& effectTarget, Entity::CharaPtr& healingTarget, uint32_t amount, Common::ActionEffectType hitType, Common::ActionResultFlag flag )
|
||||
{
|
||||
ActionResultPtr nextResult = make_ActionResult( healingTarget, 0 );
|
||||
nextResult->heal( amount, severity, flag );
|
||||
ActionResultPtr nextResult = make_ActionResult( healingTarget );
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
auto actionData = exdData.getRow< Excel::Action >( m_actionId );
|
||||
nextResult->heal( amount, hitType, std::abs( actionData->data().AttackType ), flag );
|
||||
addResultToActor( effectTarget, nextResult );
|
||||
}
|
||||
|
||||
void ActionResultBuilder::restoreMP( Entity::CharaPtr& target, Entity::CharaPtr& restoringTarget, uint32_t amount, Common::ActionResultFlag flag )
|
||||
{
|
||||
ActionResultPtr nextResult = make_ActionResult( restoringTarget, 0 ); // restore mp source actor
|
||||
ActionResultPtr nextResult = make_ActionResult( restoringTarget ); // restore mp source actor
|
||||
nextResult->restoreMP( amount, flag );
|
||||
addResultToActor( target, nextResult );
|
||||
}
|
||||
|
||||
void ActionResultBuilder::damage( Entity::CharaPtr& effectTarget, Entity::CharaPtr& damagingTarget, uint32_t amount, Common::ActionHitSeverityType severity, Common::ActionResultFlag flag )
|
||||
void ActionResultBuilder::damage( Entity::CharaPtr& effectTarget, Entity::CharaPtr& damagingTarget, uint32_t amount, Common::ActionEffectType hitType, Common::ActionResultFlag flag )
|
||||
{
|
||||
ActionResultPtr nextResult = make_ActionResult( damagingTarget, 0 );
|
||||
nextResult->damage( amount, severity, flag );
|
||||
ActionResultPtr nextResult = make_ActionResult( damagingTarget );
|
||||
auto& exdData = Common::Service< Data::ExdData >::ref();
|
||||
auto actionData = exdData.getRow< Excel::Action >( m_actionId );
|
||||
nextResult->damage( amount, hitType, std::abs( actionData->data().AttackType ), flag );
|
||||
addResultToActor( damagingTarget, nextResult );
|
||||
}
|
||||
|
||||
void ActionResultBuilder::startCombo( Entity::CharaPtr& target, uint16_t actionId )
|
||||
{
|
||||
ActionResultPtr nextResult = make_ActionResult( target, 0 );
|
||||
ActionResultPtr nextResult = make_ActionResult( target );
|
||||
nextResult->startCombo( actionId );
|
||||
addResultToActor( target, nextResult );
|
||||
}
|
||||
|
||||
void ActionResultBuilder::comboSucceed( Entity::CharaPtr& target )
|
||||
{
|
||||
ActionResultPtr nextResult = make_ActionResult( target, 0 );
|
||||
ActionResultPtr nextResult = make_ActionResult( target );
|
||||
nextResult->comboSucceed();
|
||||
addResultToActor( target, nextResult );
|
||||
}
|
||||
|
||||
void ActionResultBuilder::applyStatusEffect( Entity::CharaPtr& target, uint16_t statusId, uint32_t duration, uint8_t param, bool shouldOverride )
|
||||
{
|
||||
ActionResultPtr nextResult = make_ActionResult( target, 0 );
|
||||
ActionResultPtr nextResult = make_ActionResult( target );
|
||||
nextResult->applyStatusEffect( statusId, duration, *m_sourceChara, param, shouldOverride );
|
||||
addResultToActor( target, nextResult );
|
||||
}
|
||||
|
||||
void ActionResultBuilder::applyStatusEffectSelf( uint16_t statusId, uint32_t duration, uint8_t param, bool shouldOverride )
|
||||
{
|
||||
ActionResultPtr nextResult = make_ActionResult( m_sourceChara, 0 );
|
||||
ActionResultPtr nextResult = make_ActionResult( m_sourceChara );
|
||||
nextResult->applyStatusEffectSelf( statusId, duration, param, shouldOverride );
|
||||
addResultToActor( m_sourceChara, nextResult );
|
||||
}
|
||||
|
||||
void ActionResultBuilder::mount( Entity::CharaPtr& target, uint16_t mountId )
|
||||
{
|
||||
ActionResultPtr nextResult = make_ActionResult( target, 0 );
|
||||
ActionResultPtr nextResult = make_ActionResult( target );
|
||||
nextResult->mount( mountId );
|
||||
addResultToActor( target, nextResult );
|
||||
}
|
||||
|
|
|
@ -11,14 +11,14 @@ namespace Sapphire::World::Action
|
|||
ActionResultBuilder( Entity::CharaPtr source, uint32_t actionId, uint32_t resultId, uint16_t requestId );
|
||||
|
||||
void heal( Entity::CharaPtr& effectTarget, Entity::CharaPtr& healingTarget, uint32_t amount,
|
||||
Common::ActionHitSeverityType severity = Common::ActionHitSeverityType::NormalHeal,
|
||||
Common::ActionEffectType hitType = Common::ActionEffectType::CALC_RESULT_TYPE_RECOVER_HP,
|
||||
Common::ActionResultFlag flag = Common::ActionResultFlag::None );
|
||||
|
||||
void restoreMP( Entity::CharaPtr& effectTarget, Entity::CharaPtr& restoringTarget, uint32_t amount,
|
||||
Common::ActionResultFlag flag = Common::ActionResultFlag::None );
|
||||
|
||||
void damage( Entity::CharaPtr& effectTarget, Entity::CharaPtr& damagingTarget, uint32_t amount,
|
||||
Common::ActionHitSeverityType severity = Common::ActionHitSeverityType::NormalDamage,
|
||||
Common::ActionEffectType hitType = Common::ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP,
|
||||
Common::ActionResultFlag flag = Common::ActionResultFlag::None );
|
||||
|
||||
void startCombo( Entity::CharaPtr& target, uint16_t actionId );
|
||||
|
|
|
@ -549,7 +549,7 @@ float CalcStats::healingMagicPotency( const Sapphire::Entity::Chara& chara )
|
|||
return std::floor( 100.f * ( chara.getStatValue( Common::BaseParam::HealingMagicPotency ) - 292.f ) / 264.f + 100.f ) / 100.f;
|
||||
}
|
||||
|
||||
std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcAutoAttackDamage( const Sapphire::Entity::Chara& chara )
|
||||
std::pair< float, Sapphire::Common::ActionEffectType > CalcStats::calcAutoAttackDamage( const Sapphire::Entity::Chara& chara )
|
||||
{
|
||||
// D = ⌊ f(ptc) × f(aa) × f(ap) × f(det) × f(tnc) × traits ⌋ × f(ss) ⌋ ×
|
||||
// f(chr) ⌋ × f(dhr) ⌋ × rand[ 0.95, 1.05 ] ⌋ × buff_1 ⌋ × buff... ⌋
|
||||
|
@ -562,7 +562,7 @@ std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcAutoA
|
|||
|
||||
// todo: everything after tenacity
|
||||
auto factor = Common::Util::trunc( pot * aa * ap * det, 0 );
|
||||
Sapphire::Common::ActionHitSeverityType hitType = Sapphire::Common::ActionHitSeverityType::NormalDamage;
|
||||
Sapphire::Common::ActionEffectType hitType = Sapphire::Common::ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP;
|
||||
|
||||
// todo: traits
|
||||
|
||||
|
@ -571,7 +571,7 @@ std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcAutoA
|
|||
if( criticalHitProbability( chara ) > getRandomNumber0To100() )
|
||||
{
|
||||
factor *= criticalHitBonus( chara );
|
||||
hitType = Sapphire::Common::ActionHitSeverityType::CritDamage;
|
||||
hitType = Sapphire::Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_DAMAGE_HP;
|
||||
}
|
||||
|
||||
factor *= 1.0f + ( ( getRandomNumber0To100() - 50.0f ) / 1000.0f );
|
||||
|
@ -592,7 +592,7 @@ std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcAutoA
|
|||
return std::pair( factor, hitType );
|
||||
}
|
||||
|
||||
std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcActionDamage( const Sapphire::Entity::Chara& chara, uint32_t ptc, float wepDmg )
|
||||
std::pair< float, Sapphire::Common::ActionEffectType > CalcStats::calcActionDamage( const Sapphire::Entity::Chara& chara, uint32_t ptc, float wepDmg )
|
||||
{
|
||||
// D = ⌊ f(pot) × f(wd) × f(ap) × f(det) × f(tnc) × traits ⌋
|
||||
// × f(chr) ⌋ × f(dhr) ⌋ × rand[ 0.95, 1.05 ] ⌋ buff_1 ⌋ × buff_1 ⌋ × buff... ⌋
|
||||
|
@ -603,12 +603,12 @@ std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcActio
|
|||
auto det = determination( chara );
|
||||
|
||||
auto factor = Common::Util::trunc( pot * wd * ap * det, 0 );
|
||||
Sapphire::Common::ActionHitSeverityType hitType = Sapphire::Common::ActionHitSeverityType::NormalDamage;
|
||||
Sapphire::Common::ActionEffectType hitType = Sapphire::Common::ActionEffectType::CALC_RESULT_TYPE_DAMAGE_HP;
|
||||
|
||||
if( criticalHitProbability( chara ) > getRandomNumber0To100() )
|
||||
{
|
||||
factor *= criticalHitBonus( chara );
|
||||
hitType = Sapphire::Common::ActionHitSeverityType::CritDamage;
|
||||
hitType = Sapphire::Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_DAMAGE_HP;
|
||||
}
|
||||
|
||||
factor *= 1.0f + ( ( getRandomNumber0To100() - 50.0f ) / 1000.0f );
|
||||
|
@ -629,19 +629,20 @@ std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcActio
|
|||
return std::pair( factor, hitType );
|
||||
}
|
||||
|
||||
std::pair< float, Sapphire::Common::ActionHitSeverityType > CalcStats::calcActionHealing( const Sapphire::Entity::Chara& chara, uint32_t ptc, float wepDmg )
|
||||
std::pair< float, Sapphire::Common::ActionEffectType > CalcStats::calcActionHealing( const Sapphire::Entity::Chara& chara, uint32_t ptc, float wepDmg )
|
||||
{
|
||||
// lol just for testing
|
||||
float det = chara.getStatValue( Common::BaseParam::Determination );
|
||||
float mnd = chara.getStatValue( Common::BaseParam::Mind );
|
||||
|
||||
auto factor = std::floor( ( wepDmg * ( mnd / 200 ) + ( det / 10 ) ) * ( ptc / 100 ) * 1.3f );
|
||||
Sapphire::Common::ActionHitSeverityType hitType = Sapphire::Common::ActionHitSeverityType::NormalHeal;
|
||||
|
||||
Sapphire::Common::ActionEffectType hitType = Sapphire::Common::ActionEffectType::CALC_RESULT_TYPE_RECOVER_HP;
|
||||
|
||||
if( criticalHitProbability( chara ) > getRandomNumber0To100() )
|
||||
{
|
||||
factor *= criticalHitBonus( chara );
|
||||
hitType = Sapphire::Common::ActionHitSeverityType::CritHeal;
|
||||
hitType = Sapphire::Common::ActionEffectType::CALC_RESULT_TYPE_CRITICAL_RECOVER_HP;
|
||||
}
|
||||
|
||||
factor *= 1.0f + ( ( getRandomNumber0To100() - 50.0f ) / 1000.0f );
|
||||
|
|
|
@ -136,11 +136,11 @@ namespace Sapphire::Math
|
|||
|
||||
////////////////////////////////////////////
|
||||
|
||||
static std::pair< float, Common::ActionHitSeverityType > calcAutoAttackDamage( const Sapphire::Entity::Chara& chara );
|
||||
static std::pair< float, Common::ActionEffectType > calcAutoAttackDamage( const Sapphire::Entity::Chara& chara );
|
||||
|
||||
static std::pair< float, Common::ActionHitSeverityType > calcActionDamage( const Sapphire::Entity::Chara& chara, uint32_t ptc, float wepDmg );
|
||||
static std::pair< float, Common::ActionEffectType > calcActionDamage( const Sapphire::Entity::Chara& chara, uint32_t ptc, float wepDmg );
|
||||
|
||||
static std::pair< float, Common::ActionHitSeverityType > calcActionHealing( const Sapphire::Entity::Chara& chara, uint32_t ptc, float wepDmg );
|
||||
static std::pair< float, Common::ActionEffectType > calcActionHealing( const Sapphire::Entity::Chara& chara, uint32_t ptc, float wepDmg );
|
||||
|
||||
static uint32_t primaryStatValue( const Sapphire::Entity::Chara& chara );
|
||||
private:
|
||||
|
|
Loading…
Add table
Reference in a new issue