From 0efcfefa8c56f312f58bc6e2caf908bbd0099da7 Mon Sep 17 00:00:00 2001 From: NotAdam Date: Sun, 30 Jun 2019 19:51:18 +1000 Subject: [PATCH] cap level to 80, enable shadowbringers, new mp calc --- src/common/Common.h | 3 + src/world/Action/Action.cpp | 2 +- src/world/Actor/Player.cpp | 2 +- src/world/Math/CalcStats.cpp | 100 +++--------------- src/world/Math/CalcStats.h | 9 -- .../PacketWrappers/PlayerSetupPacket.h | 4 +- 6 files changed, 23 insertions(+), 97 deletions(-) diff --git a/src/common/Common.h b/src/common/Common.h index 5965228f..05463273 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -21,6 +21,9 @@ namespace Sapphire::Common const int32_t INVALID_GAME_OBJECT_ID = 0xE0000000; const uint64_t INVALID_GAME_OBJECT_ID64 = 0xE0000000; + const uint16_t MAX_PLAYER_LEVEL = 80; + const uint8_t CURRENT_EXPANSION_ID = 3; + /*! * @brief The maximum length (in ms) of a combo before it is canceled/voided. * diff --git a/src/world/Action/Action.cpp b/src/world/Action/Action.cpp index e4d67f4d..ba1665d0 100644 --- a/src/world/Action/Action.cpp +++ b/src/world/Action/Action.cpp @@ -466,7 +466,7 @@ bool Action::Action::primaryCostCheck( bool subtractCosts ) { auto curMp = m_pSource->getMp(); - auto cost = Math::CalcStats::calculateMpCost( *m_pSource, m_primaryCost ); + auto cost = m_primaryCost * 100; if( curMp < cost ) return false; diff --git a/src/world/Actor/Player.cpp b/src/world/Actor/Player.cpp index adab91ab..f51d4eb0 100644 --- a/src/world/Actor/Player.cpp +++ b/src/world/Actor/Player.cpp @@ -695,7 +695,7 @@ void Sapphire::Entity::Player::gainExp( uint32_t amount ) queuePacket( makeActorControl143( getId(), GainExpMsg, static_cast< uint8_t >( getClass() ), amount ) ); - if( level >= 70 ) // temporary fix for leveling over levelcap + if( level >= Common::MAX_PLAYER_LEVEL ) // temporary fix for leveling over levelcap { queuePacket( makeActorControl143( getId(), UpdateUiExp, static_cast< uint8_t >( getClass() ), amount ) ); return; diff --git a/src/world/Math/CalcStats.cpp b/src/world/Math/CalcStats.cpp index b455b48a..f3cbc566 100644 --- a/src/world/Math/CalcStats.cpp +++ b/src/world/Math/CalcStats.cpp @@ -15,7 +15,7 @@ using namespace Sapphire::Math; using namespace Sapphire::Entity; -const int levelTable[71][7] = +const int levelTable[81][7] = { // PIE, MP, MAIN,SUB,DIV,HP,ELMT,THREAT { 1, 1, 1, 1, 1, 1, 1 }, @@ -88,7 +88,19 @@ const int levelTable[71][7] = { 830, 10560, 268, 361, 1643, 3300, 292 }, { 860, 10980, 276, 362, 1802, 3400, 293 }, { 890, 11450, 284, 363, 1978, 3500, 294 }, - { 890, 12000, 292, 364, 2170, 3600, 295 } + { 890, 12000, 292, 364, 2170, 3600, 295 }, + + // todo: add proper shbr values + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, + { 890, 12000, 292, 364, 2170, 3600, 295 }, }; /* @@ -115,8 +127,8 @@ float CalcStats::calculateBaseStat( const Chara& chara ) float base = 0.0f; uint8_t level = chara.getLevel(); - if( level > 70 ) - level = 70; + if( level > Common::MAX_PLAYER_LEVEL ) + level = Common::MAX_PLAYER_LEVEL; return static_cast< float >( levelTable[level][2] ); } @@ -187,86 +199,6 @@ uint32_t CalcStats::calculateMaxMp( PlayerPtr pPlayer, Sapphire::FrameworkPtr pF return result; } -uint16_t CalcStats::calculateMpCost( const Sapphire::Entity::Chara& chara, uint16_t baseCost ) -{ - auto level = chara.getLevel(); - - // each level range is 1-10, 11-20, 21-30, ... therefore: - // level 50 should be in the 4th group, not the 5t - // dividing by 10 on the border will break this unless we subtract 1 - auto levelGroup = std::max< uint8_t >( level - 1, 1 ) / 10; - - float cost = baseCost; - - // thanks to andrew for helping me figure this shit out - // played with this some more and it seems to be accurate for everything i've tried - switch( levelGroup ) - { - // level 1-10 - case 0: - { - // r^2 = 0.9999 - cost = 0.0952f * level + 0.9467f; - break; - } - - // level 11-20 - case 1: - { - // r^2 = 1 - cost = 0.19f * level; - break; - } - - // level 21-30 - case 2: - { - // r^2 = 1 - cost = 0.38f * level - 3.8f; - break; - } - - // level 31-40 - case 3: - { - // r^2 = 1 - cost = 0.6652f * level - 12.358f; - break; - } - - // level 41-50 - case 4: - { - // r^2 = 1 - cost = 1.2352f * level - 35.159f; - break; - } - - // level 51-60 - case 5: - { - // r^2 = 1 - cost = 0.0654f * std::exp( 0.1201f * level ); - break; - } - - // level 61-70 - case 6: - { - // r^2 = 0.9998 - cost = 0.2313f * ( level * level ) - 26.98f * level + 875.21f; - break; - } - - default: - { - return 0; - } - } - - return static_cast< uint16_t >( std::round( cost * baseCost ) ); -} - float CalcStats::blockProbability( const Chara& chara ) { auto level = chara.getLevel(); diff --git a/src/world/Math/CalcStats.h b/src/world/Math/CalcStats.h index 92402124..ad8a086f 100644 --- a/src/world/Math/CalcStats.h +++ b/src/world/Math/CalcStats.h @@ -19,15 +19,6 @@ namespace Sapphire::Math static uint32_t calculateMaxHp( Sapphire::Entity::PlayerPtr pPlayer, FrameworkPtr pFw ); - /*! - * @brief Calculates the MP cost of a spell given its base cost - * - * @param chara The Chara that is casting the action - * @param baseCost The action cost - * @return The total MP to be consumed by a successful cast - */ - static uint16_t calculateMpCost( const Sapphire::Entity::Chara& chara, uint16_t baseCost ); - /*! * @brief Calculates the probability of a block happening */ diff --git a/src/world/Network/PacketWrappers/PlayerSetupPacket.h b/src/world/Network/PacketWrappers/PlayerSetupPacket.h index bc2ca1e0..2424e651 100644 --- a/src/world/Network/PacketWrappers/PlayerSetupPacket.h +++ b/src/world/Network/PacketWrappers/PlayerSetupPacket.h @@ -71,8 +71,8 @@ namespace Sapphire::Network::Packets::Server memcpy( m_data.howto, player.getHowToArray(), sizeof( m_data.howto ) ); // possibly max level or current level - m_data.maxLevel = 0x46; - m_data.expansion = 2; + m_data.maxLevel = Common::MAX_PLAYER_LEVEL; + m_data.expansion = Common::CURRENT_EXPANSION_ID; // df stuff // todo: actually do this properly