- Notifications
You must be signed in to change notification settings - Fork 181
feat(stats_calc): recalculate character stats based on master skills #300
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| | @@ -19,6 +19,47 @@ | |
| | ||
| using namespace SEASON3B; | ||
| | ||
| namespace | ||
| { | ||
| float GetMasterSkillValue(ActionSkillType skill) | ||
| { | ||
| return CharacterAttribute->MasterSkillInfo[skill].GetSkillValue(); | ||
| } | ||
| | ||
| float GetMasterSkillValue(ActionSkillType firstSkill, ActionSkillType secondSkill) | ||
| { | ||
| const auto firstSkillInfo = CharacterAttribute->MasterSkillInfo[firstSkill]; | ||
| const auto secondSkillInfo = CharacterAttribute->MasterSkillInfo[secondSkill]; | ||
| | ||
| if (secondSkillInfo.GetSkillLevel() > firstSkillInfo.GetSkillLevel()) | ||
| { | ||
| return secondSkillInfo.GetSkillValue(); | ||
| } | ||
| | ||
| return firstSkillInfo.GetSkillValue(); | ||
| } | ||
| | ||
| int GetMasterSkillValueAsInt(ActionSkillType skill) | ||
| { | ||
| return static_cast<int>(GetMasterSkillValue(skill)); | ||
| } | ||
| | ||
| int GetMasterSkillValueAsInt(ActionSkillType firstSkill, ActionSkillType secondSkill) | ||
| { | ||
| return static_cast<int>(GetMasterSkillValue(firstSkill, secondSkill)); | ||
| } | ||
| | ||
| float ClampDefenseSuccessRateMultiplier(float multiplier) | ||
| { | ||
| if (multiplier < 1.0f) | ||
| { | ||
| return 1.0f; | ||
| } | ||
| | ||
| return multiplier; | ||
| Comment on lines +54 to +59 Contributor There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. | ||
| } | ||
| } | ||
| | ||
| SEASON3B::CNewUICharacterInfoWindow::CNewUICharacterInfoWindow() | ||
| { | ||
| m_pNewUIMng = NULL; | ||
| | @@ -454,83 +495,20 @@ void SEASON3B::CNewUICharacterInfoWindow::RenderAttribute() | |
| | ||
| int add_attack_success_rate_pvm = 0; | ||
| int add_attack_success_rate_pvp = 0; | ||
| int add_defense_success_rate_pvm = 0; | ||
| float add_defense_success_rate_pvm = 0.0f; | ||
| int add_defense_success_rate_pvp = 0; | ||
| int add_attack_dmg_max = 0; | ||
| int add_attack_dmg_min = 0; | ||
| int add_defense = 0; | ||
| int add_magic_damage_min = 0; | ||
| int add_magic_damage_max = 0; | ||
| | ||
| for (int i = 0; i < MAX_SKILLS; ++i) | ||
| { | ||
| auto currentSkill = CharacterAttribute->Skill[i]; | ||
| if (currentSkill < AT_SKILL_MASTER_BEGIN || currentSkill > AT_SKILL_MASTER_END) | ||
| { | ||
| continue; | ||
| } | ||
| | ||
| auto skillValue = CharacterAttribute->MasterSkillInfo[currentSkill].GetSkillValue(); | ||
| switch (currentSkill) | ||
| { | ||
| case AT_SKILL_AttackSuccRateInc: | ||
| case AT_SKILL_IncreaseAttackSuccessRate: | ||
| add_attack_success_rate_pvm = skillValue; | ||
| break; | ||
| case AT_SKILL_PvPAttackRate: | ||
| case AT_SKILL_IncreasePvPAttackRate: | ||
| add_attack_success_rate_pvp = skillValue; | ||
| break; | ||
| case AT_SKILL_DefenseSuccessRateInc: | ||
| case AT_SKILL_IncreaseDefenseSuccessRate: | ||
| add_defense_success_rate_pvm = skillValue; | ||
| break; | ||
| case AT_SKILL_PvPDefenceRateInc: | ||
| case AT_SKILL_IncreasePvPDefenseRate: | ||
| add_defense_success_rate_pvp = skillValue; | ||
| break; | ||
| case AT_SKILL_DefenseIncrease: | ||
| case AT_SKILL_IncreasesDefense: | ||
| add_defense = skillValue; | ||
| break; | ||
| case AT_SKILL_MinimumWizardryInc: | ||
| add_magic_damage_min = skillValue; | ||
| break; | ||
| // to be continued ... | ||
| // depending on the equipped weapons this may get complex. Maybe we should leave these calculations to the server. | ||
| } | ||
| /* | ||
| else | ||
| if (CharacterAttribute->Skill[i] >= AT_SKILL_MAX_ATTACKRATE_UP && CharacterAttribute->Skill[i] < AT_SKILL_MAX_ATTACKRATE_UP + 5) | ||
| { | ||
| add_attack_dmg_max = SkillAttribute[CharacterAttribute->Skill[i]].Damage; | ||
| } | ||
| else | ||
| if (CharacterAttribute->Skill[i] >= AT_SKILL_MAX_ATT_MAGIC_UP && CharacterAttribute->Skill[i] < AT_SKILL_MAX_ATT_MAGIC_UP + 5) | ||
| { | ||
| add_mana_max = add_attack_dmg_max = SkillAttribute[CharacterAttribute->Skill[i]].Damage; | ||
| } | ||
| else | ||
| if (CharacterAttribute->Skill[i] >= AT_SKILL_MIN_ATT_MAGIC_UP && CharacterAttribute->Skill[i] < AT_SKILL_MIN_ATT_MAGIC_UP + 5) | ||
| { | ||
| add_magic_damage_min = add_attack_dmg_min = SkillAttribute[CharacterAttribute->Skill[i]].Damage; | ||
| } | ||
| else | ||
| if (CharacterAttribute->Skill[i] >= at_skill_mana && CharacterAttribute->Skill[i] < AT_SKILL_MAX_MANA_UP + 5) | ||
| { | ||
| add_mana_max = SkillAttribute[CharacterAttribute->Skill[i]].Damage; | ||
| } | ||
| else | ||
| if (CharacterAttribute->Skill[i] >= AT_SKILL_MIN_MANA_UP && CharacterAttribute->Skill[i] < AT_SKILL_MIN_MANA_UP + 5) | ||
| { | ||
| add_magic_damage_min = SkillAttribute[CharacterAttribute->Skill[i]].Damage; | ||
| } | ||
| else | ||
| if (CharacterAttribute->Skill[i] >= AT_SKILL_MIN_ATTACKRATE_UP && CharacterAttribute->Skill[i] < AT_SKILL_MIN_ATTACKRATE_UP + 5) | ||
| { | ||
| add_attack_dmg_min = SkillAttribute[CharacterAttribute->Skill[i]].Damage; | ||
| }*/ | ||
| } | ||
| add_attack_success_rate_pvm = GetMasterSkillValueAsInt(AT_SKILL_AttackSuccRateInc, AT_SKILL_IncreaseAttackSuccessRate); | ||
| add_attack_success_rate_pvp = GetMasterSkillValueAsInt(AT_SKILL_PvPAttackRate, AT_SKILL_IncreasePvPAttackRate); | ||
| add_defense_success_rate_pvm = GetMasterSkillValue(AT_SKILL_DefenseSuccessRateInc, AT_SKILL_IncreaseDefenseSuccessRate); | ||
| add_defense_success_rate_pvp = GetMasterSkillValueAsInt(AT_SKILL_PvPDefenceRateInc, AT_SKILL_IncreasePvPDefenseRate); | ||
| add_defense = GetMasterSkillValueAsInt(AT_SKILL_DefenseIncrease, AT_SKILL_IncreasesDefense); | ||
| add_magic_damage_min = GetMasterSkillValueAsInt(AT_SKILL_MinimumWizardryInc); | ||
| | ||
| ITEM* pWeaponRight = &CharacterMachine->Equipment[EQUIPMENT_WEAPON_RIGHT]; | ||
| ITEM* pWeaponLeft = &CharacterMachine->Equipment[EQUIPMENT_WEAPON_LEFT]; | ||
| | @@ -986,31 +964,34 @@ void SEASON3B::CNewUICharacterInfoWindow::RenderAttribute() | |
| | ||
| wchar_t strBlocking[256]; | ||
| | ||
| const float defenseSuccessRateMultiplier = ClampDefenseSuccessRateMultiplier(add_defense_success_rate_pvm); | ||
| const int defenseSuccessRate = static_cast<int>(CharacterAttribute->SuccessfulBlocking * defenseSuccessRateMultiplier); | ||
| | ||
| int nAdd_FulBlocking = 0; | ||
| if (g_isCharacterBuff((&Hero->Object), eBuff_Def_up_Ourforces)) | ||
| { | ||
| int _AddStat = (10 + (float)(CharacterAttribute->Energy - 80) / 10); | ||
| if (_AddStat > 100) | ||
| _AddStat = 100; | ||
| | ||
| _AddStat = CharacterAttribute->SuccessfulBlocking * _AddStat / 100; | ||
| _AddStat = defenseSuccessRate * _AddStat / 100; | ||
| nAdd_FulBlocking += _AddStat; | ||
| } | ||
| | ||
| if (bDexSuccess) | ||
| { | ||
| // memorylock | ||
| if (CharacterAttribute->SuccessfulBlocking > 0) | ||
| if (defenseSuccessRate > 0) | ||
| { | ||
| if (nAdd_FulBlocking) | ||
| { | ||
| mu_swprintf(strBlocking, GlobalText[206], t_adjdef + maxdefense + iChangeRingAddDefense, | ||
| CharacterAttribute->SuccessfulBlocking, (CharacterAttribute->SuccessfulBlocking) / 10 + nAdd_FulBlocking); | ||
| defenseSuccessRate, (defenseSuccessRate) / 10 + nAdd_FulBlocking); | ||
| } | ||
| else | ||
| { | ||
| mu_swprintf(strBlocking, GlobalText[206], t_adjdef + maxdefense + iChangeRingAddDefense, | ||
| CharacterAttribute->SuccessfulBlocking, (CharacterAttribute->SuccessfulBlocking) / 10); | ||
| defenseSuccessRate, (defenseSuccessRate) / 10); | ||
| } | ||
| } | ||
| else | ||
| | @@ -1020,15 +1001,15 @@ void SEASON3B::CNewUICharacterInfoWindow::RenderAttribute() | |
| } | ||
| else | ||
| { | ||
| if (CharacterAttribute->SuccessfulBlocking > 0) | ||
| if (defenseSuccessRate > 0) | ||
| { | ||
| if (nAdd_FulBlocking) | ||
| { | ||
| mu_swprintf(strBlocking, GlobalText[206], t_adjdef + maxdefense + iChangeRingAddDefense, CharacterAttribute->SuccessfulBlocking, nAdd_FulBlocking); | ||
| mu_swprintf(strBlocking, GlobalText[206], t_adjdef + maxdefense + iChangeRingAddDefense, defenseSuccessRate, nAdd_FulBlocking); | ||
| } | ||
| else | ||
| { | ||
| mu_swprintf(strBlocking, GlobalText[208], t_adjdef + maxdefense + iChangeRingAddDefense, CharacterAttribute->SuccessfulBlocking); | ||
| mu_swprintf(strBlocking, GlobalText[208], t_adjdef + maxdefense + iChangeRingAddDefense, defenseSuccessRate); | ||
| } | ||
| } | ||
| else | ||
| | ||
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This function can be made more concise and efficient. Using
const auto&avoids unnecessary copies of the skill info objects, and a ternary operator can simplify the logic.