mirror of
https://github.com/SapphireServer/Sapphire.git
synced 2025-04-27 22:57:45 +00:00
Style, commenting;
This commit is contained in:
parent
f75aa3767e
commit
e1f6a13f07
2 changed files with 20 additions and 37 deletions
|
@ -1,15 +1,12 @@
|
||||||
#include "CalcBattle.h"
|
|
||||||
|
|
||||||
#include <src/servers/Server_Common/Exd/ExdData.h>
|
#include <src/servers/Server_Common/Exd/ExdData.h>
|
||||||
#include <src/servers/Server_Common/Logging/Logger.h>
|
|
||||||
|
|
||||||
|
#include "CalcBattle.h"
|
||||||
#include "Actor.h"
|
#include "Actor.h"
|
||||||
#include "Player.h"
|
#include "Player.h"
|
||||||
|
|
||||||
using namespace Core::Entity;
|
using namespace Core::Entity;
|
||||||
|
|
||||||
extern Core::Data::ExdData g_exdData;
|
extern Core::Data::ExdData g_exdData;
|
||||||
extern Core::Logger g_log;
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Class used for battle-related formulas and calculations.
|
Class used for battle-related formulas and calculations.
|
||||||
|
@ -28,65 +25,58 @@ extern Core::Logger g_log;
|
||||||
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
uint32_t Core::Entity::CalcBattle::calculateBaseStat(PlayerPtr pPlayer)
|
// Don't know too much about this formula, but seems to work for some of the levels tested.
|
||||||
{
|
// Originally from Player.cpp, calculateStats().
|
||||||
// Don't know too much about this formula, but seems to work for some of the levels tested.
|
|
||||||
// Originally from Player.cpp, calculateStats().
|
|
||||||
|
|
||||||
|
uint32_t CalcBattle::calculateBaseStat( PlayerPtr pPlayer )
|
||||||
|
{
|
||||||
float base = 0.0f;
|
float base = 0.0f;
|
||||||
uint8_t level = pPlayer->getLevel();
|
uint8_t level = pPlayer->getLevel();
|
||||||
|
|
||||||
if (level < 51)
|
if (level < 51)
|
||||||
base = static_cast<uint32_t>(0.053f * (level * level) + (1.022f * level) - 0.907f + 20);
|
base = static_cast<uint32_t>( 0.053f * ( level * level ) + (1.022f * level) - 0.907f + 20 );
|
||||||
else
|
else
|
||||||
base = static_cast<uint32_t>(1.627f * level + 120.773f);
|
base = static_cast<uint32_t>( 1.627f * level + 120.773f );
|
||||||
|
|
||||||
return base;
|
return base;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Leggerless' HP Formula
|
||||||
// ROUNDDOWN(JobModHP * (BaseHP / 100)) + ROUNDDOWN(VitHPMod / 100 * (VIT - BaseDET))
|
// ROUNDDOWN(JobModHP * (BaseHP / 100)) + ROUNDDOWN(VitHPMod / 100 * (VIT - BaseDET))
|
||||||
|
|
||||||
uint32_t Core::Entity::CalcBattle::calculateMaxHp( PlayerPtr pPlayer )
|
uint32_t CalcBattle::calculateMaxHp( PlayerPtr pPlayer )
|
||||||
{
|
{
|
||||||
// TODO: Replace ApproxBaseHP with something that can get us a BaseHP reliably.
|
// TODO: Replace ApproxBaseHP with something that can get us a BaseHP reliably.
|
||||||
// Is there any way to pull BaseHP without having to manually use a pet for every level, and using the values from a table?
|
// Is there any way to pull BaseHP without having to manually use a pet for every level, and using the values from a table?
|
||||||
|
|
||||||
auto classInfoIt = g_exdData.m_classJobInfoMap.find(pPlayer->getClass());
|
auto classInfoIt = g_exdData.m_classJobInfoMap.find( pPlayer->getClass() );
|
||||||
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find(pPlayer->getLevel());
|
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
|
||||||
|
|
||||||
float baseStat = calculateBaseStat(pPlayer);
|
float baseStat = calculateBaseStat( pPlayer );
|
||||||
uint16_t vit = pPlayer->getStats().vit;
|
uint16_t vit = pPlayer->getStats().vit;
|
||||||
uint16_t hp_mod = paramGrowthInfoIt->second.hp_mod;
|
uint16_t hp_mod = paramGrowthInfoIt->second.hp_mod;
|
||||||
uint16_t jobModHp = classInfoIt->second.mod_hp;
|
uint16_t jobModHp = classInfoIt->second.mod_hp;
|
||||||
uint16_t approxBaseHp = 0; // Read above
|
uint16_t approxBaseHp = 0; // Read above
|
||||||
|
|
||||||
// These values are not precise.
|
// These values are not precise.
|
||||||
if (pPlayer->getLevel() > 50)
|
if ( pPlayer->getLevel() > 50 )
|
||||||
approxBaseHp = 0.1452f * paramGrowthInfoIt->second.mp_const + 1356.6f;
|
approxBaseHp = 0.1452f * paramGrowthInfoIt->second.mp_const + 1356.6f;
|
||||||
else
|
else
|
||||||
approxBaseHp = paramGrowthInfoIt->second.mp_const * 0.525f;
|
approxBaseHp = paramGrowthInfoIt->second.mp_const * 0.525f;
|
||||||
|
|
||||||
uint16_t result = floor( jobModHp * ( approxBaseHp / 100.0f ) ) + floor( hp_mod / 100.0f * ( vit - baseStat ) );
|
uint16_t result = floor( jobModHp * ( approxBaseHp / 100.0f ) ) + floor( hp_mod / 100.0f * ( vit - baseStat ) );
|
||||||
|
|
||||||
g_log.error("MaxHP: " + std::to_string(result)
|
|
||||||
+ " vit is " + std::to_string(vit)
|
|
||||||
+ " basestat is " + std::to_string(baseStat)
|
|
||||||
+ " hp_mod is " + std::to_string(hp_mod)
|
|
||||||
+ " approxBaseHp is " + std::to_string(approxBaseHp)
|
|
||||||
+ " jobmodhp is " + std::to_string(jobModHp)
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Floor[(Floor[(283 - 218) * (540/100)] + 8840) * (115/100)]
|
// Leggerless' MP Formula
|
||||||
// Floor[(Floor[(Piety - BaseDet) (PieMPMod / 100)] + BaseMP) * (JobModMP / 100)]
|
|
||||||
// ROUNDDOWN(((ROUNDDOWN(((PIE - BaseDET) * PieMPMod/100),0) + BaseMP) * JobModMP / 100),0)
|
// ROUNDDOWN(((ROUNDDOWN(((PIE - BaseDET) * PieMPMod/100),0) + BaseMP) * JobModMP / 100),0)
|
||||||
|
|
||||||
uint32_t Core::Entity::CalcBattle::calculateMaxMp( PlayerPtr pPlayer )
|
uint32_t CalcBattle::calculateMaxMp( PlayerPtr pPlayer )
|
||||||
{
|
{
|
||||||
auto classInfoIt = g_exdData.m_classJobInfoMap.find(pPlayer->getClass());
|
auto classInfoIt = g_exdData.m_classJobInfoMap.find( pPlayer->getClass() );
|
||||||
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find(pPlayer->getLevel());
|
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
|
||||||
|
|
||||||
float baseStat = calculateBaseStat( pPlayer );
|
float baseStat = calculateBaseStat( pPlayer );
|
||||||
uint16_t piety = pPlayer->getStats().pie;
|
uint16_t piety = pPlayer->getStats().pie;
|
||||||
|
@ -96,24 +86,16 @@ uint32_t Core::Entity::CalcBattle::calculateMaxMp( PlayerPtr pPlayer )
|
||||||
|
|
||||||
uint16_t result = floor( floor( piety - baseStat ) * ( piety_scalar / 100 ) + baseMp ) * jobModMp / 100;
|
uint16_t result = floor( floor( piety - baseStat ) * ( piety_scalar / 100 ) + baseMp ) * jobModMp / 100;
|
||||||
|
|
||||||
g_log.error("MaxMP: " + std::to_string(result)
|
|
||||||
+ " piety is " + std::to_string(piety)
|
|
||||||
+ " basestat is " + std::to_string(baseStat)
|
|
||||||
+ " mp_mod is " + std::to_string(piety_scalar)
|
|
||||||
+ " baseMp is " + std::to_string(baseMp)
|
|
||||||
+ " jobmodmp is " + std::to_string(jobModMp)
|
|
||||||
);
|
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
uint32_t Core::Entity::CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
|
uint32_t CalcBattle::calculateHealValue( PlayerPtr pPlayer, uint32_t potency )
|
||||||
{
|
{
|
||||||
auto classInfoIt = g_exdData.m_classJobInfoMap.find( pPlayer->getClass() );
|
auto classInfoIt = g_exdData.m_classJobInfoMap.find( pPlayer->getClass() );
|
||||||
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
|
auto paramGrowthInfoIt = g_exdData.m_paramGrowthInfoMap.find( pPlayer->getLevel() );
|
||||||
|
|
||||||
if (classInfoIt == g_exdData.m_classJobInfoMap.end() ||
|
if ( classInfoIt == g_exdData.m_classJobInfoMap.end() ||
|
||||||
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end())
|
paramGrowthInfoIt == g_exdData.m_paramGrowthInfoMap.end())
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@
|
||||||
#define _CALCBATTLE_H
|
#define _CALCBATTLE_H
|
||||||
|
|
||||||
#include <src/servers/Server_Common/Common.h>
|
#include <src/servers/Server_Common/Common.h>
|
||||||
|
|
||||||
#include "Actor.h"
|
#include "Actor.h"
|
||||||
|
|
||||||
namespace Core {
|
namespace Core {
|
||||||
|
|
Loading…
Add table
Reference in a new issue