Documentation
¶
Index ¶
- Constants
- Variables
- func ClearRoomCache(roomId int) error
- func ConnectRoom(fromRoomId int, toRoomId int, exitName string, mapDirection ...string) error
- func CreateEphemeralRoomIds(roomIds ...int) (map[int]int, error)
- func CreateEphemeralZone(zoneName string) (map[int]int, error)
- func CreateZone(zoneName string) (roomId int, err error)
- func EphemeralRoomMaintenance() []int
- func FindZoneName(zone string) string
- func GetAllRoomIds() []int
- func GetAllZoneNames() []string
- func GetAllZoneRoomsIds(zoneName string) []int
- func GetChunkCount() int
- func GetMemoryUsage() map[string]util.MemoryResult
- func GetNextRoomId() int
- func GetOriginalRoom(roomId int) int
- func GetRoomCount(zoneName string) int
- func GetRoomWithMostItems(skipRecentlyVisited bool, minimumItemCt int, minimumGoldCt int) (roomId int, itemCt int)
- func GetRoomsWithMobs() []int
- func GetRoomsWithPlayers() []int
- func GetZoneBiome(zone string) string
- func GetZoneRoot(zone string) (int, error)
- func GetZonesWithMutators() ([]string, []int)
- func IsEphemeralRoomId(roomId int) bool
- func IsRoomLoaded(roomId int) bool
- func LoadDataFiles()
- func MoveToRoom(userId int, toRoomId int, isSpawn ...bool) error
- func MoveToZone(roomId int, newZoneName string) error
- func RoomMaintenance() []int
- func SaveAllRooms() error
- func SaveRoomInstance(r Room) error
- func SaveRoomTemplate(roomTpl Room) error
- func SetNextRoomId(nextRoomId int)
- func TryEphemeralCleanup(ephemeralRoomId int) []int
- func ValidateZoneName(zone string) error
- func ZoneNameSanitize(zone string) string
- func ZoneStats(zone string) (rootRoomId int, totalRooms int, err error)
- func ZoneToFolder(zone string) string
- type BiomeInfo
- func (bi BiomeInfo) Burns() bool
- func (bi BiomeInfo) Description() string
- func (bi BiomeInfo) IsDark() bool
- func (bi BiomeInfo) IsLit() bool
- func (bi BiomeInfo) Name() string
- func (bi BiomeInfo) RequiredItemId() int
- func (bi BiomeInfo) Symbol() rune
- func (bi BiomeInfo) SymbolString() string
- func (bi BiomeInfo) UsesItem() bool
- type Container
- func (c *Container) AddItem(i items.Item)
- func (c *Container) Count(itemId int) int
- func (c *Container) FindItem(itemName string) (items.Item, bool)
- func (c *Container) FindItemById(itemId int) (items.Item, bool)
- func (c Container) HasLock() bool
- func (c *Container) RecipeReady() int
- func (c *Container) RemoveItem(i items.Item)
- type Corpse
- type FindFlag
- type Room
- func (r *Room) ActiveMutators(yield func(mutators.Mutator) bool)
- func (r *Room) AddCorpse(c Corpse)
- func (r *Room) AddItem(item items.Item, stash bool)
- func (r *Room) AddMob(mobInstanceId int)
- func (r *Room) AddPlayer(userId int) int
- func (r *Room) AddSign(displayText string, visibleUserId int, daysBeforeDecay int) bool
- func (r *Room) AddTemporaryExit(exitName string, t exit.TemporaryRoomExit) bool
- func (r *Room) ApplyBuffIdToMobs(buffIds []int, source string)
- func (r *Room) ApplyBuffIdToNativeMobs(buffIds []int, source string)
- func (r *Room) ApplyBuffIdToPlayers(buffIds []int, source string)
- func (r *Room) AreMobsAttacking(userId int) bool
- func (r *Room) ArePlayersAttacking(userId int) bool
- func (r *Room) CanPvp(attUser *users.UserRecord, defUser *users.UserRecord) error
- func (r *Room) CleanupMobSpawns(noCooldown bool)
- func (r *Room) Filename() string
- func (r *Room) Filepath() string
- func (r *Room) FindByName(searchName string, findTypes ...FindFlag) (playerId int, mobInstanceId int)
- func (r *Room) FindByPetName(searchName string) (playerId int)
- func (r *Room) FindContainerByName(containerNameSearch string) string
- func (r *Room) FindCorpse(searchName string) (Corpse, bool)
- func (r *Room) FindExitByName(exitNameSearch string) (exitName string, exitRoomId int)
- func (r *Room) FindExitTo(roomId int) string
- func (r *Room) FindNoun(noun string) (foundNoun string, nounDescription string)
- func (r *Room) FindOnFloor(itemName string, stash bool) (items.Item, bool)
- func (r *Room) FindTemporaryExitByUserId(userId int) (exit.TemporaryRoomExit, bool)
- func (r *Room) GetAllFloorItems(stash bool) []items.Item
- func (r *Room) GetBiome() BiomeInfo
- func (r *Room) GetDescription() string
- func (r *Room) GetDescriptionFormatted(lineSplit int, highlightNouns bool) string
- func (r *Room) GetExitInfo(exitName string) (exitInfo exit.RoomExit, ok bool)
- func (r *Room) GetLongTermData(key string) any
- func (r *Room) GetMapSymbol() string
- func (r *Room) GetMobs(findTypes ...FindFlag) []int
- func (r *Room) GetPlayers(findTypes ...FindFlag) []int
- func (r *Room) GetPrivateSigns() []Sign
- func (r *Room) GetPublicSigns() []Sign
- func (r *Room) GetRandomExit() (exitName string, roomId int)
- func (r *Room) GetScript() string
- func (r *Room) GetScriptPath() string
- func (r *Room) GetTempData(key string) any
- func (r *Room) GetVisibility() int
- func (r *Room) HasRecentVisitors() bool
- func (r *Room) HasVisited(id int, vType VisitorType) bool
- func (r *Room) Id() int
- func (r *Room) IsCalm() bool
- func (r *Room) IsEphemeral() bool
- func (r *Room) IsPvp() bool
- func (r *Room) MarkVisited(id int, vType VisitorType, subtrackTurns ...int)
- func (r *Room) MobCt() int
- func (r *Room) PlaySound(soundId string, category string, excludeUserIds ...int)
- func (r *Room) PlayerCt() int
- func (r *Room) Prepare(checkAdjacentRooms bool)
- func (r *Room) PruneSigns() []Sign
- func (r *Room) PruneTemporaryExits() []exit.TemporaryRoomExit
- func (r *Room) PruneVisitors() int
- func (r *Room) RemoveCorpse(c Corpse) bool
- func (r *Room) RemoveItem(i items.Item, stash bool)
- func (r *Room) RemoveMob(mobInstanceId int)
- func (r *Room) RemovePlayer(userId int) (int, bool)
- func (r *Room) RemoveTemporaryExit(t exit.TemporaryRoomExit) bool
- func (r *Room) RepeatSpawnItem(itemId int, roundFrequency int, containerName ...string) bool
- func (r *Room) RoundTick()
- func (r *Room) SendText(txt string, excludeUserIds ...int)
- func (r *Room) SendTextCommunication(txt string, excludeUserIds ...int)
- func (r *Room) SendTextToExits(txt string, isQuiet bool, excludeUserIds ...int)
- func (r *Room) SetExitLock(exitName string, locked bool)
- func (r *Room) SetLongTermData(key string, value any)
- func (r *Room) SetTempData(key string, value any)
- func (r *Room) SpawnTempContainer(name string, duration string, lockDifficulty int, trapBuffIds ...int) string
- func (r *Room) UpdateCorpses(roundNow uint64)
- func (r *Room) Validate() error
- func (r *Room) Visitors(vType VisitorType) map[int]float64
- type RoomManager
- type RoomTemplateDetails
- type SaveEqualityChecker
- type Sign
- type SpawnInfo
- type TrainingRange
- type VisitorType
- type ZoneConfig
- type ZoneInfo
Constants ¶
const ( AffectsNone = "" AffectsPlayer = "player" // Does it affect only the player who triggered it? AffectsRoom = "room" // Does it affect everyone in the room? // Useful for finding mobs/players FindCharmed FindFlag = 0b00000000001 // charmed FindNeutral FindFlag = 0b00000000010 // Not aggro, not charmed, not Hostile FindFightingPlayer FindFlag = 0b00000000100 // aggro vs. a player FindFightingMob FindFlag = 0b00000001000 // aggro vs. a mob FindHostile FindFlag = 0b00000010000 // will auto-attack players FindMerchant FindFlag = 0b00000100000 // is a merchant FindDowned FindFlag = 0b00001000000 // hp < 1 FindBuffed FindFlag = 0b00010000000 // has a buff FindHasLight FindFlag = 0b00100000000 // has a light source FindHasPet FindFlag = 0b01000000000 // has a pet FindNative FindFlag = 0b10000000000 // spawns in this room // Combinatorial flags FindFighting = FindFightingPlayer | FindFightingMob // Currently in combat (aggro) FindIdle = FindCharmed | FindNeutral // Not aggro or hostile FindAll FindFlag = 0b111111111 // Visitor types VisitorUser = "user" VisitorMob = "mob" )
const (
StartRoomIdAlias = 0
)
Variables ¶
var ( AllBiomes = map[string]BiomeInfo{ `city`: { // contains filtered or unexported fields }, `fort`: { // contains filtered or unexported fields }, `road`: { // contains filtered or unexported fields }, `house`: { // contains filtered or unexported fields }, `shore`: { // contains filtered or unexported fields }, `water`: { // contains filtered or unexported fields }, `forest`: { // contains filtered or unexported fields }, `mountains`: { // contains filtered or unexported fields }, `cliffs`: { // contains filtered or unexported fields }, `swamp`: { // contains filtered or unexported fields }, `snow`: { // contains filtered or unexported fields }, `spiderweb`: { // contains filtered or unexported fields }, `cave`: { // contains filtered or unexported fields }, `desert`: { // contains filtered or unexported fields }, `farmland`: { // contains filtered or unexported fields }, } )
var (
MapSymbolOverrides = map[string]string{
"*": defaultMapSymbol,
}
)
Functions ¶
func ClearRoomCache ¶
Deletes any knowledge of a room in memory. Loading this room after the fact will trigger full re-loading and caching of room data.
func ConnectRoom ¶
#build exit north 1337 Build an exit in the current room that links to room by id You still need to visit that room and connect it the opposite way
func CreateEphemeralRoomIds ¶
accepts RoomId's as arguments, and creates ephemeral copies of them, returning the new ID's of the copies.
func CreateEphemeralZone ¶
accepts RoomId's as arguments, and creates ephemeral copies of them, returning the new ID's of the copies.
func CreateZone ¶
#build zone The Arctic Build a zone, popualtes with an empty boring room
func EphemeralRoomMaintenance ¶
func EphemeralRoomMaintenance() []int
All this does is unload chunks with no players in them.
func FindZoneName ¶
func GetAllRoomIds ¶
func GetAllRoomIds() []int
func GetAllZoneNames ¶
func GetAllZoneNames() []string
func GetAllZoneRoomsIds ¶
func GetChunkCount ¶
func GetChunkCount() int
func GetMemoryUsage ¶
func GetMemoryUsage() map[string]util.MemoryResult
func GetNextRoomId ¶
func GetNextRoomId() int
func GetOriginalRoom ¶
func GetRoomCount ¶
func GetRoomWithMostItems ¶
func GetRoomWithMostItems(skipRecentlyVisited bool, minimumItemCt int, minimumGoldCt int) (roomId int, itemCt int)
skipRecentlyVisited means ignore rooms with recent visitors minimumItemCt is the minimum items in the room to care about it
func GetRoomsWithMobs ¶
func GetRoomsWithMobs() []int
func GetRoomsWithPlayers ¶
func GetRoomsWithPlayers() []int
func GetZoneBiome ¶
func GetZoneRoot ¶
func GetZonesWithMutators ¶
func IsEphemeralRoomId ¶
func IsRoomLoaded ¶
func LoadDataFiles ¶
func LoadDataFiles()
func MoveToZone ¶
func RoomMaintenance ¶
func RoomMaintenance() []int
func SaveAllRooms ¶
func SaveAllRooms() error
func SaveRoomTemplate ¶
See C. UPDATING EXISTING ROOM TEMPLATES
func SetNextRoomId ¶
func SetNextRoomId(nextRoomId int)
func TryEphemeralCleanup ¶
func ValidateZoneName ¶
func ZoneNameSanitize ¶
func ZoneToFolder ¶
Types ¶
type BiomeInfo ¶
type BiomeInfo struct {
// contains filtered or unexported fields
}
func GetAllBiomes ¶
func GetAllBiomes() []BiomeInfo
func (BiomeInfo) Description ¶
func (BiomeInfo) RequiredItemId ¶
func (BiomeInfo) SymbolString ¶
type Container ¶
type Container struct {
Lock gamelock.Lock `yaml:"lock,omitempty"` // 0 - no lock. greater than zero = difficulty to unlock.
Items []items.Item `yaml:"items,omitempty"` // Save contents now, since players can put new items in there
Gold int `yaml:"gold,omitempty"` // Save contents now, since players can put new items in there
DespawnRound uint64 `yaml:"despawnround,omitempty"` // If this is set, it's a chest that will disappear with time.
Recipes map[int][]int `yaml:"recipes,omitempty,flow"` // Item Id's (key) that are created when the recipe is present in the container (values) and it is "used"
}
func (*Container) RecipeReady ¶
Returns an itemId if it can produce one based on contents + recipe
func (*Container) RemoveItem ¶
type Corpse ¶
type Room ¶
type Room struct {
//mutex
RoomId int `yaml:"roomid"` // a unique numeric index of the room. Also the filename.
Zone string `yaml:"zone"` // zone is a way to partition rooms into groups. Also into folders.
ZoneConfig ZoneConfig `yaml:"zoneconfig,omitempty" instance:"skip"` // If non-null is a root room.
MusicFile string `yaml:"musicfile,omitempty"` // background music to play when in this room
IsBank bool `yaml:"isbank,omitempty"` // Is this a bank room? If so, players can deposit/withdraw gold here.
IsStorage bool `yaml:"isstorage,omitempty"` // Is this a storage room? If so, players can add/remove objects here.
IsCharacterRoom bool `yaml:"ischaracterroom,omitempty"` // Is this a room where characters can create new characters to swap between them?
Title string `yaml:"title"` // Title shown to the user
Description string `yaml:"description"` // Description shown to the user
MapSymbol string `yaml:"mapsymbol,omitempty"` // The symbol to use when generating a map of the zone
MapLegend string `yaml:"maplegend,omitempty"` // The text to display in the legend for this room. Should be one word.
Biome string `yaml:"biome,omitempty"` // The biome of the room. Used for weather generation.
Containers map[string]Container `yaml:"containers,omitempty"` // If this room has a chest, what is in it?
Exits map[string]exit.RoomExit `yaml:"exits"` // Exits to other rooms
ExitsTemp map[string]exit.TemporaryRoomExit `yaml:"-"` // Temporary exits that will be removed after a certain time. Don't bother saving on sever shutting down.
Nouns map[string]string `yaml:"nouns,omitempty"` // Interesting nouns to highlight in the room or reveal on succesful searches.
Items []items.Item `yaml:"items,omitempty"` // Items on the floor
Stash []items.Item `yaml:"stash,omitempty"` // list of items in the room that are not visible to players
Corpses []Corpse `yaml:"-"` // Any corpses laying around from recent deaths
Gold int `yaml:"gold,omitempty"` // How much gold is on the ground?
SpawnInfo []SpawnInfo `yaml:"spawninfo,omitempty" instance:"skip"` // key is creature ID, value is spawn chance
SkillTraining map[string]TrainingRange `yaml:"skilltraining,omitempty"` // list of skills that can be trained in this room
Signs []Sign `yaml:"sign,omitempty"` // list of scribbles in the room
IdleMessages []string `yaml:"idlemessages,omitempty" ` // list of messages that can be displayed to players in the room
LastIdleMessage uint8 `yaml:"-"` // index of the last idle message displayed
LongTermDataStore map[string]any `yaml:"longtermdatastore,omitempty"` // Long term data store for the room
Mutators mutators.MutatorList `yaml:"mutators,omitempty"` // mutators this room spawns with.
Pvp bool `yaml:"pvp,omitempty"` // if config pvp is set to `limited`, uses this value
// contains filtered or unexported fields
}
func BuildRoom ¶
#build room north Build a room to a specific direction, and connect it by exit name You still need to visit that room and connect it the opposite way
func LoadRoomTemplate ¶
Only loads the template data, ignores instance data.
func (*Room) AddTemporaryExit ¶
func (r *Room) AddTemporaryExit(exitName string, t exit.TemporaryRoomExit) bool
Can't add twoof the same exitName Will return false if it already exists
func (*Room) ApplyBuffIdToMobs ¶
applies buffs to any mobs in the room that don't already have it
func (*Room) ApplyBuffIdToNativeMobs ¶
applies buffs to any mobs in the room that don't already have it
func (*Room) ApplyBuffIdToPlayers ¶
applies buffs to any players in the room that don't already have it
func (*Room) AreMobsAttacking ¶
func (*Room) ArePlayersAttacking ¶
func (*Room) CanPvp ¶
func (r *Room) CanPvp(attUser *users.UserRecord, defUser *users.UserRecord) error
Returns an error with a reason why they cannot PVP, or nil
func (*Room) CleanupMobSpawns ¶
func (*Room) FindByName ¶
func (*Room) FindByPetName ¶
func (*Room) FindContainerByName ¶
func (*Room) FindExitByName ¶
func (*Room) FindOnFloor ¶
func (*Room) FindTemporaryExitByUserId ¶
func (r *Room) FindTemporaryExitByUserId(userId int) (exit.TemporaryRoomExit, bool)
func (*Room) GetDescription ¶
func (*Room) GetDescriptionFormatted ¶
func (*Room) GetExitInfo ¶
func (*Room) GetLongTermData ¶
func (*Room) GetMapSymbol ¶
func (*Room) GetPlayers ¶
func (*Room) GetPrivateSigns ¶
func (*Room) GetPublicSigns ¶
func (*Room) GetRandomExit ¶
func (*Room) GetScriptPath ¶
func (*Room) GetTempData ¶
func (*Room) GetVisibility ¶
0 = none (darkness). 1 = can see this room. 2 = can see this room and all exits
func (*Room) HasRecentVisitors ¶
func (*Room) HasVisited ¶
func (r *Room) HasVisited(id int, vType VisitorType) bool
func (*Room) IsEphemeral ¶
func (*Room) MarkVisited ¶
func (r *Room) MarkVisited(id int, vType VisitorType, subtrackTurns ...int)
func (*Room) Prepare ¶
The purpose of Prepare() is to ensure a room is properly setup before anyone looks into it or enters it That way if there should be anything in the room prior, it will already be there. For example, mobs shouldn't ENTER the room right as the player arrives, they should already be there.
func (*Room) PruneSigns ¶
func (*Room) PruneTemporaryExits ¶
func (r *Room) PruneTemporaryExits() []exit.TemporaryRoomExit
func (*Room) PruneVisitors ¶
func (*Room) RemoveCorpse ¶
func (*Room) RemoveTemporaryExit ¶
func (r *Room) RemoveTemporaryExit(t exit.TemporaryRoomExit) bool
func (*Room) RepeatSpawnItem ¶
Spawns an item in the room unless: 1. Item is already in the room 2. (optional) Item is currently held by someone in the room 3. item repeat-spawned too recently If containerName is provided, ony that container name will be considered
func (*Room) SendTextCommunication ¶
func (*Room) SendTextToExits ¶
func (*Room) SetExitLock ¶
func (*Room) SetLongTermData ¶
func (*Room) SetTempData ¶
func (*Room) SpawnTempContainer ¶
func (*Room) UpdateCorpses ¶
type RoomManager ¶
type RoomManager struct {
// contains filtered or unexported fields
}
func (*RoomManager) GetFilePath ¶
func (r *RoomManager) GetFilePath(roomId int) string
type RoomTemplateDetails ¶
type RoomTemplateDetails struct {
VisiblePlayers []string
VisibleMobs []string
VisibleCorpses []string
VisibleExits map[string]exit.RoomExit
TemporaryExits map[string]exit.TemporaryRoomExit
UserId int
Character *characters.Character
RoomSymbol string
RoomLegend string
Nouns []string
Zone string
Title string
Description string
IsDark bool
IsNight bool
TrackingString string
RoomAlerts []string // Messages to show below room description as a special alert
ShowPvp bool // Whether to display that the room is PVP
}
func GetDetails ¶
func GetDetails(r *Room, user *users.UserRecord, tinymap ...[]string) RoomTemplateDetails
type SaveEqualityChecker ¶
type SpawnInfo ¶
type SpawnInfo struct {
MobId int `yaml:"mobid,omitempty"` // Mob template Id to spawn
InstanceId int `yaml:"-"` // Mob instance Id that was spawned (tracks whether exists currently)
Container string `yaml:"container,omitempty"` // If set, any item or gold spawned will go into the container.
ItemId int `yaml:"itemid,omitempty"` // Item template Id to spawn on the floor
Gold int `yaml:"gold,omitempty"` // How much gold to spawn on the floor
Message string `yaml:"message,omitempty"` // (optional) message to display to the room when this creature spawns, instead of a default
Name string `yaml:"name,omitempty"` // (optional) if set, will override the mob's name
ForceHostile bool `yaml:"forcehostile,omitempty"` // (optional) if true, forces the mob to be hostile.
MaxWander int `yaml:"maxwander,omitempty"` // (optional) if set, will override the mob's max wander distance
IdleCommands []string `yaml:"idlecommands,omitempty"` // (optional) list of commands to override the default of the mob. Useful when you need a mob to be more unique.
ScriptTag string `yaml:"scripttag,omitempty"` // (optional) if set, will override the mob's script tag
QuestFlags []string `yaml:"questflags,omitempty,flow"` // (optional) list of quest flags to set on the mob
BuffIds []int `yaml:"buffids,omitempty,flow"` // (optional) list of buffs the mob always has active
Level int `yaml:"level,omitempty"` // (optional) force this mob to a specific level
LevelMod int `yaml:"levelmod,omitempty"` // (optional) modify this mobs level by this amount
// spawn tracking and rate
DespawnedRound uint64 `yaml:"-"` // When this mob was last despawned (killed)
RespawnRate string `yaml:"respawnrate,omitempty"` // How long until it respawns when not present?
}
type TrainingRange ¶
type VisitorType ¶
type VisitorType string
type ZoneConfig ¶
type ZoneConfig struct {
RoomId int `yaml:"roomid,omitempty"`
MobAutoScale struct {
Minimum int `yaml:"minimum,omitempty"` // level scaling minimum
Maximum int `yaml:"maximum,omitempty"` // level scaling maximum
} `yaml:"autoscale,omitempty"` // level scaling range if any
Mutators mutators.MutatorList `yaml:"mutators,omitempty"` // mutators defined here apply to entire zone
IdleMessages []string `yaml:"idlemessages,omitempty"` // list of messages that can be displayed to players in the zone, assuming a room has none defined
MusicFile string `yaml:"musicfile,omitempty"` // background music to play when in this zone
}
func GetZoneConfig ¶
func GetZoneConfig(zone string) *ZoneConfig
func (*ZoneConfig) GenerateRandomLevel ¶
func (z *ZoneConfig) GenerateRandomLevel() int
Generates a random number between min and max
func (*ZoneConfig) Validate ¶
func (z *ZoneConfig) Validate()