Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added BiggerGoldPiles, NoFlawGems and SafeUnsocket #99

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 12 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -156,8 +162,13 @@ Thanks!

## Upcoming Release
* Added ElementalSkills option (+Cold,Lightning,Magic,Poison Skills)

## v0.5.4
* Adding BiggerGoldPiles, NoFlawGems and SafeUnsocket.

## 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.
Expand Down
5 changes: 4 additions & 1 deletion cfg.json
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -15,6 +17,7 @@
"RemoveLevelRequirements": false,
"RemoveAttRequirements": false,
"RemoveUniqCharmLimit": false,
"SafeUnsocket": true,
"EnterToExit": true,
"RandomOptions": {
"Randomize": true,
Expand Down
39 changes: 30 additions & 9 deletions gui/react-ui/src/components/D2ModMaker/Main.js
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -37,6 +39,7 @@ const defaultCfg = {
RemoveLevelRequirements: false,
RemoveAttRequirements: false,
RemoveUniqCharmLimit: false,
SafeUnsocket: false,
EnterToExit: false,
RandomOptions: {
Randomize: true,
Expand Down Expand Up @@ -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.",
})}
</Grid>
<Grid item xs={6}>
{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.",
})}
</Grid>

Expand All @@ -220,9 +223,13 @@ export default function D2ModMaker() {
"Removes unique charm limit in inventory.",
})}
</Grid>



<Grid item xs={6}>
{mkCheckbox({
key: "SafeUnsocket",
tooltip:
"Adds Runeword: 1 quiver + item => Item + gems/runes in item",
})}
</Grid>
</Grid>
</Grid>
);
Expand Down Expand Up @@ -257,7 +264,7 @@ export default function D2ModMaker() {
<Grid item xs={6}>
<StyledTooltip
title={
"The directory that the data folder will be placed. Leave blank to use current directory. This requires a trailing slash. example: /Users/{username}/{folder}/"
"The directory that the data folder will be placed in. Leave blank to use current directory (./data/). This requires a trailing slash. example: /Users/{username}/{folder}/ Everything in this directory will be DELETED when the program runs, so don't point this at the Source Directory."
}
placement="bottom"
enterDelay={250}
Expand Down Expand Up @@ -370,6 +377,20 @@ export default function D2ModMaker() {
})}
</Grid>
</Grid>
<Grid container>
<Grid item xs={4}>
{mkCheckbox({
key: "BiggerGoldPiles",
tooltip: "10x larger, fewer piles of gold.",
})}
</Grid>
<Grid item xs={4}>
{mkCheckbox({
key: "NoFlawGems",
tooltip: "Disables Flawed & Flawless gems in Nightmare & Hell.",
})}
</Grid>
</Grid>
<Grid item xs={12} className={"SliderWrapper"}>
<Typography
id="UniqueItemDropRate"
Expand All @@ -380,7 +401,7 @@ export default function D2ModMaker() {
Unique Item Drop Rate
<StyledTooltip
title={
"Increases the drop rate of unique and set items. When using this setting, high values prevent some monsters from dropping set items."
"Increases the drop rate of unique and set items. High values may prevent set items from dropping."
}
placement="bottom"
enterDelay={250}
Expand Down Expand Up @@ -565,7 +586,7 @@ export default function D2ModMaker() {
</StyledTooltip>
</Typography>
<Slider
defaultValue={0}
defaultValue={2}
getAriaValueText={valuetext}
aria-labelledby="MinProps"
step={1}
Expand Down
8 changes: 7 additions & 1 deletion internal/d2mod/config/cfg.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ type Data struct {
IncreaseStackSizes bool `json:"IncreaseStackSizes"`
IncreaseMonsterDensity float64 `json:"IncreaseMonsterDensity"`
EnableTownSkills bool `json:"EnableTownSkills"`
BiggerGoldPiles bool `json:"BiggerGoldPiles"`
NoFlawGems bool `json:"NoFlawGems"`
NoDropZero bool `json:"NoDropZero"`
QuestDrops bool `json:"QuestDrops"`
UniqueItemDropRate float64 `json:"UniqueItemDropRate"`
Expand All @@ -38,19 +40,22 @@ type Data struct {
RemoveLevelRequirements bool `json:"RemoveLevelRequirements"`
RemoveAttRequirements bool `json:"RemoveAttRequirements"`
RemoveUniqCharmLimit bool `json:"RemoveUniqCharmLimit"`
SafeUnsocket bool `json:"SafeUnsocket"`
EnterToExit bool `json:"EnterToExit"`
RandomOptions RandomOptions `json:"RandomOptions"`
}

func DefaultData() Data {
return Data{
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,
Expand All @@ -60,6 +65,7 @@ func DefaultData() Data {
RemoveLevelRequirements: false,
RemoveAttRequirements: false,
RemoveUniqCharmLimit: false,
SafeUnsocket: false,
EnterToExit: false,
RandomOptions: RandomOptions{
Randomize: true,
Expand Down
24 changes: 24 additions & 0 deletions internal/d2mod/cuberecipes/safeunsocket.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package cuberecipes

import (
"github.com/tlentz/d2modmaker/internal/d2fs"
"github.com/tlentz/d2modmaker/internal/d2fs/txts/cubeMain"
)

// SafeUnsocket Recipe to remove runes/gems from items safely (Quiver + item=>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)

}
11 changes: 10 additions & 1 deletion internal/d2mod/make.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
}
Expand All @@ -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)
Expand Down
41 changes: 41 additions & 0 deletions internal/d2mod/treasure/biggergoldpiles.go
Original file line number Diff line number Diff line change
@@ -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)
}
35 changes: 35 additions & 0 deletions internal/d2mod/treasure/lowerprobs.go
Original file line number Diff line number Diff line change
@@ -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 }
47 changes: 47 additions & 0 deletions internal/d2mod/treasure/noflawgems.go
Original file line number Diff line number Diff line change
@@ -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)

}