feat: add enchant helper
This commit is contained in:
parent
1d0dbf86c3
commit
d7c0375416
@ -33,14 +33,4 @@ 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);
|
||||
}
|
@ -4,5 +4,4 @@
|
||||
#include <cstdint>
|
||||
|
||||
std::string ConvertFromWideChar(const wchar_t* str);
|
||||
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);
|
||||
std::string GenerateUUID();
|
@ -11,4 +11,5 @@ struct ItemData
|
||||
const uint16_t enchantLevel = 0;
|
||||
const int32_t mana = -1;
|
||||
const bool isQuest = false;
|
||||
const bool isTwoHanded = false;
|
||||
};
|
@ -197,6 +197,7 @@
|
||||
<ClInclude Include="Versions\Interlude\GameStructs\L2GameDataWrapper.h" />
|
||||
<ClInclude Include="Versions\Interlude\GameStructs\FName.h" />
|
||||
<ClInclude Include="Transports\DebugViewTransport.h" />
|
||||
<ClInclude Include="Versions\Interlude\Helpers\EnchantHelper.h" />
|
||||
<ClInclude Include="Versions\Interlude\Repositories\AbnormalEffectRepository.h" />
|
||||
<ClInclude Include="Versions\Interlude\Repositories\DropRepository.h" />
|
||||
<ClInclude Include="framework.h" />
|
||||
|
@ -183,6 +183,9 @@
|
||||
<ClInclude Include="Events\GameEngineTickedEvent.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="Versions\Interlude\Helpers\EnchantHelper.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="dllmain.cpp">
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include "GameStructs/L2GameDataWrapper.h"
|
||||
#include "GameStructs/FName.h"
|
||||
#include "../../Services/EntityHandler.h"
|
||||
#include "Helpers/EnchantHelper.h"
|
||||
|
||||
namespace Interlude
|
||||
{
|
||||
@ -94,7 +95,8 @@ namespace Interlude
|
||||
}
|
||||
ItemRepository& GetItemRepository() const override
|
||||
{
|
||||
static auto factory = ItemFactory(GetL2GameData(), GetFName());
|
||||
static EnchantHelper enchantHelper;
|
||||
static auto factory = ItemFactory(GetL2GameData(), GetFName(), enchantHelper);
|
||||
static EntityHandler handler;
|
||||
static auto result = ItemRepository(
|
||||
GetNetworkHandler(),
|
||||
|
@ -11,6 +11,7 @@
|
||||
#include "Domain/Entities/WeaponItem.h"
|
||||
#include "Domain/Entities/ShieldItem.h"
|
||||
#include "../../../DTO/ItemData.h"
|
||||
#include "../Helpers/EnchantHelper.h"
|
||||
|
||||
using namespace L2Bot::Domain;
|
||||
|
||||
@ -19,9 +20,10 @@ namespace Interlude
|
||||
class ItemFactory
|
||||
{
|
||||
public:
|
||||
ItemFactory(const L2GameDataWrapper& l2GameData, const FName& fName) :
|
||||
ItemFactory(const L2GameDataWrapper& l2GameData, const FName& fName, const EnchantHelper& enchantHelper) :
|
||||
m_L2GameData(l2GameData),
|
||||
m_FName(fName)
|
||||
m_FName(fName),
|
||||
m_EnchantHelper(enchantHelper)
|
||||
{
|
||||
}
|
||||
|
||||
@ -134,8 +136,8 @@ namespace Interlude
|
||||
itemInfo.enchantLevel,
|
||||
casted ? static_cast<Enums::ArmorType>(casted->armorType) : Enums::ArmorType::none,
|
||||
casted ? static_cast<Enums::CrystalType>(casted->crystalType) : Enums::CrystalType::none,
|
||||
GetEnchantValue(casted ? casted->pDefense : 0, itemInfo.enchantLevel, 1, 3),
|
||||
GetEnchantValue(casted ? casted->mDefense : 0, itemInfo.enchantLevel, 1, 3),
|
||||
m_EnchantHelper.GetDefenseEnchantValue(casted ? casted->pDefense : 0, itemInfo.enchantLevel),
|
||||
m_EnchantHelper.GetDefenseEnchantValue(casted ? casted->mDefense : 0, itemInfo.enchantLevel),
|
||||
setEffect,
|
||||
addSetEffect,
|
||||
enchantEffect
|
||||
@ -167,8 +169,8 @@ namespace Interlude
|
||||
casted ? static_cast<Enums::WeaponType>(casted->weaponType) : Enums::WeaponType::none,
|
||||
casted ? static_cast<Enums::CrystalType>(casted->crystalType) : Enums::CrystalType::none,
|
||||
casted ? casted->rndDamage : 0,
|
||||
GetEnchantValue(casted ? casted->pAttack : 0, itemInfo.enchantLevel, 3, 6),
|
||||
GetEnchantValue(casted ? casted->mAttack : 0, itemInfo.enchantLevel, 3, 6),
|
||||
m_EnchantHelper.GetPAttackEnchantValue(casted->weaponType, itemInfo.isTwoHanded, casted->crystalType, casted ? casted->pAttack : 0, itemInfo.enchantLevel),
|
||||
m_EnchantHelper.GetMAttackEnchantValue(casted->crystalType, casted ? casted->mAttack : 0, itemInfo.enchantLevel),
|
||||
casted ? casted->critical : 0,
|
||||
casted ? casted->hitModify : 0,
|
||||
casted ? casted->atkSpd : 0,
|
||||
@ -190,7 +192,7 @@ namespace Interlude
|
||||
itemInfo.enchantLevel,
|
||||
casted ? static_cast<Enums::CrystalType>(casted->crystalType) : Enums::CrystalType::none,
|
||||
casted ? casted->shieldEvasion : 0,
|
||||
GetEnchantValue(casted ? casted->shieldPdef : 0, itemInfo.enchantLevel, 1, 3),
|
||||
m_EnchantHelper.GetDefenseEnchantValue(casted ? casted->shieldPdef : 0, itemInfo.enchantLevel),
|
||||
casted ? casted->shieldDefRate : 0
|
||||
);
|
||||
}
|
||||
@ -198,5 +200,6 @@ namespace Interlude
|
||||
private:
|
||||
const L2GameDataWrapper& m_L2GameData;
|
||||
const FName& m_FName;
|
||||
const EnchantHelper& m_EnchantHelper;
|
||||
};
|
||||
}
|
@ -104,7 +104,8 @@ namespace Interlude
|
||||
itemInfo.isEquipped,
|
||||
itemInfo.enchantLevel,
|
||||
itemInfo.mana,
|
||||
itemInfo.type2 == L2::ItemType2::QUEST
|
||||
itemInfo.type2 == L2::ItemType2::QUEST,
|
||||
itemInfo.itemSlot == L2::ItemSlot::LR_HAND
|
||||
}
|
||||
}
|
||||
);
|
||||
@ -121,7 +122,8 @@ namespace Interlude
|
||||
itemInfo.isEquipped,
|
||||
itemInfo.enchantLevel,
|
||||
itemInfo.mana,
|
||||
itemInfo.type2 == L2::ItemType2::QUEST
|
||||
itemInfo.type2 == L2::ItemType2::QUEST,
|
||||
itemInfo.itemSlot == L2::ItemSlot::LR_HAND
|
||||
};
|
||||
|
||||
switch (actionType)
|
||||
|
130
L2BotDll/Versions/Interlude/Helpers/EnchantHelper.h
Normal file
130
L2BotDll/Versions/Interlude/Helpers/EnchantHelper.h
Normal file
@ -0,0 +1,130 @@
|
||||
#pragma once
|
||||
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include "../GameStructs/GameStructs.h"
|
||||
|
||||
namespace Interlude
|
||||
{
|
||||
class EnchantHelper
|
||||
{
|
||||
public:
|
||||
EnchantHelper()
|
||||
{
|
||||
m_PAttackDeltas =
|
||||
{
|
||||
{
|
||||
L2::CrystalType::D,
|
||||
{
|
||||
{ WeaponType::common, 2 },
|
||||
{ WeaponType::twoHand, 2 },
|
||||
{ WeaponType::bow, 4 },
|
||||
}
|
||||
},
|
||||
{
|
||||
L2::CrystalType::C,
|
||||
{
|
||||
{ WeaponType::common, 3 },
|
||||
{ WeaponType::twoHand, 4 },
|
||||
{ WeaponType::bow, 6 },
|
||||
}
|
||||
},
|
||||
{
|
||||
L2::CrystalType::B,
|
||||
{
|
||||
{ WeaponType::common, 3 },
|
||||
{ WeaponType::twoHand, 4 },
|
||||
{ WeaponType::bow, 6 },
|
||||
}
|
||||
},
|
||||
{
|
||||
L2::CrystalType::A,
|
||||
{
|
||||
{ WeaponType::common, 4 },
|
||||
{ WeaponType::twoHand, 5 },
|
||||
{ WeaponType::bow, 8 },
|
||||
}
|
||||
},
|
||||
{
|
||||
L2::CrystalType::S,
|
||||
{
|
||||
{ WeaponType::common, 5 },
|
||||
{ WeaponType::twoHand, 6 },
|
||||
{ WeaponType::bow, 10 },
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
m_MAttackDeltas =
|
||||
{
|
||||
{ L2::CrystalType::D, 2 },
|
||||
{ L2::CrystalType::C, 3 },
|
||||
{ L2::CrystalType::B, 3 },
|
||||
{ L2::CrystalType::A, 3 },
|
||||
{ L2::CrystalType::S, 4 },
|
||||
};
|
||||
}
|
||||
virtual ~EnchantHelper() = default;
|
||||
|
||||
const std::uint32_t GetPAttackEnchantValue(const L2::WeaponType weaponType, const bool is2hand, const L2::CrystalType crystalType, const std::uint16_t baseValue, const std::uint16_t enchantLevel) const
|
||||
{
|
||||
if (m_PAttackDeltas.find(crystalType) == m_PAttackDeltas.end())
|
||||
{
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
WeaponType type = WeaponType::common;
|
||||
if (weaponType == L2::WeaponType::BOW)
|
||||
{
|
||||
type = WeaponType::bow;
|
||||
}
|
||||
else if (is2hand)
|
||||
{
|
||||
type = WeaponType::twoHand;
|
||||
}
|
||||
|
||||
auto enchantDelta = m_PAttackDeltas.at(crystalType).at(type);
|
||||
|
||||
return GetEnchantValue(baseValue, enchantLevel, enchantDelta, enchantDelta * 2);
|
||||
}
|
||||
|
||||
const std::uint32_t GetMAttackEnchantValue(const L2::CrystalType crystalType, const std::uint16_t baseValue, const std::uint16_t enchantLevel) const
|
||||
{
|
||||
if (m_MAttackDeltas.find(crystalType) == m_MAttackDeltas.end())
|
||||
{
|
||||
return baseValue;
|
||||
}
|
||||
|
||||
auto enchantDelta = m_MAttackDeltas.at(crystalType);
|
||||
|
||||
return GetEnchantValue(baseValue, enchantLevel, enchantDelta, enchantDelta * 2);
|
||||
}
|
||||
|
||||
const std::uint32_t GetDefenseEnchantValue(const std::uint16_t baseValue, const std::uint16_t enchantLevel) const
|
||||
{
|
||||
return GetEnchantValue(baseValue, enchantLevel, 1, 3);
|
||||
}
|
||||
|
||||
private:
|
||||
const std::uint32_t GetEnchantValue(const std::uint16_t baseValue, const std::uint16_t enchantLevel, const uint8_t enchantDelta, const uint8_t overenchantDelta) const
|
||||
{
|
||||
if (baseValue == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
return baseValue + enchantLevel * enchantDelta + max(enchantLevel - 3, 0) * (overenchantDelta - enchantDelta);
|
||||
}
|
||||
|
||||
private:
|
||||
enum class WeaponType : uint8_t
|
||||
{
|
||||
common,
|
||||
twoHand,
|
||||
bow
|
||||
};
|
||||
|
||||
std::map<L2::CrystalType, std::map<WeaponType, uint8_t>> m_PAttackDeltas;
|
||||
std::map<L2::CrystalType, uint8_t> m_MAttackDeltas;
|
||||
};
|
||||
}
|
Loading…
Reference in New Issue
Block a user