Documentation ¶
Index ¶
- Constants
- Variables
- func AddNpc(n *NPC)
- func AddObject(o *Object)
- func AddPlayer(p *Player)
- func ParseDirection(s string) int
- func RemoveNpc(p *Player)
- func RemoveObject(o *Object)
- func RemovePlayer(p *Player)
- func ReplaceObject(old *Object, newID int)
- func WithinWorld(x, y int) bool
- type AppearanceTable
- type AttrList
- type AttributeList
- func (attributes *AttributeList) Range(fn func(string, interface{}))
- func (attributes *AttributeList) SetVar(name string, value interface{})
- func (attributes *AttributeList) UnsetVar(name string)
- func (attributes *AttributeList) VarBool(name string, zero bool) bool
- func (attributes *AttributeList) VarInt(name string, zero int) int
- func (attributes *AttributeList) VarLong(name string, zero uint64) uint64
- type Entity
- type GroundItem
- type Inventory
- type Item
- type List
- func (l *List) Add(e interface{})
- func (l *List) Contains(e interface{}) bool
- func (l *List) NearbyNPCs(p *Player) []*NPC
- func (l *List) NearbyObjects(p *Player) []*Object
- func (l *List) NearbyPlayers(p *Player) []*Player
- func (l *List) Remove(e interface{})
- func (l *List) RemovingObjects(p *Player) []*Object
- func (l *List) RemovingPlayers(p *Player) []*Player
- type Location
- func (l *Location) Above() Location
- func (l *Location) Below() Location
- func (l *Location) DeltaX(other *Location) (deltaX int)
- func (l *Location) DeltaY(other *Location) (deltaY int)
- func (l *Location) Equals(o interface{}) bool
- func (l *Location) LongestDelta(other *Location) int
- func (l *Location) Plane() int
- func (l *Location) PlaneY(up bool) int
- func (l *Location) String() string
- func (l *Location) WithinRange(other *Location, radius int) bool
- func (l *Location) WithinWorld() bool
- type Mob
- func (m *Mob) Busy() bool
- func (m *Mob) Direction() int
- func (m *Mob) FinishedPath() bool
- func (m *Mob) ResetPath()
- func (m *Mob) SetCoords(x, y int)
- func (m *Mob) SetDirection(direction int)
- func (m *Mob) SetLocation(location *Location)
- func (m *Mob) SetPath(path *Pathway)
- func (m *Mob) TraversePath()
- func (m *Mob) UpdateDirection(destX, destY int)
- type MobState
- type NPC
- type Object
- type Pathway
- type Player
- func (p *Player) AimPoints() int
- func (p *Player) ArmourPoints() int
- func (p *Player) ChatBlocked() bool
- func (p *Player) DuelBlocked() bool
- func (player *Player) EnterDoor(door *Object, dest *Location)
- func (p *Player) Fatigue() int
- func (p *Player) FightMode() int
- func (p *Player) FollowIndex() int
- func (p *Player) FollowRadius() int
- func (p *Player) FriendBlocked() bool
- func (p *Player) Friends(other uint64) bool
- func (p *Player) GetClientSetting(id int) bool
- func (p *Player) Ignoring(hash uint64) bool
- func (p *Player) IsFollowing() bool
- func (p *Player) MagicPoints() int
- func (p *Player) NearbyObjects() (objects []*Object)
- func (p *Player) NearbyPlayers() (players []*Player)
- func (p *Player) NewNPCs() (npcs []*NPC)
- func (p *Player) NewObjects() (objects []*Object)
- func (p *Player) NewPlayers() (players []*Player)
- func (p *Player) PowerPoints() int
- func (p *Player) PrayerPoints() int
- func (p *Player) RangedPoints() int
- func (p *Player) Reconnecting() bool
- func (p *Player) ResetFollowing()
- func (p *Player) RunDistancedAction(dest *Location, action func())
- func (p *Player) ServerSeed() uint64
- func (p *Player) SetAimPoints(i int)
- func (p *Player) SetArmourPoints(i int)
- func (p *Player) SetClientSetting(id int, flag bool)
- func (p *Player) SetCoords(x, y int)
- func (p *Player) SetFatigue(i int)
- func (p *Player) SetFightMode(i int)
- func (p *Player) SetFollowing(index int)
- func (p *Player) SetLocation(location *Location)
- func (p *Player) SetMagicPoints(i int)
- func (p *Player) SetPowerPoints(i int)
- func (p *Player) SetPrayerPoints(i int)
- func (p *Player) SetPrivacySettings(chatBlocked, friendBlocked, tradeBlocked, duelBlocked bool)
- func (p *Player) SetRangedPoints(i int)
- func (p *Player) SetReconnecting(flag bool)
- func (p *Player) SetServerSeed(seed uint64)
- func (p *Player) Teleport(x, y int)
- func (p *Player) TradeBlocked() bool
- type Region
- type SkillTable
Constants ¶
const ( //North Represents north. North int = iota //NorthWest Represents north-west. NorthWest //West Represents west. West //SouthWest Represents south-west. SouthWest //South represents south. South //SouthEast represents south-east SouthEast //East Represents east. East //NorthEast Represents north-east. NorthEast //MaxX Width of the game MaxX = 944 //MaxY Height of the game MaxY = 3776 )
const ( //PlaneGround Represents the value for the ground-level plane PlaneGround int = iota //PlaneSecond Represents the value for the second-story plane PlaneSecond //PlaneThird Represents the value for the third-story plane PlaneThird //PlaneBasement Represents the value for the basement plane PlaneBasement )
const ( //RegionSize Represents the size of the region RegionSize = 48 //HorizontalPlanes Represents how many columns of regions there are HorizontalPlanes = MaxX/RegionSize + 1 //VerticalPlanes Represents how many rows of regions there are VerticalPlanes = MaxY/RegionSize + 1 //LowerBound Represents a dividing line in the exact middle of a region LowerBound = RegionSize / 2 )
Variables ¶
var DeathSpot = NewLocation(0, 0)
DeathSpot The spot where mobs go to die.
var LogWarning = log.New(os.Stdout, "[WARNING] ", log.Ltime|log.Lshortfile)
LogWarning Log interface for warnings.
Functions ¶
func ParseDirection ¶
ParseDirection Tries to parse the direction indicated in s. If it can not match any direction, returns the zero-value for direction: north.
func ReplaceObject ¶
ReplaceObject Replaces old with a new game object with all of the same characteristics, except it's ID set to newID.
func WithinWorld ¶
WithinWorld Returns true if the tile at x,y is within world boundaries, false otherwise.
Types ¶
type AppearanceTable ¶
AppearanceTable Represents a mobs appearance.
func NewAppearanceTable ¶
func NewAppearanceTable(head, body int, male bool, hair, top, bottom, skin int) *AppearanceTable
NewAppearanceTable Returns a reference to a new appearance table with specified parameters
type AttrList ¶
type AttrList map[string]interface{}
AttrList A type alias for a map of strings to empty interfaces, to hold generic mob information for easy serialization and to provide dynamic insertion/deletion of new mob properties easily
type AttributeList ¶
AttributeList A concurrency-safe collection data type for storing misc. variables by a descriptive name.
func (*AttributeList) Range ¶
func (attributes *AttributeList) Range(fn func(string, interface{}))
Range Runs fn(key, value) for every entry in this attribute list.
func (*AttributeList) SetVar ¶
func (attributes *AttributeList) SetVar(name string, value interface{})
SetVar Sets the attribute mapped at name to value in the attribute map.
func (*AttributeList) UnsetVar ¶
func (attributes *AttributeList) UnsetVar(name string)
UnsetVar Removes the attribute with the key `name` from this attribute set.
func (*AttributeList) VarBool ¶
func (attributes *AttributeList) VarBool(name string, zero bool) bool
VarBool If there is an attribute assigned to the specified name, returns it. Otherwise, returns zero
type Entity ¶
Entity A stationary scene entity within the game world.
func (*Entity) AtCoords ¶
AtCoords Returns true if the entity is at the specified coordinates, otherwise returns false
func (*Entity) AtLocation ¶
AtLocation Returns true if the entity is at the specified location, otherwise returns false
type GroundItem ¶
GroundItem Represents a single ground item within the game.
type Inventory ¶
Inventory Represents an inventory of items in the game.
type List ¶
type List struct { List []interface{} // contains filtered or unexported fields }
List Represents a list of scene entities.
func (*List) NearbyObjects ¶
NearbyObjects Might remove
func (*List) NearbyPlayers ¶
NearbyPlayers Might remove
func (*List) RemovingObjects ¶
RemovingObjects Might remove
func (*List) RemovingPlayers ¶
RemovingPlayers Might remove
type Location ¶
type Location struct {
X, Y int
// contains filtered or unexported fields
}
Location A tile in the game world.
func NewLocation ¶
NewLocation Returns a reference to a new instance of the Location data structure.
func (*Location) Above ¶
Above Returns the location directly above this one, if any. Otherwise, if we are on the top floor, returns itself.
func (*Location) Below ¶
Below Returns the location directly below this one, if any. Otherwise, if we are on the bottom floor, returns itself.
func (*Location) DeltaX ¶
DeltaX Returns the difference between this locations X coord and the other locations X coord
func (*Location) DeltaY ¶
DeltaY Returns the difference between this locations Y coord and the other locations Y coord
func (*Location) LongestDelta ¶
LongestDelta Returns the largest difference in coordinates between receiver and other
func (*Location) PlaneY ¶
PlaneY Updates the location's Y coordinate, going up by one plane if up is true, else going down by one plane. Valid planes: ground=0, 2nd story=1, 3rd story=2, basement=3
func (*Location) WithinRange ¶
WithinRange Returns true if the other location is within radius tiles of the receiver location, otherwise false.
func (*Location) WithinWorld ¶
WithinWorld Returns true if the tile at x,y is within world boundaries, false otherwise.
type Mob ¶
type Mob struct { Entity State MobState Skillset *SkillTable Path *Pathway PathLock sync.RWMutex TransAttrs *AttributeList }
Mob Represents a mobile entity within the game world.
func (*Mob) Busy ¶
Busy Returns true if this mobs state is anything other than idle. otherwise returns false.
func (*Mob) FinishedPath ¶
FinishedPath Returns true if the mobs path is nil, the paths current waypoint exceeds the number of waypoints available, or the next tile in the path is not a valid location, implying that we have reached our destination.
func (*Mob) ResetPath ¶
func (m *Mob) ResetPath()
ResetPath Sets the mobs path to nil, to stop the traversal of the path instantly
func (*Mob) SetDirection ¶
SetDirection Sets the mobs direction.
func (*Mob) SetLocation ¶
SetLocation Sets the mobs location.
func (*Mob) SetPath ¶
SetPath Sets the mob's current pathway to path. If path is nil, effectively resets the mobs path.
func (*Mob) TraversePath ¶
func (m *Mob) TraversePath()
TraversePath If the mob has a path, calling this method will change the mobs location to the next location described by said Path data structure. This should be called no more than once per game tick.
func (*Mob) UpdateDirection ¶
UpdateDirection Updates the direction the mob is facing based on where the mob is trying to move, and where the mob is currently at.
type MobState ¶
type MobState uint8
MobState Mob state.
const ( //MSIdle The default MobState, means doing nothing. MSIdle MobState = iota //MSWalking The mob is walking. MSWalking //MSBanking The mob is banking. MSBanking //MSChatting The mob is chatting with a NPC MSChatting //MSMenuChoosing The mob is in a query menu MSMenuChoosing //MSTrading The mob is negotiating a trade. MSTrading //MSDueling The mob is negotiating a duel. MSDueling //MSFighting The mob is fighting. MSFighting //MSBatching The mob is performing a skill that repeats itself an arbitrary number of times. MSBatching //MSSleeping The mob is using a bed or sleeping bag, and trying to solve a CAPTCHA MSSleeping )
type Object ¶
Object Represents a game object in the world.
func GetAllObjects ¶
func GetAllObjects() (list []*Object)
GetAllObjects Returns a slice containing all objects in the game world.
func GetObject ¶
GetObject If there is an object at these coordinates, returns it. Otherwise, returns nil.
type Pathway ¶
Pathway Represents a path for a mobile entity to traverse across the virtual world.
func NewPathway ¶
NewPathway returns a new Pathway pointing to the specified coordinates. Must be a straight line from starting tile.
func NewPathwayComplete ¶
NewPathwayComplete returns a new Pathway with the specified variables. destX and destY are a straight line, and waypoints define turns from that point.
func NewPathwayFromLocation ¶
NewPathwayFromLocation returns a new Pathway pointing to the specified location. Must be a straight line from starting location.
type Player ¶
type Player struct { Username string UserBase37 uint64 Password string FriendList map[uint64]bool IgnoreList []uint64 LocalPlayers *List LocalNPCs *List LocalObjects *List Updating bool Appearances []int DatabaseIndex int Rank int Appearance *AppearanceTable AppearanceTicket int KnownAppearances map[int]int Attributes *AttributeList Items *Inventory Mob }
Player Represents a single player.
func (*Player) ArmourPoints ¶
ArmourPoints Returns the players armour points.
func (*Player) ChatBlocked ¶
ChatBlocked Returns true if public chat is blocked for this player.
func (*Player) DuelBlocked ¶
DuelBlocked Returns true if duel requests are blocked for this player.
func (*Player) EnterDoor ¶
EnterDoor Replaces door object with an open door, sleeps for one second, and returns the closed door.
func (*Player) FollowIndex ¶
FollowIndex Returns the index of the mob we are following, or -1 if we aren't following anyone.
func (*Player) FollowRadius ¶
FollowRadius Returns the radius within which we should follow whatever mob we are following, or -1 if we aren't following anyone.
func (*Player) FriendBlocked ¶
FriendBlocked Returns true if private chat is blocked for this player.
func (*Player) GetClientSetting ¶
GetClientSetting Looks up the client setting with the specified ID, and returns it. If it can't be found, returns false.
func (*Player) IsFollowing ¶
IsFollowing Returns true if the player is following another mob, otherwise false.
func (*Player) MagicPoints ¶
MagicPoints Returns the players magic points
func (*Player) NearbyObjects ¶
NearbyObjects Returns nearby objects.
func (*Player) NearbyPlayers ¶
NearbyPlayers Returns nearby players.
func (*Player) NewObjects ¶
NewObjects Returns nearby objects that this player is unaware of.
func (*Player) NewPlayers ¶
NewPlayers Returns nearby players that this player is unaware of.
func (*Player) PowerPoints ¶
PowerPoints Returns the players power points.
func (*Player) PrayerPoints ¶
PrayerPoints Returns the players prayer points
func (*Player) RangedPoints ¶
RangedPoints Returns the players ranged points.
func (*Player) Reconnecting ¶
Reconnecting Returns true if the player is reconnecting, false otherwise.
func (*Player) ResetFollowing ¶
func (p *Player) ResetFollowing()
ResetFollowing Resets the transient attribute for storing the server index of the player we want to follow.
func (*Player) RunDistancedAction ¶
RunDistancedAction Creates a distanced action belonging to this player, that runs action once the player arrives at dest, or cancels if we become busy, or we become unreasonably far from dest.
func (*Player) ServerSeed ¶
ServerSeed Returns the seed for the ISAAC cipher provided by the server for this player, if set, otherwise returns 0
func (*Player) SetAimPoints ¶
SetAimPoints Sets the players aim points to i.
func (*Player) SetArmourPoints ¶
SetArmourPoints Sets the players armour points to i.
func (*Player) SetClientSetting ¶
SetClientSetting Sets the specified client setting to flag.
func (*Player) SetFatigue ¶
SetFatigue Sets the players current fatigue to i.
func (*Player) SetFightMode ¶
SetFightMode Sets the players fightmode to i. 0=all,1=attack,2=defense,3=strength
func (*Player) SetFollowing ¶
SetFollowing Sets the transient attribute for storing the server index of the player we want to follow to index.
func (*Player) SetLocation ¶
SetLocation Sets the mobs location.
func (*Player) SetMagicPoints ¶
SetMagicPoints Sets the players magic points to i
func (*Player) SetPowerPoints ¶
SetPowerPoints Sets the players power points to i
func (*Player) SetPrayerPoints ¶
SetPrayerPoints Sets the players prayer points to i
func (*Player) SetPrivacySettings ¶
SetPrivacySettings Sets privacy settings to specified values.
func (*Player) SetRangedPoints ¶
SetRangedPoints Sets the players ranged points tp i.
func (*Player) SetReconnecting ¶
SetReconnecting Sets the player's reconnection status to flag.
func (*Player) SetServerSeed ¶
SetServerSeed Sets the player's stored server seed to seed for later comparison to ensure we decrypted the login block properly and the player received the proper seed.
func (*Player) Teleport ¶
Teleport Moves the player to x,y and sets a flag to remove said player from the local players list of every nearby player.
func (*Player) TradeBlocked ¶
TradeBlocked Returns true if trade requests are blocked for this player.
type Region ¶
Region Represents a 48x48 section of map. The purpose of this is to keep track of entities in the entire world without having to allocate tiles individually, which would make search algorithms slower and utilizes a great deal of memory.
func GetRegion ¶
GetRegion Returns the region that corresponds with the given coordinates. If it does not exist yet, it will allocate a new onr and store it for the lifetime of the application in the regions map.
func GetRegionFromLocation ¶
GetRegionFromLocation Returns the region that corresponds with the given location. If it does not exist yet, it will allocate a new onr and store it for the lifetime of the application in the regions map.
func SurroundingRegions ¶
SurroundingRegions Returns the regions surrounding the given coordinates. It wil
type SkillTable ¶
SkillTable Represents a skill table for a mob.
func (*SkillTable) CombatLevel ¶
func (s *SkillTable) CombatLevel() int
CombatLevel Calculates and returns the combat level for this skill table.