mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-06 19:44:15 -04:00
* Added RecordManager implementation to remove d2datadict singletons * fix object lookup test
60 lines
1.3 KiB
Go
60 lines
1.3 KiB
Go
package d2records
|
|
|
|
import (
|
|
"log"
|
|
|
|
"github.com/OpenDiablo2/OpenDiablo2/d2common/d2fileformats/d2txt"
|
|
)
|
|
|
|
func monsterUniqModifiersLoader(r *RecordManager, d *d2txt.DataDictionary) error {
|
|
records := make(MonsterUniqueModifiers)
|
|
constants := make([]int, 0)
|
|
|
|
for d.Next() {
|
|
record := &MonUModRecord{
|
|
Name: d.String("uniquemod"),
|
|
ID: d.Number("id"),
|
|
Enabled: d.Bool("enabled"),
|
|
ExpansionOnly: d.Number("version") == expansionCode,
|
|
Xfer: d.Bool("xfer"),
|
|
Champion: d.Bool("champion"),
|
|
FPick: d.Number("fpick"),
|
|
Exclude1: d.String("exclude1"),
|
|
Exclude2: d.String("exclude2"),
|
|
PickFrequencies: struct {
|
|
Normal *PickFreq
|
|
Nightmare *PickFreq
|
|
Hell *PickFreq
|
|
}{
|
|
Normal: &PickFreq{
|
|
Champion: d.Number("cpick"),
|
|
Unique: d.Number("upick"),
|
|
},
|
|
Nightmare: &PickFreq{
|
|
Champion: d.Number("cpick (N)"),
|
|
Unique: d.Number("upick (N)"),
|
|
},
|
|
Hell: &PickFreq{
|
|
Champion: d.Number("cpick (H)"),
|
|
Unique: d.Number("upick (H)"),
|
|
},
|
|
},
|
|
}
|
|
|
|
records[record.Name] = record
|
|
|
|
constants = append(constants, d.Number("constants"))
|
|
}
|
|
|
|
if d.Err != nil {
|
|
return d.Err
|
|
}
|
|
|
|
log.Printf("Loaded %d MonsterUniqueModifier records", len(records))
|
|
|
|
r.Monster.Unique.Mods = records
|
|
r.Monster.Unique.Constants = constants
|
|
|
|
return nil
|
|
}
|