mobs

package
v0.9.8 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 4, 2026 License: MIT Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ScriptTemplateQuest = `item-gold-quest.js`
)

Variables

View Source
var (
	SampleScripts = map[string]string{
		`item and gold`: `item-gold-quest.js`,
	}
)

Functions

func DeleteMobSpec added in v0.9.8

func DeleteMobSpec(mobId MobId) error

func DestroyInstance

func DestroyInstance(instanceId int)

func GetAllMobInstanceIds

func GetAllMobInstanceIds() []int

func GetAllMobNames

func GetAllMobNames() []string

func GetMemoryUsage

func GetMemoryUsage() map[string]util.MemoryResult

func GetMobScriptForTag added in v0.9.8

func GetMobScriptForTag(mobId MobId, tag string) (string, error)

func IsHostile

func IsHostile(groupName string, userId int) bool

func LoadDataFiles

func LoadDataFiles()

file self loads due to init()

func MakeHostile

func MakeHostile(groupName string, userId int, rounds int)

func MobInstanceExists

func MobInstanceExists(instanceId int) bool

func RecentlyDied

func RecentlyDied(instanceId int) bool

func ReduceHostility

func ReduceHostility()

func SaveMobScript added in v0.9.8

func SaveMobScript(mobId MobId, content string) error

func SaveMobScriptForTag added in v0.9.8

func SaveMobScriptForTag(mobId MobId, tag string, content string) error

func SaveMobSpec added in v0.9.8

func SaveMobSpec(spec *Mob) error

func StockMobShop added in v0.9.8

func StockMobShop(mobId MobId, entry characters.ShopItem) error

func TrackRecentDeath

func TrackRecentDeath(instanceId int)

func ZoneNameSanitize

func ZoneNameSanitize(zone string) string

Types

type Mob

type Mob struct {
	MobId           MobId
	Zone            string   `yaml:"zone,omitempty"`
	ItemDropChance  int      `yaml:"itemdropchance,omitempty"` // chance in 100
	ActivityLevel   int      `yaml:"activitylevel,omitempty"`  // 1-100%
	InstanceId      int      `yaml:"-"`
	HomeRoomId      int      `yaml:"-"`
	Hostile         bool     `yaml:"hostile,omitempty"`        // whether they attack on sight
	LastIdleCommand uint8    `yaml:"-"`                        // Track what hte last used idlecommand was
	BoredomCounter  uint8    `yaml:"-"`                        // how many rounds have passed since this mob has seen a player
	Groups          []string `yaml:"groups,omitempty"`         // What group do they identify with? Helps with teamwork
	Hates           []string `yaml:"hates,omitempty"`          // What NPC groups or races do they hate and probably fight if encountered?
	IdleCommands    []string `yaml:"idlecommands,omitempty"`   // Commands they may do while idle (not in combat)
	AngryCommands   []string `yaml:"angrycommands,omitempty"`  // randomly chosen to queue when they are angry/entering combat.
	CombatCommands  []string `yaml:"combatcommands,omitempty"` // Commands they may do while in combat
	Character       characters.Character
	MaxWander       int       `yaml:"maxwander,omitempty"`       // Max rooms to wander from home
	WanderCount     int       `yaml:"-"`                         // How many times this mob has wandered
	PreventIdle     bool      `yaml:"-"`                         // Whether they can't possibly be idle
	ScriptTag       string    `yaml:"scripttag,omitempty"`       // Script for this mob: mobs/frostfang/scripts/{mobId}-{mobname}-{ScriptTag}.js
	QuestFlags      []string  `yaml:"questflags,omitempty,flow"` // What quest flags are set on this mob?
	BuffIds         []int     `yaml:"buffids,omitempty"`         // Buff Id's this mob always has upon spawn
	EliteChance     int       `yaml:"elitechance,omitempty"`     // Percent chance (0-100) this mob spawns as elite
	IsElite         bool      `yaml:"-"`                         // Runtime flag: true if this instance is elite
	Path            PathQueue `yaml:"-"`                         // a pre-calculated path the mob is following.
	// contains filtered or unexported fields
}

func GetAllMobInfo

func GetAllMobInfo() []Mob

Gets a copy of all mob info

func GetAllMobInstances added in v0.9.8

func GetAllMobInstances() []*Mob

func GetAllMobSpecs added in v0.9.8

func GetAllMobSpecs() []Mob

func GetInstance

func GetInstance(instanceId int) *Mob

func GetMobSpec

func GetMobSpec(mobId MobId) *Mob

func NewMobById

func NewMobById(mobId MobId, homeRoomId int, forceLevel ...int) *Mob

func (*Mob) AddBuff

func (m *Mob) AddBuff(buffId int, source string)

func (*Mob) Command

func (m *Mob) Command(inputTxt string, waitSeconds ...float64)

func (*Mob) ConsidersAnAlly

func (r *Mob) ConsidersAnAlly(m *Mob) bool

func (*Mob) Converse

func (m *Mob) Converse()

func (*Mob) Despawns

func (m *Mob) Despawns() bool

func (*Mob) Filename

func (m *Mob) Filename() string

func (*Mob) Filepath

func (m *Mob) Filepath() string

func (*Mob) GetAllScriptTags added in v0.9.8

func (m *Mob) GetAllScriptTags() []string

GetAllScriptTags returns the tag (empty string for the base script) of every .js script file that exists for this mob. The base (untagged) script is always first when present; tagged scripts follow in sorted order.

func (*Mob) GetAngryCommand

func (m *Mob) GetAngryCommand() string

func (*Mob) GetIdleCommand

func (m *Mob) GetIdleCommand() string

func (*Mob) GetScript

func (m *Mob) GetScript() string

func (*Mob) GetScriptPath

func (m *Mob) GetScriptPath() string

func (*Mob) GetScriptPathForTag added in v0.9.8

func (m *Mob) GetScriptPathForTag(tag string) string

func (*Mob) GetSellPrice

func (m *Mob) GetSellPrice(item items.Item) int

func (*Mob) GetTempData

func (m *Mob) GetTempData(key string) any

func (*Mob) HasAttackedPlayer

func (m *Mob) HasAttackedPlayer(userId int) bool

func (*Mob) HasScript

func (m *Mob) HasScript() bool

func (*Mob) HasShop

func (m *Mob) HasShop() bool

func (*Mob) HatesAlignment

func (r *Mob) HatesAlignment(otherAlignment int8) bool

func (*Mob) HatesMob

func (r *Mob) HatesMob(m *Mob) bool

func (*Mob) HatesRace

func (r *Mob) HatesRace(raceName string) bool

func (*Mob) Id

func (r *Mob) Id() int

func (*Mob) InConversation

func (m *Mob) InConversation() bool

func (*Mob) IsTameable

func (m *Mob) IsTameable() bool

func (*Mob) PlayerAttacked

func (m *Mob) PlayerAttacked(userId int)

func (*Mob) Save

func (r *Mob) Save() error

func (*Mob) SetConversation

func (m *Mob) SetConversation(id int)

func (*Mob) SetTempData

func (m *Mob) SetTempData(key string, value any)

func (*Mob) ShorthandId

func (m *Mob) ShorthandId() string

func (*Mob) Sleep

func (m *Mob) Sleep(seconds int)

Cause the mob to basically wait and do nothing for x seconds

func (*Mob) Validate

func (r *Mob) Validate() error

type MobForHire

type MobForHire struct {
	MobId    MobId
	Price    int
	Quantity int
}

type MobId

type MobId int // Creating a custom type to help prevent confusion over MobId and MobInstanceId

func CreateNewMobFile

func CreateNewMobFile(newMobInfo Mob, copyScript string) (MobId, error)

func MobIdByName

func MobIdByName(mobName string) MobId

type PathQueue

type PathQueue struct {
	// contains filtered or unexported fields
}

func (*PathQueue) Clear

func (p *PathQueue) Clear()

func (PathQueue) Current

func (p PathQueue) Current() PathRoom

func (PathQueue) Len

func (p PathQueue) Len() int

func (*PathQueue) Next

func (p *PathQueue) Next() PathRoom

func (*PathQueue) SetPath

func (p *PathQueue) SetPath(path []PathRoom)

func (*PathQueue) Waypoints

func (p *PathQueue) Waypoints() []int

returns a list of remaining waypoint roomIds

type PathRoom

type PathRoom interface {
	ExitName() string
	RoomId() int
	Waypoint() bool
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL