aboutsummaryrefslogtreecommitdiff
path: root/internal/world/mob.go
diff options
context:
space:
mode:
authorhistoria <[not public]>2026-06-19 18:20:26 -0400
committerhistoria <[not public]>2026-06-19 18:20:26 -0400
commit0ea4eec5dd2122c6704216971eb1249276297867 (patch)
tree430fbbef04e837820f1d031c190f52ecd6112e25 /internal/world/mob.go
parent3a58125d14bb307f861b38c6c5b0a63babde7e08 (diff)
downloadthehouseoficarus-0ea4eec5dd2122c6704216971eb1249276297867.tar.gz
shop fixes, 'toggle' completely removed, movement speed increased
Diffstat (limited to 'internal/world/mob.go')
-rw-r--r--internal/world/mob.go41
1 files changed, 13 insertions, 28 deletions
diff --git a/internal/world/mob.go b/internal/world/mob.go
index ce9eddd..f7988ce 100644
--- a/internal/world/mob.go
+++ b/internal/world/mob.go
@@ -12,7 +12,7 @@ import (
"gopkg.in/yaml.v3"
)
-type DropTable struct {
+type MobDropTable struct {
Remains string `yaml:"remains"`
Loot []action.DropEntry `yaml:"loot"`
}
@@ -21,7 +21,6 @@ type MobDef struct {
ID string `yaml:"id"`
Name string `yaml:"name"`
Description string `yaml:"description"`
- BehaviorID string `yaml:"behavior"`
IdleDescriptions []string `yaml:"idle_descriptions"`
CombatDescriptions []string `yaml:"combat_descriptions"`
Attack int `yaml:"attack"`
@@ -35,7 +34,7 @@ type MobDef struct {
Protected bool `yaml:"protected"`
Unique bool `yaml:"unique"`
RespawnTicks float64 `yaml:"respawn_ticks"`
- Drops DropTable `yaml:"drops"`
+ Drops MobDropTable `yaml:"drops"`
AttackBonus int `yaml:"attack_bonus"`
StrengthBonus int `yaml:"strength_bonus"`
@@ -56,13 +55,16 @@ type MobDef struct {
AssassinLevel int `yaml:"assassin_level"`
FinishingBlow string `yaml:"finishing_blow"`
DamageWithout string `yaml:"damage_without"`
+
+ Talk *action.TalkConfig `yaml:"talk,omitempty"`
}
+func (d *MobDef) IsTalkable() bool { return d.Talk != nil }
+
type MobInstance struct {
InstanceID string
DefID string
Name string
- BehaviorID string
HP int
MaxHP int
Attack int
@@ -77,7 +79,7 @@ type MobInstance struct {
RespawnTicks float64
RoomID int
HomeRoomID int
- Drops DropTable
+ Drops MobDropTable
IdleDescription string
WanderRooms []int
WanderInterval float64
@@ -103,41 +105,24 @@ type MobInstance struct {
AssassinLevel int
FinishingBlow string
DamageWithout string
+
+ TalkConfig *action.TalkConfig
}
+func (m *MobInstance) IsTalkable() bool { return m.TalkConfig != nil }
+
const (
MatchNone = 0
MatchPrefix = 1
MatchExact = 2
)
-func WordPrefixMatch(input, name string) bool {
- inputWords := strings.Fields(strings.ToLower(input))
- if len(inputWords) == 0 {
- return false
- }
- nameWords := strings.Fields(strings.ToLower(name))
- for _, iw := range inputWords {
- found := false
- for _, nw := range nameWords {
- if strings.HasPrefix(nw, iw) || strings.HasPrefix(iw, nw) {
- found = true
- break
- }
- }
- if !found {
- return false
- }
- }
- return true
-}
-
func (m *MobInstance) MatchQuality(input string) int {
lower := strings.ToLower(input)
if strings.ToLower(m.Name) == lower {
return MatchExact
}
- if WordPrefixMatch(input, m.Name) {
+ if action.WordPrefixMatch(input, m.Name) {
return MatchPrefix
}
return MatchNone
@@ -281,7 +266,6 @@ func (s *MobStore) SeedMobs(roomID int, entries []RoomMob) {
InstanceID: instID,
DefID: defID,
Name: dw.def.Name,
- BehaviorID: dw.def.BehaviorID,
HP: dw.def.HP,
MaxHP: dw.def.HP,
Attack: dw.def.Attack,
@@ -315,6 +299,7 @@ func (s *MobStore) SeedMobs(roomID int, entries []RoomMob) {
AssassinLevel: dw.def.AssassinLevel,
FinishingBlow: dw.def.FinishingBlow,
DamageWithout: dw.def.DamageWithout,
+ TalkConfig: dw.def.Talk,
}
inst.IdleDescription = pickIdleDescription(dw.def.IdleDescriptions)
s.instances[instID] = inst