1
Fork 0
mirror of https://github.com/SapphireServer/Sapphire.git synced 2025-05-28 20:27:46 +00:00

Try to implement MP restoring actions.

MPP values in lut entries are input manually.
This commit is contained in:
collett 2020-01-02 20:58:50 +09:00
parent 482745624c
commit dee59aead1
10 changed files with 1474 additions and 1296 deletions

View file

@ -249,11 +249,11 @@ int main()
// action.first, data.name, data.potency, data.flankPotency, data.frontPotency, data.rearPotency, // action.first, data.name, data.potency, data.flankPotency, data.frontPotency, data.rearPotency,
// data.curePotency, data.restorePercentage ); // data.curePotency, data.restorePercentage );
auto out = fmt::format( " // {}\n {{ {}, {{ {}, {}, {}, {}, {}, {} }} }},\n", auto out = fmt::format( " // {}\n {{ {}, {{ {}, {}, {}, {}, {}, {}, {} }} }},\n",
data.name, action.first, data.name, action.first,
data.potency, data.comboPotency, data.potency, data.comboPotency,
data.flankPotency, data.frontPotency, data.rearPotency, data.flankPotency, data.frontPotency, data.rearPotency,
data.curePotency ); data.curePotency, 0 );
output += out; output += out;
// Logger::info( out ); // Logger::info( out );

View file

@ -419,9 +419,9 @@ void Action::Action::buildEffects()
// no script exists but we have a valid lut entry // no script exists but we have a valid lut entry
if( auto player = getSourceChara()->getAsPlayer() ) if( auto player = getSourceChara()->getAsPlayer() )
{ {
player->sendDebug( "Hit target: pot: {} (c: {}, f: {}, r: {}), heal pot: {}", player->sendDebug( "Hit target: pot: {} (c: {}, f: {}, r: {}), heal pot: {}, mpp: {}",
lutEntry.potency, lutEntry.comboPotency, lutEntry.flankPotency, lutEntry.rearPotency, lutEntry.potency, lutEntry.comboPotency, lutEntry.flankPotency, lutEntry.rearPotency,
lutEntry.curePotency ); lutEntry.curePotency, lutEntry.restoreMPPercentage );
} }
for( auto& actor : m_hitActors ) for( auto& actor : m_hitActors )
@ -450,6 +450,11 @@ void Action::Action::buildEffects()
m_effectBuilder->selfHeal( actor, m_pSource, lutEntry.curePotency ); m_effectBuilder->selfHeal( actor, m_pSource, lutEntry.curePotency );
} }
if ( lutEntry.restoreMPPercentage > 0 )
{
m_effectBuilder->restoreMP( actor, m_pSource, m_pSource->getMp() * lutEntry.restoreMPPercentage / 100 );
}
if ( !m_actionData->preservesCombo ) // we need something like m_actionData->hasNextComboAction if ( !m_actionData->preservesCombo ) // we need something like m_actionData->hasNextComboAction
{ {
m_effectBuilder->startCombo( actor, getId() ); m_effectBuilder->startCombo( actor, getId() );
@ -460,6 +465,16 @@ void Action::Action::buildEffects()
{ {
// todo: calcHealing() // todo: calcHealing()
m_effectBuilder->healTarget( actor, lutEntry.curePotency ); m_effectBuilder->healTarget( actor, lutEntry.curePotency );
if ( lutEntry.restoreMPPercentage > 0 )
{
// always restore caster mp I don't think there are any actions that can restore target MP post 5.0
m_effectBuilder->restoreMP( actor, m_pSource, m_pSource->getMp() * lutEntry.restoreMPPercentage / 100 );
}
}
else if ( lutEntry.restoreMPPercentage > 0 )
{
m_effectBuilder->restoreMP( m_pSource, m_pSource, m_pSource->getMp() * lutEntry.restoreMPPercentage / 100 );
} }
} }

View file

@ -13,7 +13,7 @@ namespace Sapphire::World::Action
uint16_t frontPotency; uint16_t frontPotency;
uint16_t rearPotency; uint16_t rearPotency;
uint16_t curePotency; uint16_t curePotency;
// uint16_t restorePercentage; uint16_t restoreMPPercentage;
}; };
class ActionLut class ActionLut

File diff suppressed because it is too large Load diff

View file

@ -67,6 +67,16 @@ void EffectBuilder::selfHeal( Entity::CharaPtr& target, Entity::CharaPtr& source
resultList->push_back( std::move( nextResult ) ); resultList->push_back( std::move( nextResult ) );
} }
void EffectBuilder::restoreMP( Entity::CharaPtr& target, Entity::CharaPtr& source, uint32_t amount, Common::ActionHitSeverityType severity )
{
auto resultList = getResultList( target );
assert( resultList );
EffectResultPtr nextResult = make_EffectResult( source, getResultDelayMs() ); // restore mp source actor
nextResult->restoreMP( amount );
resultList->push_back( std::move( nextResult ) );
}
void EffectBuilder::damageTarget( Entity::CharaPtr& target, uint32_t amount, Common::ActionHitSeverityType severity ) void EffectBuilder::damageTarget( Entity::CharaPtr& target, uint32_t amount, Common::ActionHitSeverityType severity )
{ {
auto resultList = getResultList( target ); auto resultList = getResultList( target );

View file

@ -18,6 +18,9 @@ namespace Sapphire::World::Action
void selfHeal( Entity::CharaPtr& target, Entity::CharaPtr& source, uint32_t amount, void selfHeal( Entity::CharaPtr& target, Entity::CharaPtr& source, uint32_t amount,
Common::ActionHitSeverityType severity = Common::ActionHitSeverityType::NormalHeal ); Common::ActionHitSeverityType severity = Common::ActionHitSeverityType::NormalHeal );
void restoreMP( Entity::CharaPtr& target, Entity::CharaPtr& source, uint32_t amount,
Common::ActionHitSeverityType severity = Common::ActionHitSeverityType::NormalHeal );
void damageTarget( Entity::CharaPtr& target, uint32_t amount, void damageTarget( Entity::CharaPtr& target, uint32_t amount,
Common::ActionHitSeverityType severity = Common::ActionHitSeverityType::NormalDamage ); Common::ActionHitSeverityType severity = Common::ActionHitSeverityType::NormalDamage );

View file

@ -57,6 +57,14 @@ void EffectResult::heal( uint32_t amount, Sapphire::Common::ActionHitSeverityTyp
m_type = Common::ActionEffectType::Heal; m_type = Common::ActionEffectType::Heal;
} }
void EffectResult::restoreMP( uint32_t amount )
{
m_value = amount;
m_flag = 0x80;
m_type = Common::ActionEffectType::MpGain;
}
void EffectResult::startCombo( uint16_t actionId ) void EffectResult::startCombo( uint16_t actionId )
{ {
m_value = actionId; m_value = actionId;
@ -100,6 +108,12 @@ void EffectResult::execute()
break; break;
} }
case Common::ActionEffectType::MpGain:
{
m_target->restoreMP( m_value );
break;
}
default: default:
break; break;
} }

View file

@ -17,6 +17,7 @@ namespace Sapphire::World::Action
void damage( uint32_t amount, Common::ActionHitSeverityType severity ); void damage( uint32_t amount, Common::ActionHitSeverityType severity );
void heal( uint32_t amount, Common::ActionHitSeverityType severity, bool isSelfHeal ); void heal( uint32_t amount, Common::ActionHitSeverityType severity, bool isSelfHeal );
void restoreMP( uint32_t amount );
void startCombo( uint16_t actionId ); void startCombo( uint16_t actionId );
void comboVisualEffect(); void comboVisualEffect();

View file

@ -438,6 +438,18 @@ void Sapphire::Entity::Chara::heal( uint32_t amount )
sendStatusUpdate(); sendStatusUpdate();
} }
void Sapphire::Entity::Chara::restoreMP( uint32_t amount )
{
if( ( m_mp + amount ) > getMaxMp() )
{
m_mp = getMaxMp();
}
else
m_mp += amount;
sendStatusUpdate();
}
/*! /*!
Send an HpMpTp update to players in range ( and potentially to self ) Send an HpMpTp update to players in range ( and potentially to self )
TODO: poor naming, should be changed. Status is not HP. Also should be virtual TODO: poor naming, should be changed. Status is not HP. Also should be virtual

View file

@ -263,6 +263,8 @@ namespace Sapphire::Entity
virtual void heal( uint32_t amount ); virtual void heal( uint32_t amount );
virtual void restoreMP( uint32_t amount );
virtual bool checkAction(); virtual bool checkAction();
virtual void update( uint64_t tickCount ); virtual void update( uint64_t tickCount );