mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-05 08:07:51 -05:00
Added loaders for compcodes.txt, events.txt and monai.txt (#665)
* added loaders for compcodes.txt, events.txt and monai.txt * fixes in response to PR comments Co-authored-by: BojanoN <bojan.novkovic@kset.org>
This commit is contained in:
parent
efb554c42b
commit
0e1b30b91a
34
d2common/d2data/d2datadict/component_codes.go
Normal file
34
d2common/d2data/d2datadict/component_codes.go
Normal file
@ -0,0 +1,34 @@
|
||||
package d2datadict
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
)
|
||||
|
||||
type ComponentCodeRecord struct {
|
||||
Component string
|
||||
Code string
|
||||
}
|
||||
|
||||
var ComponentCodes map[string]*ComponentCodeRecord
|
||||
|
||||
func LoadComponentCodes(file []byte) {
|
||||
ComponentCodes = make(map[string]*ComponentCodeRecord)
|
||||
|
||||
d := d2common.LoadDataDictionary(file)
|
||||
for d.Next() {
|
||||
record := &ComponentCodeRecord{
|
||||
Component: d.String("component"),
|
||||
Code: d.String("code"),
|
||||
}
|
||||
ComponentCodes[record.Component] = record
|
||||
}
|
||||
|
||||
if d.Err != nil {
|
||||
panic(d.Err)
|
||||
}
|
||||
|
||||
log.Printf("Loaded %d ComponentCode records", len(ComponentCodes))
|
||||
|
||||
}
|
32
d2common/d2data/d2datadict/events.go
Normal file
32
d2common/d2data/d2datadict/events.go
Normal file
@ -0,0 +1,32 @@
|
||||
package d2datadict
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
)
|
||||
|
||||
type EventRecord struct {
|
||||
Event string
|
||||
}
|
||||
|
||||
var Events map[string]*EventRecord
|
||||
|
||||
func LoadEvents(file []byte) {
|
||||
Events = make(map[string]*EventRecord)
|
||||
|
||||
d := d2common.LoadDataDictionary(file)
|
||||
for d.Next() {
|
||||
record := &EventRecord{
|
||||
Event: d.String("event"),
|
||||
}
|
||||
Events[record.Event] = record
|
||||
}
|
||||
|
||||
if d.Err != nil {
|
||||
panic(d.Err)
|
||||
}
|
||||
|
||||
log.Printf("Loaded %d Event records", len(Events))
|
||||
|
||||
}
|
33
d2common/d2data/d2datadict/monster_ai.go
Normal file
33
d2common/d2data/d2datadict/monster_ai.go
Normal file
@ -0,0 +1,33 @@
|
||||
package d2datadict
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
)
|
||||
|
||||
// The monai.txt file is a lookup table for unit AI codes
|
||||
type MonsterAIRecord struct {
|
||||
AI string
|
||||
}
|
||||
|
||||
var MonsterAI map[string]*MonsterAIRecord
|
||||
|
||||
func LoadMonsterAI(file []byte) {
|
||||
MonsterAI = make(map[string]*MonsterAIRecord)
|
||||
|
||||
d := d2common.LoadDataDictionary(file)
|
||||
for d.Next() {
|
||||
record := &MonsterAIRecord{
|
||||
AI: d.String("AI"),
|
||||
}
|
||||
MonsterAI[record.AI] = record
|
||||
}
|
||||
|
||||
if d.Err != nil {
|
||||
panic(d.Err)
|
||||
}
|
||||
|
||||
log.Printf("Loaded %d MonsterAI records", len(MonsterAI))
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user