feat(npc): expose monstats flags with undead/demon helpers
(cherry picked from commit 52a2eaa082724d36af249114b73558e5b4905a85)
This commit is contained in:
@@ -75,6 +75,62 @@ var Desc = map[int]Description{
|
||||
{{- end }}
|
||||
}`
|
||||
|
||||
const templateMonStats = `// Code generated by cmd/txttocode. DO NOT EDIT.
|
||||
// source: cmd/txttocode/txt/monstats.txt
|
||||
package npc
|
||||
|
||||
type MonStatsFlags struct {
|
||||
ID int // ID is the unit class ID (hcIdx) and matches npc.ID.
|
||||
ClassID string // ClassID is the monstats Id string used to link with other txt files.
|
||||
Name string // Name is the key used for the unit display name.
|
||||
IsEnabled bool // IsEnabled is true when the unit is allowed to exist/spawn.
|
||||
CanSpawn bool // CanSpawn is true when the unit can be spawned by area generation.
|
||||
IsKillable bool // IsKillable is true when the unit can take damage and die.
|
||||
IsNPC bool // IsNPC is true when the unit is classified as an NPC.
|
||||
IsInTown bool // IsInTown is true when the unit is allowed in town.
|
||||
CanInteract bool // CanInteract is true when the player can interact instead of attack.
|
||||
HasInventory bool // HasInventory is true when the unit can carry/generate items (like town merchants).
|
||||
IsRanged bool // IsRanged is true when the unit is classified as a ranged type.
|
||||
IsMelee bool // IsMelee is true when the unit is classified as melee-only.
|
||||
IsLUndead bool // IsLUndead is true when the unit is low undead (undead resurrectable).
|
||||
IsHUndead bool // IsHUndead is true when the unit is high undead (undead not resurrectable).
|
||||
IsDemon bool // IsDemon is true when the unit is classified as a demon.
|
||||
IsBoss bool // IsBoss is true when the unit is classified as a boss.
|
||||
IsPrimeEvil bool // IsPrimeEvil is true when the unit is an act-end (Prime Evil) boss.
|
||||
}
|
||||
|
||||
var MonStatsFlagsByID = map[ID]MonStatsFlags{
|
||||
{{- range $key, $value := . }}
|
||||
{{ default (index $value "*hcIdx") (index $value "hcIdx") }}: {ID: {{ default (index $value "*hcIdx") (index $value "hcIdx") }}, ClassID: "{{ $value.Id }}", Name: "{{ $value.NameStr }}", IsEnabled: {{ if eq $value.enabled "1" }}true{{ else }}false{{ end }}, CanSpawn: {{ if eq $value.isSpawn "1" }}true{{ else }}false{{ end }}, IsKillable: {{ if eq $value.killable "1" }}true{{ else }}false{{ end }}, IsNPC: {{ if eq $value.npc "1" }}true{{ else }}false{{ end }}, IsInTown: {{ if eq $value.inTown "1" }}true{{ else }}false{{ end }}, CanInteract: {{ if eq $value.interact "1" }}true{{ else }}false{{ end }}, HasInventory: {{ if eq $value.inventory "1" }}true{{ else }}false{{ end }}, IsRanged: {{ if eq $value.rangedtype "1" }}true{{ else }}false{{ end }}, IsMelee: {{ if eq $value.isMelee "1" }}true{{ else }}false{{ end }}, IsLUndead: {{ if eq $value.lUndead "1" }}true{{ else }}false{{ end }}, IsHUndead: {{ if eq $value.hUndead "1" }}true{{ else }}false{{ end }}, IsDemon: {{ if eq $value.demon "1" }}true{{ else }}false{{ end }}, IsBoss: {{ if eq $value.boss "1" }}true{{ else }}false{{ end }}, IsPrimeEvil: {{ if eq $value.primeevil "1" }}true{{ else }}false{{ end }}},
|
||||
{{- end }}
|
||||
}
|
||||
|
||||
func MonStatsFlagsForID(id ID) (MonStatsFlags, bool) {
|
||||
flags, ok := MonStatsFlagsByID[id]
|
||||
return flags, ok
|
||||
}
|
||||
|
||||
func IsUndead(id ID) bool {
|
||||
flags, ok := MonStatsFlagsForID(id)
|
||||
return ok && (flags.IsLUndead || flags.IsHUndead)
|
||||
}
|
||||
|
||||
func IsDemon(id ID) bool {
|
||||
flags, ok := MonStatsFlagsForID(id)
|
||||
return ok && flags.IsDemon
|
||||
}
|
||||
|
||||
func IsBeast(id ID) bool {
|
||||
flags, ok := MonStatsFlagsForID(id)
|
||||
return ok && !flags.IsLUndead && !flags.IsHUndead && !flags.IsDemon
|
||||
}
|
||||
|
||||
func IsUndeadOrDemon(id ID) bool {
|
||||
flags, ok := MonStatsFlagsForID(id)
|
||||
return ok && (flags.IsLUndead || flags.IsHUndead || flags.IsDemon)
|
||||
}
|
||||
`
|
||||
|
||||
const templateEntrances = `// Code generated by cmd/txttocode. DO NOT EDIT.
|
||||
// source: cmd/txttocode/txt/lvlwarp.txt
|
||||
package entrance
|
||||
|
||||
Reference in New Issue
Block a user