From 0a08c06b1de1037263f80d0f24747602792b0003 Mon Sep 17 00:00:00 2001 From: OldBeardedCoder <73860715+OldBeardedCoder@users.noreply.github.com> Date: Sat, 13 Feb 2021 13:50:50 -0800 Subject: [PATCH 1/2] Added BiggerGoldPiles, NoFlawGems and SafeUnsocket --- README.md | 5 ++ cfg.json | 5 +- .../src/components/D2ModMaker/Main.js | 39 +++++++++++---- internal/d2mod/config/cfg.go | 8 +++- internal/d2mod/cuberecipes/safeunsocket.go | 24 ++++++++++ internal/d2mod/make.go | 11 ++++- internal/d2mod/treasure/biggergoldpiles.go | 41 ++++++++++++++++ internal/d2mod/treasure/lowerprobs.go | 35 ++++++++++++++ internal/d2mod/treasure/noflawgems.go | 47 +++++++++++++++++++ 9 files changed, 203 insertions(+), 12 deletions(-) create mode 100644 internal/d2mod/cuberecipes/safeunsocket.go create mode 100644 internal/d2mod/treasure/biggergoldpiles.go create mode 100644 internal/d2mod/treasure/lowerprobs.go create mode 100644 internal/d2mod/treasure/noflawgems.go diff --git a/README.md b/README.md index 4fcebc6..de3bdd5 100644 --- a/README.md +++ b/README.md @@ -156,8 +156,13 @@ Thanks! ## Upcoming Release * Added ElementalSkills option (+Cold,Lightning,Magic,Poison Skills) + +## v0.5.4 +* Adding BiggerGoldPiles + ## v0.5.3 * Fixed version # + ## v0.5.2 * [bugfix] - fixed density overlap in old code, which was squaring density for nightmare, no increase for hell. * Upped density max to 45 and split between MonStats.txt & Levels.txt so that the density caps are not hit. diff --git a/cfg.json b/cfg.json index 9aaa189..14ee0fa 100644 --- a/cfg.json +++ b/cfg.json @@ -1,11 +1,13 @@ { - "Version": "v0.5.3", + "Version": "v0.5.4", "SourceDir": "", "OutputDir": "", "MeleeSplash": true, "IncreaseStackSizes": true, "IncreaseMonsterDensity": 1, "EnableTownSkills": true, + "BiggerGoldPiles": true, + "NoFlawGems": false, "NoDropZero": true, "QuestDrops": true, "UniqueItemDropRate": 1, @@ -15,6 +17,7 @@ "RemoveLevelRequirements": false, "RemoveAttRequirements": false, "RemoveUniqCharmLimit": false, + "SafeUnsocket": true, "EnterToExit": true, "RandomOptions": { "Randomize": true, diff --git a/gui/react-ui/src/components/D2ModMaker/Main.js b/gui/react-ui/src/components/D2ModMaker/Main.js index c36a458..e43b79e 100644 --- a/gui/react-ui/src/components/D2ModMaker/Main.js +++ b/gui/react-ui/src/components/D2ModMaker/Main.js @@ -21,13 +21,15 @@ const _ = require('lodash'); const axios = require("axios"); const defaultCfg = { - Version: "v0.5.3", + Version: "v0.5.4", SourceDir: "", OutputDir: "", MeleeSplash: true, IncreaseStackSizes: true, IncreaseMonsterDensity: 1, EnableTownSkills: true, + BiggerGoldPiles: false, + NoFlawGems: false, NoDropZero: true, QuestDrops: true, UniqueItemDropRate: 1, @@ -37,6 +39,7 @@ const defaultCfg = { RemoveLevelRequirements: false, RemoveAttRequirements: false, RemoveUniqCharmLimit: false, + SafeUnsocket: false, EnterToExit: false, RandomOptions: { Randomize: true, @@ -186,14 +189,14 @@ export default function D2ModMaker() { {mkCheckbox({ key: "Cowzzz", tooltip: - "Enables the ability to recreate a cow portal after killing the cow king. Adds cube recipe to cube a single tp scroll to create the cow portal4.", + "Enables the ability to recreate a cow portal after killing the cow king. Adds cube recipe to cube a single tp scroll to create the cow portal.", })} {mkCheckbox({ key: "IncreaseStackSizes", tooltip: - "Increases tome sizes to 100. Increases arrows/bolts stack sizes to 511. Increases key stack sizes to 100.", + "Increases tome sizes to 100. Increases arrows/bolts stack sizes to 511. Increases key stack size to 100.", })} @@ -220,9 +223,13 @@ export default function D2ModMaker() { "Removes unique charm limit in inventory.", })} - - - + + {mkCheckbox({ + key: "SafeUnsocket", + tooltip: + "Adds Runeword: 1 quiver + item => Item + gems/runes in item", + })} + ); @@ -257,7 +264,7 @@ export default function D2ModMaker() { + + + {mkCheckbox({ + key: "BiggerGoldPiles", + tooltip: "10x larger, fewer piles of gold.", + })} + + + {mkCheckbox({ + key: "NoFlawGems", + tooltip: "Disables Flawed & Flawless gems in Nightmare & Hell.", + })} + + Item + runes/gems) +func SafeUnsocket(d2files d2fs.Files) { + cubeF := d2files.Get(cubeMain.FileName) + tmp := make([]string, len(cubeF.Headers)) + + tmp[cubeMain.Description] = "SafeUnsocket" + tmp[cubeMain.Enabled] = "1" + tmp[cubeMain.Version] = "100" + tmp[cubeMain.NumInputs] = "2" + tmp[cubeMain.Input1] = "any,sock" + tmp[cubeMain.Input2] = "aqv,qty=1" + tmp[cubeMain.Output] = "useitem,rem" + tmp[cubeMain.Eol] = "0" + + cubeF.Rows = append(cubeF.Rows, tmp) + +} diff --git a/internal/d2mod/make.go b/internal/d2mod/make.go index 28d5611..113381b 100644 --- a/internal/d2mod/make.go +++ b/internal/d2mod/make.go @@ -7,6 +7,7 @@ import ( "github.com/tlentz/d2modmaker/internal/d2fs" "github.com/tlentz/d2modmaker/internal/d2mod/config" "github.com/tlentz/d2modmaker/internal/d2mod/cows" + "github.com/tlentz/d2modmaker/internal/d2mod/cuberecipes" "github.com/tlentz/d2modmaker/internal/d2mod/elementalskills" "github.com/tlentz/d2modmaker/internal/d2mod/monsterdensity" "github.com/tlentz/d2modmaker/internal/d2mod/qol" @@ -52,7 +53,12 @@ func Make(defaultOutDir string, cfg config.Data) { if cfg.EnableTownSkills { townskills.Enable(d2files) } - + if cfg.BiggerGoldPiles { + treasure.BiggerGoldPiles(d2files) + } + if cfg.NoFlawGems { + treasure.NoFlawGems(d2files) + } if cfg.NoDropZero { treasure.SetNoDropZero(d2files) } @@ -65,6 +71,9 @@ func Make(defaultOutDir string, cfg config.Data) { cows.AddTpRecipe(d2files) cows.AllowKingKill(d2files) } + if cfg.SafeUnsocket { + cuberecipes.SafeUnsocket(d2files) + } if cfg.RemoveLevelRequirements { reqs.RemoveLevelRequirements(d2files) diff --git a/internal/d2mod/treasure/biggergoldpiles.go b/internal/d2mod/treasure/biggergoldpiles.go new file mode 100644 index 0000000..37d571b --- /dev/null +++ b/internal/d2mod/treasure/biggergoldpiles.go @@ -0,0 +1,41 @@ +package treasure + +import ( + "fmt" + "strconv" + + "github.com/tlentz/d2modmaker/internal/d2fs" + "github.com/tlentz/d2modmaker/internal/d2fs/txts/treasureClassEx" +) + +// BiggerGoldPiles Update TreasureClassEx.txt with fewer, larger gold piles. +func BiggerGoldPiles(d2files d2fs.Files) { + f := d2files.Get(treasureClassEx.FileName) + numChanges := 0 + for idx := range f.Rows { + for colIdx := treasureClassEx.Item1; colIdx < treasureClassEx.Item10; colIdx += 2 { + itm := f.Rows[idx][colIdx] + if f.Rows[idx][treasureClassEx.TreasureClass] == "Gold" { + // Don't mess with the first row, this is for player dropped gold + continue + } + if len(itm) < 3 { + continue + } + if itm[0:3] == "gld" { + if len(itm) > 4 { + goldMult, _ := strconv.Atoi(itm[8:]) + goldMult *= 10 + itm = "gld,mul=" + strconv.Itoa(goldMult) + } else { + itm = "gld,mul=1000" + } + f.Rows[idx][colIdx] = itm + lowerProbs(f, idx, colIdx+1, 10) + numChanges++ + break // Better not be more than one or the adjust code would screw it up royally... + } + } + } + fmt.Printf("BiggerGoldPiles: %d changes\n", numChanges) +} diff --git a/internal/d2mod/treasure/lowerprobs.go b/internal/d2mod/treasure/lowerprobs.go new file mode 100644 index 0000000..f0a56f1 --- /dev/null +++ b/internal/d2mod/treasure/lowerprobs.go @@ -0,0 +1,35 @@ +package treasure + +import ( + "strconv" + + "github.com/tlentz/d2modmaker/internal/d2fs" + "github.com/tlentz/d2modmaker/internal/d2fs/txts/treasureClassEx" +) + +// lowerProbs Lowers the probability of scaleColIdx being rolled by lowerByFactor for row rowIndex in file f +// Does this by increasing the Prob(n) columns of every row except ScaleColIdx and increasing +// the NoDrop column additionally by (lowerByFactor-1) +// Used by biggergoldpiles to make fewer gold piles. +func lowerProbs(f *d2fs.File, rowIndex int, scaleColIdx int, lowerByFactor int) { + sumWeights := 0 + for colIdx := treasureClassEx.Prob1; colIdx < treasureClassEx.Prob10; colIdx += 2 { + + sumWeights += first(strconv.Atoi(f.Rows[rowIndex][colIdx])) + } + noDrop, _ := strconv.Atoi(f.Rows[rowIndex][treasureClassEx.NoDrop]) + sumWeights += noDrop + origWeight, _ := strconv.Atoi(f.Rows[rowIndex][scaleColIdx]) + + for colIdx := treasureClassEx.Prob1; colIdx < treasureClassEx.Prob10; colIdx += 2 { + if scaleColIdx == colIdx { + continue // Adjust everything except scaleColIdx + } + f.Rows[rowIndex][colIdx] = strconv.Itoa(first(strconv.Atoi(f.Rows[rowIndex][colIdx])) * lowerByFactor) + } + f.Rows[rowIndex][scaleColIdx] = strconv.Itoa(origWeight) + noDrop *= lowerByFactor + noDrop += origWeight * (lowerByFactor - 1) + f.Rows[rowIndex][treasureClassEx.NoDrop] = strconv.Itoa(noDrop) +} +func first(x int, _ error) int { return x } diff --git a/internal/d2mod/treasure/noflawgems.go b/internal/d2mod/treasure/noflawgems.go new file mode 100644 index 0000000..16e6398 --- /dev/null +++ b/internal/d2mod/treasure/noflawgems.go @@ -0,0 +1,47 @@ +package treasure + +import ( + "fmt" + "strconv" + + "github.com/tlentz/d2modmaker/internal/d2fs" + "github.com/tlentz/d2modmaker/internal/d2fs/txts/treasureClassEx" +) + +// NoFlawGems Set TreasureClassEx columns with gems up to no drop flawed or flawless +func NoFlawGems(d2files d2fs.Files) { + f := d2files.Get(treasureClassEx.FileName) + numChanges := 0 + for idx := range f.Rows { + for colIdx := treasureClassEx.Item1; colIdx < treasureClassEx.Item10; colIdx += 2 { + itm := f.Rows[idx][colIdx] + lvl, _ := strconv.Atoi(f.Rows[idx][treasureClassEx.Level]) + if lvl < 38 { + // Don't touch Normal + continue + } + if itm == "Flawless Gem" { + f.Rows[idx][colIdx] = "Perfect Gem" + lowerProbs(f, idx, colIdx+1, 3) + numChanges++ + } + } + } + for idx := range f.Rows { + for colIdx := treasureClassEx.Item1; colIdx < treasureClassEx.Item10; colIdx += 2 { + itm := f.Rows[idx][colIdx] + lvl, _ := strconv.Atoi(f.Rows[idx][treasureClassEx.Level]) + if lvl < 38 { + // Don't touch Normal + continue + } + if itm == "Flawed Gem" { + //prob,_ := strconv.Atoi(f.Rows[idx][colIdx+1]) + f.Rows[idx][colIdx+1] = "1" // Just make them unlikely + numChanges++ + } + } + } + fmt.Printf("BiggerGoldPiles: %d changes\n", numChanges) + +} From e9ff01096171126c15d0e846cb8d02dbfb7949d4 Mon Sep 17 00:00:00 2001 From: OldBeardedCoder <73860715+OldBeardedCoder@users.noreply.github.com> Date: Sat, 13 Feb 2021 15:58:28 -0800 Subject: [PATCH 2/2] Updated Readme --- README.md | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index de3bdd5..1b3f922 100644 --- a/README.md +++ b/README.md @@ -50,6 +50,10 @@ The mod config is located in `cfg.json`. You can change this config to your lik * Set to `-1` to omit #### EnableTownSkills `bool` * Enables all skills in town +#### BiggerGoldPiles `bool` +* 10x bigger, fewer gold piles +#### NoFlawGems `bool` +* (Mostly) Disables Flawed & Flawless gems from dropping on higher difficulties. #### NoDropZero `bool` * Sets "NoDrop" = 0 (Monsters will always drop items) #### QuestDrops `bool` @@ -79,12 +83,14 @@ The mod config is located in `cfg.json`. You can change this config to your lik * Removes attribute requirements from items. #### RemoveUniqCharmLimit `bool` * Allows to carry more than 1 unique charm of the same type. +#### SafeUnsocket `bool` +* Adds recipe (item + quiver) to unsocket an item, returning both the item and everything from its sockets. #### EnterToExit `bool` * If this is true, this will require the user to press enter to close the program * If false, it will not prompt user input ## RandomOptions `RandomOptions` #### Randomize `bool` -* Will randomize if set to true +* Will randomize propertiesif set to true #### Seed `int` * Will use this seed for randomization * Set to `-1` to generate a random seed @@ -158,7 +164,7 @@ Thanks! * Added ElementalSkills option (+Cold,Lightning,Magic,Poison Skills) ## v0.5.4 -* Adding BiggerGoldPiles +* Adding BiggerGoldPiles, NoFlawGems and SafeUnsocket. ## v0.5.3 * Fixed version #