mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2025-02-20 07:27:19 -05:00
Add monseq.txt loader (#664)
This commit is contained in:
parent
39ab8d19f5
commit
6514fd15de
@ -268,6 +268,7 @@ func (a *App) loadDataDict() error {
|
||||
{d2resource.UniqueAppellation, d2datadict.LoadUniqueAppellations},
|
||||
{d2resource.MonsterLevel, d2datadict.LoadMonsterLevels},
|
||||
{d2resource.MonsterSound, d2datadict.LoadMonsterSounds},
|
||||
{d2resource.MonsterSequence, d2datadict.LoadMonsterSequences},
|
||||
}
|
||||
|
||||
d2datadict.InitObjectRecords()
|
||||
|
67
d2common/d2data/d2datadict/monster_sequence.go
Normal file
67
d2common/d2data/d2datadict/monster_sequence.go
Normal file
@ -0,0 +1,67 @@
|
||||
package d2datadict
|
||||
|
||||
import (
|
||||
"log"
|
||||
|
||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||
)
|
||||
|
||||
//MonsterSequenceRecord contains a record for a monster sequence
|
||||
//Composed of multiple lines from monseq.txt with the same name in the first column.
|
||||
//Information gathered from [https://d2mods.info/forum/kb/viewarticle?a=395]
|
||||
type MonsterSequenceRecord struct {
|
||||
|
||||
//The sequence name, refered to by monstats.txt
|
||||
Name string
|
||||
|
||||
//The frames of this sequence
|
||||
Frames []*MonsterSequenceFrame
|
||||
}
|
||||
|
||||
//MonsterSequenceFrame represents a single frame of a monster sequence
|
||||
type MonsterSequenceFrame struct {
|
||||
//The animation mode for this frame (refers to MonMode.txt)
|
||||
Mode string
|
||||
|
||||
//The frame of the animation mode used for this frame of the sequence
|
||||
Frame int
|
||||
|
||||
//The direction of the frame, enumerated by d2enum.AnimationFrameDirection
|
||||
Direction int
|
||||
|
||||
//Event trigerred by this frame
|
||||
Event int
|
||||
}
|
||||
|
||||
//MonsterSequences contains the MonsterSequenceRecords
|
||||
var MonsterSequences map[string]*MonsterSequenceRecord
|
||||
|
||||
//LoadMonsterSequences loads the MonsterSequenceRecords into MonsterSequences
|
||||
func LoadMonsterSequences(file []byte) {
|
||||
MonsterSequences = make(map[string]*MonsterSequenceRecord)
|
||||
|
||||
d := d2common.LoadDataDictionary(file)
|
||||
for d.Next() {
|
||||
|
||||
name := d.String("sequence")
|
||||
if _, ok := MonsterSequences[name]; !ok {
|
||||
record := &MonsterSequenceRecord{
|
||||
Name: name,
|
||||
Frames: make([]*MonsterSequenceFrame, 0),
|
||||
}
|
||||
MonsterSequences[name] = record
|
||||
}
|
||||
MonsterSequences[name].Frames = append(MonsterSequences[name].Frames, &MonsterSequenceFrame{
|
||||
Mode: d.String("mode"),
|
||||
Frame: d.Number("frame"),
|
||||
Direction: d.Number("dir"),
|
||||
Event: d.Number("event"),
|
||||
})
|
||||
}
|
||||
|
||||
if d.Err != nil {
|
||||
panic(d.Err)
|
||||
}
|
||||
|
||||
log.Printf("Loaded %d MonsterSequence records", len(MonsterSequences))
|
||||
}
|
15
d2common/d2enum/animation_frame_direction.go
Normal file
15
d2common/d2enum/animation_frame_direction.go
Normal file
@ -0,0 +1,15 @@
|
||||
package d2enum
|
||||
|
||||
// AnimationFrameDirection enumerates animation frame directions used in d2datadict.MonsterSequenceFrame
|
||||
type AnimationFrameDirection int
|
||||
|
||||
const (
|
||||
SouthWest AnimationFrameDirection = iota
|
||||
NorthWest
|
||||
NorthEast
|
||||
SouthEast
|
||||
South
|
||||
West
|
||||
North
|
||||
East
|
||||
)
|
12
d2common/d2enum/animation_frame_event.go
Normal file
12
d2common/d2enum/animation_frame_event.go
Normal file
@ -0,0 +1,12 @@
|
||||
package d2enum
|
||||
|
||||
// AnimationFrameEvent enumerates events used in d2datadict.MonsterSequenceFrame
|
||||
type AnimationFrameEvent int
|
||||
|
||||
const (
|
||||
NoEvent AnimationFrameEvent = iota
|
||||
MeleeAttack
|
||||
MissileAttack
|
||||
PlaySound
|
||||
LaunchSpell
|
||||
)
|
@ -212,6 +212,7 @@ const (
|
||||
UniqueAppellation = "/data/global/excel/UniqueAppellation.txt"
|
||||
MonsterLevel = "/data/global/excel/monlvl.txt"
|
||||
MonsterSound = "/data/global/excel/monsounds.txt"
|
||||
MonsterSequence = "/data/global/excel/monseq.txt"
|
||||
|
||||
// --- Animations ---
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user