mobs

package
v0.9.7 Latest Latest
Warning

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

Go to latest
Published: Jul 14, 2025 License: GPL-3.0 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 DestroyInstance

func DestroyInstance(instanceId int)

func GetAllMobInstanceIds

func GetAllMobInstanceIds() []int

func GetAllMobNames

func GetAllMobNames() []string

func GetMemoryUsage

func GetMemoryUsage() map[string]util.MemoryResult

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 TrackRecentDeath

func TrackRecentDeath(instanceId int)

func ZoneNameSanitize

func ZoneNameSanitize(zone string) string

Types

type ItemTrade

type ItemTrade struct {
	AcceptedItemIds []int         `yaml:"accepteditemids,omitempty,flow"` // Must provide every item id in this list.
	AcceptedGold    int           `yaml:"acceptedgold,omitempty,flow"`    // Must provide at least this much gold.
	PrizeItemIds    []int         `yaml:"prizeitemids,omitempty,flow"`    // Will give these items in exchange.
	PrizeBuffIds    []int         `yaml:"prizebuffids,omitempty,flow"`    // Will give these buffs in exchange.
	PrizeRoomId     int           `yaml:"prizeroomid,omitempty,flow"`     // Will move player to this room in exchange.
	PrizeQuestIds   []string      `yaml:"prizequestids,omitempty,flow"`   // What quest id's will be awarded?
	PrizeGold       int           `yaml:"prizegold,omitempty,flow"`       // How much gold are they given?
	PrizeCommands   []string      `yaml:"prizecommands,omitempty,flow"`   // What commands will be executed?
	GivenItems      map[int][]int `yaml:"-"`                              // key = userId, value = Items given. Should only contain items from AcceptedItemIds
	GivenGold       map[int]int   `yaml:"-"`                              // key = userId, value = how much gold is given
}

type Mob

type Mob struct {
	MobId           MobId
	Zone            string   `yaml:"zone,omitempty"`
	ItemDropChance  int      // chance in 100
	ActivityLevel   int      `yaml:"activitylevel,omitempty"` // 1-100%
	InstanceId      int      `yaml:"-"`
	HomeRoomId      int      `yaml:"-"`
	Hostile         bool     // 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 // 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 // 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"`                 // 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

	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 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) 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) 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