mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-12-25 19:46:50 -05:00
Added loaders for itemratio.txt, Overlay.txt and UniqueAppellation.txt (#660)
* Added loaders for itemratio.txt, Overlay.txt, UniqueAppellation.txt * Adjust unique appellation loader for expansion data * fixes: response to PR comments * overlay.go: PR comment fixes Co-authored-by: Bojan Novkovic <bojan.novkovic@kset.org>
This commit is contained in:
parent
38852d0285
commit
247bda97c6
@ -229,6 +229,8 @@ func (a *App) loadDataDict() error {
|
||||
{d2resource.MagicPrefix, d2datadict.LoadMagicPrefix},
|
||||
{d2resource.MagicSuffix, d2datadict.LoadMagicSuffix},
|
||||
{d2resource.ItemStatCost, d2datadict.LoadItemStatCosts},
|
||||
{d2resource.ItemRatio, d2datadict.LoadItemRatios},
|
||||
{d2resource.Overlays, d2datadict.LoadOverlays},
|
||||
{d2resource.CharStats, d2datadict.LoadCharStats},
|
||||
{d2resource.Hireling, d2datadict.LoadHireling},
|
||||
{d2resource.Experience, d2datadict.LoadExperienceBreakpoints},
|
||||
@ -262,6 +264,7 @@ func (a *App) loadDataDict() error {
|
||||
{d2resource.PetType, d2datadict.LoadPetTypes},
|
||||
{d2resource.NPC, d2datadict.LoadNPCs},
|
||||
{d2resource.MonsterUniqueModifier, d2datadict.LoadMonsterUniqueModifiers},
|
||||
{d2resource.UniqueAppellation, d2datadict.LoadUniqueAppellations},
|
||||
{d2resource.MonsterLevel, d2datadict.LoadMonsterLevels},
|
||||
{d2resource.MonsterSound, d2datadict.LoadMonsterSounds},
|
||||
}
|
||||
|
88
d2common/d2data/d2datadict/item_ratio.go
Normal file
88
d2common/d2data/d2datadict/item_ratio.go
Normal file
@ -0,0 +1,88 @@
|
||||
package d2datadict
|
||||
|
||||
import (
|
||||
"log"
|
||||
"strconv"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
)
|
||||
|
||||
// A helper type for item drop calculation
|
||||
type dropRatioInfo struct {
|
||||
frequency int
|
||||
divisor int
|
||||
divisorMin int
|
||||
}
|
||||
|
||||
//ItemRatioRecord encapsulates information found in ItemRatio.txt
|
||||
//The information has been gathered from [https://d2mods.info/forum/kb/viewarticle?a=387]
|
||||
type ItemRatioRecord struct {
|
||||
Function string
|
||||
// 0 for classic, 1 for LoD
|
||||
Version bool
|
||||
|
||||
// 0 for normal, 1 for exceptional
|
||||
Uber bool
|
||||
ClassSpecific bool
|
||||
|
||||
// All following fields are used in item drop calculation
|
||||
UniqueDropInfo dropRatioInfo
|
||||
RareDropInfo dropRatioInfo
|
||||
SetDropInfo dropRatioInfo
|
||||
MagicDropInfo dropRatioInfo
|
||||
HiQualityDropInfo dropRatioInfo
|
||||
NormalDropInfo dropRatioInfo
|
||||
}
|
||||
|
||||
var ItemRatios map[string]*ItemRatioRecord
|
||||
|
||||
func LoadItemRatios(file []byte) {
|
||||
ItemRatios = make(map[string]*ItemRatioRecord)
|
||||
|
||||
d := d2common.LoadDataDictionary(file)
|
||||
for d.Next() {
|
||||
record := &ItemRatioRecord{
|
||||
Function: d.String("Function"),
|
||||
Version: d.Bool("Version"),
|
||||
Uber: d.Bool("Uber"),
|
||||
ClassSpecific: d.Bool("Class Specific"),
|
||||
UniqueDropInfo: dropRatioInfo{
|
||||
frequency: d.Number("Unique"),
|
||||
divisor: d.Number("UniqueDivisor"),
|
||||
divisorMin: d.Number("UniqueMin"),
|
||||
},
|
||||
RareDropInfo: dropRatioInfo{
|
||||
frequency: d.Number("Rare"),
|
||||
divisor: d.Number("RareDivisor"),
|
||||
divisorMin: d.Number("RareMin"),
|
||||
},
|
||||
SetDropInfo: dropRatioInfo{
|
||||
frequency: d.Number("Set"),
|
||||
divisor: d.Number("SetDivisor"),
|
||||
divisorMin: d.Number("SetMin"),
|
||||
},
|
||||
MagicDropInfo: dropRatioInfo{
|
||||
frequency: d.Number("Magic"),
|
||||
divisor: d.Number("MagicDivisor"),
|
||||
divisorMin: d.Number("MagicMin"),
|
||||
},
|
||||
HiQualityDropInfo: dropRatioInfo{
|
||||
frequency: d.Number("HiQuality"),
|
||||
divisor: d.Number("HiQualityDivisor"),
|
||||
divisorMin: 0,
|
||||
},
|
||||
NormalDropInfo: dropRatioInfo{
|
||||
frequency: d.Number("Normal"),
|
||||
divisor: d.Number("NormalDivisor"),
|
||||
divisorMin: 0,
|
||||
},
|
||||
}
|
||||
ItemRatios[record.Function+strconv.FormatBool(record.Version)] = record
|
||||
}
|
||||
|
||||
if d.Err != nil {
|
||||
panic(d.Err)
|
||||
}
|
||||
|
||||
log.Printf("Loaded %d ItemRatio records", len(ItemRatios))
|
||||
}
|
105
d2common/d2data/d2datadict/overlay.go
Normal file
105
d2common/d2data/d2datadict/overlay.go
Normal file
@ -0,0 +1,105 @@
|
||||
package d2datadict
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
)
|
||||
|
||||
// OverlayRecord encapsulates information found in Overlay.txt
|
||||
// The information has been gathered from [https://d2mods.info/forum/kb/viewarticle?a=465]
|
||||
type OverlayRecord struct {
|
||||
// Overlay name
|
||||
Overlay string
|
||||
// .dcc file found in Data/Globals/Overlays
|
||||
Filename string
|
||||
Version bool
|
||||
// Apparently unused, a similar field in the .dcc file is used instead
|
||||
Frames int
|
||||
// Unused
|
||||
Character string
|
||||
// Controls overlay drawing precedence
|
||||
PreDraw bool
|
||||
// Unknown
|
||||
OneOfN int
|
||||
|
||||
// Unknown
|
||||
Dir bool
|
||||
Open bool
|
||||
Beta bool
|
||||
|
||||
XOffset int
|
||||
YOffset int
|
||||
|
||||
// These values modify Y-axis placement
|
||||
Height1 int
|
||||
Height2 int
|
||||
Height3 int
|
||||
Height4 int
|
||||
|
||||
// Animation speed control
|
||||
AnimRate int
|
||||
// Unused
|
||||
LoopWaitTime int
|
||||
// Controls overlay blending mode, check out the link for more info
|
||||
// This should probably become an "enum" later on
|
||||
Trans int
|
||||
// Maximum light radius
|
||||
Radius int
|
||||
// Light radius increase per frame
|
||||
InitRadius int
|
||||
|
||||
Red uint8
|
||||
Green uint8
|
||||
Blue uint8
|
||||
|
||||
// Unknown
|
||||
NumDirections int
|
||||
LocalBlood int
|
||||
}
|
||||
|
||||
var Overlays map[string]*OverlayRecord
|
||||
|
||||
func LoadOverlays(file []byte) {
|
||||
Overlays = make(map[string]*OverlayRecord)
|
||||
d := d2common.LoadDataDictionary(file)
|
||||
|
||||
for d.Next() {
|
||||
record := &OverlayRecord{
|
||||
Overlay: d.String("Overlay"),
|
||||
Filename: d.String("Filename"),
|
||||
Version: d.Bool("Version"),
|
||||
Frames: d.Number("Frames"),
|
||||
Character: d.String("Character"),
|
||||
PreDraw: d.Bool("PreDraw"),
|
||||
OneOfN: d.Number("1ofN"),
|
||||
Dir: d.Bool("Dir"),
|
||||
Open: d.Bool("Open"),
|
||||
Beta: d.Bool("Beta"),
|
||||
XOffset: d.Number("Xoffset"),
|
||||
YOffset: d.Number("Yoffset"),
|
||||
Height1: d.Number("Height1"),
|
||||
Height2: d.Number("Height1"),
|
||||
Height3: d.Number("Height1"),
|
||||
Height4: d.Number("Height1"),
|
||||
AnimRate: d.Number("AnimRate"),
|
||||
LoopWaitTime: d.Number("LoopWaitTime"),
|
||||
Trans: d.Number("Trans"),
|
||||
InitRadius: d.Number("InitRadius"),
|
||||
Radius: d.Number("Radius"),
|
||||
Red: uint8(d.Number("Red")),
|
||||
Green: uint8(d.Number("Green")),
|
||||
Blue: uint8(d.Number("Blue")),
|
||||
NumDirections: d.Number("NumDirections"),
|
||||
LocalBlood: d.Number("LocalBlood"),
|
||||
}
|
||||
Overlays[record.Overlay] = record
|
||||
}
|
||||
|
||||
if d.Err != nil {
|
||||
panic(d.Err)
|
||||
}
|
||||
|
||||
log.Printf("Loaded %d Overlay records", len(Overlays))
|
||||
|
||||
}
|
32
d2common/d2data/d2datadict/unique_appellation.go
Normal file
32
d2common/d2data/d2datadict/unique_appellation.go
Normal file
@ -0,0 +1,32 @@
|
||||
package d2datadict
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
)
|
||||
|
||||
type UniqueAppellationRecord struct {
|
||||
// The title
|
||||
Name string
|
||||
}
|
||||
|
||||
var UniqueAppellations map[string]*UniqueAppellationRecord
|
||||
|
||||
func LoadUniqueAppellations(file []byte) {
|
||||
UniqueAppellations = make(map[string]*UniqueAppellationRecord)
|
||||
|
||||
d := d2common.LoadDataDictionary(file)
|
||||
for d.Next() {
|
||||
record := &UniqueAppellationRecord{
|
||||
Name: d.String("Name"),
|
||||
}
|
||||
UniqueAppellations[record.Name] = record
|
||||
}
|
||||
|
||||
if d.Err != nil {
|
||||
panic(d.Err)
|
||||
}
|
||||
|
||||
log.Printf("Loaded %d UniqueAppellation records", len(UniqueAppellations))
|
||||
}
|
@ -180,8 +180,10 @@ const (
|
||||
ObjectDetails = "/data/global/excel/Objects.txt"
|
||||
SoundSettings = "/data/global/excel/Sounds.txt"
|
||||
ItemStatCost = "/data/global/excel/ItemStatCost.txt"
|
||||
ItemRatio = "/data/global/excel/itemratio.txt"
|
||||
ItemTypes = "/data/global/excel/ItemTypes.txt"
|
||||
QualityItems = "/data/global/excel/qualityitems.txt"
|
||||
Overlays = "/data/global/excel/Overlay.txt"
|
||||
Runes = "/data/global/excel/runes.txt"
|
||||
Sets = "/data/global/excel/Sets.txt"
|
||||
SetItems = "/data/global/excel/SetItems.txt"
|
||||
@ -206,6 +208,7 @@ const (
|
||||
PetType = "/data/global/excel/pettype.txt"
|
||||
NPC = "/data/global/excel/npc.txt"
|
||||
MonsterUniqueModifier = "/data/global/excel/monumod.txt"
|
||||
UniqueAppellation = "/data/global/excel/UniqueAppellation.txt"
|
||||
MonsterLevel = "/data/global/excel/monlvl.txt"
|
||||
MonsterSound = "/data/global/excel/monsounds.txt"
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user