Fix typos and minor descriptions in item enchants file. Enchantment data structures and configuration reading implemented. Release Build 10498.
This commit is contained in:
parent
3c40b3ee41
commit
b9f5b80300
@ -491,6 +491,10 @@
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ItemEnchant.h">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ItemMapData.h">
|
||||
<SubType>
|
||||
</SubType>
|
||||
@ -944,6 +948,10 @@
|
||||
</ClCompile>
|
||||
<ClCompile Include="Item.cpp" />
|
||||
<ClCompile Include="ItemDrop.cpp" />
|
||||
<ClCompile Include="ItemEnchant.cpp">
|
||||
<SubType>
|
||||
</SubType>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ItemLoadoutWindow.cpp" />
|
||||
<ClCompile Include="Key.cpp" />
|
||||
<ClCompile Include="LargeStone.cpp" />
|
||||
@ -1175,6 +1183,7 @@
|
||||
<Text Include="assets\config\items\Equipment.txt" />
|
||||
<Text Include="assets\config\items\ItemCategory.txt" />
|
||||
<Text Include="assets\config\items\ItemDatabase.txt" />
|
||||
<Text Include="assets\config\items\ItemEnchants.txt" />
|
||||
<Text Include="assets\config\items\items.txt" />
|
||||
<Text Include="assets\config\items\ItemScript.txt" />
|
||||
<Text Include="assets\config\items\ItemSets.txt" />
|
||||
@ -1210,7 +1219,6 @@
|
||||
<Text Include="Crawler_System_Overview.txt" />
|
||||
<Text Include="Crawler_Trapper_Witch_thief.txt" />
|
||||
<Text Include="debug.log" />
|
||||
<Text Include="ItemEnchants.txt" />
|
||||
<Text Include="Merchant%27s Items.txt" />
|
||||
<Text Include="NewClasses.txt" />
|
||||
<Text Include="InitialConcept.txt" />
|
||||
|
@ -672,6 +672,9 @@
|
||||
<ClInclude Include="State_Dialog.h">
|
||||
<Filter>Header Files\State</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="ItemEnchant.h">
|
||||
<Filter>Header Files</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="Player.cpp">
|
||||
@ -1181,6 +1184,9 @@
|
||||
<ClCompile Include="ArtificerEnchantConfirmWindow.cpp">
|
||||
<Filter>Source Files\Interface</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="ItemEnchant.cpp">
|
||||
<Filter>Source Files</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<None Include="cpp.hint" />
|
||||
@ -1379,7 +1385,7 @@
|
||||
<Text Include="assets\config\story\Chapter 6.txt">
|
||||
<Filter>Configurations\Story</Filter>
|
||||
</Text>
|
||||
<Text Include="ItemEnchants.txt">
|
||||
<Text Include="assets\config\items\ItemEnchants.txt">
|
||||
<Filter>Configurations\Items</Filter>
|
||||
</Text>
|
||||
</ItemGroup>
|
||||
|
@ -51,6 +51,7 @@ All rights reserved.
|
||||
#include "steam/isteamuserstats.h"
|
||||
#endif
|
||||
#include <ranges>
|
||||
#include "ItemEnchant.h"
|
||||
|
||||
INCLUDE_game
|
||||
INCLUDE_DATA
|
||||
@ -397,6 +398,8 @@ void ItemInfo::InitializeItems(){
|
||||
}
|
||||
#pragma endregion
|
||||
|
||||
ItemEnchantInfo::Initialize();
|
||||
|
||||
ITEM_DATA.SetInitialized();
|
||||
ITEM_CATEGORIES.SetInitialized();
|
||||
ITEM_CONVERSIONS.SetInitialized();
|
||||
|
141
Adventures in Lestoria/ItemEnchant.cpp
Normal file
141
Adventures in Lestoria/ItemEnchant.cpp
Normal file
@ -0,0 +1,141 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above
|
||||
copyright notice. This list of conditions and the following disclaimer must be
|
||||
reproduced in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
Portions of this software are copyright © 2024 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
|
||||
#include "olcUTIL_DataFile.h"
|
||||
#include "ItemEnchant.h"
|
||||
#include "DEFINES.h"
|
||||
#include <unordered_set>
|
||||
|
||||
INCLUDE_DATA
|
||||
|
||||
std::unordered_map<std::string,ItemEnchantInfo>ItemEnchantInfo::ENCHANT_LIST;
|
||||
std::unordered_map<ItemEnchantInfo::ItemEnchantCategory,ItemEnchantInfo::ItemEnchantCategoryData>ItemEnchantInfo::ENCHANT_CATEGORIES;
|
||||
|
||||
void ItemEnchantInfo::Initialize(){
|
||||
float minCategoryRollWeight{};
|
||||
float maxCategoryRollWeight{};
|
||||
for(const auto&[key,size]:DATA["Item Enchants"]){
|
||||
ItemEnchantCategory enchantCategory{};
|
||||
if(key=="General Enchants"){
|
||||
enchantCategory=ItemEnchantCategory::GENERAL;
|
||||
}else
|
||||
if(key=="Class Enchants"){
|
||||
enchantCategory=ItemEnchantCategory::CLASS;
|
||||
}else
|
||||
if(key=="Unique Enchants"){
|
||||
enchantCategory=ItemEnchantCategory::UNIQUE;
|
||||
}else ERR(std::format("WARNING! Enchant type {} is not supported! THIS SHOULD NOT BE HAPPENING! Please check ItemEnchants.txt",key));
|
||||
|
||||
datafile&enchantData=DATA["Item Enchants"][key];
|
||||
|
||||
ItemEnchantCategoryData categoryData;
|
||||
|
||||
minCategoryRollWeight=maxCategoryRollWeight;
|
||||
maxCategoryRollWeight+=enchantData["Percent Chance"].GetReal();
|
||||
|
||||
categoryData.displayCol=enchantData["Enchant Display Color"].GetPixel();
|
||||
categoryData.weightedRollRange={minCategoryRollWeight,maxCategoryRollWeight};
|
||||
|
||||
ENCHANT_CATEGORIES.insert({enchantCategory,categoryData});
|
||||
|
||||
for(const auto&[key,size]:enchantData){
|
||||
if(key=="Percent Chance"||key=="Enchant Display Color")continue;
|
||||
|
||||
const auto MakeEnchant=[](const std::string_view keyName,datafile&enchant){
|
||||
ItemEnchantInfo newEnchant;
|
||||
newEnchant.name=keyName;
|
||||
newEnchant.description=enchant["Description"].GetString();
|
||||
using enum AbilitySlot;
|
||||
const std::unordered_map<std::string,AbilitySlot>affectSlots{
|
||||
{"Auto Attack",AUTO_ATTACK},
|
||||
{"Right Click Ability",RIGHT_CLICK},
|
||||
{"Ability 1",ABILITY_1},
|
||||
{"Ability 2",ABILITY_2},
|
||||
{"Ability 3",ABILITY_3},
|
||||
};
|
||||
|
||||
if(enchant.HasProperty("Affects")){
|
||||
std::string affectStr{enchant["Affects"].GetString()};
|
||||
if(!affectSlots.count(affectStr))ERR(std::format("WARNING! Could not find translate ability affect slot name {} to a valid slot! Valid slot names are: \"Auto Attack, Right Click Ability, Ability 1, Ability 2, Ability 3\"",affectStr));
|
||||
newEnchant.abilitySlot=affectSlots.at(affectStr);
|
||||
}
|
||||
|
||||
size_t statModifierInd{};
|
||||
while(enchant.HasProperty(std::format("Stat Modifier[{}]",statModifierInd))){
|
||||
const datafile&stat{enchant[std::format("Stat Modifier[{}]",statModifierInd)]};
|
||||
newEnchant.minStatModifiers.A(stat.GetString(0))=stat.GetReal(1);
|
||||
newEnchant.maxStatModifiers.A(stat.GetString(0))=stat.GetReal(2);
|
||||
statModifierInd++;
|
||||
}
|
||||
|
||||
for(auto&[key,size]:enchant){
|
||||
if(key=="Description"||key=="Affects"||key.starts_with("Stat Modifier["))continue;
|
||||
const auto&result{newEnchant.config.insert({key,enchant[key].GetReal()})};
|
||||
const bool InsertFailed{!result.second};
|
||||
if(InsertFailed)ERR(std::format("WARNING! Enchant {} already had an extra property named {}. Duplicates not allowed!",keyName,key));
|
||||
}
|
||||
|
||||
return newEnchant;
|
||||
};
|
||||
|
||||
using enum ItemEnchantCategory;
|
||||
if(enchantCategory==CLASS){
|
||||
Class itemEnchantClass{classutils::StringToClass(key)};
|
||||
datafile&classEnchantData{enchantData[key]};
|
||||
for(const auto&[key,size]:classEnchantData){
|
||||
ItemEnchantInfo newEnchant{MakeEnchant(key,classEnchantData[key])};
|
||||
const auto&result{ENCHANT_LIST.insert({key,newEnchant})};
|
||||
const bool InsertFailed{!result.second};
|
||||
if(InsertFailed)ERR(std::format("WARNING! Enchant {} already existed in Enchantment List! Duplicates are not allowed!",key));
|
||||
}
|
||||
}else{
|
||||
ItemEnchantInfo newEnchant{MakeEnchant(key,enchantData[key])};
|
||||
const auto&result{ENCHANT_LIST.insert({key,newEnchant})};
|
||||
const bool InsertFailed{!result.second};
|
||||
if(InsertFailed)ERR(std::format("WARNING! Enchant {} already existed in Enchantment List! Duplicates are not allowed!",key));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const ItemEnchantInfo&ItemEnchantInfo::GetEnchant(const std::string_view name){
|
||||
return ENCHANT_LIST.at(std::string(name));
|
||||
}
|
||||
|
||||
ItemEnchant::ItemEnchant(const std::string_view enchantName)
|
||||
:enchant(ItemEnchantInfo::GetEnchant(enchantName)){}
|
87
Adventures in Lestoria/ItemEnchant.h
Normal file
87
Adventures in Lestoria/ItemEnchant.h
Normal file
@ -0,0 +1,87 @@
|
||||
#pragma region License
|
||||
/*
|
||||
License (OLC-3)
|
||||
~~~~~~~~~~~~~~~
|
||||
|
||||
Copyright 2024 Joshua Sigona <sigonasr2@gmail.com>
|
||||
|
||||
Redistribution and use in source and binary forms, with or without modification,
|
||||
are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions or derivations of source code must retain the above copyright
|
||||
notice, this list of conditions and the following disclaimer.
|
||||
|
||||
2. Redistributions or derivative works in binary form must reproduce the above
|
||||
copyright notice. This list of conditions and the following disclaimer must be
|
||||
reproduced in the documentation and/or other materials provided with the distribution.
|
||||
|
||||
3. Neither the name of the copyright holder nor the names of its contributors may
|
||||
be used to endorse or promote products derived from this software without specific
|
||||
prior written permission.
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY
|
||||
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
|
||||
SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
|
||||
TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR
|
||||
BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||
SUCH DAMAGE.
|
||||
|
||||
Portions of this software are copyright © 2024 The FreeType
|
||||
Project (www.freetype.org). Please see LICENSE_FT.txt for more information.
|
||||
All rights reserved.
|
||||
*/
|
||||
#pragma endregion
|
||||
#pragma once
|
||||
|
||||
#include "AttributableStat.h"
|
||||
#include "Pixel.h"
|
||||
#include "Class.h"
|
||||
|
||||
class ItemEnchantInfo{
|
||||
public:
|
||||
static void Initialize();
|
||||
const static ItemEnchantInfo&GetEnchant(const std::string_view name);
|
||||
|
||||
const std::string_view Name();
|
||||
const std::string_view Description();
|
||||
const float GetConfigValue(const std::string_view keyName);
|
||||
enum class AbilitySlot{
|
||||
AUTO_ATTACK,
|
||||
RIGHT_CLICK,
|
||||
ABILITY_1,
|
||||
ABILITY_2,
|
||||
ABILITY_3,
|
||||
};
|
||||
private:
|
||||
enum class ItemEnchantCategory{
|
||||
GENERAL,
|
||||
CLASS,
|
||||
UNIQUE,
|
||||
};
|
||||
class ItemEnchantCategoryData{
|
||||
friend class ItemEnchantInfo;
|
||||
using LowestNumber=int;
|
||||
using HighestNumber=int;
|
||||
std::pair<LowestNumber,HighestNumber>weightedRollRange;
|
||||
Pixel displayCol;
|
||||
};
|
||||
std::string name;
|
||||
std::string description;
|
||||
std::optional<AbilitySlot>abilitySlot;
|
||||
ItemAttributable minStatModifiers;
|
||||
ItemAttributable maxStatModifiers;
|
||||
std::unordered_map<std::string,float>config;
|
||||
static std::unordered_map<std::string,ItemEnchantInfo>ENCHANT_LIST;
|
||||
static std::unordered_map<ItemEnchantCategory,ItemEnchantCategoryData>ENCHANT_CATEGORIES;
|
||||
};
|
||||
|
||||
class ItemEnchant:public ItemAttributable{
|
||||
public:
|
||||
ItemEnchant(const std::string_view enchantName);
|
||||
private:
|
||||
const ItemEnchantInfo&enchant;
|
||||
};
|
@ -39,7 +39,7 @@ All rights reserved.
|
||||
#define VERSION_MAJOR 1
|
||||
#define VERSION_MINOR 2
|
||||
#define VERSION_PATCH 3
|
||||
#define VERSION_BUILD 10487
|
||||
#define VERSION_BUILD 10498
|
||||
|
||||
#define stringify(a) stringify_(a)
|
||||
#define stringify_(a) #a
|
||||
|
@ -272,7 +272,7 @@ Item Enchants
|
||||
}
|
||||
Auto Guard
|
||||
{
|
||||
Description = "If Block is up and you take damage, Block will activate immediately, blocking the attack."
|
||||
Description = "If Block is up and you take damage, Block will activate immediately, preventing the attack."
|
||||
Affects = Right Click Ability
|
||||
# Stat, Lowest, Highest Value
|
||||
# Stat Modifier[0] = ..., 0, 0
|
||||
@ -286,7 +286,7 @@ Item Enchants
|
||||
}
|
||||
Advance Shield
|
||||
{
|
||||
Description = "Block no longer grants invulnerability or knockback reduction. Block now grants a shield equal to 20% of your health for 10 seconds."
|
||||
Description = "Block no longer grants invulnerability or knockback reduction. Block now grants a shield equal to 20% of your health for 10 seconds. You can perform other actions while the shield is active."
|
||||
Affects = Right Click Ability
|
||||
# Stat, Lowest, Highest Value
|
||||
# Stat Modifier[0] = ..., 0, 0
|
||||
@ -433,11 +433,11 @@ Item Enchants
|
||||
Stat Modifier[0] = Attack %, 4, 8
|
||||
Stat Modifier[1] = Crit Rate, 5, 10
|
||||
Stat Modifier[2] = CDR, 5, 10
|
||||
Stat Modifier[3] = Crit Dmg 15, 20
|
||||
Stat Modifier[3] = Crit Dmg, 15, 20
|
||||
}
|
||||
Lethal Tempo
|
||||
{
|
||||
Description = "Increases Attack Speed by 5% with each strike, up to 25%."
|
||||
Description = "Increases Attack Speed by 5% with each strike, up to 25%. Lasts for 5 seconds."
|
||||
# Stat, Lowest, Highest Value
|
||||
# Stat Modifier[0] = ..., 0, 0
|
||||
}
|
@ -1,6 +1,7 @@
|
||||
ItemConfiguration
|
||||
{
|
||||
Item Database = ItemDatabase.txt
|
||||
Item Enchants = ItemEnchants.txt
|
||||
Item Scripts = ItemScript.txt
|
||||
Item Categories = ItemCategory.txt
|
||||
Equipment = Equipment.txt
|
||||
|
Binary file not shown.
Loading…
x
Reference in New Issue
Block a user