diff --git a/Adventures in Lestoria/AdventuresInLestoria.cpp b/Adventures in Lestoria/AdventuresInLestoria.cpp index f31a921a..7a9cc144 100644 --- a/Adventures in Lestoria/AdventuresInLestoria.cpp +++ b/Adventures in Lestoria/AdventuresInLestoria.cpp @@ -1636,7 +1636,9 @@ void AiL::InitializeLevel(std::string mapFile,MapName map){ for(auto&[key,size]:DATA["Levels"][map]){ if(key.starts_with("Loot")){ datafile data=DATA["Levels"][map][key]; - MAP_DATA[map].stageLoot.push_back(ItemMapData(data.GetString(0U),data.GetInt(1U),data.GetInt(2U))); + int pctChance=100; + if(data.GetValueCount()>3)pctChance=data.GetInt(3U); + MAP_DATA[map].stageLoot.push_back(ItemMapData(data.GetString(0U),data.GetInt(1U),data.GetInt(2U),pctChance)); } } diff --git a/Adventures in Lestoria/ItemMapData.h b/Adventures in Lestoria/ItemMapData.h index 21129e07..4f0f4f17 100644 --- a/Adventures in Lestoria/ItemMapData.h +++ b/Adventures in Lestoria/ItemMapData.h @@ -30,7 +30,7 @@ CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -Portions of this software are copyright © 2023 The FreeType +Portions of this software are copyright � 2023 The FreeType Project (www.freetype.org). Please see LICENSE_FT.txt for more information. All rights reserved. */ @@ -40,8 +40,11 @@ All rights reserved. struct ItemMapData{ IT item; - uint8_t amt; + uint8_t minAmt; + uint8_t maxAmt; int chance; - inline ItemMapData(IT item,uint8_t amt,int chance) - :item(item),amt(amt),chance(chance){} + inline ItemMapData(IT item,uint8_t minAmt,uint8_t maxAmt,int chance) + :item(item),minAmt(minAmt),maxAmt(maxAmt),chance(chance){ + if(minAmt>maxAmt)ERR(std::format("WARNING! The max amount specified for item {} is less than the minimum amount! {} > {}!",item,minAmt,maxAmt)); + } }; \ No newline at end of file diff --git a/Adventures in Lestoria/State_LevelComplete.cpp b/Adventures in Lestoria/State_LevelComplete.cpp index 57fc3c92..42fd595f 100644 --- a/Adventures in Lestoria/State_LevelComplete.cpp +++ b/Adventures in Lestoria/State_LevelComplete.cpp @@ -52,7 +52,12 @@ void State_LevelComplete::OnStateChange(GameState*prevState){ Component(MenuType::LEVEL_COMPLETE,"Level EXP Gain Outline")->SetLabel(std::format("+{} Exp",game->GetPlayer()->GetAccumulatedXP())); game->GetPlayer()->AddXP(game->GetPlayer()->GetAccumulatedXP()); for(const ItemMapData&data:game->GetCurrentMap().stageLoot){ - for(uint8_t rolls=0;rolls0){ //This check avoids division by zero. + randomAmt=util::random()%(amountDiff+1)+data.minAmt; + } + for(uint8_t rolls=0;rolls