diff --git a/L2BotCore/Domain/Entities/ArmorItem.h b/L2BotCore/Domain/Entities/ArmorItem.h index 8d7117e..a8ff049 100644 --- a/L2BotCore/Domain/Entities/ArmorItem.h +++ b/L2BotCore/Domain/Entities/ArmorItem.h @@ -99,8 +99,8 @@ namespace L2Bot::Domain::Entities const uint16_t enchantLevel, const Enums::ArmorType armorType, const Enums::CrystalType crystalType, - const uint16_t pDef, - const uint16_t mDef, + const uint32_t pDef, + const uint32_t mDef, const std::string& setEffect, const std::string& addSetEffect, const std::string& enchantEffect @@ -150,8 +150,8 @@ namespace L2Bot::Domain::Entities { bool isEquipped = 0; uint16_t enchantLevel = 0; - uint16_t pDef = 0; - uint16_t mDef = 0; + uint32_t pDef = 0; + uint32_t mDef = 0; bool isNewState = true; }; @@ -161,8 +161,8 @@ namespace L2Bot::Domain::Entities uint16_t m_EnchantLevel = 0; Enums::ArmorType m_ArmorType = Enums::ArmorType::none; Enums::CrystalType m_CrystalType = Enums::CrystalType::none; - uint16_t m_PDef = 0; - uint16_t m_MDef = 0; + uint32_t m_PDef = 0; + uint32_t m_MDef = 0; std::string m_SetEffect = ""; std::string m_AddSetEffect = ""; std::string m_EnchantEffect = ""; diff --git a/L2BotCore/Domain/Entities/ShieldItem.h b/L2BotCore/Domain/Entities/ShieldItem.h index 814f325..8722813 100644 --- a/L2BotCore/Domain/Entities/ShieldItem.h +++ b/L2BotCore/Domain/Entities/ShieldItem.h @@ -85,7 +85,7 @@ namespace L2Bot::Domain::Entities const uint16_t enchantLevel, const Enums::CrystalType crystalType, const int16_t evasion, - const uint16_t pDef, + const uint32_t pDef, const uint16_t defRate ) : BaseItem @@ -128,7 +128,7 @@ namespace L2Bot::Domain::Entities { bool isEquipped = 0; uint16_t enchantLevel = 0; - uint16_t pDef = 0; + uint32_t pDef = 0; bool isNewState = true; }; @@ -138,7 +138,7 @@ namespace L2Bot::Domain::Entities uint16_t m_EnchantLevel = 0; Enums::CrystalType m_CrystalType = Enums::CrystalType::none; int16_t m_Evasion = 0; - uint16_t m_PDef = 0; + uint32_t m_PDef = 0; uint16_t m_DefRate = 0; GetState m_PrevState = GetState(); diff --git a/L2BotCore/Domain/Entities/WeaponItem.h b/L2BotCore/Domain/Entities/WeaponItem.h index 0b20108..f357072 100644 --- a/L2BotCore/Domain/Entities/WeaponItem.h +++ b/L2BotCore/Domain/Entities/WeaponItem.h @@ -112,8 +112,8 @@ namespace L2Bot::Domain::Entities const Enums::WeaponType weaponType, const Enums::CrystalType crystalType, const uint8_t rndDamage, - const uint16_t pAtk, - const uint16_t mAtk, + const uint32_t pAtk, + const uint32_t mAtk, const uint16_t critical, const int8_t hitModify, const uint16_t atkSpd, @@ -175,8 +175,8 @@ namespace L2Bot::Domain::Entities { bool isEquipped = 0; uint16_t enchantLevel = 0; - uint16_t pAtk = 0; - uint16_t mAtk = 0; + uint32_t pAtk = 0; + uint32_t mAtk = 0; bool isNewState = true; }; @@ -187,8 +187,8 @@ namespace L2Bot::Domain::Entities Enums::WeaponType m_WeaponType = Enums::WeaponType::none; Enums::CrystalType m_CrystalType = Enums::CrystalType::none; uint8_t m_RndDamage = 0; - uint16_t m_PAtk = 0; - uint16_t m_MAtk = 0; + uint32_t m_PAtk = 0; + uint32_t m_MAtk = 0; uint16_t m_Critical = 0; int8_t m_HitModify = 0; uint16_t m_AtkSpd = 0; diff --git a/L2BotDll/Common/Common.cpp b/L2BotDll/Common/Common.cpp index c61ed45..d665e44 100644 --- a/L2BotDll/Common/Common.cpp +++ b/L2BotDll/Common/Common.cpp @@ -1,5 +1,7 @@ #include "pch.h" + #include "Common.h" +#include #include #pragma comment(lib, "Rpcrt4.lib") @@ -31,4 +33,14 @@ std::string GenerateUUID() wszUuid = NULL; return std::string(ws.begin(), ws.end()); +} + +std::uint32_t GetEnchantValue(const std::uint16_t baseValue, const std::uint16_t enchantLevel, const uint8_t lowEnchantDelta, const uint8_t highEnchantDelta) +{ + if (baseValue == 0) + { + return 0; + } + + return baseValue + enchantLevel * lowEnchantDelta + max(enchantLevel - 3, 0) * (highEnchantDelta - lowEnchantDelta); } \ No newline at end of file diff --git a/L2BotDll/Common/Common.h b/L2BotDll/Common/Common.h index 05d7856..b11b05d 100644 --- a/L2BotDll/Common/Common.h +++ b/L2BotDll/Common/Common.h @@ -1,6 +1,8 @@ #pragma once #include +#include std::string ConvertFromWideChar(const wchar_t* str); -std::string GenerateUUID(); \ No newline at end of file +std::string GenerateUUID(); +std::uint32_t GetEnchantValue(const std::uint16_t baseValue, const std::uint16_t enchantLevel, const uint8_t lowEnchantDelta, const uint8_t highEnchantDelta); \ No newline at end of file diff --git a/L2BotDll/Versions/Interlude/Factories/ItemFactory.h b/L2BotDll/Versions/Interlude/Factories/ItemFactory.h index 1f66b13..6e62515 100644 --- a/L2BotDll/Versions/Interlude/Factories/ItemFactory.h +++ b/L2BotDll/Versions/Interlude/Factories/ItemFactory.h @@ -134,8 +134,8 @@ namespace Interlude itemInfo.enchantLevel, casted ? static_cast(casted->armorType) : Enums::ArmorType::none, casted ? static_cast(casted->crystalType) : Enums::CrystalType::none, - casted ? casted->pDef : 0, - casted ? casted->mDef : 0, + GetEnchantValue(casted ? casted->pDef : 0, itemInfo.enchantLevel, 1, 3), + GetEnchantValue(casted ? casted->mDef : 0, itemInfo.enchantLevel, 1, 3), setEffect, addSetEffect, enchantEffect @@ -167,8 +167,8 @@ namespace Interlude casted ? static_cast(casted->weaponType) : Enums::WeaponType::none, casted ? static_cast(casted->crystalType) : Enums::CrystalType::none, casted ? casted->rndDamage : 0, - casted ? casted->pAtk : 0, - casted ? casted->mAtk : 0, + GetEnchantValue(casted ? casted->pAtk : 0, itemInfo.enchantLevel, 3, 6), + GetEnchantValue(casted ? casted->mAtk : 0, itemInfo.enchantLevel, 3, 6), casted ? casted->critical : 0, casted ? casted->hitModify : 0, casted ? casted->atkSpd : 0, @@ -190,7 +190,7 @@ namespace Interlude itemInfo.enchantLevel, casted ? static_cast(casted->crystalType) : Enums::CrystalType::none, casted ? casted->shieldEvasion : 0, - casted ? casted->shieldPdef : 0, + GetEnchantValue(casted ? casted->shieldPdef : 0, itemInfo.enchantLevel, 1, 3), casted ? casted->shieldDefRate : 0 ); } diff --git a/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h b/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h index db0ecab..f840f80 100644 --- a/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/ItemRepository.h @@ -72,6 +72,7 @@ namespace Interlude } } + //todo need to delete items if they are not exists in create "queue" void OnItemCreated(const Event& evt) { std::shared_lock(m_Mutex); @@ -112,7 +113,6 @@ namespace Interlude } } - //todo deleted ehchant scroll void OnItemDeleted(const Event& evt) { //fixme may be a race condition diff --git a/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h b/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h index d4c7743..0090878 100644 --- a/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h +++ b/L2BotDll/Versions/Interlude/Repositories/SkillRepository.h @@ -66,7 +66,6 @@ namespace Interlude EventDispatcher::GetInstance().Subscribe(HeroDeletedEvent::name, [this](const Event& evt) { OnHeroDeleted(evt); }); - // TODO delete outdated skills: on hero change subclass? } SkillRepository() = delete; @@ -91,6 +90,8 @@ namespace Interlude m_ReloadingTimers.StopAll(); } } + + //todo need to delete skills if they are not exists in create "queue" void OnSkillCreated(const Event& evt) { std::shared_lock(m_Mutex);