characters

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: 25 Imported by: 0

README

Characters

TODO: Flesh out more.

Stat Points

Players have statistics that naturally improve with experience levels based on their race.

These stat points can be further augmented by Buffs and by worn Equipment that provides stat mods.

Players also receive a stat point that they can manually assign as they please with each level.

Stat Point Definitions/Philosophy

  • Strength - Physical mass and power. Affects feats of strength and damage in combat (crit damage)
  • Speed - Affects hitting and being hit, ability to perform many actions, etc
  • Smarts - Raw intelligence. Memorization, effectiveness of spells, etc.
  • Vitality - Capability to take damage and keep functioning. affects HP
  • Mysticism - Magical capabiity - affects MP. Affects spell casting success and resistance to other spells.
  • Perception - Ability to see hidden things (i.e. hidden exits), understand complexities (i.e. lock picking), remain unseen (i.e. hiding), etc.

Stats that reach 105 get recalculated with anything over 100 applied as SQRT(overage)*2

So a stat of 150 would actually be calculated as 114

Documentation

Index

Constants

View Source
const (
	// MinMax alignment
	AlignmentMinimum int8 = -100
	AlignmentMaximum int8 = 100
	// Good
	AlignmentHoly     int8 = 80
	AlignmentGood     int8 = 60
	AlignmentVirtuous int8 = 40
	AlignmentLawful   int8 = 20
	// Neutral
	AlignmentNeutralHigh int8 = 19
	AlignmentNeutral     int8 = 0
	AlignmentNeutralLow  int8 = -19
	// Evil
	AlignmentMisguided int8 = -20
	AlignmentCorrupt   int8 = -40
	AlignmentEvil      int8 = -60
	AlignmentUnholy    int8 = -80
	// Threshold by which mobs will auto aggro
	AlignmentAggroThreshold int = 190 // Possible delta is 0 - 200

)
View Source
const (
	CharmPermanent      = -1 // Never expires due to time
	CharmExpiredDespawn = `emote bows and bids you farewell, disappearing into the scenery;despawn charmed mob expired`
	CharmExpiredRevert  = `emote reverts to its old ways`
)
View Source
const (
	StockTemporary = -1
	StockUnlimited = 0
)

Variables

View Source
var OnGetFormattedName util.Hook[FormattedName]

OnGetFormattedName is fired at the end of getFormattedName with the fully-populated FormattedName. Modules may register handlers to modify the name before it is returned to the caller (e.g. to append a title).

View Source
var (
	StartingRoomId = -1
)

Functions

func AlignmentToString

func AlignmentToString(alignment int8) string

func AllSlots added in v0.9.8

func AllSlots() []items.ItemType

AllSlots returns every equipment slot in canonical display order. Delegates to items.AllEquipSlots() so the single source of truth lives alongside the ItemType constants.

func ArmorSlots added in v0.9.8

func ArmorSlots() []items.ItemType

ArmorSlots returns every equipment slot except Weapon.

func CompileAdjectiveSwaps

func CompileAdjectiveSwaps()

func GetAllSlotTypes

func GetAllSlotTypes() []string

GetAllSlotTypes returns all slot names as strings. Kept for backward compatibility; prefer AllSlots() for typed access.

func GetFormattedAdjective

func GetFormattedAdjective(adjName string) string

func GetFormattedAdjectives

func GetFormattedAdjectives(excludeShort bool) []string

func SlotLabel added in v0.9.8

func SlotLabel(slot items.ItemType) string

SlotLabel returns the short display label (with trailing colon) for a slot, e.g. items.Head -> "Head:". Used by UI code so label strings are not scattered across rendering packages.

func WeaponSlots added in v0.9.8

func WeaponSlots() []items.ItemType

WeaponSlots returns the slots that hold weapons.

Types

type Aggro

type Aggro struct {
	Type          AggroType
	MobInstanceId int
	UserId        int
	SpellInfo     SpellAggroInfo // If Type is SpellCast, this is the spell info
	ExitName      string         // For example, firing a weapon in a direction
	RoundsWaiting int            // How many rounds must pass before this triggers
}

type AggroType

type AggroType int
const (
	// Enumerated Aggro Types
	DefaultAttack AggroType = iota // Regular H2H combat, everything can decay to this. Starts at zero
	Shooting
	BackStab
	SpellCast
	Flee
)

type Character

type Character struct {
	Name            string                         // The name of the character
	Description     string                         // A description of the character.
	Adjectives      []string                       `yaml:"adjectives,omitempty"`    // Decorative text for the name of the character (e.g. "sleeping", "dead", "wounded")
	RoomId          int                            `yaml:"roomid,omitempty"`        // The room id the character is in.
	RoomIdOnReset   int                            `yaml:"roomidonreset,omitempty"` // The room they are sent to if their RoomId isn't found.
	Zone            string                         `yaml:"zone,omitempty"`          // The zone the character is in. The folder the room can be located in too.
	RaceId          int                            `yaml:"raceid,omitempty"`        // Character race
	FormRaceId      int                            `yaml:"formraceid,omitempty"`    // Temporary race override (0 = not transformed)
	Stats           stats.Statistics               // Character stats
	Level           int                            `yaml:"level,omitempty"`          // The level of the character
	Experience      int                            `yaml:"experience,omitempty"`     // The experience of the character
	TrainingPoints  int                            `yaml:"trainingpoints,omitempty"` // The number of training points the character has
	StatPoints      int                            `yaml:"statpoints,omitempty"`     // The number of skill points the character has
	Health          int                            `yaml:"health,omitempty"`         // The health of the character
	Mana            int                            `yaml:"mana,omitempty"`           // The mana of the character
	ActionPoints    int                            `yaml:"actionpoints,omitempty"`   // The resevoir of action points the character has to spend on movement etc.
	Alignment       int8                           `yaml:"alignment,omitempty"`      // The alignment of the character
	Gold            int                            `yaml:"gold,omitempty"`           // The gold the character is holding
	Bank            int                            `yaml:"bank,omitempty"`           // The gold the character has in the bank
	Shop            Shop                           `yaml:"shop,omitempty"`           // Definition of shop services/items this character stocks (or just has at the moment)
	SpellBook       map[string]int                 `yaml:"spellbook,omitempty"`      // The spells the character has learned
	Charmed         *CharmInfo                     `yaml:"-"`                        // If they are charmed, this is the info
	CharmedMobs     []int                          `yaml:"-"`                        // If they have charmed anyone, this is the list of mob instance ids
	Items           []items.Item                   `yaml:"items,omitempty"`          // The items the character is holding
	Buffs           buffs.Buffs                    `yaml:"buffs,omitempty"`          // The buffs the character has active
	Equipment       Worn                           `yaml:"equipment,omitempty"`      // The equipment the character is wearing
	TNLScale        float32                        `yaml:"-"`                        // The experience scale of the character. Don't write to yaml since is dynamically calculated.
	HealthMax       stats.StatInfo                 `yaml:"-"`                        // The maximum health of the character. Don't write to yaml since is dynamically calculated.
	ManaMax         stats.StatInfo                 `yaml:"-"`                        // The maximum mana of the character. Don't write to yaml since is dynamically calculated.
	ActionPointsMax stats.StatInfo                 `yaml:"-"`                        // The maximum actions of character. Don't write to yaml since is dynamically calculated.
	Aggro           *Aggro                         `yaml:"-"`                        // Dont' store this. If they leave they break their aggro
	Skills          map[string]int                 `yaml:"skills,omitempty"`         // The skills the character has, and what level they are at
	Cooldowns       Cooldowns                      `yaml:"cooldowns,omitempty"`      // How many rounds until it is cooled down
	Settings        map[string]string              `yaml:"settings,omitempty"`       // custom setting tracking, used for anything.
	QuestProgress   map[int]string                 `yaml:"questprogress,omitempty"`  // quest progress tracking
	KeyRing         map[string]string              `yaml:"keyring,omitempty"`        // key is the lock id, value is the sequence
	KD              KDStats                        `yaml:"kd,omitempty"`             // Kill/Death stats
	MiscData        map[string]any                 `yaml:"miscdata,omitempty"`       // Any random other data that needs to be stored
	ExtraLives      int                            `yaml:"extralives,omitempty"`     // How many lives remain. If enabled, players can perma-die if they die at zero
	MobMastery      MobMasteries                   `yaml:"mobmastery,omitempty"`     // Tracks particular masteries around a given mob
	Pet             pets.Pet                       `yaml:"pet,omitempty"`            // Do they have a pet?
	Created         time.Time                      `yaml:"created"`                  // When this character was created
	Timers          map[string]gametime.RoundTimer `yaml:"timers,omitempty"`         // any special timers added to this character
	ZonesVisited    map[string]RoomBitset          `yaml:"zonesvisited,omitempty"`   // permanent record of every room visited, keyed by zone name

	PlayerDamage        map[int]int `yaml:"-"` // key = who, value = how much
	LastPlayerDamage    uint64      `yaml:"-"` // last round a player damaged this character
	KillerMobInstanceId int         `yaml:"-"` // transient: mob instance that delivered the killing blow
	KillerMobIsElite    bool        `yaml:"-"` // transient: true if the killing mob was elite
	KillerMobName       string      `yaml:"-"` // transient: name of the mob that delivered the killing blow
	// contains filtered or unexported fields
}

func New

func New() *Character

func (*Character) AddBuff

func (c *Character) AddBuff(buffId int, isPermanent bool, triggerCountOverride ...int) error

func (*Character) AlignmentName

func (c *Character) AlignmentName() string

func (*Character) ApplyFormChange added in v0.9.8

func (c *Character) ApplyFormChange(newRaceId int) []items.Item

func (*Character) ApplyHealthChange

func (c *Character) ApplyHealthChange(healthChange int) int

func (*Character) ApplyManaChange

func (c *Character) ApplyManaChange(manaChange int) int

func (*Character) AutoTrain

func (c *Character) AutoTrain()

AutoTrain() spends any training points for this character

func (*Character) BarterPrice

func (c *Character) BarterPrice(startPrice int) int

func (*Character) BestUpgrades added in v0.9.8

func (c *Character) BestUpgrades() map[items.ItemType]items.Item

BestUpgrades returns a map of equipment slot -> best backpack item that beats whatever is currently worn in that slot (or fills an empty slot). The caller receives only slots where an upgrade exists; worn items that already beat every backpack alternative are omitted.

Two-handed weapon / offhand mutual-exclusion is respected: a two-handed weapon candidate is skipped when an offhand item is already worn (or already chosen as an upgrade), and an offhand candidate is skipped when a two-handed weapon is already worn (or already chosen).

func (*Character) CanDualWield

func (c *Character) CanDualWield() bool

func (*Character) CancelBuffsWithFlag

func (c *Character) CancelBuffsWithFlag(buffFlag buffs.Flag) bool

func (*Character) CarryCapacity

func (c *Character) CarryCapacity() int

func (*Character) Charm

func (c *Character) Charm(userId int, rounds int, expireCommand string)

func (*Character) ClearQuestToken

func (c *Character) ClearQuestToken(questToken string)

func (*Character) DecayAlignment added in v0.9.8

func (c *Character) DecayAlignment()

DecayAlignment drifts alignment one step toward neutral. The amount decayed per call scales quadratically with distance from neutral so extreme alignments decay faster and are harder to maintain.

func (*Character) DeductActionPoints

func (c *Character) DeductActionPoints(amount int) bool

func (*Character) DisableSpell

func (c *Character) DisableSpell(spellName string) bool

func (*Character) EnableSpell

func (c *Character) EnableSpell(spellName string) bool

func (*Character) EndAggro

func (c *Character) EndAggro()

func (*Character) FindInBackpack

func (c *Character) FindInBackpack(itemName string) (items.Item, bool)

func (*Character) FindKeyInBackpack

func (c *Character) FindKeyInBackpack(lockId string) (items.Item, bool)

func (*Character) FindOnBody

func (c *Character) FindOnBody(itemName string) (items.Item, bool)

func (*Character) GetAdjectives

func (c *Character) GetAdjectives() []string

func (*Character) GetAllBackpackItems

func (c *Character) GetAllBackpackItems() []items.Item

func (*Character) GetAllCooldowns

func (c *Character) GetAllCooldowns() map[string]int

func (*Character) GetAllSkillRanks

func (c *Character) GetAllSkillRanks() map[string]int

func (*Character) GetAllWornItems

func (c *Character) GetAllWornItems() []items.Item

func (*Character) GetBaseCastSuccessChance

func (c *Character) GetBaseCastSuccessChance(spellId string) int

All spells should have a 10% minimum chance of success.

func (*Character) GetBuffs

func (c *Character) GetBuffs(buffId ...int) []*buffs.Buff

func (*Character) GetCharmIds

func (c *Character) GetCharmIds() []int

func (*Character) GetCharmedUserId

func (c *Character) GetCharmedUserId() int

func (*Character) GetCooldown

func (c *Character) GetCooldown(trackingTag string) int

func (*Character) GetDefaultDiceRoll

func (c *Character) GetDefaultDiceRoll() (attacks int, dCount int, dSides int, bonus int, buffOnCrit []int)

func (*Character) GetDefense

func (c *Character) GetDefense() int

Returns an integer representing a % damage reduction

func (*Character) GetDescription

func (c *Character) GetDescription() string

returns description unless description is a hash which points to another description location.

func (*Character) GetGearValue

func (c *Character) GetGearValue() int

func (*Character) GetHealthAppearance

func (c *Character) GetHealthAppearance() string

USERNAME appears to be <BLANK>

func (*Character) GetKey

func (c *Character) GetKey(lockId string) string

func (*Character) GetMapSprawlCapacity

func (c *Character) GetMapSprawlCapacity() int

func (*Character) GetMaxCharmedCreatures

func (c *Character) GetMaxCharmedCreatures() int

func (*Character) GetMemoryCapacity

func (c *Character) GetMemoryCapacity() int

func (*Character) GetMiscData

func (c *Character) GetMiscData(key string) any

func (*Character) GetMiscDataKeys

func (c *Character) GetMiscDataKeys(prefixMatch ...string) []string

func (*Character) GetMobName

func (c *Character) GetMobName(viewingUserId int, renderFlags ...NameRenderFlag) FormattedName

func (*Character) GetPlayerName

func (c *Character) GetPlayerName(viewingUserId int, renderFlags ...NameRenderFlag) FormattedName

func (*Character) GetQuestProgress

func (c *Character) GetQuestProgress() map[int]string

func (*Character) GetRaceId added in v0.9.8

func (c *Character) GetRaceId() int

func (*Character) GetRandomItem

func (c *Character) GetRandomItem() (items.Item, bool)

func (*Character) GetSetting

func (c *Character) GetSetting(settingName string) string

func (*Character) GetSkillLevel

func (c *Character) GetSkillLevel(skillName skills.SkillTag) int

Gets the current value of the skillname provided

func (*Character) GetSkillLevelCost

func (c *Character) GetSkillLevelCost(currentLevel int) int

func (*Character) GetSkills

func (c *Character) GetSkills() map[string]int

func (*Character) GetSpells

func (c *Character) GetSpells() map[string]int

func (*Character) GiveQuestToken

func (c *Character) GiveQuestToken(questToken string) bool

func (*Character) GrantXP

func (c *Character) GrantXP(xp int) (actualXP int, xpScale int)

func (*Character) HandsRequired

func (c *Character) HandsRequired(i items.Item) int

func (*Character) HasAdjective

func (c *Character) HasAdjective(adj string) bool

func (*Character) HasBuff

func (c *Character) HasBuff(buffId int) bool

func (*Character) HasBuffFlag

func (c *Character) HasBuffFlag(buffFlag buffs.Flag) bool

func (*Character) HasKey

func (c *Character) HasKey(lockId string, difficulty int) (hasKey bool, hasSequence bool)

func (*Character) HasQuest

func (c *Character) HasQuest(questToken string) bool

func (*Character) HasSpell

func (c *Character) HasSpell(spellName string) bool

func (*Character) HasVisitedRoom added in v0.9.8

func (c *Character) HasVisitedRoom(roomId int, zone string) bool

HasVisitedRoom reports whether this character has ever visited roomId in zone.

func (*Character) Heal

func (c *Character) Heal(hp int, mana int) (int, int)

func (*Character) HealthPerRound

func (c *Character) HealthPerRound() int

func (*Character) IsAggro

func (c *Character) IsAggro(targetUserId int, targetMobInstanceId int) bool

func (*Character) IsCharmed

func (c *Character) IsCharmed(userId ...int) bool

func (*Character) IsDisabled

func (c *Character) IsDisabled() bool

func (*Character) IsFormChanged added in v0.9.8

func (c *Character) IsFormChanged() bool

func (*Character) IsQuestDone

func (c *Character) IsQuestDone(questToken string) bool

func (*Character) KeyCount

func (c *Character) KeyCount() int

func (*Character) KnowsFirstAid

func (c *Character) KnowsFirstAid() bool

func (*Character) LearnSpell

func (c *Character) LearnSpell(spellName string) bool

func (*Character) LevelUp

func (c *Character) LevelUp() (bool, stats.Statistics)

func (*Character) ManaPerRound

func (c *Character) ManaPerRound() int

func (*Character) MarkVisitedRoom added in v0.9.8

func (c *Character) MarkVisitedRoom(roomId int, zone string, validRoomIds map[int]struct{}) bool

MarkVisitedRoom permanently records that this character has visited roomId in the given zone. Safe to call every time a player enters a room. Returns true only if this specific call completed the zone (i.e. every room in validRoomIds is now visited). Returns false if the room was already visited, if validRoomIds is empty, or if the zone is still incomplete.

func (*Character) MovementCost

func (c *Character) MovementCost() int

Where 1000 = a full round

func (*Character) PruneCooldowns

func (c *Character) PruneCooldowns()

func (*Character) Race

func (c *Character) Race() string

func (*Character) RaceSize added in v0.9.8

func (c *Character) RaceSize() string

func (*Character) RecalculateStats

func (c *Character) RecalculateStats()

returns true if something has changed.

func (*Character) RememberRoom

func (c *Character) RememberRoom(roomId int)

Remember visiting a room. This may cause to forget an older room if the memory is full.

func (*Character) RemoveBuff

func (c *Character) RemoveBuff(buffId int)

func (*Character) RemoveCharm

func (c *Character) RemoveCharm() int

Returns userId of whoever had charmed them

func (*Character) RemoveFromBody

func (c *Character) RemoveFromBody(i items.Item) bool

func (*Character) RemoveItem

func (c *Character) RemoveItem(i items.Item) bool

func (*Character) RevertFormChange added in v0.9.8

func (c *Character) RevertFormChange() []items.Item

func (*Character) SetAdjective

func (c *Character) SetAdjective(adj string, addToList bool)

func (*Character) SetAggro

func (c *Character) SetAggro(userId int, mobInstanceId int, aggroType AggroType, roundsWaitTime ...int)

func (*Character) SetAggroRemote

func (c *Character) SetAggroRemote(exitName string, userId int, mobInstanceId int, aggroType AggroType, roundsWaitTime ...int)

func (*Character) SetCast

func (c *Character) SetCast(roundsWaitTime int, sInfo SpellAggroInfo)

func (*Character) SetKey

func (c *Character) SetKey(lockId string, sequence string)

func (*Character) SetMiscData

func (c *Character) SetMiscData(key string, value any)

func (*Character) SetPermaBuffs

func (c *Character) SetPermaBuffs(buffIds []int)

Used with SpawnInfo to gift spawning mobs with permabuffs

func (*Character) SetSetting

func (c *Character) SetSetting(settingName string, settingValue string)

func (*Character) SetSkill

func (c *Character) SetSkill(skillName string, level int)

func (*Character) SetUserId

func (c *Character) SetUserId(userId int)

Sometimes it's useful for a character to know what user it belongs to.

func (*Character) StatMod

func (c *Character) StatMod(statName string) int

func (*Character) StoreItem

func (c *Character) StoreItem(i items.Item) bool

func (*Character) TimerExists

func (c *Character) TimerExists(name string) bool

func (*Character) TimerExpired

func (c *Character) TimerExpired(name string) bool

func (*Character) TimerSet

func (c *Character) TimerSet(name, period string)

func (*Character) TrackBuffStarted

func (c *Character) TrackBuffStarted(buffId int)

func (*Character) TrackCharmed

func (c *Character) TrackCharmed(mobId int, add bool)

func (*Character) TrackPlayerDamage

func (c *Character) TrackPlayerDamage(userId int, damageAmt int)

returns description unless description is a hash which points to another description location.

func (*Character) TrackSpellCast

func (c *Character) TrackSpellCast(spellName string) bool

func (*Character) TrainSkill

func (c *Character) TrainSkill(skillName string, targetLevel ...int) int

Increases the skill training counter and returns the new value

func (*Character) TryCooldown

func (c *Character) TryCooldown(trackingTag string, cooldownTime string) bool

func (*Character) UnLearnSpell added in v0.9.8

func (c *Character) UnLearnSpell(spellName string) bool

func (*Character) Uncurse

func (c *Character) Uncurse() []items.Item

func (*Character) UpdateAlignment

func (c *Character) UpdateAlignment(amt int)

func (*Character) UpdateItem

func (c *Character) UpdateItem(originalItm items.Item, replacement items.Item) bool

Copies over an existing item with a new item Returns true if successfully replaces an item

func (*Character) UseItem

func (c *Character) UseItem(i items.Item) int

func (*Character) Validate

func (c *Character) Validate(recalcPermaBuffs ...bool) error

Returns whether a correction was in order

func (*Character) Wear

func (c *Character) Wear(i items.Item) (returnItems []items.Item, newItemWorn bool, failureReason string)

func (*Character) XPTL

func (c *Character) XPTL(lvl int) int

Amt TNL for a specific level

func (*Character) XPTNL

func (c *Character) XPTNL() int

func (*Character) XPTNLActual

func (c *Character) XPTNLActual() (xpPastCurrentLevel int, tnlXP int)

Returns the actual xp in regards to the current level/next level

func (*Character) ZoneVisitPercent added in v0.9.8

func (c *Character) ZoneVisitPercent(zone string, validRoomIds map[int]struct{}) int

ZoneVisitPercent returns the percentage (0–100) of rooms in zone that the character has visited. Returns 0 when the zone has no rooms.

func (*Character) ZoneVisitProgress added in v0.9.8

func (c *Character) ZoneVisitProgress(zone string, validRoomIds map[int]struct{}) (visited int, total int)

ZoneVisitProgress returns how many rooms the character has visited in zone and the total number of rooms in that zone, allowing callers to compute a completion percentage. validRoomIds should come from ZoneConfig.RoomIds.

type CharmInfo

type CharmInfo struct {
	UserId          int    // Charmed or serving a player?
	RoundsRemaining int    // If -1, never expires
	ExpiredCommand  string // Any valid mob commands such as `emote bows and waves farewell;despawn`
}

func NewCharm

func NewCharm(userId int, rounds int, expireCommand string) *CharmInfo

func (*CharmInfo) Expire

func (ch *CharmInfo) Expire()

type Cooldowns

type Cooldowns map[string]int

func (Cooldowns) Prune

func (cd Cooldowns) Prune()

func (Cooldowns) RoundTick

func (cd Cooldowns) RoundTick()

func (Cooldowns) Try

func (cd Cooldowns) Try(trackingTag string, cooldownPeriod string) bool

type FormattedName

type FormattedName struct {
	Name               string
	Type               string // mob/user
	Suffix             string // What ansi alias suffix to use (if any)
	Title              string // Optional title appended after name (e.g. "Mayor of Frostfang")
	Adjectives         []string
	UseShortAdjectives bool   // Whether to failover to short adjectives
	QuestAlert         bool   // Whether this mob is relevant to a current quest
	PetName            string // Name of pet (if any)
}

func (FormattedName) String

func (f FormattedName) String() string

type KDStats

type KDStats struct {
	TotalKills  int         `json:"totalkills,omitempty"`  // Quick tally of kills
	Kills       map[int]int `json:"kills,omitempty"`       // map of MobId to count
	TotalDeaths int         `json:"totaldeaths,omitempty"` // Quick tally of deaths

	TotalPvpKills  int            `json:"totalpvpkills,omitempty"`  // Quick tally of pvp kills
	PlayerKills    map[string]int `json:"playerkills,omitempty"`    // map of userid:username to count
	PlayerDeaths   map[string]int `json:"playerdeaths,omitempty"`   // map of userid:username to count
	TotalPvpDeaths int            `json:"totalpvpdeaths,omitempty"` // Quick tally of pvp deaths

	EliteKills  map[string]int `json:"elitekills,omitempty"`  // map of mobId:mobName to count (not included in TotalKills)
	EliteDeaths map[string]int `json:"elitedeaths,omitempty"` // map of mobId:mobName to count of times killed by an elite
}

func (*KDStats) AddEliteDeath added in v0.9.8

func (kd *KDStats) AddEliteDeath(mobId int, mobName string)

func (*KDStats) AddEliteKill added in v0.9.8

func (kd *KDStats) AddEliteKill(mobId int, mobName string)

func (*KDStats) AddMobDeath

func (kd *KDStats) AddMobDeath()

func (*KDStats) AddMobKill

func (kd *KDStats) AddMobKill(mobId int)

func (*KDStats) AddPlayerDeath

func (kd *KDStats) AddPlayerDeath(killedByUserId int, killedByCharName string)

func (*KDStats) AddPlayerKill

func (kd *KDStats) AddPlayerKill(killedUserId int, killedCharName string)

func (*KDStats) AddPvpDeath

func (kd *KDStats) AddPvpDeath()

func (*KDStats) GetEliteKills added in v0.9.8

func (kd *KDStats) GetEliteKills(mobId ...int) int

func (*KDStats) GetMobDeaths

func (kd *KDStats) GetMobDeaths() int

func (*KDStats) GetMobKDRatio

func (kd *KDStats) GetMobKDRatio() float64

func (*KDStats) GetMobKills

func (kd *KDStats) GetMobKills(mobId ...int) int

func (*KDStats) GetPvpDeaths

func (kd *KDStats) GetPvpDeaths() int

func (*KDStats) GetPvpKDRatio

func (kd *KDStats) GetPvpKDRatio() float64

type MobMasteries

type MobMasteries struct {
	Tame map[int]int `json:"tame,omitempty"` // mobId to proficiency
}

func (*MobMasteries) GetAllTame

func (m *MobMasteries) GetAllTame() map[int]int

func (*MobMasteries) GetTame

func (m *MobMasteries) GetTame(mobId int) int

func (*MobMasteries) SetTame

func (m *MobMasteries) SetTame(mobId int, amt int)

type NameRenderFlag

type NameRenderFlag uint8
const (
	RenderHealth NameRenderFlag = iota
	RenderAggro
	RenderShortAdjectives
)

type RoomBitset added in v0.9.8

type RoomBitset map[uint16]uint64

RoomBitset is a memory-efficient set of visited room IDs using a chunked bitset. The map key is roomId/64 (the block index) and the value is a uint64 where bit (roomId%64) represents that room. Blocks are only allocated for room ID ranges that have been visited, so sparse zones cost nothing for unvisited regions.

YAML serialization uses hex strings ("0x...") so the data is human-readable in character save files.

func (RoomBitset) Count added in v0.9.8

func (rb RoomBitset) Count() int

Count returns the total number of visited rooms across all blocks.

func (RoomBitset) CountIn added in v0.9.8

func (rb RoomBitset) CountIn(roomIds map[int]struct{}) int

CountIn returns how many rooms from the provided set have been visited.

func (RoomBitset) Has added in v0.9.8

func (rb RoomBitset) Has(roomId int) bool

Has reports whether a room has been visited. Non-positive room IDs always return true because they are sentinel values that are considered visited by definition.

func (RoomBitset) IsComplete added in v0.9.8

func (rb RoomBitset) IsComplete(roomIds map[int]struct{}) bool

IsComplete reports whether every room in the provided set has been visited.

func (RoomBitset) MarshalYAML added in v0.9.8

func (rb RoomBitset) MarshalYAML() (interface{}, error)

MarshalYAML serialises the bitset as a map of block-index to hex string so that character save files remain human-readable.

Example output:

0: "0x0000000000000003"
9: "0xFFFFFFFFFFFFFFFF"

func (RoomBitset) Prune added in v0.9.8

func (rb RoomBitset) Prune(validRoomIds map[int]struct{})

Prune clears any bits that do not correspond to a live room in validRoomIds, then removes blocks that become empty. This handles the case where rooms are deleted from a zone after a player has already visited them.

func (RoomBitset) Set added in v0.9.8

func (rb RoomBitset) Set(roomId int)

Set marks a room as visited. Room IDs must be positive; non-positive IDs are silently ignored because they represent special sentinel values (e.g. -1 for the character-creation room, 0 for StartRoomIdAlias) that are always considered visited.

func (RoomBitset) ToSet added in v0.9.8

func (rb RoomBitset) ToSet() map[int]struct{}

ToSet expands the bitset into a map[int]struct{} of all visited room IDs.

func (*RoomBitset) UnmarshalYAML added in v0.9.8

func (rb *RoomBitset) UnmarshalYAML(unmarshal func(interface{}) error) error

UnmarshalYAML deserialises the hex-string map produced by MarshalYAML.

type Shop

type Shop []ShopItem

func (*Shop) Destock

func (s *Shop) Destock(si ShopItem) bool

func (*Shop) GetInstock

func (s *Shop) GetInstock() Shop

func (*Shop) Restock

func (s *Shop) Restock() bool

func (*Shop) StockItem

func (s *Shop) StockItem(itemId int) bool

type ShopItem

type ShopItem struct {
	MobId       int    `yaml:"mobid,omitempty"`       // Is it a mercenary for sale?
	ItemId      int    `yaml:"itemid,omitempty"`      // Is it an item for sale?
	BuffId      int    `yaml:"buffid,omitempty"`      // Does this shop keeper apply a buff if purchased?
	PetType     string `yaml:"pettype,omitempty"`     // Does this shop sell pets?
	Quantity    int    `yaml:"quantity,omitempty"`    // How many currently avilable
	QuantityMax int    `yaml:"quantitymax,omitempty"` // 0 for unlimited, or a maximum that can be stocked at one time
	Price       int    `yaml:"price,omitempty"`       // If a price is provided, use it
	TradeItemId int    `yaml:"tradeitemid,omitempty"` // ItemId required in trade
	RestockRate string `yaml:"restockrate,omitempty"` // 1 day, 1 week, 1 real month, etc
	// contains filtered or unexported fields
}

func (*ShopItem) Available

func (si *ShopItem) Available() bool

type SpellAggroInfo

type SpellAggroInfo struct {
	SpellId              string
	SpellRest            string
	TargetUserIds        []int
	TargetMobInstanceIds []int
}

type Worn

type Worn struct {
	Weapon  items.Item `yaml:"weapon,omitempty"`
	Offhand items.Item `yaml:"offhand,omitempty"`
	Head    items.Item `yaml:"head,omitempty"`
	Neck    items.Item `yaml:"neck,omitempty"`
	Body    items.Item `yaml:"body,omitempty"`
	Belt    items.Item `yaml:"belt,omitempty"`
	Gloves  items.Item `yaml:"gloves,omitempty"`
	Ring    items.Item `yaml:"ring,omitempty"`
	Legs    items.Item `yaml:"legs,omitempty"`
	Feet    items.Item `yaml:"feet,omitempty"`
}

func (*Worn) EnableAll

func (w *Worn) EnableAll()

func (*Worn) Get added in v0.9.8

func (w *Worn) Get(slot items.ItemType) *items.Item

Get returns a pointer to the item in the given slot, or nil for an unrecognized slot type. This is the single place that maps an ItemType to a Worn struct field; add new slots here and nowhere else.

func (*Worn) GetAllItems

func (w *Worn) GetAllItems() []items.Item

func (*Worn) Set added in v0.9.8

func (w *Worn) Set(slot items.ItemType, item items.Item)

Set places item into the given slot. Does nothing for an unrecognized slot.

func (*Worn) StatMod

func (w *Worn) StatMod(stat ...string) int

Jump to

Keyboard shortcuts

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