model

package
v0.0.0-...-d091464 Latest Latest
Warning

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

Go to latest
Published: Feb 15, 2024 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

View Source
const (
	EquipmentSlotTypeHead     EquipmentSlotType = 0
	EquipmentSlotTypeCape                       = 1
	EquipmentSlotTypeNecklace                   = 2
	EquipmentSlotTypeWeapon                     = 3
	EquipmentSlotTypeBody                       = 4
	EquipmentSlotTypeShield                     = 5
	EquipmentSlotTypeLegs                       = 7
	EquipmentSlotTypeHands                      = 9
	EquipmentSlotTypeFeet                       = 10
	EquipmentSlotTypeRing                       = 12
	EquipmentSlotTypeAmmo                       = 13
)
View Source
const DefaultPrayerResistance = 60

DefaultPrayerResistance is the default prayer resistance for a player.

View Source
const MaxInventorySlots = 28

MaxInventorySlots is the maximum number of inventory slots.

View Source
const MaxRunEnergyUnits = 10000

MaxRunEnergyUnits is the maximum run energy a player may have, in units.

View Source
const NumBodyColors = 5

NumBodyColors is the number of customizable character body parts.

Variables

EquipmentSlotTypes is a slice of all EquipmentSlotType enums sorted according to their slot IDs in ascending order.

View Source
var MaxStackableSize = int64(math.Pow(2, 31) - 1)

MaxStackableSize is the maximum size of a single stack of an item.

View Source
var SkillExperienceLevels = func() []float64 {
	rawExp := make([]float64, 100)
	rawExp[1] = 0

	for i := 2; i <= 99; i++ {
		e := 0.25 * math.Floor(float64(i-1)+300.0*math.Pow(2, float64(i-1)/7.0))
		rawExp[i] = rawExp[i-1] + e
	}

	exp := make([]float64, 100)
	for i := 1; i <= 99; i++ {
		exp[i] = math.Floor(rawExp[i])
	}
	return exp
}()

SkillExperienceLevels is a slice of experience points corresponding to each skill level.

Functions

func InitAttackStyleMap

func InitAttackStyleMap() map[WeaponStyle]AttackStyle

InitAttackStyleMap returns a map of weapon styles and default attack styles.

Types

type AnimationID

type AnimationID int
const (
	AnimationStand AnimationID = iota
	AnimationStandTurn
	AnimationWalk
	AnimationTurnAbout
	AnimationTurnRight
	AnimationTurnLeft
	AnimationRun
)

type AttackStyle

type AttackStyle int

AttackStyle enumerates possible weapon attack styles an entity may use.

const (
	AttackStyleChop AttackStyle = iota
	AttackStyleSlash
	AttackStyleLunge
	AttackStyleBlock
	AttackStylePunch
	AttackStyleKick
	AttackStylePound
	AttackStylePummel
	AttackStyleSpike
	AttackStyleImpale
	AttackStyleSmash
	AttackStyleJab
	AttackStyleSwipe
	AttackStyleFend
	AttackStyleBash
	AttackStyleReap
	AttackStyleFlick
	AttackStyleLash
	AttackStyleDeflect
	AttackStyleAccurate
	AttackStyleRapid
	AttackStyleLongRange
	AttackStyleArmAndFire
	AttackStyleFocus
	AttackStyleStab
)

type Boundary

type Boundary uint8

Boundary enumerates the cardinal boundaries of a map area, region or chunk.

const (
	BoundaryNone  Boundary = 0
	BoundaryNorth Boundary = 1 << iota
	BoundaryWest
	BoundaryEast
	BoundarySouth
)

type ChatColor

type ChatColor int

ChatColor is a color applied to a chat message.

const (
	ChatColorYellow ChatColor = iota
	ChatColorRed
	ChatColorGreen
	ChatColorCyan
	ChatColorPurple
	ChatColorWhite
	ChatColorFlash1
	ChatColorFlash2
	ChatColorFlash3
	ChatColorGlow1
	ChatColorGlow2
	ChatColorGlow3
)

type ChatEffect

type ChatEffect int

ChatEffect is a visual effect applied to chat messages.

const (
	ChatEffectNone ChatEffect = iota
	ChatEffectWave
	ChatEffectWave2
	ChatEffectShake
	ChatEffectScroll
	ChatEffectSlide
)

type ChatMessage

type ChatMessage struct {
	Color  ChatColor
	Effect ChatEffect
	Text   string
}

ChatMessage is a chat message sent by a player. Chat messages may have associated effects and font color modifiers.

type ChatMode

type ChatMode int

ChatMode restricts which types of chat messages a player receives.

const (
	ChatModePublic ChatMode = iota
	ChatModeFriends
	ChatModeOff
	ChatModeHide
)

type ClientTab

type ClientTab int

ClientTab enumerates the possible client sidebar tabs available for displaying interface.

const (
	ClientTabEquippedItem ClientTab = iota
	ClientTabSkills
	ClientTabQuests
	ClientTabInventory
	ClientTabEquipment
	ClientTabPrayers
	ClientTabSpells
	ClientTabFriendsList
	ClientTabIgnoreList
	ClientTabLogout
	ClientTabSettings
	ClientTabControls
	ClientTabMusic
)

type Color

type Color struct {
	Red   int
	Green int
	Blue  int
}

Color is an RGB color displayed by the client.

func (Color) Validate

func (c Color) Validate() error

Validate checks that the color RGB values are valid, returning an error if not.

type Direction

type Direction int

Direction is a cardinal direction with respect to the map.

const (
	DirectionNone Direction = iota
	DirectionNorthEast
	DirectionNorth
	DirectionNorthWest
	DirectionWest
	DirectionSouthWest
	DirectionSouth
	DirectionSouthEast
	DirectionEast
)

func DirectionFromDelta

func DirectionFromDelta(v Vector2D) Direction

DirectionFromDelta returns a direction represented by a difference in x and/or y coordinates. The vector v does not need to be a unit vector.

type Entity

type Entity struct {
	// ID is the globally unique identifier for the entity.
	ID int
	// GlobalPos is the position of the entity in global coordinates.
	GlobalPos Vector3D
}

Entity is a character in the game world, controlled by either a human or the game engine itself.

type EntityAppearance

type EntityAppearance struct {
	// Base is the base model appearance.
	Base EntityBase
	// NPCAppearance is a flag that indicates if the entity assumes a predefined NPC appearance.
	NPCAppearance int
	// Equipment is a map of equipment slots to the items equipped at those slots.
	Equipment map[EquipmentSlotType]*EquipmentSlot
	// BodyColors is a slice of color codes for each body part.
	BodyColors []int
	// Animations is a map of animation types to their animation sequence IDs.
	Animations map[AnimationID]int
	// GraphicID is the ID of a graphic the player assumes, or -1 if none.
	GraphicID int
	// GraphicHeight is the height offset from the ground where the graphic should be rendered.
	GraphicHeight int
	// GraphicDelay is the amount of game ticks to wait before initially displaying the graphic.
	GraphicDelay int
	// Gender is the entity's gender.
	Gender EntityGender
	// OverheadIconID is the ID of the graphic to use for an overhead icon.
	OverheadIconID int
	// CombatLevel is the entity's combat level.
	CombatLevel int
	// TotalLevel is the entity's total skill level.
	TotalLevel int
}

EntityAppearance describes the properties of an entity such as a player or NPC.

func (*EntityAppearance) IsNPCAppearance

func (a *EntityAppearance) IsNPCAppearance() bool

IsNPCAppearance returns true if the appearance should take that of a predefined NPC, false if not.

func (*EntityAppearance) SetNPCAppearance

func (a *EntityAppearance) SetNPCAppearance(id int)

SetNPCAppearance sets the ID of an NPC to use for the appearance.

type EntityBase

type EntityBase struct {
	Head  int
	Face  int
	Body  int
	Arms  int
	Hands int
	Legs  int
	Feet  int
}

EntityBase describes the entity's base model. Each entity model has a fixed amount of slots that can be assigned model IDs, which comprise the entity if it has no items equipped.

type EntityCombatAttributes

type EntityCombatAttributes struct {
	Stab  int
	Slash int
	Crush int
	Magic int
	Range int
}

EntityCombatAttributes are the combat modifiers for an entity based on their equipment.

type EntityCombatStats

type EntityCombatStats struct {
	Attack   EntityCombatAttributes
	Defense  EntityCombatAttributes
	Strength int
	Prayer   int
}

EntityCombatStats are the effective combat stats for an entity.

type EntityGender

type EntityGender int

EntityGender enumerates valid genders for players or NPCs.

const (
	EntityMale EntityGender = iota
	EntityFemale
)

type EquipmentSlot

type EquipmentSlot struct {
	SlotType EquipmentSlotType
	Item     *Item
	Amount   int
}

EquipmentSlot is an item equipped in an entity's equipment.

type EquipmentSlotType

type EquipmentSlotType int

EquipmentSlotType enumerates the different slots items may be equipped to.

func (EquipmentSlotType) Visible

func (s EquipmentSlotType) Visible() bool

Visible returns true if the equipment slot affects an entity's appearance, false if not.

type FriendsListStatus

type FriendsListStatus int

FriendsListStatus enumerates which state a player's client should show the friends list.

const (
	FriendsListStatusLoading FriendsListStatus = iota
	FriendsListStatusPending
	FriendsListStatusLoaded
)

type InteractionMode

type InteractionMode int

InteractionMode controls from whom a player receives trades and duels requests.

const (
	InteractionModePublic InteractionMode = iota
	InteractionModeFriends
	InteractionModeOff
)

type Interface

type Interface struct {
	// ID is the identifier for this interface.
	ID int
	// Parent is the parent interface.
	Parent *Interface
	// Children is a slice of child interfaces.
	Children []*Interface
	// Type is the type of interface.
	Type int
	// Actions is a slice of actions that this interface supports.
	Actions []string
	// Conditions is a slice of conditions for this interface.
	Conditions []InterfaceCondition
	// OpCodes is a map of op codes to their sub codes
	OpCodes map[int][]int
}

Interface is a client-side interface that displays information and allows actions.

type InterfaceCondition

type InterfaceCondition struct {
	Type  int
	Value int
}

InterfaceCondition is a condition for an interface to be active.

type InventorySlot

type InventorySlot struct {
	// ID is the identifier of the inventory slot.
	ID int
	// Item is a pointer to a model.Item in this slot.
	Item *Item
	// Amount is the stack size of the item in this slot.
	Amount int
}

InventorySlot is an item stored in a player's inventory.

type Item

type Item struct {
	ID             int
	Name           string
	Description    string
	Rotation       Vector3D
	Scale          Vector3D
	Stackable      bool
	MembersOnly    bool
	NoteID         int
	NoteTemplateID int
	TeamID         int
	GroundActions  []string
	Actions        []string
	Stackables     []ItemStackable
	Attributes     *ItemAttributes
}

Item represents a player-usable object.

func (*Item) CanEquip

func (i *Item) CanEquip() bool

CanEquip returns true if the item can be equipped, or false if not.

type ItemAttributes

type ItemAttributes struct {
	// ItemID is the ID of the item.
	ItemID int
	// Nature describes the uses for the item.
	Nature ItemNature
	// EquipSlotType is the equipment slot where the item is equipped to.
	EquipSlotType EquipmentSlotType
	// WeaponStyle is the set of attack options for a weapon item.
	WeaponStyle WeaponStyle
	// Speed is the amount of milliseconds between item actions.
	Speed int
	// Weight is the weight of the item.
	Weight float32
	// Value is the value of the item, in coins.
	Value int
	// AttackBonuses are the offensive combat attributes.
	Attack ItemCombatAttributes
	// DefenseBonuses are the defensive combat attributes.
	Defense ItemCombatAttributes
	// StrengthBonus is the bonus granted to an entity's strength level.
	StrengthBonus int
	// PrayerBonus is the bonus granted to an entity's prayer level.
	PrayerBonus int
}

ItemAttributes are additional properties for an item.

type ItemCombatAttributes

type ItemCombatAttributes struct {
	Stab  int
	Slash int
	Crush int
	Magic int
	Range int
}

ItemCombatAttributes are the attack and defense bonuses granted by an item.

type ItemNature

type ItemNature int

ItemNature enumerates the possible uses for an item

const (
	ItemNatureNotUsable ItemNature = iota
	ItemNatureEquippable
)

type ItemStackable

type ItemStackable struct {
	ID     int
	Amount int
}

ItemStackable is a descriptor of sprites to use for certain item stackable thresholds.

type Map

type Map struct {
	// Tiles are stored in (z, x, y) coordinates.
	Tiles map[int]map[int]map[int]*Tile
	// RegionOrigins enumerate all region origins in global coordinates that are on the map.
	RegionOrigins []Vector3D
	// MaxTile is the position of the tile the furthest on the x- and y-axes.
	MaxTile Vector2D
}

Map represents the game world map and its static objects.

func NewMap

func NewMap() *Map

NewMap returns a new world map.

func (*Map) SetTile

func (m *Map) SetTile(pos Vector3D, tile *Tile)

SetTile puts a tile at a location. Any existing tile will be replaced.

func (*Map) Tile

func (m *Map) Tile(pos Vector3D) *Tile

Tile returns a tile at a location on the world map. If there is no tile, nil will be returned instead.

type MovementSpeed

type MovementSpeed int

MovementSpeed enumerates the speeds at which an entity moves.

const (
	MovementSpeedWalk MovementSpeed = iota
	MovementSpeedRun
)

type NPC

type NPC struct {
	*Entity
	// DefinitionID is the identifier for the NPC's appearance.
	DefinitionID int
	// ScriptSlug is the slug for the game script to execute for this NPC.
	ScriptSlug string
}

NPC is a non-player controlled character in the game world.

func NewNPC

func NewNPC(definitionID int, scriptSlug string) *NPC

NewNPC returns a new NPC model.

type Player

type Player struct {
	*Entity
	// Username is the player's display name.
	Username string
	// PasswordHash is the player's hashed password.
	PasswordHash string
	// Type determines the level of access this player is granted.
	Type PlayerType
	// Flagged is true when the player is suspected of cheating, false if not.
	Flagged bool
	// Appearance is the player's model appearance.
	Appearance EntityAppearance
	// AutoRetaliate controls if the player automatically responds to combat.
	AutoRetaliate bool
	// Modes determine what level of chat and trade interaction the player has configured.
	Modes PlayerModes
	// Muted is true when the player is not able to chat, false if not.
	Muted bool
	// Friends is a slice of usernames of players added as friends.
	Friends []string
	// Ignored is a slice of usernames of players that are ignored.
	Ignored []string
	// Skills is a map of this player's skill levels and experience.
	Skills SkillMap
	// Member is true when the player has an active subscription, false if not.
	Member bool
	// MemberDays is the number of days of subscription remaining.
	MemberDays int
	// Inventory is the player's current inventory of items.
	Inventory [MaxInventorySlots]*InventorySlot
	// CombatStats are the player's combat statistics.
	CombatStats EntityCombatStats
	// AttackStyles if a map of the player's preferred attack styles for a given weapon style.
	AttackStyles map[WeaponStyle]AttackStyle
	// GameOptions is a map of client/game option IDs to their values.
	GameOptions map[int]string
	// RunEnergy is the player's run energy.
	RunEnergy int
	// QuestStatus is a map of quest IDs to their status.
	QuestStatuses map[int]QuestStatus
	// QuestFlags is a map of quest IDs to maps of their flag IDs to values.
	QuestFlags map[int]map[int]int
	// MusicTracks is a map of song IDs to flags indicating if the player has unlocked them.
	MusicTracks map[int]bool
	// UpdateDesign is true when the player should be shown the character design interface, false if not.
	UpdateDesign bool
	// MovementSpeed determines if the player is moving by walking or running
	MovementSpeed MovementSpeed
	// PrayerDrainCounter is the player's current usage of activated prayer drain points.
	PrayerDrainCounter int
	// ActivePrayers is a map of prayer IDs and drain effects for prayers that are currently active on the player.
	ActivePrayers map[int]int
	// HitpointsRegenRate is the amount of hitpoints recovered after each interval.
	HitpointsRegenRate int
	// StatRegenRate is the amount of stat levels for non-hitpoints skills recovered after each interval.
	StatRegenRate int
}

Player is a human player connected to the game server. This struct stores a player's persistent data, including various preferences, game world properties and other such attributes.

func NewPlayer

func NewPlayer(username string) *Player

NewPlayer returns a new player model.

func (*Player) AttackStyle

func (p *Player) AttackStyle(weaponStyle WeaponStyle) AttackStyle

AttackStyle returns the active attack style for a particular weapon style.

func (*Player) ClearEquippedItem

func (p *Player) ClearEquippedItem(slot EquipmentSlotType)

ClearEquippedItem removes any equipped item at a slot.

func (*Player) ClearInventoryItem

func (p *Player) ClearInventoryItem(slot int)

ClearInventoryItem removes an item from the player's inventory slot.

func (*Player) EquipmentSlot

func (p *Player) EquipmentSlot(slot EquipmentSlotType) *EquipmentSlot

EquipmentSlot returns an EquipmentSlot for a slot. If no item is equipped, nil will be returned instead.

func (*Player) EquippedWeaponStyle

func (p *Player) EquippedWeaponStyle() WeaponStyle

EquippedWeaponStyle returns the attack style of the player's equipped weapon, if any.

func (*Player) GameOption

func (p *Player) GameOption(optionID int) string

GameOption returns the player's preference value for a game option. If no value is set for the option, an empty string is returned instead.

func (*Player) HasFriend

func (p *Player) HasFriend(username string) bool

HasFriend determines if the given player username is on this player's friends list.

func (*Player) InventoryCanHoldItem

func (p *Player) InventoryCanHoldItem(item *Item) bool

InventoryCanHoldItem determines if an item can be added to the player's inventory. This will account for both stackable and non-stackable items.

func (*Player) InventorySlotWithItem

func (p *Player) InventorySlotWithItem(itemID int) *InventorySlot

InventorySlotWithItem returns the slot that contains an item with an ID. If no slot contains such an item, then nil will be returned.

func (*Player) IsEquipmentSlotUsed

func (p *Player) IsEquipmentSlotUsed(slot EquipmentSlotType) bool

IsEquipmentSlotUsed returns true if an equipment slot is in use, false if it's free.

func (*Player) IsIgnored

func (p *Player) IsIgnored(username string) bool

IsIgnored determines if the given player username is on this player's ignore list.

func (*Player) MusicTrackUnlocked

func (p *Player) MusicTrackUnlocked(songID int) bool

MusicTrackUnlocked returns true if a music track has been unlocked by the player.

func (*Player) NextFreeInventorySlot

func (p *Player) NextFreeInventorySlot() int

NextFreeInventorySlot returns the ID of the next available slot in the player's inventory. If no slot is free, -1 will be returned.

func (*Player) PrayerDrainResistance

func (p *Player) PrayerDrainResistance() int

PrayerDrainResistance returns the player's resistance threshold to losing prayer points.

func (*Player) QuestFlag

func (p *Player) QuestFlag(questID, flagID int) int

QuestFlag returns the value of a quest flag. If a flag does not have a value, -1 will be returned.

func (*Player) QuestStatus

func (p *Player) QuestStatus(questID int) QuestStatus

QuestStatus returns the status of a quest.

func (*Player) RunEnergyPercentage

func (p *Player) RunEnergyPercentage() float32

RunEnergyPercentage returns the player's current run energy as a percentage of the maximum run energy.

func (*Player) SetAttackStyle

func (p *Player) SetAttackStyle(weaponStyle WeaponStyle, attackStyle AttackStyle)

SetAttackStyle sets the active attack style for a weapon style, overwriting any previously applied style.

func (*Player) SetEquippedItem

func (p *Player) SetEquippedItem(item *Item, amount int, slot EquipmentSlotType)

SetEquippedItem sets an item to be equipped at a slot.

func (*Player) SetGameOption

func (p *Player) SetGameOption(optionID int, optionValue string)

SetGameOption sets a value for a game option, overwriting any previous value.

func (*Player) SetInventoryItem

func (p *Player) SetInventoryItem(item *Item, amount, slot int)

SetInventoryItem puts an item in a slot of the player's inventory. This will replace any existing items at that slot.

func (*Player) SetMusicTrackUnlocked

func (p *Player) SetMusicTrackUnlocked(songID int, enabled bool)

SetMusicTrackUnlocked sets that a music track is available for the player to play.

func (*Player) SetQuestFlag

func (p *Player) SetQuestFlag(questID, flagID, value int)

SetQuestFlag sets the value of a flag for a quest, overwriting any previously set value.

func (*Player) SetQuestStatus

func (p *Player) SetQuestStatus(questID int, status QuestStatus)

SetQuestStatus sets the status of a quest, overwriting any previous status.

func (*Player) SetSkillExperience

func (p *Player) SetSkillExperience(skillType SkillType, experience float64)

SetSkillExperience sets the experience points for a player skill. The skill level and combat levels will be recomputed after the fact.

func (*Player) SkillExperience

func (p *Player) SkillExperience(skillType SkillType) float64

SkillExperience returns the player's current experience points for a skill.

func (*Player) Weight

func (p *Player) Weight() float32

Weight returns the total weight of all player inventory and equipment.

type PlayerChangeEvent

type PlayerChangeEvent int

PlayerChangeEvent is an event that occurs on a player's attributes.

const (
	PlayerChangeRunEnergy PlayerChangeEvent = iota
	PlayerPrayerExhausted
)

type PlayerModes

type PlayerModes struct {
	// PublicChat is the player's public chat interaction setting.
	PublicChat ChatMode
	// PrivateChat is the player's public chat interaction setting.
	PrivateChat ChatMode
	// Interaction is the player's trade/duel request interaction setting.
	Interaction InteractionMode
}

PlayerModes indicates what types of chat and interactions a player wishes to receive.

type PlayerType

type PlayerType int

PlayerType enumerates the possible player access levels.

const (
	PlayerNormal PlayerType = iota
	PlayerModerator
	PlayerAdmin
)

type QuestStatus

type QuestStatus int

QuestStatus enumerates a player's status of a quest.

const (
	QuestStatusNotStarted QuestStatus = iota
	QuestStatusInProgress
	QuestStatusFinished
)

type Rectangle

type Rectangle struct {
	X1 int
	Y1 int
	X2 int
	Y2 int
}

Rectangle is a rectangle aligned on the x- and y-axes.

func MakeRectangle

func MakeRectangle(x1, y1, x2, y2 int) Rectangle

MakeRectangle returns a Rectangle initialized with a top-left and bottom-right boundary point.

type Skill

type Skill struct {
	// Type is the unique identifier for the skill.
	Type SkillType
	// StatLevel is the current, effective level for the skill modified by (de)buffs.
	StatLevel int
	// BaseLevel is the skill's level based on experience points.
	BaseLevel int
	// Experience is the number of experience points gained in the skill.
	Experience float64
}

Skill represents progress in a single skill.

func NewSkill

func NewSkill(skillType SkillType) *Skill

NewSkill returns a Skill initialized to its base level.

type SkillMap

type SkillMap map[SkillType]*Skill

SkillMap is a map of skill types to their progress. Use the EmptySkillMap() function to create a map of all skills initialized to their base levels.

func EmptySkillMap

func EmptySkillMap() SkillMap

EmptySkillMap returns a SkillMap initialized with all skills to their base levels.

type SkillType

type SkillType int

SkillType is an individual skill that can be trained by a player. Each skill has a well-known identifier that is shared between the client and server.

const (
	SkillTypeAttack      SkillType = 0
	SkillTypeDefense     SkillType = 1
	SkillTypeStrength    SkillType = 2
	SkillTypeHitpoints   SkillType = 3
	SkillTypeRanged      SkillType = 4
	SkillTypePrayer      SkillType = 5
	SkillTypeMagic       SkillType = 6
	SkillTypeCooking     SkillType = 7
	SkillTypeWoodcutting SkillType = 8
	SkillTypeFletching   SkillType = 9
	SkillTypeFishing     SkillType = 10
	SkillTypeFiremaking  SkillType = 11
	SkillTypeCrafting    SkillType = 12
	SkillTypeSmithing    SkillType = 13
	SkillTypeMining      SkillType = 14
	SkillTypeHerblore    SkillType = 15
	SkillTypeAgility     SkillType = 16
	SkillTypeThieving    SkillType = 17
	SkillTypeSlayer      SkillType = 18
	SkillTypeFarming     SkillType = 19
	SkillTypeRunecraft   SkillType = 20
)

type Tile

type Tile struct {
	Height     int
	OverlayID  int
	RenderFlag int
	UnderlayID int
	// contains filtered or unexported fields
}

Tile is the smallest unit of space on the world map.

func (*Tile) AddItem

func (t *Tile) AddItem(id int) uuid.UUID

AddItem adds a non-stackable ground item to the tile, returning its unique instance UUID.

func (*Tile) AddObject

func (t *Tile) AddObject(object *WorldObject)

AddObject places a world object on the tile.

func (*Tile) AddStackableItem

func (t *Tile) AddStackableItem(id, amount int) (uuid.UUID, bool, int)

AddStackableItem adds a stackable ground item with a stack amount to the tile, returning its unique instance UUID. If a new item was added to the tile, true will be returned in the second tuple element, otherwise false if an existing item's stack was updated. If an existing item was updated, the previous stack amount will be returned in the third tuple element.

func (*Tile) Clear

func (t *Tile) Clear()

Clear removes all ground items on the tile.

func (*Tile) GroundItems

func (t *Tile) GroundItems() []*TileGroundItem

GroundItems returns a slice of ground items located on this tile.

func (*Tile) RemoveItemByID

func (t *Tile) RemoveItemByID(id int) *TileGroundItem

RemoveItemByID removes the first ground item that matches the item ID. If the item was found and removed, a pointer to the TileGroundItem model will be returned. If there are multiple ground items with the same item ID, only the first will be removed.

func (*Tile) RemoveItemByInstanceUUID

func (t *Tile) RemoveItemByInstanceUUID(instanceUUID uuid.UUID) *int

RemoveItemByInstanceUUID removes a ground item that matches the instance UUID. If the item was found and removed, its item ID will be returned.

type TileGroundItem

type TileGroundItem struct {
	InstanceUUID uuid.UUID
	ItemID       int
	Amount       int
}

TileGroundItem is an instance of an item placed on a tile.

type Vector2D

type Vector2D struct {
	X int
	Y int
}

Vector2D is a vector in two-dimensional space.

func (Vector2D) String

func (v Vector2D) String() string

func (Vector2D) Sub

func (v Vector2D) Sub(w Vector2D) Vector2D

Sub subtracts another vector from this one, returning a new Vector2D.

func (Vector2D) To3D

func (v Vector2D) To3D(z int) Vector3D

To3D returns a Vector3D with the 2D components of this vector.

type Vector3D

type Vector3D struct {
	X int
	Y int
	Z int
}

Vector3D is a vector in three-dimensional space.

func (Vector3D) Add

func (v Vector3D) Add(w Vector3D) Vector3D

Add adds another vector to this one, returning a new Vector3D.

func (Vector3D) Divide

func (v Vector3D) Divide(w Vector3D) Vector3D

Divide divides this vector by another one, returning a new Vector3D.

func (Vector3D) Mod

func (v Vector3D) Mod(w Vector3D) Vector3D

Mod computes the modulo of this vector and another, returning a new Vector3D.

func (Vector3D) Multiply

func (v Vector3D) Multiply(w Vector3D) Vector3D

Multiply multiplies another vector by this one, returning a new Vector3D.

func (Vector3D) String

func (v Vector3D) String() string

func (Vector3D) Sub

func (v Vector3D) Sub(w Vector3D) Vector3D

Sub subtracts another vector from this one, returning a new Vector3D.

func (Vector3D) To2D

func (v Vector3D) To2D() Vector2D

To2D returns a Vector2D with only the two-dimensional components of this vector.

type WeaponStyle

type WeaponStyle int

WeaponStyle enumerates the possible attack styles of a weapon.

const (
	WeaponStyleUnarmed WeaponStyle = iota
	WeaponStyle2HSword
	WeaponStyleAxe
	WeaponStyleBow
	WeaponStyleBlunt
	WeaponStyleClaw
	WeaponStyleCrossbow
	WeaponStyleGun
	WeaponStylePickaxe
	WeaponStylePoleArm
	WeaponStylePoleStaff
	WeaponStyleScythe
	WeaponStyleSlashSword
	WeaponStyleSpear
	WeaponStyleSpiked
	WeaponStyleStabSword
	WeaponStyleStaff
	WeaponStyleThrown
	WeaponStyleWhip
)

type WorldObject

type WorldObject struct {
	ID              int
	Description     string
	Name            string
	Walkable        bool
	Actions         []string
	UnwalkableSolid bool
	Translation     Vector3D
	Size            Vector2D
	Scale           Vector3D
	FaceID          int
	MapSceneID      int
	Shadowless      bool
	Rotated         bool
	OffsetAmplified bool
	AdjustToTerrain bool
	DelayedShading  bool
	HasActions      bool
	Solid           bool
	Wall            bool
	Static          bool
	VariableID      int
	ConfigID        int
	ChildIDs        []int
}

WorldObject is an entity that can appear on the game world.

Jump to

Keyboard shortcuts

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