mirror of
https://github.com/OpenDiablo2/OpenDiablo2
synced 2024-09-27 21:56:19 -04:00
Refactored d2enum (#567)
* Refactored animation mode enum * More d2enum changes * Refactored tile enum * Refactored weapon class enum * Refactored more enums * Refactored item event enum * Fixed init_functions animation mode * Removed string2enum from MonsterAnimationMode * Refactored ItemStatCost description * Last enum lint errors * Regenerated monster stringer file
This commit is contained in:
parent
6030f68632
commit
9e58b134e5
@ -1,6 +1,7 @@
|
|||||||
package d2datadict
|
package d2datadict
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
|
|
||||||
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
"github.com/OpenDiablo2/OpenDiablo2/d2common"
|
||||||
@ -35,9 +36,6 @@ type ItemStatCostRecord struct {
|
|||||||
// entire op stuff.
|
// entire op stuff.
|
||||||
Stuff string
|
Stuff string
|
||||||
|
|
||||||
DescFn interface{} // the sprintf func
|
|
||||||
DescGroupFn interface{} // group sprintf func
|
|
||||||
|
|
||||||
Index int
|
Index int
|
||||||
|
|
||||||
// path_d2.mpq version doesnt have Ranged columne, excluding for now
|
// path_d2.mpq version doesnt have Ranged columne, excluding for now
|
||||||
@ -75,7 +73,7 @@ type ItemStatCostRecord struct {
|
|||||||
EventFuncID2 d2enum.ItemEventFuncID
|
EventFuncID2 d2enum.ItemEventFuncID
|
||||||
|
|
||||||
DescPriority int // determines order when displayed
|
DescPriority int // determines order when displayed
|
||||||
DescFnID d2enum.DescFuncID
|
DescFnID int
|
||||||
|
|
||||||
// Controls whenever and if so in what way the stat value is shown
|
// Controls whenever and if so in what way the stat value is shown
|
||||||
// 0 = doesn't show the value of the stat
|
// 0 = doesn't show the value of the stat
|
||||||
@ -87,7 +85,7 @@ type ItemStatCostRecord struct {
|
|||||||
// group func for desc (they need to be in the same affix)
|
// group func for desc (they need to be in the same affix)
|
||||||
DescGroup int
|
DescGroup int
|
||||||
DescGroupVal int
|
DescGroupVal int
|
||||||
DescGroupFuncID d2enum.DescFuncID
|
DescGroupFuncID int
|
||||||
|
|
||||||
CallbackEnabled bool // whether callback fn is called if value changes
|
CallbackEnabled bool // whether callback fn is called if value changes
|
||||||
Signed bool // whether the stat is signed
|
Signed bool // whether the stat is signed
|
||||||
@ -103,6 +101,61 @@ type ItemStatCostRecord struct {
|
|||||||
DamageRelated bool // prevents stacking of stats while dual wielding
|
DamageRelated bool // prevents stacking of stats while dual wielding
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gochecknoglobals // better for lookup
|
||||||
|
var itemStatCostRecordLookup = []string{
|
||||||
|
"+%f %s",
|
||||||
|
"%f%% %s",
|
||||||
|
"%f %s",
|
||||||
|
"+%f%% %s",
|
||||||
|
"%f%% %s",
|
||||||
|
"+%f %s %s",
|
||||||
|
"%f%% %s %s",
|
||||||
|
"+%f%% %s %s",
|
||||||
|
"%f %s %s",
|
||||||
|
"%f %s %s",
|
||||||
|
"Repairs 1 Durability In %.0f Seconds",
|
||||||
|
"+%f %s",
|
||||||
|
"+%.0f to %s Skill Levels",
|
||||||
|
"+%.0f to %s Skill Levels (%s Only)",
|
||||||
|
"%.0f%% chance to cast %d %s on %s",
|
||||||
|
"Level %d %s Aura When Equipped",
|
||||||
|
"%f %s (Increases near %d)",
|
||||||
|
"%f%% %s (Increases near %d)",
|
||||||
|
"",
|
||||||
|
"%f%% %s",
|
||||||
|
"%f %s",
|
||||||
|
"%f%% %s %s",
|
||||||
|
"",
|
||||||
|
"%f%% %s %s",
|
||||||
|
"Level %.0f %s (%d/%d Charges)",
|
||||||
|
"",
|
||||||
|
"",
|
||||||
|
"+%f to %s (%s Only)",
|
||||||
|
"+%.0f to %s",
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescString return a string based on the DescFnID
|
||||||
|
func (r *ItemStatCostRecord) DescString(a ...interface{}) string {
|
||||||
|
if r.DescFnID < 0 || r.DescFnID > len(itemStatCostRecordLookup) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
format := itemStatCostRecordLookup[r.DescFnID]
|
||||||
|
|
||||||
|
return fmt.Sprintf(format, a...)
|
||||||
|
}
|
||||||
|
|
||||||
|
// DescGroupString return a string based on the DescGroupFuncID
|
||||||
|
func (r *ItemStatCostRecord) DescGroupString(a ...interface{}) string {
|
||||||
|
if r.DescGroupFuncID < 0 || r.DescGroupFuncID > len(itemStatCostRecordLookup) {
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
|
format := itemStatCostRecordLookup[r.DescGroupFuncID]
|
||||||
|
|
||||||
|
return fmt.Sprintf(format, a...)
|
||||||
|
}
|
||||||
|
|
||||||
// ItemStatCosts stores all of the ItemStatCostRecords
|
// ItemStatCosts stores all of the ItemStatCostRecords
|
||||||
//nolint:gochecknoglobals // Currently global by design
|
//nolint:gochecknoglobals // Currently global by design
|
||||||
var ItemStatCosts map[string]*ItemStatCostRecord
|
var ItemStatCosts map[string]*ItemStatCostRecord
|
||||||
@ -159,20 +212,19 @@ func LoadItemStatCosts(file []byte) {
|
|||||||
|
|
||||||
EventID1: d2enum.GetItemEventType(d.String("itemevent1")),
|
EventID1: d2enum.GetItemEventType(d.String("itemevent1")),
|
||||||
EventID2: d2enum.GetItemEventType(d.String("itemevent2")),
|
EventID2: d2enum.GetItemEventType(d.String("itemevent2")),
|
||||||
EventFuncID1: d2enum.GetItemEventFuncID(d.Number("itemeventfunc1")),
|
EventFuncID1: d2enum.ItemEventFuncID(d.Number("itemeventfunc1")),
|
||||||
EventFuncID2: d2enum.GetItemEventFuncID(d.Number("itemeventfunc2")),
|
EventFuncID2: d2enum.ItemEventFuncID(d.Number("itemeventfunc2")),
|
||||||
|
|
||||||
DescPriority: d.Number("descpriority"),
|
DescPriority: d.Number("descpriority"),
|
||||||
DescFnID: d2enum.DescFuncID(d.Number("descfunc")),
|
DescFnID: d.Number("descfunc"),
|
||||||
DescFn: d2enum.GetDescFunction(d2enum.DescFuncID(d.Number("descfunc"))),
|
|
||||||
DescVal: d.Number("descval"),
|
DescVal: d.Number("descval"),
|
||||||
DescStrPos: d.String("descstrpos"),
|
DescStrPos: d.String("descstrpos"),
|
||||||
DescStrNeg: d.String("descstrneg"),
|
DescStrNeg: d.String("descstrneg"),
|
||||||
DescStr2: d.String("descstr2"),
|
DescStr2: d.String("descstr2"),
|
||||||
|
|
||||||
DescGroup: d.Number("dgrp"),
|
DescGroup: d.Number("dgrp"),
|
||||||
DescGroupFuncID: d2enum.DescFuncID(d.Number("dgrpfunc")),
|
DescGroupFuncID: d.Number("dgrpfunc"),
|
||||||
DescGroupFn: d2enum.GetDescFunction(d2enum.DescFuncID(d.Number("dgrpfunc"))),
|
|
||||||
DescGroupVal: d.Number("dgrpval"),
|
DescGroupVal: d.Number("dgrpval"),
|
||||||
DescGroupStrPos: d.String("dgrpstrpos"),
|
DescGroupStrPos: d.String("dgrpstrpos"),
|
||||||
DescGroupStrNeg: d.String("dgrpstrneg"),
|
DescGroupStrNeg: d.String("dgrpstrneg"),
|
||||||
|
@ -308,7 +308,7 @@ func LoadMonStats2(file []byte) {
|
|||||||
InfernoLen: d.Number("InfernoLen"),
|
InfernoLen: d.Number("InfernoLen"),
|
||||||
InfernoAnim: d.Number("InfernoAnim"),
|
InfernoAnim: d.Number("InfernoAnim"),
|
||||||
InfernoRollback: d.Number("InfernoRollback"),
|
InfernoRollback: d.Number("InfernoRollback"),
|
||||||
ResurrectMode: d2enum.MonsterAnimationModeFromString(d.String("ResurrectMode")),
|
ResurrectMode: monsterAnimationModeFromString(d.String("ResurrectMode")),
|
||||||
ResurrectSkill: d.String("ResurrectSkill"),
|
ResurrectSkill: d.String("ResurrectSkill"),
|
||||||
}
|
}
|
||||||
MonStats2[record.Key] = record
|
MonStats2[record.Key] = record
|
||||||
@ -320,3 +320,20 @@ func LoadMonStats2(file []byte) {
|
|||||||
|
|
||||||
log.Printf("Loaded %d MonStats2 records", len(MonStats2))
|
log.Printf("Loaded %d MonStats2 records", len(MonStats2))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//nolint:gochecknoglobals // better for lookup
|
||||||
|
var monsterAnimationModeLookup = map[string]d2enum.MonsterAnimationMode{
|
||||||
|
d2enum.MonsterAnimationModeNeutral.String(): d2enum.MonsterAnimationModeNeutral,
|
||||||
|
d2enum.MonsterAnimationModeSkill1.String(): d2enum.MonsterAnimationModeSkill1,
|
||||||
|
d2enum.MonsterAnimationModeSequence.String(): d2enum.MonsterAnimationModeSequence,
|
||||||
|
}
|
||||||
|
|
||||||
|
func monsterAnimationModeFromString(s string) d2enum.MonsterAnimationMode {
|
||||||
|
v, ok := monsterAnimationModeLookup[s]
|
||||||
|
if !ok {
|
||||||
|
log.Fatalf("unhandled MonsterAnimationMode %q", s)
|
||||||
|
return d2enum.MonsterAnimationModeNeutral
|
||||||
|
}
|
||||||
|
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
@ -3,19 +3,11 @@ package d2enum
|
|||||||
// AnimationFrame represents a single frame of animation.
|
// AnimationFrame represents a single frame of animation.
|
||||||
type AnimationFrame int
|
type AnimationFrame int
|
||||||
|
|
||||||
|
// AnimationFrame types
|
||||||
const (
|
const (
|
||||||
// AnimationFrameNoEvent represents an animation frame with no event
|
|
||||||
AnimationFrameNoEvent AnimationFrame = iota
|
AnimationFrameNoEvent AnimationFrame = iota
|
||||||
|
|
||||||
// AnimationFrameAttack represents an animation frame with an attack event
|
|
||||||
AnimationFrameAttack
|
AnimationFrameAttack
|
||||||
|
|
||||||
// AnimationFrameMissile represents an animation frame with a missile event
|
|
||||||
AnimationFrameMissile
|
AnimationFrameMissile
|
||||||
|
|
||||||
// AnimationFrameSound represents an animation frame with a sound event
|
|
||||||
AnimationFrameSound
|
AnimationFrameSound
|
||||||
|
|
||||||
// AnimationFrameSkill represents an animation frame with a skill event
|
|
||||||
AnimationFrameSkill
|
AnimationFrameSkill
|
||||||
)
|
)
|
||||||
|
@ -1,153 +0,0 @@
|
|||||||
package d2enum
|
|
||||||
|
|
||||||
// PlayerAnimationMode represents player animation modes
|
|
||||||
type PlayerAnimationMode int
|
|
||||||
|
|
||||||
// MonsterAnimationMode represents monster animation modes
|
|
||||||
type MonsterAnimationMode int
|
|
||||||
|
|
||||||
// ObjectAnimationMode represents object animation modes
|
|
||||||
type ObjectAnimationMode int
|
|
||||||
|
|
||||||
const (
|
|
||||||
// AnimationModePlayerDeath represents DT
|
|
||||||
AnimationModePlayerDeath PlayerAnimationMode = iota
|
|
||||||
|
|
||||||
// AnimationModePlayerNeutral represents NU
|
|
||||||
AnimationModePlayerNeutral
|
|
||||||
|
|
||||||
// AnimationModePlayerWalk represents WL
|
|
||||||
AnimationModePlayerWalk
|
|
||||||
|
|
||||||
// AnimationModePlayerRun represents RN
|
|
||||||
AnimationModePlayerRun
|
|
||||||
|
|
||||||
// AnimationModePlayerGetHit represents GH
|
|
||||||
AnimationModePlayerGetHit
|
|
||||||
|
|
||||||
// AnimationModePlayerTownNeutral represents TN
|
|
||||||
AnimationModePlayerTownNeutral
|
|
||||||
|
|
||||||
// AnimationModePlayerTownWalk represents TW
|
|
||||||
AnimationModePlayerTownWalk
|
|
||||||
|
|
||||||
// AnimationModePlayerAttack1 represents A1
|
|
||||||
AnimationModePlayerAttack1
|
|
||||||
|
|
||||||
// AnimationModePlayerAttack2 represents A2
|
|
||||||
AnimationModePlayerAttack2
|
|
||||||
|
|
||||||
// AnimationModePlayerBlock represents BL
|
|
||||||
AnimationModePlayerBlock
|
|
||||||
|
|
||||||
// AnimationModePlayerCast represents SC
|
|
||||||
AnimationModePlayerCast
|
|
||||||
|
|
||||||
// AnimationModePlayerThrow represents TH
|
|
||||||
AnimationModePlayerThrow
|
|
||||||
|
|
||||||
// AnimationModePlayerKick represents KK
|
|
||||||
AnimationModePlayerKick
|
|
||||||
|
|
||||||
// AnimationModePlayerSkill1 represents S1
|
|
||||||
AnimationModePlayerSkill1
|
|
||||||
|
|
||||||
// AnimationModePlayerSkill2 represents S2
|
|
||||||
AnimationModePlayerSkill2
|
|
||||||
|
|
||||||
// AnimationModePlayerSkill3 represents S3
|
|
||||||
AnimationModePlayerSkill3
|
|
||||||
|
|
||||||
// AnimationModePlayerSkill4 represents S4
|
|
||||||
AnimationModePlayerSkill4
|
|
||||||
|
|
||||||
// AnimationModePlayerDead represents DD
|
|
||||||
AnimationModePlayerDead
|
|
||||||
|
|
||||||
// AnimationModePlayerSequence represents GH
|
|
||||||
AnimationModePlayerSequence
|
|
||||||
|
|
||||||
// AnimationModePlayerKnockBack represents GH
|
|
||||||
AnimationModePlayerKnockBack
|
|
||||||
)
|
|
||||||
const (
|
|
||||||
|
|
||||||
// AnimationModeMonsterDeath represents DT
|
|
||||||
AnimationModeMonsterDeath MonsterAnimationMode = iota
|
|
||||||
|
|
||||||
// AnimationModeMonsterNeutral represents NU
|
|
||||||
AnimationModeMonsterNeutral
|
|
||||||
|
|
||||||
// AnimationModeMonsterWalk represents WL
|
|
||||||
AnimationModeMonsterWalk
|
|
||||||
|
|
||||||
// AnimationModeMonsterGetHit represents GH
|
|
||||||
AnimationModeMonsterGetHit
|
|
||||||
|
|
||||||
// AnimationModeMonsterAttack1 represents A1
|
|
||||||
AnimationModeMonsterAttack1
|
|
||||||
|
|
||||||
// AnimationModeMonsterAttack2 represents A2
|
|
||||||
AnimationModeMonsterAttack2
|
|
||||||
|
|
||||||
// AnimationModeMonsterBlock represents BL
|
|
||||||
AnimationModeMonsterBlock
|
|
||||||
|
|
||||||
// AnimationModeMonsterCast represents SC
|
|
||||||
AnimationModeMonsterCast
|
|
||||||
|
|
||||||
// AnimationModeMonsterSkill1 represents S1
|
|
||||||
AnimationModeMonsterSkill1
|
|
||||||
|
|
||||||
// AnimationModeMonsterSkill2 represents S2
|
|
||||||
AnimationModeMonsterSkill2
|
|
||||||
|
|
||||||
// AnimationModeMonsterSkill3 represents S3
|
|
||||||
AnimationModeMonsterSkill3
|
|
||||||
|
|
||||||
// AnimationModeMonsterSkill4 represents S4
|
|
||||||
AnimationModeMonsterSkill4
|
|
||||||
|
|
||||||
// AnimationModeMonsterDead represents DD
|
|
||||||
AnimationModeMonsterDead
|
|
||||||
|
|
||||||
// AnimationModeMonsterKnockback represents GH
|
|
||||||
AnimationModeMonsterKnockback
|
|
||||||
|
|
||||||
// AnimationModeMonsterSequence represents xx
|
|
||||||
AnimationModeMonsterSequence
|
|
||||||
|
|
||||||
// AnimationModeMonsterRun represents RN
|
|
||||||
AnimationModeMonsterRun
|
|
||||||
)
|
|
||||||
const (
|
|
||||||
|
|
||||||
// AnimationModeObjectNeutral represents NU
|
|
||||||
AnimationModeObjectNeutral ObjectAnimationMode = iota
|
|
||||||
|
|
||||||
// AnimationModeObjectOperating represents OP
|
|
||||||
AnimationModeObjectOperating
|
|
||||||
|
|
||||||
// AnimationModeObjectOpened represents ON
|
|
||||||
AnimationModeObjectOpened
|
|
||||||
|
|
||||||
// AnimationModeObjectSpecial1 represents S1
|
|
||||||
AnimationModeObjectSpecial1
|
|
||||||
|
|
||||||
// AnimationModeObjectSpecial2 represents S2
|
|
||||||
AnimationModeObjectSpecial2
|
|
||||||
|
|
||||||
// AnimationModeObjectSpecial3 represents S3
|
|
||||||
AnimationModeObjectSpecial3
|
|
||||||
|
|
||||||
// AnimationModeObjectSpecial4 represents S4
|
|
||||||
AnimationModeObjectSpecial4
|
|
||||||
|
|
||||||
// AnimationModeObjectSpecial5 represents S5
|
|
||||||
AnimationModeObjectSpecial5
|
|
||||||
)
|
|
||||||
|
|
||||||
//go:generate stringer -linecomment -type PlayerAnimationMode
|
|
||||||
//go:generate stringer -linecomment -type MonsterAnimationMode
|
|
||||||
//go:generate stringer -linecomment -type ObjectAnimationMode
|
|
||||||
//go:generate string2enum -samepkg -linecomment -type ObjectAnimationMode
|
|
@ -1,60 +1,27 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
//go:generate stringer -linecomment -type CompositeType -output composite_type_string.go
|
||||||
|
|
||||||
// CompositeType represents a composite type
|
// CompositeType represents a composite type
|
||||||
type CompositeType int
|
type CompositeType int
|
||||||
|
|
||||||
|
// Composite types
|
||||||
const (
|
const (
|
||||||
|
|
||||||
// CompositeTypeHead is a composite type for heads
|
|
||||||
CompositeTypeHead CompositeType = iota // HD
|
CompositeTypeHead CompositeType = iota // HD
|
||||||
|
|
||||||
// CompositeTypeTorso is a composite type for torsos
|
|
||||||
CompositeTypeTorso // TR
|
CompositeTypeTorso // TR
|
||||||
|
|
||||||
// CompositeTypeLegs is a composite type for legs
|
|
||||||
CompositeTypeLegs // LG
|
CompositeTypeLegs // LG
|
||||||
|
|
||||||
// CompositeTypeRightArm is a composite type for right arms
|
|
||||||
CompositeTypeRightArm // RA
|
CompositeTypeRightArm // RA
|
||||||
|
|
||||||
// CompositeTypeLeftArm is a composite type for left arms
|
|
||||||
CompositeTypeLeftArm // LA
|
CompositeTypeLeftArm // LA
|
||||||
|
|
||||||
// CompositeTypeRightHand is a composite type for right hands
|
|
||||||
CompositeTypeRightHand // RH
|
CompositeTypeRightHand // RH
|
||||||
|
|
||||||
// CompositeTypeLeftHand is a composite type for left hands
|
|
||||||
CompositeTypeLeftHand // LH
|
CompositeTypeLeftHand // LH
|
||||||
|
|
||||||
// CompositeTypeShield is a composite type for shields
|
|
||||||
CompositeTypeShield // SH
|
CompositeTypeShield // SH
|
||||||
|
|
||||||
// CompositeTypeSpecial1 is a composite type for special type 1s
|
|
||||||
CompositeTypeSpecial1 // S1
|
CompositeTypeSpecial1 // S1
|
||||||
|
|
||||||
// CompositeTypeSpecial2 is a composite type for special type 2s
|
|
||||||
CompositeTypeSpecial2 // S2
|
CompositeTypeSpecial2 // S2
|
||||||
|
|
||||||
// CompositeTypeSpecial3 is a composite type for special type 3s
|
|
||||||
CompositeTypeSpecial3 // S3
|
CompositeTypeSpecial3 // S3
|
||||||
|
|
||||||
// CompositeTypeSpecial4 is a composite type for special type 4s
|
|
||||||
CompositeTypeSpecial4 // S4
|
CompositeTypeSpecial4 // S4
|
||||||
|
|
||||||
// CompositeTypeSpecial5 is a composite type for special type 5s
|
|
||||||
CompositeTypeSpecial5 // S5
|
CompositeTypeSpecial5 // S5
|
||||||
|
|
||||||
// CompositeTypeSpecial6 is a composite type for special type 6s
|
|
||||||
CompositeTypeSpecial6 // S6
|
CompositeTypeSpecial6 // S6
|
||||||
|
|
||||||
// CompositeTypeSpecial7 is a composite type for special type 7s
|
|
||||||
CompositeTypeSpecial7 // S7
|
CompositeTypeSpecial7 // S7
|
||||||
|
|
||||||
// CompositeTypeSpecial8 is a composite type for special type 8s
|
|
||||||
CompositeTypeSpecial8 // S8
|
CompositeTypeSpecial8 // S8
|
||||||
|
|
||||||
// CompositeTypeMax is used to determine the max number of composite types
|
|
||||||
CompositeTypeMax
|
CompositeTypeMax
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate stringer -linecomment -type CompositeType
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -linecomment -type CompositeType"; DO NOT EDIT.
|
// Code generated by "stringer -linecomment -type CompositeType -output composite_type_string.go"; DO NOT EDIT.
|
||||||
|
|
||||||
package d2enum
|
package d2enum
|
||||||
|
|
@ -1,58 +0,0 @@
|
|||||||
// Code generated by "string2enum -samepkg -linecomment -type CompositeType"; DO NOT EDIT.
|
|
||||||
|
|
||||||
package d2enum
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// CompositeTypeFromString returns the CompositeType enum corresponding to s.
|
|
||||||
func CompositeTypeFromString(s string) CompositeType {
|
|
||||||
if len(s) == 0 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
for i := range _CompositeType_index[:len(_CompositeType_index)-1] {
|
|
||||||
if s == _CompositeType_name[_CompositeType_index[i]:_CompositeType_index[i+1]] {
|
|
||||||
return CompositeType(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("unable to locate CompositeType enum corresponding to %q", s))
|
|
||||||
}
|
|
||||||
|
|
||||||
func _(s string) {
|
|
||||||
// Check for duplicate string values in type "CompositeType".
|
|
||||||
switch s {
|
|
||||||
// 0
|
|
||||||
case "HD":
|
|
||||||
// 1
|
|
||||||
case "TR":
|
|
||||||
// 2
|
|
||||||
case "LG":
|
|
||||||
// 3
|
|
||||||
case "RA":
|
|
||||||
// 4
|
|
||||||
case "LA":
|
|
||||||
// 5
|
|
||||||
case "RH":
|
|
||||||
// 6
|
|
||||||
case "LH":
|
|
||||||
// 7
|
|
||||||
case "SH":
|
|
||||||
// 8
|
|
||||||
case "S1":
|
|
||||||
// 9
|
|
||||||
case "S2":
|
|
||||||
// 10
|
|
||||||
case "S3":
|
|
||||||
// 11
|
|
||||||
case "S4":
|
|
||||||
// 12
|
|
||||||
case "S5":
|
|
||||||
// 13
|
|
||||||
case "S6":
|
|
||||||
// 14
|
|
||||||
case "S7":
|
|
||||||
// 15
|
|
||||||
case "S8":
|
|
||||||
// 16
|
|
||||||
case "CompositeTypeMax":
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,194 +0,0 @@
|
|||||||
package d2enum
|
|
||||||
|
|
||||||
import (
|
|
||||||
"fmt"
|
|
||||||
)
|
|
||||||
|
|
||||||
type DescFuncID int
|
|
||||||
|
|
||||||
func Format1(value float64, string1 string) string {
|
|
||||||
// +[value] [string1]
|
|
||||||
return fmt.Sprintf("+%f %s", value, string1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format2(value float64, string1 string) string {
|
|
||||||
// [value]% [string1]
|
|
||||||
return fmt.Sprintf("%f%% %s", value, string1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format3(value float64, string1 string) string {
|
|
||||||
// [value] [string1]
|
|
||||||
return fmt.Sprintf("%f %s", value, string1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format4(value float64, string1 string) string {
|
|
||||||
// +[value]% [string1]
|
|
||||||
return fmt.Sprintf("+%f%% %s", value, string1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format5(value float64, string1 string) string {
|
|
||||||
// [value*100/128]% [string1]
|
|
||||||
return fmt.Sprintf("%f%% %s", (value*100.0)/128.0, string1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format6(value float64, string1, string2 string) string {
|
|
||||||
// +[value] [string1] [string2]
|
|
||||||
return fmt.Sprintf("+%f %s %s", value, string1, string2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format7(value float64, string1, string2 string) string {
|
|
||||||
// [value]% [string1] [string2]
|
|
||||||
return fmt.Sprintf("%f%% %s %s", value, string1, string2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format8(value float64, string1, string2 string) string {
|
|
||||||
// +[value]% [string1] [string2]
|
|
||||||
return fmt.Sprintf("+%f%% %s %s", value, string1, string2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format9(value float64, string1, string2 string) string {
|
|
||||||
// [value] [string1] [string2]
|
|
||||||
return fmt.Sprintf("%f %s %s", value, string1, string2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format10(value float64, string1, string2 string) string {
|
|
||||||
// [value*100/128]% [string1] [string2]
|
|
||||||
return fmt.Sprintf("%f%% %s %s", (value*100.0)/128.0, string1, string2)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format11(value float64) string {
|
|
||||||
// Repairs 1 Durability In [100 / value] Seconds
|
|
||||||
return fmt.Sprintf("Repairs 1 Durability In %.0f Seconds", 100.0/value)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format12(value float64, string1 string) string {
|
|
||||||
// +[value] [string1]
|
|
||||||
return fmt.Sprintf("+%f %s", value, string1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format13(value float64, class string) string {
|
|
||||||
// +[value] to [class] Skill Levels
|
|
||||||
return fmt.Sprintf("+%.0f to %s Skill Levels", value, class)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format14(value float64, skilltab, class string) string {
|
|
||||||
// +[value] to [skilltab] Skill Levels ([class] Only)
|
|
||||||
fmtStr := "+%.0f to %s Skill Levels (%s Only)"
|
|
||||||
return fmt.Sprintf(fmtStr, value, skilltab, class)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format15(value float64, slvl int, skill, event string) string {
|
|
||||||
// [value]% chance to cast [slvl] [skill] on [event]
|
|
||||||
fmtStr := "%.0f%% chance to cast %d %s on %s"
|
|
||||||
return fmt.Sprintf(fmtStr, value, slvl, skill, event)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format16(slvl int, skill string) string {
|
|
||||||
// Level [sLvl] [skill] Aura When Equipped
|
|
||||||
return fmt.Sprintf("Level %d %s Aura When Equipped", slvl, skill)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format17(value float64, string1 string, time int) string {
|
|
||||||
// [value] [string1] (Increases near [time])
|
|
||||||
return fmt.Sprintf("%f %s (Increases near %d)", value, string1, time)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format18(value float64, string1 string, time int) string {
|
|
||||||
// [value]% [string1] (Increases near [time])
|
|
||||||
return fmt.Sprintf("%f%% %s (Increases near %d)", value, string1, time)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format19(value float64, string1 string) string {
|
|
||||||
// this is used by stats that use Blizzard's sprintf implementation
|
|
||||||
// (if you don't know what that is, it won't be of interest to you
|
|
||||||
// eitherway I guess), look at how prismatic is setup, the string is
|
|
||||||
// the format that gets passed to their sprintf spinoff.
|
|
||||||
return "" // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format20(value float64, string1 string) string {
|
|
||||||
// [value * -1]% [string1]
|
|
||||||
return fmt.Sprintf("%f%% %s", value*-1.0, string1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format21(value float64, string1 string) string {
|
|
||||||
// [value * -1] [string1]
|
|
||||||
return fmt.Sprintf("%f %s", value*-1.0, string1)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format22(value float64, string1, montype string) string {
|
|
||||||
// [value]% [string1] [montype]
|
|
||||||
return fmt.Sprintf("%f%% %s %s", value, string1, montype)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format23(value float64, string1 string) string {
|
|
||||||
// (warning: this is bugged in vanilla and doesn't work properly
|
|
||||||
// see CE forum)
|
|
||||||
return "" // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format24(value float64, string1, monster string) string {
|
|
||||||
// [value]% [string1] [monster]
|
|
||||||
return fmt.Sprintf("%f%% %s %s", value, string1, monster)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format25(slvl float64, skill string, charges, maxCharges int) string {
|
|
||||||
// Level [slvl] [skill] ([charges]/[maxCharges] Charges)
|
|
||||||
fmtStr := "Level %.0f %s (%d/%d Charges)"
|
|
||||||
return fmt.Sprintf(fmtStr, slvl, skill, charges, maxCharges)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format26(value float64, string1 string) string {
|
|
||||||
// not used by vanilla, present in the code but I didn't test it yet
|
|
||||||
return "" // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format27(value float64, string1 string) string {
|
|
||||||
// not used by vanilla, present in the code but I didn't test it yet
|
|
||||||
return "" // TODO
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format28(value float64, skill, class string) string {
|
|
||||||
// +[value] to [skill] ([class] Only)
|
|
||||||
return fmt.Sprintf("+%f to %s (%s Only)", value, skill, class)
|
|
||||||
}
|
|
||||||
|
|
||||||
func Format29(value float64, skill string) string {
|
|
||||||
// +[value] to [skill]
|
|
||||||
return fmt.Sprintf("+%.0f to %s", value, skill)
|
|
||||||
}
|
|
||||||
|
|
||||||
func GetDescFunction(n DescFuncID) interface{} {
|
|
||||||
m := map[DescFuncID]interface{}{
|
|
||||||
DescFuncID(0): Format1,
|
|
||||||
DescFuncID(1): Format2,
|
|
||||||
DescFuncID(2): Format3,
|
|
||||||
DescFuncID(3): Format4,
|
|
||||||
DescFuncID(4): Format5,
|
|
||||||
DescFuncID(5): Format6,
|
|
||||||
DescFuncID(6): Format7,
|
|
||||||
DescFuncID(7): Format8,
|
|
||||||
DescFuncID(8): Format9,
|
|
||||||
DescFuncID(9): Format10,
|
|
||||||
DescFuncID(10): Format11,
|
|
||||||
DescFuncID(11): Format12,
|
|
||||||
DescFuncID(12): Format13,
|
|
||||||
DescFuncID(13): Format14,
|
|
||||||
DescFuncID(14): Format15,
|
|
||||||
DescFuncID(15): Format16,
|
|
||||||
DescFuncID(16): Format17,
|
|
||||||
DescFuncID(17): Format18,
|
|
||||||
DescFuncID(18): Format19,
|
|
||||||
DescFuncID(19): Format20,
|
|
||||||
DescFuncID(20): Format21,
|
|
||||||
DescFuncID(21): Format22,
|
|
||||||
DescFuncID(22): Format23,
|
|
||||||
DescFuncID(23): Format24,
|
|
||||||
DescFuncID(24): Format25,
|
|
||||||
DescFuncID(25): Format26,
|
|
||||||
DescFuncID(26): Format27,
|
|
||||||
DescFuncID(27): Format28,
|
|
||||||
DescFuncID(28): Format29,
|
|
||||||
}
|
|
||||||
return m[n]
|
|
||||||
}
|
|
@ -5,7 +5,6 @@ type DrawEffect int
|
|||||||
|
|
||||||
// Names courtesy of Necrolis
|
// Names courtesy of Necrolis
|
||||||
const (
|
const (
|
||||||
|
|
||||||
// DrawEffectPctTransparency25 is a draw effect that implements the following function:
|
// DrawEffectPctTransparency25 is a draw effect that implements the following function:
|
||||||
// GL_MODULATE; GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA 25 % transparency (colormaps 49-304 in a .pl2)
|
// GL_MODULATE; GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA 25 % transparency (colormaps 49-304 in a .pl2)
|
||||||
DrawEffectPctTransparency25 DrawEffect = iota
|
DrawEffectPctTransparency25 DrawEffect = iota
|
||||||
|
@ -1,7 +1,9 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
// EncodingType represents a encoding type
|
||||||
type EncodingType int
|
type EncodingType int
|
||||||
|
|
||||||
|
// Encoding types
|
||||||
const (
|
const (
|
||||||
EncodeDefault EncodingType = iota
|
EncodeDefault EncodingType = iota
|
||||||
)
|
)
|
||||||
|
@ -2,19 +2,25 @@ package d2enum
|
|||||||
|
|
||||||
import "log"
|
import "log"
|
||||||
|
|
||||||
|
//go:generate stringer -linecomment -type Hero
|
||||||
|
//go:generate string2enum -samepkg -linecomment -type Hero
|
||||||
|
|
||||||
|
// Hero is used for different types of hero's
|
||||||
type Hero int
|
type Hero int
|
||||||
|
|
||||||
|
// Heroes
|
||||||
const (
|
const (
|
||||||
HeroNone Hero = 0 //
|
HeroNone Hero = iota //
|
||||||
HeroBarbarian Hero = 1 // Barbarian
|
HeroBarbarian // Barbarian
|
||||||
HeroNecromancer Hero = 2 // Necromancer
|
HeroNecromancer // Necromancer
|
||||||
HeroPaladin Hero = 3 // Paladin
|
HeroPaladin // Paladin
|
||||||
HeroAssassin Hero = 4 // Assassin
|
HeroAssassin // Assassin
|
||||||
HeroSorceress Hero = 5 // Sorceress
|
HeroSorceress // Sorceress
|
||||||
HeroAmazon Hero = 6 // Amazon
|
HeroAmazon // Amazon
|
||||||
HeroDruid Hero = 7 // Druid
|
HeroDruid // Druid
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// GetToken returns a 2 letter token
|
||||||
func (h Hero) GetToken() string {
|
func (h Hero) GetToken() string {
|
||||||
switch h {
|
switch h {
|
||||||
case HeroBarbarian:
|
case HeroBarbarian:
|
||||||
@ -34,8 +40,6 @@ func (h Hero) GetToken() string {
|
|||||||
default:
|
default:
|
||||||
log.Fatalf("Unknown hero token: %d", h)
|
log.Fatalf("Unknown hero token: %d", h)
|
||||||
}
|
}
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
}
|
}
|
||||||
|
|
||||||
//go:generate stringer -linecomment -type Hero
|
|
||||||
//go:generate string2enum -samepkg -linecomment -type Hero
|
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
// HeroStance used to render hero stance
|
||||||
type HeroStance int
|
type HeroStance int
|
||||||
|
|
||||||
|
// HeroStance types
|
||||||
const (
|
const (
|
||||||
HeroStanceIdle HeroStance = 0
|
HeroStanceIdle HeroStance = iota
|
||||||
HeroStanceIdleSelected HeroStance = 1
|
HeroStanceIdleSelected
|
||||||
HeroStanceApproaching HeroStance = 2
|
HeroStanceApproaching
|
||||||
HeroStanceSelected HeroStance = 3
|
HeroStanceSelected
|
||||||
HeroStanceRetreating HeroStance = 4
|
HeroStanceRetreating
|
||||||
)
|
)
|
||||||
|
@ -22,9 +22,9 @@ const _Hero_name = "BarbarianNecromancerPaladinAssassinSorceressAmazonDruid"
|
|||||||
|
|
||||||
var _Hero_index = [...]uint8{0, 0, 9, 20, 27, 35, 44, 50, 55}
|
var _Hero_index = [...]uint8{0, 0, 9, 20, 27, 35, 44, 50, 55}
|
||||||
|
|
||||||
func (h Hero) String() string {
|
func (i Hero) String() string {
|
||||||
if h < 0 || h >= Hero(len(_Hero_index)-1) {
|
if i < 0 || i >= Hero(len(_Hero_index)-1) {
|
||||||
return "Hero(" + strconv.FormatInt(int64(h), 10) + ")"
|
return "Hero(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||||
}
|
}
|
||||||
return _Hero_name[_Hero_index[h]:_Hero_index[h+1]]
|
return _Hero_name[_Hero_index[i]:_Hero_index[i+1]]
|
||||||
}
|
}
|
||||||
|
@ -16,3 +16,25 @@ func HeroFromString(s string) Hero {
|
|||||||
}
|
}
|
||||||
panic(fmt.Errorf("unable to locate Hero enum corresponding to %q", s))
|
panic(fmt.Errorf("unable to locate Hero enum corresponding to %q", s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _(s string) {
|
||||||
|
// Check for duplicate string values in type "Hero".
|
||||||
|
switch s {
|
||||||
|
// 0
|
||||||
|
case "":
|
||||||
|
// 1
|
||||||
|
case "Barbarian":
|
||||||
|
// 2
|
||||||
|
case "Necromancer":
|
||||||
|
// 3
|
||||||
|
case "Paladin":
|
||||||
|
// 4
|
||||||
|
case "Assassin":
|
||||||
|
// 5
|
||||||
|
case "Sorceress":
|
||||||
|
// 6
|
||||||
|
case "Amazon":
|
||||||
|
// 7
|
||||||
|
case "Druid":
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -3,12 +3,9 @@ package d2enum
|
|||||||
// Priority of the event handler
|
// Priority of the event handler
|
||||||
type Priority int
|
type Priority int
|
||||||
|
|
||||||
//noinspection GoUnusedConst // nothing is low priority yet
|
// Priorities
|
||||||
const (
|
const (
|
||||||
// PriorityLow is a low priority handler
|
|
||||||
PriorityLow Priority = iota
|
PriorityLow Priority = iota
|
||||||
// PriorityDefault is a default priority handler
|
|
||||||
PriorityDefault
|
PriorityDefault
|
||||||
// PriorityHigh is a high priority handler
|
|
||||||
PriorityHigh
|
PriorityHigh
|
||||||
)
|
)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
// InventoryItemType represents a inventory item type
|
||||||
type InventoryItemType int
|
type InventoryItemType int
|
||||||
|
|
||||||
|
// Inventry item types
|
||||||
const (
|
const (
|
||||||
InventoryItemTypeItem InventoryItemType = 0 // Item
|
InventoryItemTypeItem InventoryItemType = iota
|
||||||
InventoryItemTypeWeapon InventoryItemType = 1 // Weapon
|
InventoryItemTypeWeapon
|
||||||
InventoryItemTypeArmor InventoryItemType = 2 // Armor
|
InventoryItemTypeArmor
|
||||||
)
|
)
|
||||||
|
@ -1,13 +1,18 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
// ItemAffixSuperType represents a item affix super type
|
||||||
type ItemAffixSuperType int
|
type ItemAffixSuperType int
|
||||||
type ItemAffixSubType int
|
|
||||||
|
|
||||||
|
// Super types
|
||||||
const (
|
const (
|
||||||
ItemAffixPrefix ItemAffixSuperType = iota
|
ItemAffixPrefix ItemAffixSuperType = iota
|
||||||
ItemAffixSuffix
|
ItemAffixSuffix
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// ItemAffixSubType represents a item affix sub type
|
||||||
|
type ItemAffixSubType int
|
||||||
|
|
||||||
|
// Sub types
|
||||||
const (
|
const (
|
||||||
ItemAffixCommon ItemAffixSubType = iota
|
ItemAffixCommon ItemAffixSubType = iota
|
||||||
ItemAffixMagic
|
ItemAffixMagic
|
||||||
|
@ -1,11 +1,13 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
// ItemEventFuncID represents a item event function
|
||||||
type ItemEventFuncID int
|
type ItemEventFuncID int
|
||||||
|
|
||||||
|
// Item event functions
|
||||||
const (
|
const (
|
||||||
// shoots a missile at the owner of a missile that has just hit you
|
// shoots a missile at the owner of a missile that has just hit you
|
||||||
// (Chilling Armor uses this)
|
// (Chilling Armor uses this)
|
||||||
ReflectMissile = ItemEventFuncID(iota)
|
ReflectMissile ItemEventFuncID = iota
|
||||||
|
|
||||||
// freezes the attacker for a set duration the attacker
|
// freezes the attacker for a set duration the attacker
|
||||||
// (Frozen Armor uses this)
|
// (Frozen Armor uses this)
|
||||||
@ -102,42 +104,3 @@ const (
|
|||||||
// reanimate the target as the specified monster
|
// reanimate the target as the specified monster
|
||||||
ReanimateTargetAsMonster
|
ReanimateTargetAsMonster
|
||||||
)
|
)
|
||||||
|
|
||||||
func GetItemEventFuncID(n int) ItemEventFuncID {
|
|
||||||
m := map[int]ItemEventFuncID{
|
|
||||||
0: ReflectMissile,
|
|
||||||
1: FreezeAttacker,
|
|
||||||
2: FreezeChillAttacker,
|
|
||||||
3: ReflectPercentDamage,
|
|
||||||
4: DamageDealtToHealth,
|
|
||||||
5: AttackerTakesPhysical,
|
|
||||||
6: Knockback,
|
|
||||||
7: InduceFear,
|
|
||||||
8: BlindTarget,
|
|
||||||
9: AttackerTakesLightning,
|
|
||||||
10: AttackerTakesFire,
|
|
||||||
11: AttackerTakesCold,
|
|
||||||
12: DamageTakenToMana,
|
|
||||||
13: FreezeTarget,
|
|
||||||
14: OpenWounds,
|
|
||||||
15: CrushingBlow,
|
|
||||||
16: ManaOnKillMonster,
|
|
||||||
17: LifeOnKillDemon,
|
|
||||||
18: SlowTarget,
|
|
||||||
19: CastSkillAgainstDefender,
|
|
||||||
20: CastSkillAgainstAttacker,
|
|
||||||
21: AbsorbPhysical,
|
|
||||||
22: TakeSummonDamage,
|
|
||||||
23: ManaAbsorbsDamage,
|
|
||||||
24: AbsorbElementalDamage,
|
|
||||||
25: TakeSummonDamage2,
|
|
||||||
26: TargetSlowsTarget,
|
|
||||||
27: LifeOnKillMonster,
|
|
||||||
28: RestInPeace,
|
|
||||||
29: CastSkillWithoutTarget,
|
|
||||||
30: ReanimateTargetAsMonster,
|
|
||||||
}
|
|
||||||
return m[n]
|
|
||||||
}
|
|
||||||
|
|
||||||
//? do i need to do this ? //go:generate stringer -linecomment -type AnimationMode
|
|
||||||
|
@ -1,39 +1,52 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
// used in ItemStatCost
|
// ItemEventType used in ItemStatCost
|
||||||
type ItemEventType int
|
type ItemEventType int
|
||||||
|
|
||||||
|
// Item event types
|
||||||
const (
|
const (
|
||||||
HitByMissile = ItemEventType(iota) // hit By a Missile
|
ItemEventNone ItemEventType = iota
|
||||||
DamagedInMelee // Damaged in Melee
|
ItemEventHitByMissile // hit By a Missile
|
||||||
DamagedByMissile // Damaged By Missile
|
ItemEventDamagedInMelee // Damaged in Melee
|
||||||
AttackedInMelee // melee Attack atttempt
|
ItemEventDamagedByMissile // Damaged By Missile
|
||||||
DoActive // do active state skill
|
ItemEventAttackedInMelee // melee Attack atttempt
|
||||||
DoMeleeDamage // do damage in melee
|
ItemEventDoActive // do active state skill
|
||||||
DoMissileDamage // do missile damage
|
ItemEventDoMeleeDamage // do damage in melee
|
||||||
DoMeleeAttack // do melee attack
|
ItemEventDoMissileDamage // do missile damage
|
||||||
DoMissileAttack // do missile attack
|
ItemEventDoMeleeAttack // do melee attack
|
||||||
Kill // killed something
|
ItemEventDoMissileAttack // do missile attack
|
||||||
Killed // killed By something
|
ItemEventKill // killed something
|
||||||
AbsorbDamage // dealt damage
|
ItemEventKilled // killed By something
|
||||||
LevelUp // gain a level
|
ItemEventAbsorbDamage // dealt damage
|
||||||
|
ItemEventLevelUp // gain a level
|
||||||
)
|
)
|
||||||
|
|
||||||
|
//nolint:gochecknoglobals // better for lookup
|
||||||
|
var itemEventsLookup = map[string]ItemEventType{
|
||||||
|
"hitbymissile": ItemEventHitByMissile,
|
||||||
|
"damagedinmelee": ItemEventDamagedInMelee,
|
||||||
|
"damagedbymissile": ItemEventDamagedByMissile,
|
||||||
|
"attackedinmelee": ItemEventAttackedInMelee,
|
||||||
|
"doactive": ItemEventDoActive,
|
||||||
|
"domeleedamage": ItemEventDoMeleeDamage,
|
||||||
|
"domissiledamage": ItemEventDoMissileDamage,
|
||||||
|
"domeleeattack": ItemEventDoMeleeAttack,
|
||||||
|
"domissileattack": ItemEventDoMissileAttack,
|
||||||
|
"kill": ItemEventKill,
|
||||||
|
"killed": ItemEventKilled,
|
||||||
|
"absorbdamage": ItemEventAbsorbDamage,
|
||||||
|
"levelup": ItemEventLevelUp,
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetItemEventType returns the ItemEventType from string, expects lowercase input
|
||||||
func GetItemEventType(s string) ItemEventType {
|
func GetItemEventType(s string) ItemEventType {
|
||||||
strLookupTable := map[string]ItemEventType{
|
if s == "" {
|
||||||
"HitByMissile": HitByMissile,
|
return ItemEventNone
|
||||||
"DamagedInMelee": DamagedInMelee,
|
|
||||||
"DamagedByMissile": DamagedByMissile,
|
|
||||||
"AttackedInMelee": AttackedInMelee,
|
|
||||||
"DoActive": DoActive,
|
|
||||||
"DoMeleeDamage": DoMeleeDamage,
|
|
||||||
"DoMissileDamage": DoMissileDamage,
|
|
||||||
"DoMeleeAttack": DoMeleeAttack,
|
|
||||||
"DoMissileAttack": DoMissileAttack,
|
|
||||||
"Kill": Kill,
|
|
||||||
"Killed": Killed,
|
|
||||||
"AbsorbDamage": AbsorbDamage,
|
|
||||||
"LevelUp": LevelUp,
|
|
||||||
}
|
}
|
||||||
return strLookupTable[s]
|
|
||||||
|
if v, ok := itemEventsLookup[s]; ok {
|
||||||
|
return v
|
||||||
|
}
|
||||||
|
|
||||||
|
return ItemEventNone
|
||||||
}
|
}
|
||||||
|
@ -1,18 +1,20 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
// LayerStreamType represents a layer stream type
|
||||||
type LayerStreamType int
|
type LayerStreamType int
|
||||||
|
|
||||||
|
// Layer stream types
|
||||||
const (
|
const (
|
||||||
LayerStreamWall1 LayerStreamType = 0
|
LayerStreamWall1 LayerStreamType = iota
|
||||||
LayerStreamWall2 LayerStreamType = 1
|
LayerStreamWall2
|
||||||
LayerStreamWall3 LayerStreamType = 2
|
LayerStreamWall3
|
||||||
LayerStreamWall4 LayerStreamType = 3
|
LayerStreamWall4
|
||||||
LayerStreamOrientation1 LayerStreamType = 4
|
LayerStreamOrientation1
|
||||||
LayerStreamOrientation2 LayerStreamType = 5
|
LayerStreamOrientation2
|
||||||
LayerStreamOrientation3 LayerStreamType = 6
|
LayerStreamOrientation3
|
||||||
LayerStreamOrientation4 LayerStreamType = 7
|
LayerStreamOrientation4
|
||||||
LayerStreamFloor1 LayerStreamType = 8
|
LayerStreamFloor1
|
||||||
LayerStreamFloor2 LayerStreamType = 9
|
LayerStreamFloor2
|
||||||
LayerStreamShadow LayerStreamType = 10
|
LayerStreamShadow
|
||||||
LayerStreamSubstitute LayerStreamType = 11
|
LayerStreamSubstitute
|
||||||
)
|
)
|
||||||
|
@ -3,13 +3,13 @@ package d2enum
|
|||||||
// from levels.txt, field `DrlgType`
|
// from levels.txt, field `DrlgType`
|
||||||
// https://d2mods.info/forum/kb/viewarticle?a=301
|
// https://d2mods.info/forum/kb/viewarticle?a=301
|
||||||
|
|
||||||
// Setting for Level Generation: You have 3 possibilities here:
|
// LevelGenerationType Setting for Level Generation: You have 3 possibilities here:
|
||||||
// 1 Random Maze
|
// 1 Random Maze
|
||||||
// 2 Preset Area
|
// 2 Preset Area
|
||||||
// 3 Wilderness level
|
// 3 Wilderness level
|
||||||
|
|
||||||
type LevelGenerationType int
|
type LevelGenerationType int
|
||||||
|
|
||||||
|
// Level generation types
|
||||||
const (
|
const (
|
||||||
LevelTypeRandomMaze LevelGenerationType = iota
|
LevelTypeRandomMaze LevelGenerationType = iota
|
||||||
LevelTypePreset
|
LevelTypePreset
|
||||||
|
@ -3,14 +3,14 @@ package d2enum
|
|||||||
// from levels.txt, field `Teleport`
|
// from levels.txt, field `Teleport`
|
||||||
// https://d2mods.info/forum/kb/viewarticle?a=301
|
// https://d2mods.info/forum/kb/viewarticle?a=301
|
||||||
|
|
||||||
// Controls if teleport is allowed in that level.
|
// TeleportFlag Controls if teleport is allowed in that level.
|
||||||
// 0 = Teleport not allowed
|
// 0 = Teleport not allowed
|
||||||
// 1 = Teleport allowed
|
// 1 = Teleport allowed
|
||||||
// 2 = Teleport allowed, but not able to use teleport throu walls/objects
|
// 2 = Teleport allowed, but not able to use teleport throu walls/objects
|
||||||
// (maybe for objects)
|
// (maybe for objects)
|
||||||
|
|
||||||
type TeleportFlag int
|
type TeleportFlag int
|
||||||
|
|
||||||
|
// Teleport flag types
|
||||||
const (
|
const (
|
||||||
TeleportDisabled TeleportFlag = iota
|
TeleportDisabled TeleportFlag = iota
|
||||||
TeleportEnabled
|
TeleportEnabled
|
||||||
|
26
d2common/d2enum/monster_animation_mode.go
Normal file
26
d2common/d2enum/monster_animation_mode.go
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
package d2enum
|
||||||
|
|
||||||
|
//go:generate stringer -linecomment -type MonsterAnimationMode -output monster_animation_mode_string.go
|
||||||
|
|
||||||
|
// MonsterAnimationMode represents monster animation modes
|
||||||
|
type MonsterAnimationMode int
|
||||||
|
|
||||||
|
// Monster animation modes
|
||||||
|
const (
|
||||||
|
MonsterAnimationModeDeath MonsterAnimationMode = iota // DT
|
||||||
|
MonsterAnimationModeNeutral // NU
|
||||||
|
MonsterAnimationModeWalk // WL
|
||||||
|
MonsterAnimationModeGetHit // GH
|
||||||
|
MonsterAnimationModeAttack1 // A1
|
||||||
|
MonsterAnimationModeAttack2 // A2
|
||||||
|
MonsterAnimationModeBlock // BL
|
||||||
|
MonsterAnimationModeCast // SC
|
||||||
|
MonsterAnimationModeSkill1 // S1
|
||||||
|
MonsterAnimationModeSkill2 // S2
|
||||||
|
MonsterAnimationModeSkill3 // S3
|
||||||
|
MonsterAnimationModeSkill4 // S4
|
||||||
|
MonsterAnimationModeDead // DD
|
||||||
|
MonsterAnimationModeKnockback // GH
|
||||||
|
MonsterAnimationModeSequence // xx
|
||||||
|
MonsterAnimationModeRun // RN
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -linecomment -type MonsterAnimationMode"; DO NOT EDIT.
|
// Code generated by "stringer -linecomment -type MonsterAnimationMode -output monster_animation_mode_string.go"; DO NOT EDIT.
|
||||||
|
|
||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
@ -8,22 +8,22 @@ func _() {
|
|||||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||||
// Re-run the stringer command to generate them again.
|
// Re-run the stringer command to generate them again.
|
||||||
var x [1]struct{}
|
var x [1]struct{}
|
||||||
_ = x[AnimationModeMonsterDeath-0]
|
_ = x[MonsterAnimationModeDeath-0]
|
||||||
_ = x[AnimationModeMonsterNeutral-1]
|
_ = x[MonsterAnimationModeNeutral-1]
|
||||||
_ = x[AnimationModeMonsterWalk-2]
|
_ = x[MonsterAnimationModeWalk-2]
|
||||||
_ = x[AnimationModeMonsterGetHit-3]
|
_ = x[MonsterAnimationModeGetHit-3]
|
||||||
_ = x[AnimationModeMonsterAttack1-4]
|
_ = x[MonsterAnimationModeAttack1-4]
|
||||||
_ = x[AnimationModeMonsterAttack2-5]
|
_ = x[MonsterAnimationModeAttack2-5]
|
||||||
_ = x[AnimationModeMonsterBlock-6]
|
_ = x[MonsterAnimationModeBlock-6]
|
||||||
_ = x[AnimationModeMonsterCast-7]
|
_ = x[MonsterAnimationModeCast-7]
|
||||||
_ = x[AnimationModeMonsterSkill1-8]
|
_ = x[MonsterAnimationModeSkill1-8]
|
||||||
_ = x[AnimationModeMonsterSkill2-9]
|
_ = x[MonsterAnimationModeSkill2-9]
|
||||||
_ = x[AnimationModeMonsterSkill3-10]
|
_ = x[MonsterAnimationModeSkill3-10]
|
||||||
_ = x[AnimationModeMonsterSkill4-11]
|
_ = x[MonsterAnimationModeSkill4-11]
|
||||||
_ = x[AnimationModeMonsterDead-12]
|
_ = x[MonsterAnimationModeDead-12]
|
||||||
_ = x[AnimationModeMonsterKnockback-13]
|
_ = x[MonsterAnimationModeKnockback-13]
|
||||||
_ = x[AnimationModeMonsterSequence-14]
|
_ = x[MonsterAnimationModeSequence-14]
|
||||||
_ = x[AnimationModeMonsterRun-15]
|
_ = x[MonsterAnimationModeRun-15]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _MonsterAnimationMode_name = "DTNUWLGHA1A2BLSCS1S2S3S4DDGHxxRN"
|
const _MonsterAnimationMode_name = "DTNUWLGHA1A2BLSCS1S2S3S4DDGHxxRN"
|
@ -1,57 +0,0 @@
|
|||||||
// Manually edited to remove duplicate
|
|
||||||
// If you generate it again you need fix it up
|
|
||||||
|
|
||||||
// Code generated by "string2enum -samepkg -linecomment -type MonsterAnimationMode ."; DO NOT EDIT.
|
|
||||||
|
|
||||||
package d2enum
|
|
||||||
|
|
||||||
import "fmt"
|
|
||||||
|
|
||||||
// MonsterAnimationModeFromString returns the MonsterAnimationMode enum corresponding to s.
|
|
||||||
func MonsterAnimationModeFromString(s string) MonsterAnimationMode {
|
|
||||||
if len(s) == 0 {
|
|
||||||
return 0
|
|
||||||
}
|
|
||||||
for i := range _MonsterAnimationMode_index[:len(_MonsterAnimationMode_index)-1] {
|
|
||||||
if s == _MonsterAnimationMode_name[_MonsterAnimationMode_index[i]:_MonsterAnimationMode_index[i+1]] {
|
|
||||||
return MonsterAnimationMode(i)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
panic(fmt.Errorf("unable to locate MonsterAnimationMode enum corresponding to %q", s))
|
|
||||||
}
|
|
||||||
|
|
||||||
func _(s string) {
|
|
||||||
// Check for duplicate string values in type "MonsterAnimationMode".
|
|
||||||
switch s {
|
|
||||||
// 0
|
|
||||||
case "DT":
|
|
||||||
// 1
|
|
||||||
case "NU":
|
|
||||||
// 2
|
|
||||||
case "WL":
|
|
||||||
// 3
|
|
||||||
case "GH":
|
|
||||||
// 4
|
|
||||||
case "A1":
|
|
||||||
// 5
|
|
||||||
case "A2":
|
|
||||||
// 6
|
|
||||||
case "BL":
|
|
||||||
// 7
|
|
||||||
case "SC":
|
|
||||||
// 8
|
|
||||||
case "S1":
|
|
||||||
// 9
|
|
||||||
case "S2":
|
|
||||||
// 10
|
|
||||||
case "S3":
|
|
||||||
// 11
|
|
||||||
case "S4":
|
|
||||||
// 12
|
|
||||||
case "DD":
|
|
||||||
// 14
|
|
||||||
case "xx":
|
|
||||||
// 15
|
|
||||||
case "RN":
|
|
||||||
}
|
|
||||||
}
|
|
19
d2common/d2enum/object_animation_mode.go
Normal file
19
d2common/d2enum/object_animation_mode.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package d2enum
|
||||||
|
|
||||||
|
//go:generate stringer -linecomment -type ObjectAnimationMode -output object_animation_mode_string.go
|
||||||
|
//go:generate string2enum -samepkg -linecomment -type ObjectAnimationMode -output object_animation_mode_string2enum.go
|
||||||
|
|
||||||
|
// ObjectAnimationMode represents object animation modes
|
||||||
|
type ObjectAnimationMode int
|
||||||
|
|
||||||
|
// Object animation modes
|
||||||
|
const (
|
||||||
|
ObjectAnimationModeNeutral ObjectAnimationMode = iota // NU
|
||||||
|
ObjectAnimationModeOperating // OP
|
||||||
|
ObjectAnimationModeOpened // ON
|
||||||
|
ObjectAnimationModeSpecial1 // S1
|
||||||
|
ObjectAnimationModeSpecial2 // S2
|
||||||
|
ObjectAnimationModeSpecial3 // S3
|
||||||
|
ObjectAnimationModeSpecial4 // S4
|
||||||
|
ObjectAnimationModeSpecial5 // S5
|
||||||
|
)
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -linecomment -type ObjectAnimationMode"; DO NOT EDIT.
|
// Code generated by "stringer -linecomment -type ObjectAnimationMode -output object_animation_mode_string.go"; DO NOT EDIT.
|
||||||
|
|
||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
@ -8,14 +8,14 @@ func _() {
|
|||||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||||
// Re-run the stringer command to generate them again.
|
// Re-run the stringer command to generate them again.
|
||||||
var x [1]struct{}
|
var x [1]struct{}
|
||||||
_ = x[AnimationModeObjectNeutral-0]
|
_ = x[ObjectAnimationModeNeutral-0]
|
||||||
_ = x[AnimationModeObjectOperating-1]
|
_ = x[ObjectAnimationModeOperating-1]
|
||||||
_ = x[AnimationModeObjectOpened-2]
|
_ = x[ObjectAnimationModeOpened-2]
|
||||||
_ = x[AnimationModeObjectSpecial1-3]
|
_ = x[ObjectAnimationModeSpecial1-3]
|
||||||
_ = x[AnimationModeObjectSpecial2-4]
|
_ = x[ObjectAnimationModeSpecial2-4]
|
||||||
_ = x[AnimationModeObjectSpecial3-5]
|
_ = x[ObjectAnimationModeSpecial3-5]
|
||||||
_ = x[AnimationModeObjectSpecial4-6]
|
_ = x[ObjectAnimationModeSpecial4-6]
|
||||||
_ = x[AnimationModeObjectSpecial5-7]
|
_ = x[ObjectAnimationModeSpecial5-7]
|
||||||
}
|
}
|
||||||
|
|
||||||
const _ObjectAnimationMode_name = "NUOPONS1S2S3S4S5"
|
const _ObjectAnimationMode_name = "NUOPONS1S2S3S4S5"
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "string2enum -samepkg -linecomment -type ObjectAnimationMode"; DO NOT EDIT.
|
// Code generated by "string2enum -samepkg -linecomment -type ObjectAnimationMode -output object_animation_mode_string2enum.go"; DO NOT EDIT.
|
||||||
|
|
||||||
package d2enum
|
package d2enum
|
||||||
|
|
@ -3,6 +3,7 @@ package d2enum
|
|||||||
// ObjectType is the type of an object
|
// ObjectType is the type of an object
|
||||||
type ObjectType int
|
type ObjectType int
|
||||||
|
|
||||||
|
// Object types
|
||||||
const (
|
const (
|
||||||
ObjectTypePlayer ObjectType = iota
|
ObjectTypePlayer ObjectType = iota
|
||||||
ObjectTypeCharacter
|
ObjectTypeCharacter
|
||||||
|
30
d2common/d2enum/player_animation_mode.go
Normal file
30
d2common/d2enum/player_animation_mode.go
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package d2enum
|
||||||
|
|
||||||
|
//go:generate stringer -linecomment -type PlayerAnimationMode -output player_animation_mode_string.go
|
||||||
|
|
||||||
|
// PlayerAnimationMode represents player animation modes
|
||||||
|
type PlayerAnimationMode int
|
||||||
|
|
||||||
|
// Player animation modes
|
||||||
|
const (
|
||||||
|
PlayerAnimationModeDeath PlayerAnimationMode = iota // DT
|
||||||
|
PlayerAnimationModeNeutral // NU
|
||||||
|
PlayerAnimationModeWalk // WL
|
||||||
|
PlayerAnimationModeRun // RN
|
||||||
|
PlayerAnimationModeGetHit // GH
|
||||||
|
PlayerAnimationModeTownNeutral // TN
|
||||||
|
PlayerAnimationModeTownWalk // TW
|
||||||
|
PlayerAnimationModeAttack1 // A1
|
||||||
|
PlayerAnimationModeAttack2 // A2
|
||||||
|
PlayerAnimationModeBlock // BL
|
||||||
|
PlayerAnimationModeCast // SC
|
||||||
|
PlayerAnimationModeThrow // TH
|
||||||
|
PlayerAnimationModeKick // KK
|
||||||
|
PlayerAnimationModeSkill1 // S1
|
||||||
|
PlayerAnimationModeSkill2 // S2
|
||||||
|
PlayerAnimationModeSkill3 // S3
|
||||||
|
PlayerAnimationModeSkill4 // S4
|
||||||
|
PlayerAnimationModeDead // DD
|
||||||
|
PlayerAnimationModeSequence // GH
|
||||||
|
PlayerAnimationModeKnockBack // GH
|
||||||
|
)
|
42
d2common/d2enum/player_animation_mode_string.go
Normal file
42
d2common/d2enum/player_animation_mode_string.go
Normal file
@ -0,0 +1,42 @@
|
|||||||
|
// Code generated by "stringer -linecomment -type PlayerAnimationMode -output player_animation_mode_string.go"; DO NOT EDIT.
|
||||||
|
|
||||||
|
package d2enum
|
||||||
|
|
||||||
|
import "strconv"
|
||||||
|
|
||||||
|
func _() {
|
||||||
|
// An "invalid array index" compiler error signifies that the constant values have changed.
|
||||||
|
// Re-run the stringer command to generate them again.
|
||||||
|
var x [1]struct{}
|
||||||
|
_ = x[PlayerAnimationModeDeath-0]
|
||||||
|
_ = x[PlayerAnimationModeNeutral-1]
|
||||||
|
_ = x[PlayerAnimationModeWalk-2]
|
||||||
|
_ = x[PlayerAnimationModeRun-3]
|
||||||
|
_ = x[PlayerAnimationModeGetHit-4]
|
||||||
|
_ = x[PlayerAnimationModeTownNeutral-5]
|
||||||
|
_ = x[PlayerAnimationModeTownWalk-6]
|
||||||
|
_ = x[PlayerAnimationModeAttack1-7]
|
||||||
|
_ = x[PlayerAnimationModeAttack2-8]
|
||||||
|
_ = x[PlayerAnimationModeBlock-9]
|
||||||
|
_ = x[PlayerAnimationModeCast-10]
|
||||||
|
_ = x[PlayerAnimationModeThrow-11]
|
||||||
|
_ = x[PlayerAnimationModeKick-12]
|
||||||
|
_ = x[PlayerAnimationModeSkill1-13]
|
||||||
|
_ = x[PlayerAnimationModeSkill2-14]
|
||||||
|
_ = x[PlayerAnimationModeSkill3-15]
|
||||||
|
_ = x[PlayerAnimationModeSkill4-16]
|
||||||
|
_ = x[PlayerAnimationModeDead-17]
|
||||||
|
_ = x[PlayerAnimationModeSequence-18]
|
||||||
|
_ = x[PlayerAnimationModeKnockBack-19]
|
||||||
|
}
|
||||||
|
|
||||||
|
const _PlayerAnimationMode_name = "DTNUWLRNGHTNTWA1A2BLSCTHKKS1S2S3S4DDGHGH"
|
||||||
|
|
||||||
|
var _PlayerAnimationMode_index = [...]uint8{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40}
|
||||||
|
|
||||||
|
func (i PlayerAnimationMode) String() string {
|
||||||
|
if i < 0 || i >= PlayerAnimationMode(len(_PlayerAnimationMode_index)-1) {
|
||||||
|
return "PlayerAnimationMode(" + strconv.FormatInt(int64(i), 10) + ")"
|
||||||
|
}
|
||||||
|
return _PlayerAnimationMode_name[_PlayerAnimationMode_index[i]:_PlayerAnimationMode_index[i+1]]
|
||||||
|
}
|
@ -1,42 +0,0 @@
|
|||||||
// Code generated by "stringer -linecomment -type PlayerAnimationMode"; DO NOT EDIT.
|
|
||||||
|
|
||||||
package d2enum
|
|
||||||
|
|
||||||
import "strconv"
|
|
||||||
|
|
||||||
func _() {
|
|
||||||
// An "invalid array index" compiler error signifies that the constant values have changed.
|
|
||||||
// Re-run the stringer command to generate them again.
|
|
||||||
var x [1]struct{}
|
|
||||||
_ = x[AnimationModePlayerDeath-0]
|
|
||||||
_ = x[AnimationModePlayerNeutral-1]
|
|
||||||
_ = x[AnimationModePlayerWalk-2]
|
|
||||||
_ = x[AnimationModePlayerRun-3]
|
|
||||||
_ = x[AnimationModePlayerGetHit-4]
|
|
||||||
_ = x[AnimationModePlayerTownNeutral-5]
|
|
||||||
_ = x[AnimationModePlayerTownWalk-6]
|
|
||||||
_ = x[AnimationModePlayerAttack1-7]
|
|
||||||
_ = x[AnimationModePlayerAttack2-8]
|
|
||||||
_ = x[AnimationModePlayerBlock-9]
|
|
||||||
_ = x[AnimationModePlayerCast-10]
|
|
||||||
_ = x[AnimationModePlayerThrow-11]
|
|
||||||
_ = x[AnimationModePlayerKick-12]
|
|
||||||
_ = x[AnimationModePlayerSkill1-13]
|
|
||||||
_ = x[AnimationModePlayerSkill2-14]
|
|
||||||
_ = x[AnimationModePlayerSkill3-15]
|
|
||||||
_ = x[AnimationModePlayerSkill4-16]
|
|
||||||
_ = x[AnimationModePlayerDead-17]
|
|
||||||
_ = x[AnimationModePlayerSequence-18]
|
|
||||||
_ = x[AnimationModePlayerKnockBack-19]
|
|
||||||
}
|
|
||||||
|
|
||||||
const _PlayerAnimationMode_name = "DTNUWLRNGHTNTWA1A2BLSCTHKKS1S2S3S4DDGHGH"
|
|
||||||
|
|
||||||
var _PlayerAnimationMode_index = [...]uint8{0, 2, 4, 6, 8, 10, 12, 14, 16, 18, 20, 22, 24, 26, 28, 30, 32, 34, 36, 38, 40}
|
|
||||||
|
|
||||||
func (i PlayerAnimationMode) String() string {
|
|
||||||
if i < 0 || i >= PlayerAnimationMode(len(_PlayerAnimationMode_index)-1) {
|
|
||||||
return "PlayerAnimationMode(" + strconv.FormatInt(int64(i), 10) + ")"
|
|
||||||
}
|
|
||||||
return _PlayerAnimationMode_name[_PlayerAnimationMode_index[i]:_PlayerAnimationMode_index[i+1]]
|
|
||||||
}
|
|
@ -1,42 +1,44 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
type RegionIdType int
|
// RegionIdType represents a region Id
|
||||||
|
type RegionIdType int //nolint:golint,stylecheck // many changed needed when changing to ID
|
||||||
|
|
||||||
|
// Regions
|
||||||
const (
|
const (
|
||||||
RegionNone RegionIdType = 0
|
RegionNone RegionIdType = iota
|
||||||
RegionAct1Town RegionIdType = 1
|
RegionAct1Town
|
||||||
RegionAct1Wilderness RegionIdType = 2
|
RegionAct1Wilderness
|
||||||
RegionAct1Cave RegionIdType = 3
|
RegionAct1Cave
|
||||||
RegionAct1Crypt RegionIdType = 4
|
RegionAct1Crypt
|
||||||
RegionAct1Monestary RegionIdType = 5
|
RegionAct1Monestary
|
||||||
RegionAct1Courtyard RegionIdType = 6
|
RegionAct1Courtyard
|
||||||
RegionAct1Barracks RegionIdType = 7
|
RegionAct1Barracks
|
||||||
RegionAct1Jail RegionIdType = 8
|
RegionAct1Jail
|
||||||
RegionAct1Cathedral RegionIdType = 9
|
RegionAct1Cathedral
|
||||||
RegionAct1Catacombs RegionIdType = 10
|
RegionAct1Catacombs
|
||||||
RegionAct1Tristram RegionIdType = 11
|
RegionAct1Tristram
|
||||||
RegionAct2Town RegionIdType = 12
|
RegionAct2Town
|
||||||
RegionAct2Sewer RegionIdType = 13
|
RegionAct2Sewer
|
||||||
RegionAct2Harem RegionIdType = 14
|
RegionAct2Harem
|
||||||
RegionAct2Basement RegionIdType = 15
|
RegionAct2Basement
|
||||||
RegionAct2Desert RegionIdType = 16
|
RegionAct2Desert
|
||||||
RegionAct2Tomb RegionIdType = 17
|
RegionAct2Tomb
|
||||||
RegionAct2Lair RegionIdType = 18
|
RegionAct2Lair
|
||||||
RegionAct2Arcane RegionIdType = 19
|
RegionAct2Arcane
|
||||||
RegionAct3Town RegionIdType = 20
|
RegionAct3Town
|
||||||
RegionAct3Jungle RegionIdType = 21
|
RegionAct3Jungle
|
||||||
RegionAct3Kurast RegionIdType = 22
|
RegionAct3Kurast
|
||||||
RegionAct3Spider RegionIdType = 23
|
RegionAct3Spider
|
||||||
RegionAct3Dungeon RegionIdType = 24
|
RegionAct3Dungeon
|
||||||
RegionAct3Sewer RegionIdType = 25
|
RegionAct3Sewer
|
||||||
RegionAct4Town RegionIdType = 26
|
RegionAct4Town
|
||||||
RegionAct4Mesa RegionIdType = 27
|
RegionAct4Mesa
|
||||||
RegionAct4Lava RegionIdType = 28
|
RegionAct4Lava
|
||||||
RegonAct5Town RegionIdType = 29
|
RegonAct5Town
|
||||||
RegionAct5Siege RegionIdType = 30
|
RegionAct5Siege
|
||||||
RegionAct5Barricade RegionIdType = 31
|
RegionAct5Barricade
|
||||||
RegionAct5Temple RegionIdType = 32
|
RegionAct5Temple
|
||||||
RegionAct5IceCaves RegionIdType = 33
|
RegionAct5IceCaves
|
||||||
RegionAct5Baal RegionIdType = 34
|
RegionAct5Baal
|
||||||
RegionAct5Lava RegionIdType = 35
|
RegionAct5Lava
|
||||||
)
|
)
|
||||||
|
@ -1,9 +1,11 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
// RegionLayerType represents a region layer
|
||||||
type RegionLayerType int
|
type RegionLayerType int
|
||||||
|
|
||||||
|
// Region layer types
|
||||||
const (
|
const (
|
||||||
RegionLayerTypeFloors RegionLayerType = 0
|
RegionLayerTypeFloors RegionLayerType = iota
|
||||||
RegionLayerTypeWalls RegionLayerType = 1
|
RegionLayerTypeWalls
|
||||||
RegionLayerTypeShadows RegionLayerType = 2
|
RegionLayerTypeShadows
|
||||||
)
|
)
|
||||||
|
@ -3,7 +3,7 @@ package d2enum
|
|||||||
// RenderType defines the type of rendering engine to use
|
// RenderType defines the type of rendering engine to use
|
||||||
type RenderType int
|
type RenderType int
|
||||||
|
|
||||||
|
// Render types
|
||||||
const (
|
const (
|
||||||
// Ebiten is the render type of ebiten
|
Ebiten RenderType = iota + 1
|
||||||
Ebiten = RenderType(1)
|
|
||||||
)
|
)
|
||||||
|
71
d2common/d2enum/tile.go
Normal file
71
d2common/d2enum/tile.go
Normal file
@ -0,0 +1,71 @@
|
|||||||
|
package d2enum
|
||||||
|
|
||||||
|
// TileType represents a tile type
|
||||||
|
type TileType byte
|
||||||
|
|
||||||
|
// Tile types
|
||||||
|
const (
|
||||||
|
TileFloor TileType = iota
|
||||||
|
TileLeftWall
|
||||||
|
TileRightWall
|
||||||
|
TileRightPartOfNorthCornerWall
|
||||||
|
TileLeftPartOfNorthCornerWall
|
||||||
|
TileLeftEndWall
|
||||||
|
TileRightEndWall
|
||||||
|
TileSouthCornerWall
|
||||||
|
TileLeftWallWithDoor
|
||||||
|
TileRightWallWithDoor
|
||||||
|
TileSpecialTile1
|
||||||
|
TileSpecialTile2
|
||||||
|
TilePillarsColumnsAndStandaloneObjects
|
||||||
|
TileShadow
|
||||||
|
TileTree
|
||||||
|
TileRoof
|
||||||
|
TileLowerWallsEquivalentToLeftWall
|
||||||
|
TileLowerWallsEquivalentToRightWall
|
||||||
|
TileLowerWallsEquivalentToRightLeftNorthCornerWall
|
||||||
|
TileLowerWallsEquivalentToSouthCornerwall
|
||||||
|
)
|
||||||
|
|
||||||
|
// LowerWall checks for lower wall tiles
|
||||||
|
func (tile TileType) LowerWall() bool {
|
||||||
|
switch tile {
|
||||||
|
case TileLowerWallsEquivalentToLeftWall,
|
||||||
|
TileLowerWallsEquivalentToRightWall,
|
||||||
|
TileLowerWallsEquivalentToRightLeftNorthCornerWall,
|
||||||
|
TileLowerWallsEquivalentToSouthCornerwall:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// UpperWall checks for upper wall tiles
|
||||||
|
func (tile TileType) UpperWall() bool {
|
||||||
|
switch tile {
|
||||||
|
case TileLeftWall,
|
||||||
|
TileRightWall,
|
||||||
|
TileRightPartOfNorthCornerWall,
|
||||||
|
TileLeftPartOfNorthCornerWall,
|
||||||
|
TileLeftEndWall,
|
||||||
|
TileRightEndWall,
|
||||||
|
TileSouthCornerWall,
|
||||||
|
TileLeftWallWithDoor,
|
||||||
|
TileRightWallWithDoor,
|
||||||
|
TilePillarsColumnsAndStandaloneObjects,
|
||||||
|
TileTree:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
|
||||||
|
// Special checks for special tiles
|
||||||
|
func (tile TileType) Special() bool {
|
||||||
|
switch tile {
|
||||||
|
case TileSpecialTile1, TileSpecialTile2:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
|
||||||
|
return false
|
||||||
|
}
|
@ -1,53 +0,0 @@
|
|||||||
package d2enum
|
|
||||||
|
|
||||||
type TileType byte
|
|
||||||
|
|
||||||
const (
|
|
||||||
Floor TileType = 0
|
|
||||||
LeftWall TileType = 1
|
|
||||||
RightWall TileType = 2
|
|
||||||
RightPartOfNorthCornerWall TileType = 3
|
|
||||||
LeftPartOfNorthCornerWall TileType = 4
|
|
||||||
LeftEndWall TileType = 5
|
|
||||||
RightEndWall TileType = 6
|
|
||||||
SouthCornerWall TileType = 7
|
|
||||||
LeftWallWithDoor TileType = 8
|
|
||||||
RightWallWithDoor TileType = 9
|
|
||||||
SpecialTile1 TileType = 10
|
|
||||||
SpecialTile2 TileType = 11
|
|
||||||
PillarsColumnsAndStandaloneObjects TileType = 12
|
|
||||||
Shadow TileType = 13
|
|
||||||
Tree TileType = 14
|
|
||||||
Roof TileType = 15
|
|
||||||
LowerWallsEquivalentToLeftWall TileType = 16
|
|
||||||
LowerWallsEquivalentToRightWall TileType = 17
|
|
||||||
LowerWallsEquivalentToRightLeftNorthCornerWall TileType = 18
|
|
||||||
LowerWallsEquivalentToSouthCornerwall TileType = 19
|
|
||||||
)
|
|
||||||
|
|
||||||
func (tile TileType) LowerWall() bool {
|
|
||||||
switch tile {
|
|
||||||
case 16, 17, 18, 19:
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tile TileType) UpperWall() bool {
|
|
||||||
switch tile {
|
|
||||||
case 1, 2, 3, 4, 5, 6, 7, 8, 9, 12, 14:
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
func (tile TileType) Special() bool {
|
|
||||||
switch tile {
|
|
||||||
case 10, 11:
|
|
||||||
return true
|
|
||||||
default:
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,24 +1,26 @@
|
|||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
//go:generate stringer -linecomment -type WeaponClass -output weapon_class_string.go
|
||||||
|
//go:generate string2enum -samepkg -linecomment -type WeaponClass -output weapon_class_string2enum.go
|
||||||
|
|
||||||
|
// WeaponClass represents a weapon class
|
||||||
type WeaponClass int
|
type WeaponClass int
|
||||||
|
|
||||||
|
// Weapon classes
|
||||||
const (
|
const (
|
||||||
WeaponClassNone WeaponClass = 0 //
|
WeaponClassNone WeaponClass = iota //
|
||||||
WeaponClassHandToHand WeaponClass = 1 // hth
|
WeaponClassHandToHand // hth
|
||||||
WeaponClassBow WeaponClass = 2 // bow
|
WeaponClassBow // bow
|
||||||
WeaponClassOneHandSwing WeaponClass = 3 // 1hs
|
WeaponClassOneHandSwing // 1hs
|
||||||
WeaponClassOneHandThrust WeaponClass = 4 // 1ht
|
WeaponClassOneHandThrust // 1ht
|
||||||
WeaponClassStaff WeaponClass = 5 // stf
|
WeaponClassStaff // stf
|
||||||
WeaponClassTwoHandSwing WeaponClass = 6 // 2hs
|
WeaponClassTwoHandSwing // 2hs
|
||||||
WeaponClassTwoHandThrust WeaponClass = 7 // 2ht
|
WeaponClassTwoHandThrust // 2ht
|
||||||
WeaponClassCrossbow WeaponClass = 8 // xbw
|
WeaponClassCrossbow // xbw
|
||||||
WeaponClassLeftJabRightSwing WeaponClass = 9 // 1js
|
WeaponClassLeftJabRightSwing // 1js
|
||||||
WeaponClassLeftJabRightThrust WeaponClass = 10 // 1jt
|
WeaponClassLeftJabRightThrust // 1jt
|
||||||
WeaponClassLeftSwingRightSwing WeaponClass = 11 // 1ss
|
WeaponClassLeftSwingRightSwing // 1ss
|
||||||
WeaponClassLeftSwingRightThrust WeaponClass = 12 // 1st
|
WeaponClassLeftSwingRightThrust // 1st
|
||||||
WeaponClassOneHandToHand WeaponClass = 13 // ht1
|
WeaponClassOneHandToHand // ht1
|
||||||
WeaponClassTwoHandToHand WeaponClass = 14 // ht2
|
WeaponClassTwoHandToHand // ht2
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:generate stringer -linecomment -type WeaponClass
|
|
||||||
//go:generate string2enum -samepkg -linecomment -type WeaponClass
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "stringer -linecomment -type WeaponClass"; DO NOT EDIT.
|
// Code generated by "stringer -linecomment -type WeaponClass -output weapon_class_string.go"; DO NOT EDIT.
|
||||||
|
|
||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
// Code generated by "string2enum -samepkg -linecomment -type WeaponClass"; DO NOT EDIT.
|
// Code generated by "string2enum -samepkg -linecomment -type WeaponClass -output weapon_class_string2enum.go"; DO NOT EDIT.
|
||||||
|
|
||||||
package d2enum
|
package d2enum
|
||||||
|
|
||||||
@ -16,3 +16,39 @@ func WeaponClassFromString(s string) WeaponClass {
|
|||||||
}
|
}
|
||||||
panic(fmt.Errorf("unable to locate WeaponClass enum corresponding to %q", s))
|
panic(fmt.Errorf("unable to locate WeaponClass enum corresponding to %q", s))
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func _(s string) {
|
||||||
|
// Check for duplicate string values in type "WeaponClass".
|
||||||
|
switch s {
|
||||||
|
// 0
|
||||||
|
case "":
|
||||||
|
// 1
|
||||||
|
case "hth":
|
||||||
|
// 2
|
||||||
|
case "bow":
|
||||||
|
// 3
|
||||||
|
case "1hs":
|
||||||
|
// 4
|
||||||
|
case "1ht":
|
||||||
|
// 5
|
||||||
|
case "stf":
|
||||||
|
// 6
|
||||||
|
case "2hs":
|
||||||
|
// 7
|
||||||
|
case "2ht":
|
||||||
|
// 8
|
||||||
|
case "xbw":
|
||||||
|
// 9
|
||||||
|
case "1js":
|
||||||
|
// 10
|
||||||
|
case "1jt":
|
||||||
|
// 11
|
||||||
|
case "1ss":
|
||||||
|
// 12
|
||||||
|
case "1st":
|
||||||
|
// 13
|
||||||
|
case "ht1":
|
||||||
|
// 14
|
||||||
|
case "ht2":
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -71,9 +71,14 @@ func (c *Composite) Render(target d2interface.Surface) error {
|
|||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ObjectAnimationMode returns the object animation mode
|
||||||
|
func (c *Composite) ObjectAnimationMode() d2enum.ObjectAnimationMode {
|
||||||
|
return c.mode.animationMode.(d2enum.ObjectAnimationMode)
|
||||||
|
}
|
||||||
|
|
||||||
// GetAnimationMode returns the animation mode the Composite should render with.
|
// GetAnimationMode returns the animation mode the Composite should render with.
|
||||||
func (c *Composite) GetAnimationMode() string {
|
func (c *Composite) GetAnimationMode() string {
|
||||||
return c.mode.animationMode
|
return c.mode.animationMode.String()
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetWeaponClass returns the currently loaded weapon class
|
// GetWeaponClass returns the currently loaded weapon class
|
||||||
@ -82,8 +87,8 @@ func (c *Composite) GetWeaponClass() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// SetMode sets the Composite's animation mode weapon class and direction
|
// SetMode sets the Composite's animation mode weapon class and direction
|
||||||
func (c *Composite) SetMode(animationMode, weaponClass string) error {
|
func (c *Composite) SetMode(animationMode animationMode, weaponClass string) error {
|
||||||
if c.mode != nil && c.mode.animationMode == animationMode && c.mode.weaponClass == weaponClass {
|
if c.mode != nil && c.mode.animationMode.String() == animationMode.String() && c.mode.weaponClass == weaponClass {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -188,10 +193,13 @@ func (c *Composite) resetPlayedCount() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type animationMode interface {
|
||||||
|
String() string
|
||||||
|
}
|
||||||
|
|
||||||
type compositeMode struct {
|
type compositeMode struct {
|
||||||
cof *d2cof.COF
|
cof *d2cof.COF
|
||||||
animationMode string
|
animationMode animationMode
|
||||||
weaponClass string
|
weaponClass string
|
||||||
playedCount int
|
playedCount int
|
||||||
|
|
||||||
@ -203,7 +211,7 @@ type compositeMode struct {
|
|||||||
lastFrameTime float64
|
lastFrameTime float64
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *Composite) createMode(animationMode, weaponClass string) (*compositeMode, error) {
|
func (c *Composite) createMode(animationMode animationMode, weaponClass string) (*compositeMode, error) {
|
||||||
cofPath := fmt.Sprintf("%s/%s/COF/%s%s%s.COF", c.basePath, c.token, c.token, animationMode, weaponClass)
|
cofPath := fmt.Sprintf("%s/%s/COF/%s%s%s.COF", c.basePath, c.token, c.token, animationMode, weaponClass)
|
||||||
if exists, _ := FileExists(cofPath); !exists {
|
if exists, _ := FileExists(cofPath); !exists {
|
||||||
return nil, errors.New("composite not found")
|
return nil, errors.New("composite not found")
|
||||||
@ -214,7 +222,7 @@ func (c *Composite) createMode(animationMode, weaponClass string) (*compositeMod
|
|||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
animationKey := strings.ToLower(c.token + animationMode + weaponClass)
|
animationKey := strings.ToLower(c.token + animationMode.String() + weaponClass)
|
||||||
|
|
||||||
animationData := d2data.AnimationData[animationKey]
|
animationData := d2data.AnimationData[animationKey]
|
||||||
if len(animationData) == 0 {
|
if len(animationData) == 0 {
|
||||||
@ -242,7 +250,7 @@ func (c *Composite) createMode(animationMode, weaponClass string) (*compositeMod
|
|||||||
drawEffect = cofLayer.DrawEffect
|
drawEffect = cofLayer.DrawEffect
|
||||||
}
|
}
|
||||||
|
|
||||||
layer, err := c.loadCompositeLayer(cofLayer.Type.String(), layerValue, animationMode,
|
layer, err := c.loadCompositeLayer(cofLayer.Type.String(), layerValue, animationMode.String(),
|
||||||
cofLayer.WeaponClass.String(), c.palettePath, drawEffect)
|
cofLayer.WeaponClass.String(), c.palettePath, drawEffect)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
layer.SetPlaySpeed(mode.animationSpeed)
|
layer.SetPlaySpeed(mode.animationSpeed)
|
||||||
|
@ -19,7 +19,7 @@ func (m *MapEngine) RegenerateWalkPaths() {
|
|||||||
isBlocked := false
|
isBlocked := false
|
||||||
|
|
||||||
for _, floor := range tile.Floors {
|
for _, floor := range tile.Floors {
|
||||||
tileData := m.GetTileData(int32(floor.Style), int32(floor.Sequence), d2enum.Floor)
|
tileData := m.GetTileData(int32(floor.Style), int32(floor.Sequence), d2enum.TileFloor)
|
||||||
if tileData == nil {
|
if tileData == nil {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
|
@ -47,7 +47,7 @@ func CreateNPC(x, y int, monstat *d2datadict.MonStatsRecord, direction int) *NPC
|
|||||||
d2resource.PaletteUnits)
|
d2resource.PaletteUnits)
|
||||||
result.composite = composite
|
result.composite = composite
|
||||||
|
|
||||||
composite.SetMode("NU", result.monstatEx.BaseWeaponClass)
|
composite.SetMode(d2enum.MonsterAnimationModeNeutral, result.monstatEx.BaseWeaponClass)
|
||||||
composite.Equip(&equipment)
|
composite.Equip(&equipment)
|
||||||
|
|
||||||
result.SetSpeed(float64(monstat.SpeedBase))
|
result.SetSpeed(float64(monstat.SpeedBase))
|
||||||
@ -133,24 +133,24 @@ func (v *NPC) wait() bool {
|
|||||||
func (v *NPC) next() {
|
func (v *NPC) next() {
|
||||||
v.isDone = true
|
v.isDone = true
|
||||||
v.repetitions = 3 + rand.Intn(5)
|
v.repetitions = 3 + rand.Intn(5)
|
||||||
newAnimationMode := d2enum.AnimationModeMonsterNeutral
|
newAnimationMode := d2enum.MonsterAnimationModeNeutral
|
||||||
// TODO: Figure out what 1-3 are for, 4 is correct.
|
// TODO: Figure out what 1-3 are for, 4 is correct.
|
||||||
switch v.action {
|
switch v.action {
|
||||||
case 1:
|
case 1:
|
||||||
newAnimationMode = d2enum.AnimationModeMonsterNeutral
|
newAnimationMode = d2enum.MonsterAnimationModeNeutral
|
||||||
case 2:
|
case 2:
|
||||||
newAnimationMode = d2enum.AnimationModeMonsterNeutral
|
newAnimationMode = d2enum.MonsterAnimationModeNeutral
|
||||||
case 3:
|
case 3:
|
||||||
newAnimationMode = d2enum.AnimationModeMonsterNeutral
|
newAnimationMode = d2enum.MonsterAnimationModeNeutral
|
||||||
case 4:
|
case 4:
|
||||||
newAnimationMode = d2enum.AnimationModeMonsterSkill1
|
newAnimationMode = d2enum.MonsterAnimationModeSkill1
|
||||||
v.repetitions = 0
|
v.repetitions = 0
|
||||||
default:
|
default:
|
||||||
v.repetitions = 0
|
v.repetitions = 0
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.composite.GetAnimationMode() != newAnimationMode.String() {
|
if v.composite.GetAnimationMode() != newAnimationMode.String() {
|
||||||
v.composite.SetMode(newAnimationMode.String(), v.composite.GetWeaponClass())
|
v.composite.SetMode(newAnimationMode, v.composite.GetWeaponClass())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -158,13 +158,13 @@ func (v *NPC) next() {
|
|||||||
func (v *NPC) rotate(direction int) {
|
func (v *NPC) rotate(direction int) {
|
||||||
var newMode d2enum.MonsterAnimationMode
|
var newMode d2enum.MonsterAnimationMode
|
||||||
if !v.IsAtTarget() {
|
if !v.IsAtTarget() {
|
||||||
newMode = d2enum.AnimationModeMonsterWalk
|
newMode = d2enum.MonsterAnimationModeWalk
|
||||||
} else {
|
} else {
|
||||||
newMode = d2enum.AnimationModeMonsterNeutral
|
newMode = d2enum.MonsterAnimationModeNeutral
|
||||||
}
|
}
|
||||||
|
|
||||||
if newMode.String() != v.composite.GetAnimationMode() {
|
if newMode.String() != v.composite.GetAnimationMode() {
|
||||||
v.composite.SetMode(newMode.String(), v.composite.GetWeaponClass())
|
v.composite.SetMode(newMode, v.composite.GetWeaponClass())
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.composite.GetDirection() != direction {
|
if v.composite.GetDirection() != direction {
|
||||||
|
@ -73,8 +73,7 @@ func CreatePlayer(id, name string, x, y int, direction int, heroType d2enum.Hero
|
|||||||
//result.nameLabel.Alignment = d2ui.LabelAlignCenter
|
//result.nameLabel.Alignment = d2ui.LabelAlignCenter
|
||||||
//result.nameLabel.SetText(name)
|
//result.nameLabel.SetText(name)
|
||||||
//result.nameLabel.Color = color.White
|
//result.nameLabel.Color = color.White
|
||||||
err = composite.SetMode(d2enum.AnimationModePlayerTownNeutral.String(), equipment.RightHand.GetWeaponClass())
|
err = composite.SetMode(d2enum.PlayerAnimationModeTownNeutral, equipment.RightHand.GetWeaponClass())
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
panic(err)
|
panic(err)
|
||||||
}
|
}
|
||||||
@ -130,7 +129,7 @@ func (v *Player) Advance(tickTime float64) {
|
|||||||
|
|
||||||
if v.IsCasting() && v.composite.GetPlayedCount() >= 1 {
|
if v.IsCasting() && v.composite.GetPlayedCount() >= 1 {
|
||||||
v.isCasting = false
|
v.isCasting = false
|
||||||
v.SetAnimationMode(v.GetAnimationMode().String())
|
v.SetAnimationMode(v.GetAnimationMode())
|
||||||
}
|
}
|
||||||
v.composite.Advance(tickTime)
|
v.composite.Advance(tickTime)
|
||||||
|
|
||||||
@ -159,38 +158,37 @@ func (v *Player) Render(target d2interface.Surface) {
|
|||||||
// GetAnimationMode returns the current animation mode based on what the player is doing and where they are.
|
// GetAnimationMode returns the current animation mode based on what the player is doing and where they are.
|
||||||
func (v *Player) GetAnimationMode() d2enum.PlayerAnimationMode {
|
func (v *Player) GetAnimationMode() d2enum.PlayerAnimationMode {
|
||||||
if v.IsRunning() && !v.IsAtTarget() {
|
if v.IsRunning() && !v.IsAtTarget() {
|
||||||
return d2enum.AnimationModePlayerRun
|
return d2enum.PlayerAnimationModeRun
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.IsInTown() {
|
if v.IsInTown() {
|
||||||
if !v.IsAtTarget() {
|
if !v.IsAtTarget() {
|
||||||
return d2enum.AnimationModePlayerTownWalk
|
return d2enum.PlayerAnimationModeTownWalk
|
||||||
}
|
}
|
||||||
|
|
||||||
return d2enum.AnimationModePlayerTownNeutral
|
return d2enum.PlayerAnimationModeTownNeutral
|
||||||
}
|
}
|
||||||
|
|
||||||
if !v.IsAtTarget() {
|
if !v.IsAtTarget() {
|
||||||
return d2enum.AnimationModePlayerWalk
|
return d2enum.PlayerAnimationModeWalk
|
||||||
}
|
}
|
||||||
|
|
||||||
if v.IsCasting() {
|
if v.IsCasting() {
|
||||||
return d2enum.AnimationModePlayerCast
|
return d2enum.PlayerAnimationModeCast
|
||||||
}
|
}
|
||||||
|
|
||||||
return d2enum.AnimationModePlayerNeutral
|
return d2enum.PlayerAnimationModeNeutral
|
||||||
}
|
}
|
||||||
|
|
||||||
// SetAnimationMode sets the animation mode for this entity's animated composite.
|
func (v *Player) SetAnimationMode(animationMode d2enum.PlayerAnimationMode) error {
|
||||||
func (v *Player) SetAnimationMode(animationMode string) error {
|
|
||||||
return v.composite.SetMode(animationMode, v.composite.GetWeaponClass())
|
return v.composite.SetMode(animationMode, v.composite.GetWeaponClass())
|
||||||
}
|
}
|
||||||
|
|
||||||
// rotate sets direction and changes animation
|
// rotate sets direction and changes animation
|
||||||
func (v *Player) rotate(direction int) {
|
func (v *Player) rotate(direction int) {
|
||||||
newAnimationMode := v.GetAnimationMode().String()
|
newAnimationMode := v.GetAnimationMode()
|
||||||
|
|
||||||
if newAnimationMode != v.composite.GetAnimationMode() {
|
if newAnimationMode.String() != v.composite.GetAnimationMode() {
|
||||||
v.composite.SetMode(newAnimationMode, v.composite.GetWeaponClass())
|
v.composite.SetMode(newAnimationMode, v.composite.GetWeaponClass())
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -213,7 +211,7 @@ func (v *Player) IsCasting() bool {
|
|||||||
// sets the animation mode to the casting animation.
|
// sets the animation mode to the casting animation.
|
||||||
func (v *Player) SetCasting() {
|
func (v *Player) SetCasting() {
|
||||||
v.isCasting = true
|
v.isCasting = true
|
||||||
v.SetAnimationMode(d2enum.AnimationModePlayerCast.String())
|
v.SetAnimationMode(d2enum.PlayerAnimationModeCast)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Selectable returns true if the player is in town.
|
// Selectable returns true if the player is in town.
|
||||||
|
@ -229,7 +229,7 @@ func (mr *MapRenderer) renderTilePass2(tile *d2ds1.TileRecord, target d2interfac
|
|||||||
|
|
||||||
func (mr *MapRenderer) renderTilePass3(tile *d2ds1.TileRecord, target d2interface.Surface) {
|
func (mr *MapRenderer) renderTilePass3(tile *d2ds1.TileRecord, target d2interface.Surface) {
|
||||||
for _, wall := range tile.Walls {
|
for _, wall := range tile.Walls {
|
||||||
if wall.Type == d2enum.Roof {
|
if wall.Type == d2enum.TileRoof {
|
||||||
mr.renderWall(wall, mr.viewport, target)
|
mr.renderWall(wall, mr.viewport, target)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,15 +27,15 @@ func initObject(ob *Object) bool {
|
|||||||
|
|
||||||
// Initializes torch/brazier type objects
|
// Initializes torch/brazier type objects
|
||||||
func initTorch(ob *Object) {
|
func initTorch(ob *Object) {
|
||||||
if ob.objectRecord.HasAnimationMode[d2enum.AnimationModeObjectOperating] {
|
if ob.objectRecord.HasAnimationMode[d2enum.ObjectAnimationModeOpened] {
|
||||||
ob.setMode("ON", 0, true)
|
ob.setMode(d2enum.ObjectAnimationModeOpened, 0, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func initWaypoint(ob *Object) {
|
func initWaypoint(ob *Object) {
|
||||||
// Turn these on unconditionally for now, they look nice :)
|
// Turn these on unconditionally for now, they look nice :)
|
||||||
if ob.objectRecord.HasAnimationMode[d2enum.AnimationModeObjectOperating] {
|
if ob.objectRecord.HasAnimationMode[d2enum.ObjectAnimationModeOpened] {
|
||||||
ob.setMode("ON", 0, true)
|
ob.setMode(d2enum.ObjectAnimationModeOpened, 0, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -44,8 +44,8 @@ func initTorchRnd(ob *Object) {
|
|||||||
n := rand.Intn(2)
|
n := rand.Intn(2)
|
||||||
|
|
||||||
if n > 0 {
|
if n > 0 {
|
||||||
ob.setMode("NU", 0, true)
|
ob.setMode(d2enum.ObjectAnimationModeNeutral, 0, true)
|
||||||
} else {
|
} else {
|
||||||
ob.setMode("OP", 0, true)
|
ob.setMode(d2enum.ObjectAnimationModeOperating, 0, true)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -50,7 +50,7 @@ func CreateObject(x, y int, objectRec *d2datadict.ObjectRecord, palettePath stri
|
|||||||
|
|
||||||
entity.composite = composite
|
entity.composite = composite
|
||||||
|
|
||||||
entity.setMode("NU", 0, false)
|
entity.setMode(d2enum.ObjectAnimationModeNeutral, 0, false)
|
||||||
|
|
||||||
initObject(entity)
|
initObject(entity)
|
||||||
|
|
||||||
@ -58,7 +58,7 @@ func CreateObject(x, y int, objectRec *d2datadict.ObjectRecord, palettePath stri
|
|||||||
}
|
}
|
||||||
|
|
||||||
// setMode changes the graphical mode of this animated entity
|
// setMode changes the graphical mode of this animated entity
|
||||||
func (ob *Object) setMode(animationMode string, direction int, randomFrame bool) error {
|
func (ob *Object) setMode(animationMode d2enum.ObjectAnimationMode, direction int, randomFrame bool) error {
|
||||||
err := ob.composite.SetMode(animationMode, "HTH")
|
err := ob.composite.SetMode(animationMode, "HTH")
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
@ -66,23 +66,23 @@ func (ob *Object) setMode(animationMode string, direction int, randomFrame bool)
|
|||||||
|
|
||||||
ob.composite.SetDirection(direction)
|
ob.composite.SetDirection(direction)
|
||||||
|
|
||||||
mode := d2enum.ObjectAnimationModeFromString(animationMode)
|
// mode := d2enum.ObjectAnimationModeFromString(animationMode)
|
||||||
ob.drawLayer = ob.objectRecord.OrderFlag[d2enum.AnimationModeObjectNeutral]
|
ob.drawLayer = ob.objectRecord.OrderFlag[d2enum.ObjectAnimationModeNeutral]
|
||||||
|
|
||||||
// For objects their txt record entry overrides animationdata
|
// For objects their txt record entry overrides animationdata
|
||||||
speed := ob.objectRecord.FrameDelta[mode]
|
speed := ob.objectRecord.FrameDelta[animationMode]
|
||||||
if speed != 0 {
|
if speed != 0 {
|
||||||
ob.composite.SetAnimSpeed(speed)
|
ob.composite.SetAnimSpeed(speed)
|
||||||
}
|
}
|
||||||
|
|
||||||
frameCount := ob.objectRecord.FrameCount[mode]
|
frameCount := ob.objectRecord.FrameCount[animationMode]
|
||||||
|
|
||||||
if frameCount != 0 {
|
if frameCount != 0 {
|
||||||
ob.composite.SetSubLoop(0, frameCount)
|
ob.composite.SetSubLoop(0, frameCount)
|
||||||
}
|
}
|
||||||
|
|
||||||
ob.composite.SetPlayLoop(ob.objectRecord.CycleAnimation[mode])
|
ob.composite.SetPlayLoop(ob.objectRecord.CycleAnimation[animationMode])
|
||||||
ob.composite.SetCurrentFrame(ob.objectRecord.StartFrame[mode])
|
ob.composite.SetCurrentFrame(ob.objectRecord.StartFrame[animationMode])
|
||||||
|
|
||||||
if randomFrame {
|
if randomFrame {
|
||||||
n := rand.Intn(frameCount)
|
n := rand.Intn(frameCount)
|
||||||
@ -98,7 +98,7 @@ func (ob *Object) Highlight() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (ob *Object) Selectable() bool {
|
func (ob *Object) Selectable() bool {
|
||||||
mode := d2enum.ObjectAnimationModeFromString(ob.composite.GetAnimationMode())
|
mode := ob.composite.ObjectAnimationMode()
|
||||||
return ob.objectRecord.Selectable[mode]
|
return ob.objectRecord.Selectable[mode]
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -114,7 +114,7 @@ func (g *GameClient) OnPacketReceived(packet d2netpacket.NetPacket) error {
|
|||||||
} else {
|
} else {
|
||||||
player.SetIsInTown(false)
|
player.SetIsInTown(false)
|
||||||
}
|
}
|
||||||
err := player.SetAnimationMode(player.GetAnimationMode().String())
|
err := player.SetAnimationMode(player.GetAnimationMode())
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Printf("GameClient: error setting animation mode for player %s: %s", player.Id, err)
|
log.Printf("GameClient: error setting animation mode for player %s: %s", player.Id, err)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user