📄 characterformula.cpp
字号:
#include "StdAfx.h"
#include "CharacterFormula.h"
#include "misc.h"
#include "ItemOptionHeader.h"
#include "NumericValues.h"
#include "FormulaRatioParser.h"
BYTE g_ArmorDamageRatio[eARMOR_TYPE_MAX][eMELEE_TYPE_MAX] =
{
// NONE, 海扁, 骂福扁, 鸥拜
{ 100, 100, 100, 100 }, // NONE
{ 100, 100, 100, 120 }, // eARMOR_HARD == 1,
{ 100, 100, 120, 100 }, // eARMOR_MEDIUM,
{ 100, 120, 100, 100 }, // eARMOR_SOFT,
{ 100, 20, 20, 150 }, // eARMOR_SIEGE,
{ 100, 100, 100, 100 } // eARMOR_UNARMOR,
};
BYTE GetArmorDamageRatio(eARMOR_TYPE armorType, eMELEE_TYPE attackType)
{
SASSERT( armorType < eARMOR_TYPE_MAX, "[GetArmorDamageRatio] Invalid armorType" );
SASSERT( attackType < eMELEE_TYPE_MAX, "[GetArmorDamageRatio] Invalid attackType" );
return g_ArmorDamageRatio[armorType][attackType];
}
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
// 概锅 荤侩秦具 登绰 窃荐甸
////////////////////////////////////////////////////////////////////////////////////////////////////////////////
DWORD FastRecoveryTime( DWORD delayTime, SHORT Dexterity, DWORD dwItemFastRecovery, DWORD dwSkillFastRecovery )
{
return (DWORD)( delayTime * ( 100 / (100+Dexterity/30+dwItemFastRecovery+dwSkillFastRecovery) ) );
}
BOOL IsAttSuccess( eCHAR_TYPE eCharType, LEVELTYPE LV, SHORT Dexterity, DWORD dwItemAttSuccessInc, DWORD dwSKillAttSuccessInc )
{
DWORD dwPercentage = 0;
switch( eCharType )
{
case eCHAR_DRAGON:
dwPercentage = (DWORD)( (LV*3) + (Dexterity*8) + dwItemAttSuccessInc + dwSKillAttSuccessInc );
break;
case eCHAR_BERSERKER:
dwPercentage = (DWORD)( (LV*3) + (Dexterity*6) + dwItemAttSuccessInc + dwSKillAttSuccessInc );
break;
case eCHAR_SHADOW:
dwPercentage = (DWORD)( (LV*3) + (Dexterity*9) + dwItemAttSuccessInc + dwSKillAttSuccessInc );
break;
case eCHAR_VALKYRIE:
dwPercentage = (DWORD)( (LV*3) + (Dexterity*10) + dwItemAttSuccessInc + dwSKillAttSuccessInc );
break;
case eCHAR_MAGICIAN: //< 拱府客 付过栏肺 唱炊促.!!!!!
dwPercentage = (DWORD)( (LV*3) + (Dexterity*6) + dwItemAttSuccessInc + dwSKillAttSuccessInc );
break;
default:
{
SASSERT( FALSE, "Wrong Char_Type in CalcAttackSpeed()" );
}
}
if( random(1, 100) <= (int)dwPercentage )
return TRUE;
return FALSE;
}
// 敲饭捞绢 HP, MP 雀汗樊
int CalcHPRecover( eCHAR_TYPE eCharType, DWORD maxHP, BYTE byCharState, LEVELTYPE Level )
{
int recoverValue = 0;
float recoverRatio = 1.0f;
// 旧扁 惑怕老 版快 雀汗樊捞 撇府促.
if( byCharState == eCHAR_CONDITION_SITDOWN )
{
recoverRatio = 2.0f;
}
switch( eCharType )
{
case eCHAR_DRAGON : recoverValue = 4; break;
case eCHAR_BERSERKER: recoverValue = 5; break;
case eCHAR_SHADOW : recoverValue = 4; break;
case eCHAR_VALKYRIE : recoverValue = 3.5; break;
case eCHAR_MAGICIAN : recoverValue = 3; break;
default:
{
SASSERT( FALSE, "Wrong Char_Type in CalcHPRecover()" );
}
}
int RecoverHP = (int)(maxHP * recoverRatio / recoverValue + Level / 5 ) - 2;
if( 0 > RecoverHP)
RecoverHP = 1;
return RecoverHP;
}
int CalcMPRecover( eCHAR_TYPE eCharType, DWORD spirit, BYTE byCharState )
{
int recoverValue = 0;
float recoverRatio = 1.0f;
// 旧扁 惑怕老 版快 雀汗樊捞 撇府促.
if( byCharState == eCHAR_CONDITION_SITDOWN )
{
recoverRatio = 3.0f;
}
switch( eCharType )
{
case eCHAR_DRAGON : recoverValue = 1; break;
// 滚辑目/绩档快绰 鸥拜拌 雀汗捞扼.. 傍拜/嘎阑锭 MP啊 雀汗等促.
case eCHAR_BERSERKER: return -1; // 18
case eCHAR_SHADOW : return -1; // 8
case eCHAR_VALKYRIE : recoverValue = 1; break;
case eCHAR_MAGICIAN : recoverValue = 1; break;
default:
{
SASSERT( FALSE, "Wrong Char_Type in CalcMPRecover()" );
}
}
int RecoverMP = (int)(spirit * recoverRatio / recoverValue / 5) +1;
return RecoverMP;
}
DWORD CalcMPRecoverByAttack( eCHAR_TYPE eCharType, DWORD spirit, DWORD skillRecoverPercent, DWORD skillRequireMP )
{
DWORD recoverValue = 0;
switch( eCharType )
{
case eCHAR_DRAGON : return 0;
// 滚辑目/绩档快绰 鸥拜拌 雀汗捞扼.. 傍拜/嘎阑锭 MP啊 雀汗等促.
case eCHAR_BERSERKER: recoverValue = 18; break;
case eCHAR_SHADOW : recoverValue = 8; break;
case eCHAR_VALKYRIE : return 0;
case eCHAR_MAGICIAN : return 0;
default:
{
SASSERT( FALSE, "Wrong Char_Type in CalcMPRecover()" );
}
}
// MP/SP 雀汗剧 = (隆脚仿/ 某腐磐喊 惑荐)*欺季飘 雀汗 胶懦 + 胶懦 夸备 SP,MP/5 + 3
DWORD regenMP = spirit/recoverValue * skillRecoverPercent/100 + skillRequireMP/5 + 1;
return regenMP;
}
DWORD CalcMPRecoverByAttacked( eCHAR_TYPE eCharType, DWORD spirit, DAMAGETYPE damage )
{
DWORD recoverValue = 0;
switch( eCharType )
{
case eCHAR_DRAGON : return 0;
// 滚辑目/绩档快绰 鸥拜拌 雀汗捞扼.. 傍拜/嘎阑锭 MP啊 雀汗等促.
case eCHAR_BERSERKER: recoverValue = 18; break;
case eCHAR_SHADOW : recoverValue = 8; break;
case eCHAR_VALKYRIE : return 0;
case eCHAR_MAGICIAN : return 0;
default:
{
SASSERT( FALSE, "Wrong Char_Type in CalcMPRecover()" );
}
}
// (沥脚仿/某腐磐喊 惑荐) + 角力 罐篮 单固瘤/30 + 3
DWORD regenMP = spirit / recoverValue + damage/30 + 1;
return regenMP;
}
// HP, MP 雀汗樊(阁胶磐)
int CalcNPCHPRecover( DWORD maxHP, DWORD recoverRatio )
{
return (int)( maxHP * 0.005f * recoverRatio );
}
int CalcNPCMPRecover( DWORD maxMP, DWORD recoverRatio )
{
return (int)( maxMP * 0.01f * recoverRatio );
}
// 1 ~ 某腐磐 傍拜 己傍’ 荤捞俊辑 罚待 窍霸 唱柯 荐摹啊
// 阁胶磐 Lv + 阁胶磐 雀乔’焊促 臭阑 版快 傍拜捞 己傍茄促.
BOOL IsPhysicalAttackSuccess(LEVELTYPE targetLV, DWORD attackRate, DWORD avoidRate)
{
DWORD attackDice = random(1, attackRate);
if (attackDice > targetLV + avoidRate)
{
return TRUE;
}
return FALSE;
}
BOOL IsMagicAttackSuccess()
{
// 付过篮 公炼扒 己傍
return TRUE;
}
DWORD GetKillExpOfParty( BYTE byRoomBonusType, DWORD partymemberNum, LEVELTYPE partyTotalLV, LEVELTYPE attackerLV,
LEVELTYPE targetLV, BYTE byNPCGrade, DAMAGETYPE attackDamage, DWORD targetMaxHP)
{
if( !partymemberNum || !targetMaxHP || !partyTotalLV ) return 0;
DWORD ResultExp = 0, DecisionExp, DamageExp;
// 颇萍盔狼 乞闭饭骇
//LEVELTYPE PartyLV = (LEVELTYPE)(partyTotalLV / partymemberNum);
// 炼沥%蔼
float fLevelRatio = GetExpLevelRatio( abs(attackerLV - targetLV) );
// 殿鞭利侩%蔼
float fRankRatio = GetExpRankRatio( byNPCGrade );
// 清泼可记%蔼
float fHuntingOptionRatio = GetRoomBonusTypeRatio( byRoomBonusType );
// 胶农赋飘 硅啦%蔼
BASE_FORMULA_RATIOINFO *pFormulaRatio = FormulaRatioParser::Instance()->GetFormulaRatio( RATIO_TYPE_EXP );
float fScriptRatio = 1.0f;
if( pFormulaRatio ) fScriptRatio = pFormulaRatio->m_fRatio;
// 胶农赋飘 眠啊硅啦%蔼
BASE_FORMULA_RATIOINFO *pFormulaAddRatio = FormulaRatioParser::Instance()->GetFormulaRatio( RATIO_TYPE_ADDEXP );
float fScriptAddRatio = 1.0f;
if( pFormulaAddRatio ) fScriptAddRatio = pFormulaAddRatio->m_fRatio;
// Seed 版氰摹 拌魂
float fSeedExp = (targetLV + 45) * 0.03f;
// 弥家 版氰摹
float fMinExp = (DWORD)(fSeedExp*fSeedExp*fSeedExp*fSeedExp + 3 * fSeedExp*fSeedExp*fSeedExp - 7) * fRankRatio * fScriptRatio;
// 犬沥 版氰摹
DecisionExp = (DWORD)( fMinExp + random(0, fMinExp/2) );
// 单固瘤寸 版氰摹
DamageExp = ( attackDamage * DecisionExp ) / targetMaxHP;
// 弥辆 裙垫 版氰摹
ResultExp = (DWORD)( DamageExp * CalcExpRatioNum(partymemberNum) * GetAdditionalExpRatio(partymemberNum) * attackerLV / partyTotalLV * fLevelRatio * fScriptAddRatio );
if ( 0 == ResultExp )
{
ResultExp = 1;
}
return ResultExp;
}
// Exp 硅啦荐
float CalcExpRatioNum( DWORD partymemberNum )
{
return (float)partymemberNum;
}
//----------------------------------------------------------------------------------------------------
// 单固瘤 拌魂 包访(扁檬 傍侥甸)
//----------------------------------------------------------------------------------------------------
// 1瞒 单固瘤 拌魂
int CalcFirstDamage( int iBaseAttackPower, int iSkillAttackPower, SHORT sSkillStat,
float fSkillPercentDamage, eATTACK_TYPE eAttackType )
{
float fRate;
if( eATTACK_TYPE_PHYSICAL_OPTION == eAttackType )
fRate = 1.0;
else if( eATTACK_TYPE_MAGIC_OPTION == eAttackType )
fRate = 1.0;
else
fRate = 1.0; // 惯积窍瘤 富酒具 登绰 蔼!!
int iFirstDamage = (int)( (iBaseAttackPower + iSkillAttackPower + sSkillStat / 3) * ( fRate + fSkillPercentDamage ) );
iFirstDamage = (int)( max( 0, iFirstDamage ) );
return iFirstDamage;
}
// 2瞒 单固瘤 拌魂(拱府)
int CalcSecondDamage_Physical( int iFirstMinDamage, int iFirstMaxDamage, int iBonusDamage, int iTargetDefense, float fArmorDamageRatio )
{
int iFirstDamage = random( iFirstMinDamage, iFirstMaxDamage );
int iSecondDamage = 0;
if( iFirstDamage >= (int)(iTargetDefense/3) )
{
iSecondDamage = iFirstDamage - iTargetDefense/3;
}
iSecondDamage = (int)( iSecondDamage * fArmorDamageRatio );
iSecondDamage += iBonusDamage;
if( iSecondDamage < 0 ) iSecondDamage = 0;
// 弥家焊厘阑 眉农茄促.
if( iSecondDamage <= (int)( iFirstMinDamage / 20 ) )
{
int damageBound = iFirstMinDamage / 40 + 1;
iSecondDamage = damageBound + random( 0, damageBound );
}
return iSecondDamage;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -