itemsotb

package
v0.0.7 Latest Latest
Warning

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

Go to latest
Published: Mar 26, 2024 License: GPL-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package itemsotb reads in an items.otb file.

Top level OTB node's data represents version header, and its children represents individual items.

Index

Constants

View Source
const (
	CLIENT_VERSION_750                     = 1
	CLIENT_VERSION_755                     = 2
	CLIENT_VERSION_760, CLIENT_VERSION_770 = 3, 3
	CLIENT_VERSION_780                     = 4
	CLIENT_VERSION_790                     = 5
	CLIENT_VERSION_792                     = 6
	CLIENT_VERSION_800                     = 7
	CLIENT_VERSION_810                     = 8
	CLIENT_VERSION_811                     = 9
	CLIENT_VERSION_820                     = 10
	CLIENT_VERSION_830                     = 11
	CLIENT_VERSION_840                     = 12
	CLIENT_VERSION_841                     = 13
	CLIENT_VERSION_842                     = 14
	CLIENT_VERSION_850                     = 15
	CLIENT_VERSION_854_BAD                 = 16
	CLIENT_VERSION_854                     = 17
	CLIENT_VERSION_855                     = 18
	CLIENT_VERSION_860_OLD                 = 19
	CLIENT_VERSION_860                     = 20
	CLIENT_VERSION_861                     = 21
	CLIENT_VERSION_862                     = 22
	CLIENT_VERSION_870                     = 23
)

Enumeration containing recognized protocol versions for which a particular items.otb file might be targeted.

Implementation detail: iota is not used primarily for easier referencing in case of an error.

View Source
const (
	ROOT_ATTR_VERSION = 0x01
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Item

type Item struct {
	Group      ItemGroup
	Flags      ItemsFlags
	Attributes map[ItemsAttribute]interface{}
	// contains filtered or unexported fields
}

Item represents a single item stored in the items.otb file.

func (*Item) Name

func (i *Item) Name() string

Name returns the name of the item. This may be sourced from XML, if loaded.

type ItemGroup

type ItemGroup int

Enumeration containing which overarching item group this item belongs to.

Useful primarily for editors.

const (
	ITEM_GROUP_NONE ItemGroup = iota
	ITEM_GROUP_GROUND
	ITEM_GROUP_CONTAINER
	ITEM_GROUP_WEAPON     // deprecated
	ITEM_GROUP_AMMUNITION // deprecated
	ITEM_GROUP_ARMOR      // deprecated
	ITEM_GROUP_CHARGES
	ITEM_GROUP_TELEPORT   // deprecated
	ITEM_GROUP_MAGICFIELD // deprecated
	ITEM_GROUP_WRITEABLE  // deprecated
	ITEM_GROUP_KEY        // deprecated
	ITEM_GROUP_SPLASH
	ITEM_GROUP_FLUID
	ITEM_GROUP_DOOR // deprecated
	ITEM_GROUP_DEPRECATED
	ITEM_GROUP_LAST
)

func (ItemGroup) String

func (g ItemGroup) String() string

type Items

type Items struct {
	otb.OTB
	Version ItemsVersion
	Items   []Item

	ClientIDToArrayIndex map[uint16]int
	ServerIDToArrayIndex map[uint16]int
}

func New

func New(r io.ReadSeeker) (*Items, error)

New reads an OTB file from a given reader.

func (*Items) AddXMLInfo

func (otb *Items) AddXMLInfo(r io.Reader) error

func (*Items) ItemByClientID

func (otb *Items) ItemByClientID(clientID uint16) (*Item, error)

ItemByClientID allows lookup of an item stored in an items.otb file based on its ID used by the network protocol and associated data files.

func (*Items) ItemByServerID

func (otb *Items) ItemByServerID(serverID uint16) (*Item, error)

ItemByServerID allows lookup of an item stored in an items.otb file based on its persistent 'server' ID, which stays fixed between versions, and is used by the server-side data storage, by map files, etc.

type ItemsAttribute

type ItemsAttribute uint8
const (
	ITEM_ATTR_FIRST    ItemsAttribute = 0x10
	ITEM_ATTR_SERVERID ItemsAttribute = iota + 0x10 - 1
	ITEM_ATTR_CLIENTID
	ITEM_ATTR_NAME  // deprecated
	ITEM_ATTR_DESCR // deprecated
	ITEM_ATTR_SPEED
	ITEM_ATTR_SLOT         // deprecated
	ITEM_ATTR_MAXITEMS     // deprecated
	ITEM_ATTR_WEIGHT       // deprecated
	ITEM_ATTR_WEAPON       // deprecated
	ITEM_ATTR_AMU          // deprecated
	ITEM_ATTR_ARMOR        // deprecated
	ITEM_ATTR_MAGLEVEL     // deprecated
	ITEM_ATTR_MAGFIELDTYPE // deprecated
	ITEM_ATTR_WRITEABLE    // deprecated
	ITEM_ATTR_ROTATETO     // deprecated
	ITEM_ATTR_DECAY        // deprecated
	ITEM_ATTR_SPRITEHASH
	ITEM_ATTR_MINIMAPCOLOR
	ITEM_ATTR_07
	ITEM_ATTR_08
	ITEM_ATTR_LIGHT

	// 1byte aligned
	ITEM_ATTR_DECAY2     // deprecated
	ITEM_ATTR_WEAPON2    // deprecated
	ITEM_ATTR_AMU2       // deprecated
	ITEM_ATTR_ARMOR2     // deprecated
	ITEM_ATTR_WRITEABLE2 // deprecated
	ITEM_ATTR_LIGHT2
	ITEM_ATTR_TOPORDER
	ITEM_ATTR_WRITEABLE3 // deprecated
	ITEM_ATTR_LAST
)

Enumeration containing recognized attributes in the items.otb file.

func (ItemsAttribute) String

func (a ItemsAttribute) String() string

type ItemsDataSize

type ItemsDataSize uint16

type ItemsFlags

type ItemsFlags uint32
const (
	FLAG_BLOCK_SOLID ItemsFlags = 1 << iota
	FLAG_BLOCK_PROJECTILE
	FLAG_BLOCK_PATHFIND
	FLAG_HAS_HEIGHT
	FLAG_USEABLE
	FLAG_PICKUPABLE
	FLAG_MOVEABLE
	FLAG_STACKABLE
	FLAG_FLOORCHANGEDOWN
	FLAG_FLOORCHANGENORTH
	FLAG_FLOORCHANGEEAST
	FLAG_FLOORCHANGESOUTH
	FLAG_FLOORCHANGEWEST
	FLAG_ALWAYSONTOP
	FLAG_READABLE
	FLAG_ROTABLE
	FLAG_HANGABLE
	FLAG_VERTICAL
	FLAG_HORIZONTAL
	FLAG_CANNOTDECAY
	FLAG_ALLOWDISTREAD
	FLAG_UNUSED
	FLAG_CLIENTCHARGES // deprecated
	FLAG_LOOKTHROUGH
	FLAG_ANIMATION
	FLAG_WALKSTACK

	FLAG_LAST
)

Enumeration containing possible bits in the `flags` bitmask of an item.

func (ItemsFlags) String

func (f ItemsFlags) String() string

type ItemsVersion

type ItemsVersion struct {
	MajorVersion, MinorVersion, BuildNumber uint32
	CSDVersion                              [128]uint8
}

ItemsVersion represents the version of the items.otb file.

MajorVersion means a revision of the file format, MinorVersion means the targeted protocol version, BuildNumber is an arbitrary number representing ther revision of the file, and CSDVersion is a byte array with a C-style null-terminated string.

func (ItemsVersion) CSDVersionAsString

func (v ItemsVersion) CSDVersionAsString() string

CSDVersionAsString formats null-terminated C-style string `CSDArray` from a byte array into usual Go string.

type Light

type Light struct {
	LightLevel uint16
	LightColor uint16
}

Light represents the data structure describing a lit-up item's light attribute ITEM_ATTR_LIGHT2, as stored in an items.otb file.

Jump to

Keyboard shortcuts

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