Documentation ¶
Index ¶
- Constants
- Variables
- func AddHandler(name string, h HandlerFunc)
- func AddItem(i *GroundItem)
- func AddNpc(n *NPC)
- func AddObject(o *Object)
- func AddPlayer(p *Player)
- func BankOpen(player *Player) (p *net.Packet)
- func BankUpdateItem(index, id, amount int) (p *net.Packet)
- func BigInformationBox(msg string) (p *net.Packet)
- func BoundaryLocations(player *Player) (p *net.Packet)
- func BoundedChance(percent float64, minPercent, maxPercent float64) bool
- func Chance(percent float64) bool
- func ChanceByte(threshold int) bool
- func Clear()
- func ClearDistantChunks(player *Player) (p *net.Packet)
- func ClientSettings(player *Player) (p *net.Packet)
- func ClipBit(direction int) int
- func CurrentTick() int
- func DuelConfirmationOpen(player, other *Player) (p *net.Packet)
- func DuelOpen(targetIndex int) (p *net.Packet)
- func DuelOptions(player *Player) (p *net.Packet)
- func DuelTargetAccept(accepted bool) (p *net.Packet)
- func DuelUpdate(player *Player) (p *net.Packet)
- func EquipmentStats(player *Player) (p *net.Packet)
- func Fatigue(player *Player) (p *net.Packet)
- func FightMode(player *Player) (p *net.Packet)
- func FriendList(player *Player) (p *net.Packet)
- func FriendUpdate(hash uint64, online bool) (p *net.Packet)
- func GetAllObjects() (list []entity.Entity)
- func HandlerCount() int
- func HandshakeResponse(v int) (p *net.Packet)
- func IgnoreList(player *Player) (p *net.Packet)
- func InformationBox(msg string) (p *net.Packet)
- func InventoryItems(player *Player) (p *net.Packet)
- func IsTileBlocking(x, y int, bit byte, current bool) bool
- func ItemLocations(player *Player) (p *net.Packet)
- func LoadCollisionData()
- func LoginBox(inactiveDays int, lastIP string) (p *net.Packet)
- func NPCPositions(player *Player) (p *net.Packet)
- func NewHitsplat(target entity.MobileEntity, damage int) interface{}
- func NpcEvents(player *Player) (p *net.Packet)
- func ObjectLocations(player *Player) (p *net.Packet)
- func OptionMenuOpen(questions ...string) (p *net.Packet)
- func PacketCount() int
- func ParseDirection(s string) int
- func PlaneInfo(player *Player) (p *net.Packet)
- func PlayerAppearances(ourPlayer *Player) (p *net.Packet)
- func PlayerExperience(player *Player, idx int) (p *net.Packet)
- func PlayerPositions(player *Player) (p *net.Packet)
- func PlayerStat(player *Player, idx int) (p *net.Packet)
- func PlayerStats(player *Player) (p *net.Packet)
- func PrayerStatus(player *Player) (p *net.Packet)
- func PrivacySettings(player *Player) (p *net.Packet)
- func PrivateMessage(hash uint64, msg string) (p *net.Packet)
- func QuestStatus(player *Player) (p *net.Packet)
- func Region(x, y int) *region
- func RemoveItem(i *GroundItem)
- func RemoveNpc(n *NPC)
- func RemoveObject(o *Object)
- func RemovePlayer(p *Player)
- func RunScripts()
- func ScriptEnv() *env.Env
- func ServerMessage(msg string) (p *net.Packet)
- func ShopOpen(shop *Shop) (p *net.Packet)
- func SleepFatigue(player *Player) (p *net.Packet)
- func SleepWord(player *Player) (p *net.Packet)
- func Sound(name string) (p *net.Packet)
- func StartCombat(attacker, defender entity.MobileEntity)
- func Statistical(rng *isaac.ISAAC, options IntProbabilitys) int
- func SystemUpdate(t int64) (p *net.Packet)
- func TeleBubble(offsetX, offsetY int) (p *net.Packet)
- func TradeAccept(accepted bool) (p *net.Packet)
- func TradeConfirmationOpen(player, other *Player) (p *net.Packet)
- func TradeOpen(targetIndex int) (p *net.Packet)
- func TradeTargetAccept(accepted bool) (p *net.Packet)
- func TradeUpdate(player *Player) (p *net.Packet)
- func UnmarshalPackets()
- func UpdateRegions(m entity.MobileEntity, x, y int)
- func VisibleRegions(x, y int) (regions [4]*region)
- func VisibleRegionsFrom(l entity.Location) (regions [4]*region)
- func WeightedChoice(choices IntProbabilitys) int
- func WithinWorld(x, y int) bool
- type Callback
- type ChatMessage
- type CollisionMask
- type Direction
- type Entity
- type GroundItem
- func (i *GroundItem) Command() string
- func (i *GroundItem) DeltaAmount(o *Item) int
- func (i *GroundItem) Name() string
- func (i *GroundItem) Price() Price
- func (i *GroundItem) Remove()
- func (i *GroundItem) ScalePrice(percent int) int
- func (i *GroundItem) SpawnedTime() time.Time
- func (i *GroundItem) Stackable() bool
- func (i *GroundItem) Visibility() int
- func (i *GroundItem) VisibleTo(p *Player) bool
- func (i *GroundItem) WieldPos() int
- type HandlerFunc
- type HitSplat
- type IntProbabilitys
- type Inventory
- func (i *Inventory) Add(id int, qty int) int
- func (i *Inventory) CanHold(id, amount int) bool
- func (i *Inventory) Clear()
- func (i *Inventory) Clone() *Inventory
- func (i *Inventory) CountID(id int) int
- func (i *Inventory) DeathDrops(keep int) []*GroundItem
- func (i *Inventory) Equipped(id int) bool
- func (i *Inventory) Get(index int) *Item
- func (i *Inventory) GetByID(ID int) *Item
- func (i *Inventory) GetIndex(ID int) int
- func (i *Inventory) Range(fn func(*Item) bool) int
- func (i *Inventory) RangeRev(fn func(*Item) bool) int
- func (i *Inventory) Remove(index int) bool
- func (i *Inventory) RemoveAll(offer *Inventory) int
- func (i *Inventory) RemoveByID(id, amt int) int
- func (i *Inventory) Size() int
- type Item
- type ItemBubble
- type ItemOnPlayerTrigger
- type ItemTrigger
- type Location
- func (l Location) Above() entity.Location
- func (l Location) Below() entity.Location
- func (l Location) CanReach(bounds [2]entity.Location) bool
- func (l Location) Clone() entity.Location
- func (l Location) Collides(dst entity.Location) bool
- func (l Location) Delta(other entity.Location) (delta int)
- func (l Location) DeltaX(other entity.Location) (deltaX int)
- func (l Location) DeltaY(other entity.Location) (deltaY int)
- func (l Location) DirectionTo(destX, destY int) int
- func (l Location) DirectionToward(end entity.Location) int
- func (l Location) Equals(o interface{}) bool
- func (l Location) EuclideanDistance(other entity.Location) float64
- func (l Location) Hash() int
- func (l Location) IsValid() bool
- func (l Location) LongestDelta(other entity.Location) int
- func (l Location) LongestDeltaCoords(x, y int) int
- func (l Location) Mask(toward entity.Location) byte
- func (l Location) Masks(x, y int) (masks [2]byte)
- func (l Location) Near(other entity.Location, radius int) bool
- func (l Location) NextStep(d entity.Location) entity.Location
- func (l Location) NextTileToward(dst entity.Location) entity.Location
- func (l Location) NextTo(target entity.Location) bool
- func (l Location) PivotTo(loc entity.Location) (deltas [2][]int)
- func (l Location) Plane() int
- func (l Location) PlaneY(up bool) int
- func (l Location) Point() entity.Location
- func (l Location) Reachable(other entity.Location) bool
- func (l Location) ReachableCoords(x, y int) bool
- func (l Location) SetX(x int)
- func (l Location) SetY(y int)
- func (l Location) Step(dir int) entity.Location
- func (l Location) String() string
- func (l Location) Targetable(other Location) bool
- func (l Location) TheirDeltaX(other entity.Location) (deltaY int)
- func (l Location) TheirDeltaY(other entity.Location) (deltaY int)
- func (l Location) Wilderness() int
- func (l Location) Within(minX, maxX, minY, maxY int) bool
- func (l Location) WithinArea(area [2]entity.Location) bool
- func (l Location) WithinRange(other entity.Location, radius int) bool
- func (l Location) WithinReach(other entity.Location) bool
- func (l Location) X() int
- func (l Location) Y() int
- type Mob
- func (m *Mob) AddState(state int)
- func (m *Mob) AimPoints() int
- func (m *Mob) ArmourPoints() int
- func (m *Mob) AttackPoints() float64
- func (m *Mob) Busy() bool
- func (m *Mob) BusyInput() bool
- func (m *Mob) CombatRng() *rand.Rand
- func (m *Mob) CombatRngSrc() *isaac.ISAAC
- func (m *Mob) DefensePoints() float64
- func (m *Mob) Direction() int
- func (m *Mob) ExperienceReward() float64
- func (m *Mob) FightMode() int
- func (m *Mob) FightRound() int
- func (m *Mob) FightTarget() entity.MobileEntity
- func (m *Mob) FinishedPath() bool
- func (m *Mob) GenerateHit(max float64) int
- func (m *Mob) HasState(state ...int) bool
- func (m *Mob) IncAimPoints(i int)
- func (m *Mob) IncArmourPoints(i int)
- func (m *Mob) IncMagicPoints(i int)
- func (m *Mob) IncPoints(id string, amt int)
- func (m *Mob) IncPowerPoints(i int)
- func (m *Mob) IncPrayerPoints(i int)
- func (m *Mob) IncRangedPoints(i int)
- func (m *Mob) IsFighting() bool
- func (m *Mob) Isaac() *rand.Rand
- func (m *Mob) LastFight() time.Time
- func (m *Mob) LastRetreat() time.Time
- func (m *Mob) MagicDamage(target entity.MobileEntity, maximum float64) int
- func (m *Mob) MagicPoints() int
- func (m *Mob) MaxMeleeDamage() float64
- func (m *Mob) MeleeDamage(target entity.MobileEntity) int
- func (m *Mob) Path() *Pathway
- func (m *Mob) PowerPoints() int
- func (m *Mob) PrayerActivated(i int) bool
- func (m *Mob) PrayerModifiers() (modifiers [3]int)
- func (m *Mob) PrayerPoints() int
- func (m *Mob) Random(low, high int) int
- func (m *Mob) RandomIncl(low, high int) int
- func (m *Mob) RangedPoints() int
- func (m *Mob) RemoveState(state int)
- func (m *Mob) ResetAppearanceChanged()
- func (m *Mob) ResetFighting()
- func (m *Mob) ResetPath()
- func (m *Mob) ResetRegionMoved()
- func (m *Mob) ResetRegionRemoved()
- func (m *Mob) ResetSpriteUpdated()
- func (m *Mob) ResetState()
- func (m *Mob) SessionCache() *entity.AttributeList
- func (m *Mob) SetAimPoints(i int)
- func (m *Mob) SetAppearanceChanged()
- func (m *Mob) SetArmourPoints(i int)
- func (m *Mob) SetCoords(x, y int, teleport bool)
- func (m *Mob) SetDirection(direction int)
- func (m *Mob) SetFightMode(i int)
- func (m *Mob) SetFightRound(i int)
- func (m *Mob) SetFightTarget(m2 entity.MobileEntity)
- func (m *Mob) SetMagicPoints(i int)
- func (m *Mob) SetPath(path *Pathway)
- func (m *Mob) SetPowerPoints(i int)
- func (m *Mob) SetPrayerPoints(i int)
- func (m *Mob) SetRangedPoints(i int)
- func (m *Mob) SetRegionMoved()
- func (m *Mob) SetRegionRemoved()
- func (m *Mob) SetSpriteUpdated()
- func (m *Mob) Skills() *entity.SkillTable
- func (m *Mob) Skulls() map[uint64]time.Time
- func (m *Mob) State() int
- func (m *Mob) StyleBonus(stat int) int
- func (m *Mob) TargetMob() entity.MobileEntity
- func (m *Mob) TargetNpc() *NPC
- func (m *Mob) TargetPlayer() *Player
- func (m *Mob) UpdateLastFight()
- func (m *Mob) UpdateLastRetreat()
- func (m *Mob) WalkTo(end entity.Location) bool
- type MobList
- func (l *MobList) Add(m entity.MobileEntity) int
- func (l *MobList) Contains(mob entity.MobileEntity) bool
- func (l *MobList) Get(idx int) entity.MobileEntity
- func (l *MobList) Range(action func(entity.MobileEntity) bool) int
- func (l *MobList) RangeNpcs(action func(*NPC) bool) int
- func (l *MobList) RangePlayers(action func(*Player) bool) int
- func (l *MobList) Remove(m entity.MobileEntity) bool
- func (l *MobList) Size() int
- type MobState
- type NPC
- func (n *NPC) Aggressive() bool
- func (n *NPC) Attackable() bool
- func (n *NPC) CacheDamage(hash uint64, dmg int)
- func (n *NPC) Chat(target *Player, msgs ...string)
- func (n *NPC) ChatIndirect(target *Player, msg string)
- func (n *NPC) Command() string
- func (n *NPC) DamageFrom(m entity.MobileEntity, damage int, kind int) bool
- func (n *NPC) Enqueue(handle string, e interface{})
- func (n *NPC) IsNpc() bool
- func (n *NPC) IsPlayer() bool
- func (n *NPC) Killed(killer entity.MobileEntity)
- func (n *NPC) MeleeDamage(target entity.MobileEntity) int
- func (n *NPC) Name() string
- func (n *NPC) Remove()
- func (n *NPC) Respawn()
- func (n *NPC) Retreats() bool
- func (n *NPC) SetLocation(l entity.Location, teleport bool)
- func (n *NPC) Teleport(x, y int)
- func (n *NPC) TraversePath()
- func (n *NPC) Type() entity.Type
- type NpcAction
- type NpcActionPredicate
- type NpcBlockingTrigger
- type NpcTrigger
- type Object
- func (o *Object) Boundaries() [2]entity.Location
- func (o *Object) ClipType() int
- func (o *Object) Command(click int) string
- func (o *Object) Command1() string
- func (o *Object) Command2() string
- func (o *Object) Defined() bool
- func (o *Object) Height() int
- func (o *Object) Name() string
- func (o *Object) String() string
- func (o *Object) TypeData() mapBarrier
- func (o *Object) Width() int
- type ObjectTrigger
- type Pathfinder
- type Pathway
- type Plane
- type Player
- func (p *Player) ActivatePrayer(idx int)
- func (p *Player) AddItem(id, amount int)
- func (p *Player) AddSkull(user uint64)
- func (p *Player) AppearanceTicket() int
- func (p *Player) AtObject(object *Object) bool
- func (p *Player) Attribute(id string) interface{}
- func (p *Player) Bank() *Inventory
- func (p *Player) BoolAttribute(id string) bool
- func (p *Player) Cache(name string) interface{}
- func (p *Player) CanAttack(target entity.MobileEntity) bool
- func (p *Player) CanReachDiag(bounds [2]entity.Location) bool
- func (p *Player) CanWalk() bool
- func (p *Player) Chat(msgs ...string)
- func (p *Player) ChatBlocked() bool
- func (p *Player) CloseBank()
- func (p *Player) CloseDuel()
- func (p *Player) CloseOptionMenu()
- func (p *Player) CloseShop()
- func (p *Player) CloseTradeScreens()
- func (p *Player) CombatDelta(other entity.MobileEntity) int
- func (p *Player) Connected() bool
- func (p *Player) CurrentIP() string
- func (p *Player) CurrentShop() *Shop
- func (p *Player) Damage(amt int)
- func (p *Player) DamageFrom(m entity.MobileEntity, damage int, kind int) bool
- func (p *Player) DeactivatePrayer(idx int)
- func (p *Player) DequipItem(item *Item)
- func (p *Player) Destroy()
- func (p *Player) DistributeMeleeExp(experience float64)
- func (p *Player) DuelAccepted(screen int) bool
- func (p *Player) DuelBlocked() bool
- func (p *Player) DuelEquipment() bool
- func (p *Player) DuelMagic() bool
- func (p *Player) DuelPrayer() bool
- func (p *Player) DuelRetreating() bool
- func (p *Player) DuelRules() [4]bool
- func (p *Player) Enqueue(id string, e interface{})
- func (p *Player) EquipItem(item *Item)
- func (p *Player) Equips() []int
- func (p *Player) Fatigue() int
- func (p *Player) FirstLogin() bool
- func (p *Player) FriendBlocked() bool
- func (p *Player) FriendsWith(other uint64) bool
- func (p *Player) GetClientSetting(id int) bool
- func (p *Player) Ignoring(hash uint64) bool
- func (p *Player) IncCurStat(idx int, lvl int)
- func (p *Player) IncExp(idx int, amt int)
- func (p *Player) Initialize()
- func (p *Player) IsDueling() bool
- func (p *Player) IsNpc() bool
- func (p *Player) IsPanelOpened() bool
- func (p *Player) IsPlayer() bool
- func (p *Player) IsTrading() bool
- func (p *Player) IsWebsocket() bool
- func (p *Player) ItemBubble(id int)
- func (p *Player) Killed(killer entity.MobileEntity)
- func (p *Player) Message(msg string)
- func (p *Player) NearbyNpcs() (npcs []*NPC)
- func (p *Player) NearbyObjects() (objects []entity.Entity)
- func (p *Player) NearbyPlayers() (players []*Player)
- func (p *Player) NewItems() (items []*GroundItem)
- func (p *Player) NewNPCs() (npcs *MobList)
- func (p *Player) NewObjects() (objects []*Object)
- func (p *Player) NewPlayers() (players *MobList)
- func (p *Player) NextToCoords(x, y int) bool
- func (p *Player) OpenAppearanceChanger()
- func (p *Player) OpenBank()
- func (p *Player) OpenDuelConfirm(target *Player)
- func (p *Player) OpenDuelScreen(target *Player)
- func (p *Player) OpenOptionMenu(options ...string) int
- func (p *Player) OpenShop(shop *Shop)
- func (p *Player) OpenSleepScreen()
- func (p *Player) OpenTradeConfirmation(target *Player)
- func (p *Player) OpenTradeScreen(target *Player)
- func (p *Player) PlaySound(soundName string)
- func (p *Player) PrayerOff(idx int)
- func (p *Player) PrayerOn(idx int)
- func (p *Player) ProcPacketsIn()
- func (p *Player) ProcPacketsOut()
- func (p *Player) QuestBroadcast(owner, target entity.MobileEntity, message string)
- func (p *Player) QueueHitsplat(owner entity.MobileEntity, dmg int)
- func (p *Player) QueueItemBubble(owner *Player, id int)
- func (p *Player) QueueNpcChat(owner, target entity.MobileEntity, message string)
- func (p *Player) QueueNpcSplat(owner *NPC, dmg int)
- func (p *Player) QueueProjectile(owner, target entity.MobileEntity, kind int)
- func (p *Player) QueuePublicChat(owner entity.MobileEntity, message string)
- func (p *Player) QueueQuestChat(owner, _ entity.MobileEntity, message string)
- func (p *Player) Rank() int
- func (p *Player) Read(data []byte) (n int, err error)
- func (p *Player) ReadPacket() (*net.Packet, error)
- func (p *Player) Reconnecting() bool
- func (p *Player) RemoteAddress() string
- func (p *Player) RemoveCache(name string)
- func (p *Player) ResetAll()
- func (p *Player) ResetAllExceptDueling()
- func (p *Player) ResetDuel()
- func (p *Player) ResetDuelAccepted()
- func (p *Player) ResetDuelRules()
- func (p *Player) ResetDuelTarget()
- func (p *Player) ResetFighting()
- func (p *Player) ResetTickAction()
- func (p *Player) ResetTrade()
- func (p *Player) SendEquipBonuses()
- func (p *Player) SendInventory()
- func (p *Player) SendMessageBox(msg string, big bool)
- func (p *Player) SendPlane()
- func (p *Player) SendPrayers()
- func (p *Player) SendStat(idx int)
- func (p *Player) SendStatExp(idx int)
- func (p *Player) SendStats()
- func (p *Player) SendUpdateTimer()
- func (p *Player) Server() Server
- func (p *Player) ServerSeed() uint64
- func (p *Player) SetCache(name string, val interface{})
- func (p *Player) SetClientSetting(id int, flag bool)
- func (p *Player) SetConnected(flag bool)
- func (p *Player) SetCurStat(idx int, lvl int)
- func (p *Player) SetDuelAccepted(screen int, b bool)
- func (p *Player) SetDuelRule(index int, b bool)
- func (p *Player) SetDuelTarget(p1 *Player)
- func (p *Player) SetFatigue(i int)
- func (p *Player) SetFirstLogin(flag bool)
- func (p *Player) SetLocation(l entity.Location, teleport bool)
- func (p *Player) SetMaxStat(idx int, lvl int)
- func (p *Player) SetPrivacySettings(chatBlocked, friendBlocked, tradeBlocked, duelBlocked bool)
- func (p *Player) SetReconnecting(flag bool)
- func (p *Player) SetServerSeed(seed uint64)
- func (p *Player) SetSkulled(val bool)
- func (p *Player) SetStat(idx, lvl int)
- func (p *Player) SetTickAction(action func() bool)
- func (p *Player) SetTradeTarget(index int)
- func (p *Player) SetTradeTargetAccepted()
- func (p *Player) SkullOn(p1 *Player)
- func (p *Player) Skulled() bool
- func (p *Player) SkulledOn(user uint64) bool
- func (p *Player) Skulls() map[uint64]time.Time
- func (p *Player) StartCombat(defender entity.MobileEntity)
- func (p *Player) String() string
- func (p *Player) Teleport(x, y int)
- func (p *Player) TickAction() func() bool
- func (p *Player) TogglePrayer(idx int) bool
- func (p *Player) TradeBlocked() bool
- func (p *Player) TradeTarget() int
- func (p *Player) TraversePath()
- func (p *Player) Type() entity.Type
- func (p *Player) Unregister()
- func (p *Player) UpdateAppearance()
- func (p *Player) UpdateDuel()
- func (p *Player) UpdateDuelAccept(accept bool)
- func (p *Player) UpdateDuelSettings()
- func (p *Player) UpdateRegion(x, y int)
- func (p *Player) UpdateStatus(status bool)
- func (p *Player) UpdateTradeOffer(target *Player)
- func (p *Player) UpdatedRegions()
- func (p *Player) Username() string
- func (p *Player) UsernameHash() uint64
- func (p *Player) ViewRadius() int
- func (p *Player) WalkingArrivalAction(t entity.MobileEntity, dist int, action func())
- func (p *Player) WalkingRangedAction(t entity.MobileEntity, fn func())
- func (p *Player) WriteNow(packet net.Packet)
- func (p *Player) WritePacket(packet *net.Packet)
- type PlayerList
- func (m *PlayerList) AsyncRange(fn func(*Player))
- func (m *PlayerList) Contains(player *Player) bool
- func (m *PlayerList) ContainsHash(hash uint64) bool
- func (m *PlayerList) Find(player *Player) int
- func (m *PlayerList) FindHash(hash uint64) (*Player, bool)
- func (m *PlayerList) FindIndex(index int) (*Player, bool)
- func (m *PlayerList) ForEach(action func(*Player) bool) int
- func (m *PlayerList) Put(player *Player)
- func (m *PlayerList) Range(action func(*Player))
- func (m *PlayerList) Remove(player *Player)
- func (m *PlayerList) Set() []*Player
- func (m *PlayerList) Size() int
- type PlayerService
- type PlayersList
- type Price
- type Projectile
- type Sector
- type Server
- type Shop
- type ShopContainer
- type ShopItems
- func (s *ShopItems) Add(item *Item)
- func (s *ShopItems) AddItem(id, amt int)
- func (s *ShopItems) Clone() *ShopItems
- func (s *ShopItems) Contains(id int) bool
- func (s *ShopItems) Count(id int) int
- func (s *ShopItems) Get(id int) *Item
- func (s *ShopItems) Range(fn func(*Item) bool)
- func (s *ShopItems) Remove(removingItem *Item)
- func (s *ShopItems) RemoveID(id, amount int, remove bool)
- func (s *ShopItems) Size() int
- type SpellDef
- type Trigger
Constants ¶
const ( //ClipNorth Bitmask to represent a wall to the north. ClipNorth = 1 << iota //ClipEast Bitmask to represent a wall to the west. ClipEast //ClipSouth Bitmask to represent a wall to the south. ClipSouth //ClipWest Bitmask to represent a wall to the east. ClipWest ClipCanProjectile //ClipDiag1 Bitmask to represent a diagonal wall. ClipSwNe //ClipDiag2 Bitmask to represent a diagonal wall facing the opposite way. ClipSeNw //ClipFullBlock Bitmask to represent an object blocking an entire tile. ClipFullBlock )
const ( //StateIdle The default MobState, means doing nothing. StateIdle MobState = 0 //StateChatting The mob is chatting with another mob. StateChatting = 1 << iota //StateFighting The mob is fighting. StateFighting //StateBanking The mob is banking. StateBanking //StateMenu The mob is in an option menu. The option menu handling routines will remove this state as soon // as they end, so if this is activated, there is an option menu waiting for a reply. StateMenu //StateTrading The mob is negotiating a trade. StateTrading //StateDueling The mob is negotiating a duel. StateDueling //MSBatching The mob is performing a skill that repeats itself an arbitrary number of times. MSBatching //StateSleeping The mob is using a bed or sleeping bag, and trying to solve a CAPTCHA StateSleeping //StateChangingLooks Indicates that the mob in this state is in the player aooearance changing screen StateChangingLooks //StateShopping Indicates that the mob in this state is using a shop interface StateShopping //MSItemAction Indicates that the mob in this state is doing an inventory action MSItemAction // StateAction generic doing-a-thing state StateAction StateFightingDuel = StateDueling | StateFighting StateChatChoosing = StateMenu | StateChatting StateItemChoosing = StateMenu | MSItemAction StateObjectChoosing = StateMenu | MSBatching StatePanelActive = StateBanking | StateShopping | StateChangingLooks | StateSleeping | StateTrading | StateDueling StateBusy = StatePanelActive | StateChatting | MSItemAction | MSBatching | StateAction StateWaitEvent = StateMenu | StateChatting | MSItemAction | MSBatching )
StateIdle The default MobState, means doing nothing.
const ( SyncInit = 0 SyncSprite = 1 << iota SyncMoved SyncRemoved SyncAppearance SyncNeedsPosition = SyncRemoved | SyncMoved | SyncSprite )
const ( // The percentage to increase or decrease the price of an item by as players use it. // // For every item the shop buys, the asking price decreases by ShopNormalDeltaRate% of the items base price. // However, for every item the shop sells, the asking price increases by ShopNormalDeltaRate% of the items base price. ShopNormalDeltaRate = 3 // Defines the base selling price for buying items from players in the general store. ShopBuyPriceBasePercent = 40 // Defines the base asking price for selling items to players in the general store. ShopSellPriceBasePercent = 130 // Defines how often to normalize most general stores inventorys. Might be an exception to this rule later. ShopGeneralRespawnTime = 50 )
const ( TicksDay = 135000 TicksHour = 5625 TicksTwentyMin = 1875 TicksMinute = 100 TickMinute = TicksMinute * TickMillis TickHour = TicksHour * TickMillis TickDay = TicksDay * TickMillis TickMillis = 640 * time.Millisecond ClientTickMillis = TickMillis >> 5 //MaxX Width of the game MaxX = 944 // MaxX = 960 //MaxY Height of the game // MaxY = 944 * 4 - 16 // View area for player is 16 tiles wide MaxY = 944 * 4 // 4 planes, 944 tiles per plane )
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 )
const DefaultDrop = 20
DefaultDrop returns the default item ID all mobs should drop on death
Variables ¶
var ( //DeathSpot The spot where NPCs go to be dead. DeathPoint = NewLocation(0, 0) //SpawnPoint The default spawn point, where new players start and dead players respawn. SpawnPoint = Lumbridge.Clone() //Lumbridge Lumbridge teleport point Lumbridge = NewLocation(122, 647) //Varrock Varrock teleport point Varrock = NewLocation(122, 647) //Edgeville Edgeville teleport point Edgeville = NewLocation(220, 445) )
var AppearanceKeepalive = net.NewEmptyPacket(213)
var BankClose = net.NewEmptyPacket(203)
var BoundaryTriggers []ObjectTrigger
BoundaryTriggers List of script callbacks to run for boundary actions
var CannotLogout = net.NewEmptyPacket(183)
CannotLogout Message that you can not logout right now.
var CommandHandlers = make(map[string]func(*Player, []string))
CommandHandlers A map to assign in-game commands to the functions they should execute.
var Death = net.NewEmptyPacket(83)
Death The 'Oh dear...You are dead' fade-to-black graphic effect when you die.
var DefaultActionMessage = ServerMessage("Nothing interesting happens.")
DefaultActionMessage This is a message to inform the player that the action they were trying to perform didn't do anything.
var DuelClose = net.NewEmptyPacket(225)
var Handlers = make(map[string]HandlerFunc)
handlers A map with descriptive names for the keys, and functions to run for the value.
var InvOnBoundaryTriggers []func(player *Player, object *Object, item *Item) bool
InvOnBoundaryTriggers a list of actions to run when a player uses an inventory item on a boundary object
var InvOnObjectTriggers []func(player *Player, object *Object, item *Item) bool
InvOnObjectTriggers a list of actions to run when a player uses an inventory item on a object
var InvOnPlayerTriggers []ItemOnPlayerTrigger
InvOnPlayerTriggers a list of actions to run when a player uses an inventory item on another player object
var ItemIndexer = atomic.NewUint32(0)
ItemIndexer Ensures unique indexes for ground items.
TODO: Proper indexing
var ItemTriggers []ItemTrigger
ItemTriggers List of script callbacks to run for inventory item actions
var LoginTriggers []func(player *Player)
LoginTriggers a list of actions to run when a player logs in.
var Logout = net.NewEmptyPacket(4)
Logout Resets client to login welcome screen
var NpcAtkTriggers []NpcBlockingTrigger
NpcAtkTriggers List of script callbacks to run when you attack an NPC
var NpcDeathTriggers []NpcBlockingTrigger
NpcDeathTriggers List of script callbacks to run when you kill an NPC
var NpcTalkList = make([]Callback, 0, 800)
NpcTriggers List of script callbacks to run for NPC talking actions
var Npcs = NewMobList()
Npcs A collection of every NPC in the game, sorted by index
var ObjectCounter = atomic.NewUint32(0)
var ObjectTriggers []ObjectTrigger
ObjectTriggers List of script callbacks to run for object actions
var OpenChangeAppearance = net.NewEmptyPacket(59)
OpenChangeAppearance The appearance changing window.
var OptionMenuClose = net.NewEmptyPacket(252)
var OrderedDirections = [...]Direction{West, East, North, South, SouthWest, SouthEast, NorthWest, NorthEast}
OrderedDirections This is an array containing all of the directions a mob can walk in, ordered by path finder precedent. West, East, North, South, SouthWest, SouthEast, NorthWest, NorthEast
var PacketTriggers = make(map[byte]Trigger)
var Players = &PlayerList{free: make(indexQueue, 0, 1250), PlayersList: make(PlayersList)}
Players Collection containing all of the active client, by index and username hash, guarded by a mutex
var ResponsePong = net.NewEmptyPacket(9)
ResponsePong Response to a RSC protocol ping net
var Sectors = make(map[int]*Sector)
Sectors A map to store landscape sectors by their hashed file name.
var SectorsLock sync.RWMutex
var ShopClose = net.NewEmptyPacket(137)
ShopClose A net to tell the client to close any open shop interface.
var ( //Shops contains all shop instances in the game world mapped to identifying names. // // No Shops need to be loaded until a player requests one, in my opinion. From that point on, Shops are active for // the entire runtime of the game, unless a system admin does something to stop them. The structures use so // little memory in practice, that I can't imagine a shop ever needing unset for performance or resource usage issues. Shops = &ShopContainer{ set: make(map[string]*Shop), } )
var SleepClose = net.NewEmptyPacket(84)
var SleepWrong = net.NewEmptyPacket(194)
var SpellTriggers = make(map[int]Trigger)
var TradeClose = net.NewEmptyPacket(128)
TradeClose Closes a trade window
var UpdateTime time.Time
UpdateTime a point in time in the future to log all active players out and shut down the game for updates. Before the command is issued to set this time, it is initialized to time.Time{} zero value.
var WelcomeMessage = ServerMessage("Welcome to RuneScape")
WelcomeMessage Welcome to the game on login
Functions ¶
func AddHandler ¶
func AddHandler(name string, h HandlerFunc)
AddHandler Adds and assigns the packethandler to the handlers with the specified name.
func BankUpdateItem ¶
func BigInformationBox ¶
BigInformationBox Builds a packet to trigger the opening of a large black text window with msg as its contents
func BoundaryLocations ¶
BoundaryLocations Builds a packet with the view-area boundary positions in it, relative to the player. If no new objects are available and no existing local boundarys are removed from area, returns nil.
func BoundedChance ¶
BoundedChance is a statistically random function that should return true percent/maxPercent% of the time. This should return true approximately percent/maxPercent of the time, and false (maxPercent-percent)/maxPercent of the time. percent defines the percentage of chance for this check to pass, clamped to the provided boundaries. minPercent is the minimum allowed value of percent. If percent is larger than minPercent, then minPercent is used in its place. maxPercent is the maximum allowed value of percent, and also the denominator used when scaling the percentage to a 1-byte value Returns: randByte <= max(min(percent, maxPercent), minPercent)/maxPercent*256.0, (with uniform randomness)
func Chance ¶
Chance should return true (percent)% of the time, and false (100-percent)% of the time. It uses ISAAC64+ to provide randomness.
percent defines the percentage of chance for this check to pass.
func ChanceByte ¶
ChanceByte Grabs a single 8-bit unsigned byte out of the rscgo/rand pkg, and returns true if it's less than or equals the provided threshold.
func ClearDistantChunks ¶
ClearDistantChunks iterates through a players transient `distantChunks` attribute and sends them to the client to signal a removal of all stationary entities within an 8x8 chunk of tiles surrounding the cached location.
func ClientSettings ¶
ClientSettings Builds a packet containing the players client settings, e.g camera mode, mouse mode, sound fx...
func CurrentTick ¶
func CurrentTick() int
func DuelConfirmationOpen ¶
DuelConfirmationOpen Builds a packet to open the duel confirmation page
func DuelOptions ¶
DuelOptions Builds a packet to update duel fight options
func DuelTargetAccept ¶
DuelTargetAccept Builds a packet to change duel targets accepted status
func DuelUpdate ¶
DuelUpdate Builds a packet to update a duel offer
func EquipmentStats ¶
EquipmentStats Builds a packet with the players equipment statistics in it.
func FriendList ¶
FriendList Builds a packet with the players friend entityList information in it.
func FriendUpdate ¶
FriendUpdate Builds a packet with an online status update for the player with the specified hash
func GetAllObjects ¶
GetAllObjects Returns a slice containing all objects in the game
func HandlerCount ¶
func HandlerCount() int
HandlerCount returns the number of pDefinitions that are handled
func HandshakeResponse ¶
HandshakeResponse Builds a bare net with the login response code.
func IgnoreList ¶
IgnoreList Builds a packet with the players ignore entityList information in it.
func InformationBox ¶
InformationBox Builds a packet to trigger the opening of a small black text window with msg as its contents
func InventoryItems ¶
InventoryItems Builds a packet containing the players inventory items.
func IsTileBlocking ¶
var blockedOverlays = [...]int{OverlayWater, definitions.OverlayDarkWater, definitions.OverlayBlack, definitions.OverlayWhite, definitions.OverlayLava, definitions.OverlayBlack2, definitions.OverlayBlack3, definitions.OverlayBlack4}
func isOverlayBlocked(overlay int) bool { for _, v := range blockedOverlays { if v == definitions.Overlay { return true } } return false }
func ItemLocations ¶
ItemLocations Builds a packet with the view-area item positions in it, relative to the player. If no new items are available and no existing items are removed from area, returns nil.
func LoadCollisionData ¶
func LoadCollisionData()
LoadCollisionData Loads the JAG archive './data/landscape.jag', decodes it, and stores the map sectors it holds in memory for quick access.
func LoginBox ¶
LoginBox Builds a packet to create a welcome box on the client with the inactiveDays since login, and lastIP connected from.
func NPCPositions ¶
NPCPositions Builds a packet containing view area NPC position and sprite information
func NewHitsplat ¶
func NewHitsplat(target entity.MobileEntity, damage int) interface{}
func ObjectLocations ¶
ObjectLocations Builds a packet with the view-area object positions in it, relative to the player. If no new objects are available and no existing local objects are removed from area, returns nil.
func OptionMenuOpen ¶
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 PlaneInfo ¶
PlaneInfo Builds a packet to update information about the client environment, e.g height, player index...
func PlayerAppearances ¶
PlayerAppearances Builds a packet with the view-area player appearance profiles in it.
func PlayerExperience ¶
PlayerStat Builds a packet containing player's stat information for skill at idx and returns it.
func PlayerPositions ¶
PlayerPositions Builds a packet containing view area player position and sprite information, including ones own information, and returns it. If no players need to be updated, returns nil.
func PlayerStat ¶
PlayerStat Builds a packet containing player's stat information for skill at idx and returns it.
func PlayerStats ¶
PlayerStats Builds a packet containing all the player's stat information and returns it.
func PrayerStatus ¶
func PrivacySettings ¶
PrivacySettings Builds a packet containing the players privacy settings for display in the settings menu.
func PrivateMessage ¶
PrivateMessage Builds a packet with a private message from hash with content msg.
func QuestStatus ¶
func Region ¶
func Region(x, y int) *region
Region 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 RemoveItem ¶
func RemoveItem(i *GroundItem)
RemoveItem SetRegionRemoved a ground item to the region.
func RemoveObject ¶
func RemoveObject(o *Object)
RemoveObject SetRegionRemoved an object from the region.
func RunScripts ¶
func RunScripts()
RunScripts Loads all of the scripts in ./scripts. This will ignore any folders named definitions or lib.
func ServerMessage ¶
ServerMessage Builds a packet containing a game message to display in the chat box.
func SleepFatigue ¶
func StartCombat ¶
func StartCombat(attacker, defender entity.MobileEntity)
func SystemUpdate ¶
SystemUpdate A packet with the time until servers next system update, measured in server ticks (640ms intervals)
func TeleBubble ¶
TeleBubble Builds a packet to draw a teleport bubble at the specified offsets.
func TradeAccept ¶
TradeAccept Builds a packet to change trade targets accepted status
func TradeConfirmationOpen ¶
TradeConfirmationOpen Builds a packet to open the trade confirmation page
func TradeTargetAccept ¶
TradeTargetAccept Builds a packet to change trade targets accepted status
func TradeUpdate ¶
TradeUpdate Builds a packet to update a trade offer
func UnmarshalPackets ¶
func UnmarshalPackets()
UnmarshalPackets Loads the handlers pDefinitions into memory from the configured TOML file
func UpdateRegions ¶
func UpdateRegions(m entity.MobileEntity, x, y int)
func VisibleRegions ¶
func VisibleRegions(x, y int) (regions [4]*region)
VisibleRegions Returns the regions surrounding the given coordinates.
func VisibleRegionsFrom ¶
func WeightedChoice ¶
func WeightedChoice(choices IntProbabilitys) int
WeightedChoice Awesome API call takes map[retVal]probability as input and returns a statistically weighted randomized retVal as output.
The input's mapped value assigned to each key is its return probability, out of the total sum of all return probabilities. You can determine the percentage chance of any given input entry being returned by: probability/sumOfAllProbabilities*100 E.g, if the sum of all probabilities is 100, and you have a total probability of 100, where the first retVal maps to 25.0, the chance it will be returned is 25%
You can make the total anything. Useful for anything that needs to return certain values deterministically more often than others, but randomly.
func WithinWorld ¶
IsValid Returns true if the tile at x,y is within world boundaries, false otherwise.
Types ¶
type ChatMessage ¶
type ChatMessage struct { Owner entity.MobileEntity Target entity.MobileEntity // contains filtered or unexported fields }
func NewChatMessage ¶
func NewChatMessage(owner entity.MobileEntity, content string) ChatMessage
func NewTargetedMessage ¶
func NewTargetedMessage(owner entity.MobileEntity, target entity.MobileEntity, content string) ChatMessage
type CollisionMask ¶
type CollisionMask int16
CollisionMask Represents a single tile in the game's landscape.
func CollisionData ¶
func CollisionData(x, y int) CollisionMask
type Direction ¶
type Direction = int
Direction represents directions that mobs can face within the game world. Ranges from 1-8
type Entity ¶
Entity A stationary scene entity within the game world.
func (*Entity) AtLocation ¶
AtLocation Returns true if the entity is at the specified location, otherwise returns false
func (*Entity) ServerIndex ¶
func (*Entity) SetServerIndex ¶
type GroundItem ¶
type GroundItem struct {
ID, Amount int
Owner string
*entity.AttributeList
Entity
}
GroundItem Represents a single ground item within the game.
func GetItem ¶
func GetItem(x, y, id int) *GroundItem
GetItem Returns the item at x,y with the specified id. Returns nil if it can not find the item.
func NewGroundItem ¶
func NewGroundItem(id, amount, x, y int) *GroundItem
NewGroundItem Creates a new ground item in the game world and returns a reference to it.
func NewGroundItemFor ¶
func NewGroundItemFor(owner uint64, id, amount, x, y int) *GroundItem
NewGroundItemFor Creates a new ground item with an Owner in the game world and returns a reference to it.
func NewPersistentGroundItem ¶
func NewPersistentGroundItem(id, amount, x, y, respawn int) *GroundItem
NewPersistentGroundItem Returns a new ground item that respawns at a set rate after pickup.
func (*GroundItem) Command ¶
func (i *GroundItem) Command() string
Command Returns the command for this item, or nil if none.
func (*GroundItem) DeltaAmount ¶
func (i *GroundItem) DeltaAmount(o *Item) int
DeltaAmount returns the difference between the amount of o and the amount of the receiver
func (*GroundItem) Price ¶
func (i *GroundItem) Price() Price
Price returns the receivers base price
func (*GroundItem) Remove ¶
func (i *GroundItem) Remove()
Remove removes the ground item from the world.
func (*GroundItem) ScalePrice ¶
func (i *GroundItem) ScalePrice(percent int) int
ScalePrice returns the receivers base price, scaled by percent%.
func (*GroundItem) SpawnedTime ¶
func (i *GroundItem) SpawnedTime() time.Time
SpawnedTime Returns: the time this item was spawned into the game world.
func (*GroundItem) Stackable ¶
func (i *GroundItem) Stackable() bool
Stackable returns true if the items stackable, otherwise returns false.
func (*GroundItem) Visibility ¶
func (i *GroundItem) Visibility() int
Visibility This is a special state attribute to indicate who the receiver item is visible to. Value 0 means the item has expired and is no longer visible to anybody.
Value 1 means the item is visible to only the Owner of it and game administrators(rank=2), e.g if you kill someone or something, this will be the value for the first minute or two after it is created, and then will change to value 2. NOTE: If this is the current value, but the belongsTo attribute is not set e.g nobody owns this item, it will update itself to value 2 prior to when it normally would.
Value 2 means the item is visible to all players. This is the value when e.g the game starts and makes the worlds default item spawns, or an NPC kills a player and they drop their items and/or bones...This is the state that most transient ground items will likely spend the most time in before unsetting the visibility attribute(same as value=0) and thus disappearing.
func (*GroundItem) VisibleTo ¶
func (i *GroundItem) VisibleTo(p *Player) bool
VisibleTo Returns true if the ground item is visible to this player, otherwise returns false.
func (*GroundItem) WieldPos ¶
func (i *GroundItem) WieldPos() int
WieldPos Returns the equip slot for this item, or -1 if none.
type HandlerFunc ¶
HandlerFunc Represents a func that is to be called whenever a connected client receives a specific incoming handlers.
func Handler ¶
func Handler(opcode byte) HandlerFunc
Handler Returns the handlers handler function assigned to this opcode. If it can't be found, returns nil.
type HitSplat ¶
type HitSplat struct { Owner entity.MobileEntity Damage int }
type Inventory ¶
type Inventory struct { List []*Item Owner *Player Capacity int Lock sync.RWMutex // contains filtered or unexported fields }
Inventory Represents an inventory of items in the game.
func (*Inventory) Add ¶
Add Puts an item into the inventory with the specified id and quantity, and returns its index.
func (*Inventory) CanHold ¶
CanHold returns true if this inventory can hold the specified amount of the item with the specified ID
func (*Inventory) CountID ¶
CountID Returns the total amount of all the items with this ID in this inventory.
func (*Inventory) DeathDrops ¶
func (i *Inventory) DeathDrops(keep int) []*GroundItem
DeathDrops returns a list of items to drop upon dying. It decides what to keep using a few simple rules: If the item is stackable, it gets dropped no matter what, even if it is the only item and keep is 3. If the item isn't stackable, the inventory is first sorted by descending BasePrice, and the first `keep` items are sliced off of the top of this sorted list which leaves us with the 30-keep least valuable items.
func (*Inventory) Equipped ¶
Equipped Returns true if the item with the given ID exists and is wielded in this inventory
func (*Inventory) Get ¶
Get Returns a reference to the item at index if it exists, otherwise returns nil.
func (*Inventory) GetByID ¶
GetByID Returns a reference to the item at index if it exists, otherwise returns nil.
func (*Inventory) RemoveAll ¶
RemoveAll Removes all of the items in offer from this inventory, returns count of items removed.
func (*Inventory) RemoveByID ¶
RemoveByID Removes amt items from this inventory by ID, returns the items index if successful, otherwise returns -1
type Item ¶
Item Represents a single item in the game.
func (*Item) DeltaAmount ¶
DeltaAmount returns the difference between the amount of o and the amount of the receiver
func (*Item) ScalePrice ¶
ScalePrice returns the receivers base price, scaled by percent%.
type ItemBubble ¶
type ItemOnPlayerTrigger ¶
type ItemOnPlayerTrigger struct { // Check returns true if this handler should run. Check func(*Item) bool // Action is the function that will run if Check returned true. Action func(*Player, *Player, *Item) }
ItemOnPlayerTrigger A type that defines a callback to run when certain item are used on players, and a predicate to decide whether or not the callback should run
type ItemTrigger ¶
type ItemTrigger struct { // Check returns true if this handler should run. Check func(*Item) bool // Action is the function that will run if Check returned true. Action func(*Player, *Item) }
ItemTrigger A type that defines a callback to run when certain item actions are performed, and a predicate to decide whether or not the callback should run
type Location ¶
type Location struct {
// 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 NewRandomLocation ¶
NewRandomLocation Returns a new random location within the specified bounds. bounds[0] should be lowest corner, and bounds[1] should be the highest corner.
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) DirectionTo ¶
func (Location) EuclideanDistance ¶
func (Location) Hash ¶
This produces a unique hash for each tile possible within the current game world; in this sense, it is a perfect hashing algorithm. If the world ever expands a great deal, this may need to change to accomodate larger values.
func (Location) IsValid ¶
IsValid Returns true if the tile at x,y is within world boundaries, false otherwise.
func (Location) LongestDelta ¶
LongestDelta Returns the largest difference in coordinates between receiver and other
func (Location) LongestDeltaCoords ¶
LongestDeltaCoords returns the number of tiles the coordinates provided
func (Location) Masks ¶
Masks returns appropriate collision bitmasks to check for obstacles on when traversing from this location toward the given x,y coordinates. Returns: [2]byte {verticalMasks, horizontalMasks}
func (Location) Near ¶
EntityWithin Returns true if the other location is within radius tiles of the receiver location, otherwise false.
func (Location) NextTileToward ¶
NextTileToward Returns the next tile toward the final destination of this pathway from currentLocation
func (Location) NextTo ¶
NextTo returns true if we can walk a straight line to target without colliding with any walls or objects, otherwise returns false.
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) ReachableCoords ¶
func (Location) Targetable ¶
Targetable returns true if you are able to see the other location from the receiever location without hitting any obstacles, and you are within range. Otherwise returns false.
func (Location) TheirDeltaX ¶
DeltaY Returns the difference between this locations y coord and the other locations y coord
func (Location) TheirDeltaY ¶
DeltaY Returns the difference between this locations y coord and the other locations y coord
func (Location) Wilderness ¶
func (Location) WithinRange ¶
WithinRange Returns true if the other location is within radius tiles of the receiver location, otherwise false.
func (Location) WithinReach ¶
WithinReach returns true if you are able to physically touch the other person you are so close without obstacles Otherwise returns false.
type Mob ¶
type Mob struct { SyncMask int Prayers [15]bool entity.Entity *entity.AttributeList sync.RWMutex // contains filtered or unexported fields }
Mob Represents a mobile entity within the game world.
func (*Mob) ArmourPoints ¶
ArmourPoints Returns the players armour points.
func (*Mob) AttackPoints ¶
AttackPoints Calculates and returns the accuracy capability of this mob, based on many variables, as a single variable.
func (*Mob) Busy ¶
Busy Returns true if this mobs state is anything other than idle. otherwise returns false.
func (*Mob) CombatRngSrc ¶
func (*Mob) DefensePoints ¶
DefensePoints Calculates and returns the defensive capability of this mob, based on many variables, as a single variable.
func (*Mob) ExperienceReward ¶
ExperienceReward returns the total rewarded experience upon killing a mob.
func (*Mob) FightRound ¶
func (*Mob) FightTarget ¶
func (m *Mob) FightTarget() entity.MobileEntity
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) GenerateHit ¶
GenerateHit returns a normally distributed random number from this mobs PRNG instance, between 1 and max, inclusive. This is widely believed to be how Jagex generated damage hits, and it feels accurate while playing.
func (*Mob) IncAimPoints ¶
func (*Mob) IncArmourPoints ¶
func (*Mob) IncMagicPoints ¶
func (*Mob) IncPowerPoints ¶
func (*Mob) IncPrayerPoints ¶
func (*Mob) IncRangedPoints ¶
func (*Mob) IsFighting ¶
func (*Mob) LastRetreat ¶
func (*Mob) MagicDamage ¶
func (m *Mob) MagicDamage(target entity.MobileEntity, maximum float64) int
MagicDamage Calculates and returns a combat spells damage from the receiver mob cast unto the target MobileEntity. This basically wraps a statistically random percentage check around a call to GenerateHit.
func (*Mob) MagicPoints ¶
MagicPoints Returns the players magic points
func (*Mob) MaxMeleeDamage ¶
MaxMeleeDamage Calculates and returns the current max hit for this mob, based on many variables.
func (*Mob) MeleeDamage ¶
func (m *Mob) MeleeDamage(target entity.MobileEntity) int
MeleeDamage Calculates and returns a melee damage from the receiver mob onto the target mob. This basically wraps a statistically random percentage check around a call to GenerateHit. Generally believed to be a near-perfect approximation of canonical Jagex RSClassic melee damage formula. Kenix mentioned running monte-carlo sims when coming up with it, so presumably this formula matched up statistically fairly well to the real game. I can not say for sure as I didn't do these things myself, though.
func (*Mob) PowerPoints ¶
PowerPoints Returns the players power points.
func (*Mob) PrayerActivated ¶
func (*Mob) PrayerModifiers ¶
func (*Mob) PrayerPoints ¶
PrayerPoints Returns the players prayer points
func (*Mob) Random ¶
Random This generates a pseudo-random integer using a member instance of ISAAC. Note: Generated integers are high-exclusive and low-inclusive.
func (*Mob) RandomIncl ¶
RandomIncl This generates a pseudo-random integer using a member instance of ISAAC. Note: Generated integers are high and low inclusive.
func (*Mob) RangedPoints ¶
RangedPoints Returns the players ranged points.
func (*Mob) RemoveState ¶
func (*Mob) ResetAppearanceChanged ¶
func (m *Mob) ResetAppearanceChanged()
func (*Mob) ResetFighting ¶
func (m *Mob) ResetFighting()
ResetFighting Resets melee fight related variables
func (*Mob) ResetPath ¶
func (m *Mob) ResetPath()
ResetPath Sets the mobs path to nil, to stop the traversal of the path instantly
func (*Mob) ResetRegionMoved ¶
func (m *Mob) ResetRegionMoved()
func (*Mob) ResetRegionRemoved ¶
func (m *Mob) ResetRegionRemoved()
func (*Mob) ResetSpriteUpdated ¶
func (m *Mob) ResetSpriteUpdated()
func (*Mob) ResetState ¶
func (m *Mob) ResetState()
func (*Mob) SessionCache ¶
func (m *Mob) SessionCache() *entity.AttributeList
func (*Mob) SetAimPoints ¶
SetAimPoints Sets the players aim points to i.
func (*Mob) SetAppearanceChanged ¶
func (m *Mob) SetAppearanceChanged()
func (*Mob) SetArmourPoints ¶
SetArmourPoints Sets the players armour points to i.
func (*Mob) SetDirection ¶
SetDirection Sets the mobs direction.
func (*Mob) SetFightMode ¶
SetFightMode Sets the players fightmode to i. 0=all,1=attack,2=defense,3=strength
func (*Mob) SetFightRound ¶
func (*Mob) SetFightTarget ¶
func (m *Mob) SetFightTarget(m2 entity.MobileEntity)
func (*Mob) SetMagicPoints ¶
SetMagicPoints Sets the players magic points to i
func (*Mob) SetPath ¶
SetPath Sets the mob's current pathway to path. If path is nil, effectively resets the mobs path.
func (*Mob) SetPowerPoints ¶
SetPowerPoints Sets the players power points to i
func (*Mob) SetPrayerPoints ¶
SetPrayerPoints Sets the players prayer points to i
func (*Mob) SetRangedPoints ¶
SetRangedPoints Sets the players ranged points tp i.
func (*Mob) SetRegionMoved ¶
func (m *Mob) SetRegionMoved()
UpdateSelf Sets the synchronization flag for whether this mob has moved to true.
func (*Mob) SetRegionRemoved ¶
func (m *Mob) SetRegionRemoved()
SetRegionRemoved Sets the synchronization flag for whether this mob needs to be removed to true.
func (*Mob) SetSpriteUpdated ¶
func (m *Mob) SetSpriteUpdated()
SetSpriteUpdated Sets the synchronization flag for whether this mob changed directions to true.
func (*Mob) Skills ¶
func (m *Mob) Skills() *entity.SkillTable
func (*Mob) StyleBonus ¶
func (*Mob) TargetMob ¶
func (m *Mob) TargetMob() entity.MobileEntity
func (*Mob) TargetPlayer ¶
func (*Mob) UpdateLastFight ¶
func (m *Mob) UpdateLastFight()
func (*Mob) UpdateLastRetreat ¶
func (m *Mob) UpdateLastRetreat()
type MobList ¶
MobList a container type for holding entity.MobileEntitys
func NewMobList ¶
func NewMobList() *MobList
NewMobList returns a pointer to a newly pre-allocated MobList, with an initial capacity of 255.
func (*MobList) Add ¶
func (l *MobList) Add(m entity.MobileEntity) int
Add Adds a entity.MobileEntity to this MobList
func (*MobList) Contains ¶
func (l *MobList) Contains(mob entity.MobileEntity) bool
Size returns the number of mobile entitys entered into this list.
func (*MobList) Range ¶
func (l *MobList) Range(action func(entity.MobileEntity) bool) int
Range Runs action(entity.MobileEntity) for each entity.MobileEntity in the lists collection, until either running out of entries, or action returns true.
type NPC ¶
type NPC struct { Mob ID int StartPoint entity.Location Boundaries [2]entity.Location Steps, Ticks int // contains filtered or unexported fields }
NPC Represents a single non-playable character within the game world.
func NpcNearest ¶
NpcNearest looks for the NPC with the given ID, that is the closest to the given coordinates and then returns it. Returns nil if it can not find an NPC to fit the given description.
func NpcVisibleFrom ¶
NpcVisibleFrom looks for any NPC with the given ID, that is within a 16x16 square surrounding the given coordinates, and then returns it. Returns nil if it can not find an NPC to fit the given parameters.
func (*NPC) Aggressive ¶
Returns true if this NPCs definition has the aggressive hostility bit set.
func (*NPC) Attackable ¶
Returns true if this NPCs definition has the attackable hostility bit set.
func (*NPC) CacheDamage ¶
func (*NPC) Chat ¶
Chat sends chat messages to target and all of target's view area players, with a 1800ms(3 tick) delay between each message.
func (*NPC) ChatIndirect ¶
ChatIndirect sends a chat message to target and all of target's view area players, without any delay.
func (*NPC) DamageFrom ¶
func (*NPC) Killed ¶
func (n *NPC) Killed(killer entity.MobileEntity)
func (*NPC) MeleeDamage ¶
func (n *NPC) MeleeDamage(target entity.MobileEntity) int
func (*NPC) Retreats ¶
Returns true if this NPCs definition has the retreat near death hostility bit set.
func (*NPC) TraversePath ¶
func (n *NPC) 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.
type NpcActionPredicate ¶
NpcActionPredicate A type alias for an NPC related action predicate.
type NpcBlockingTrigger ¶
type NpcTrigger ¶
type NpcTrigger struct { // Check returns true if this handler should run. Check func(*NPC) bool // Action is the function that will run if Check returned true. Action func(*Player, *NPC) }
NpcTrigger A type that defines a callback to run when certain NPC actions are performed, and a predicate to decide whether or not the callback should run
type Object ¶
Object Represents a game object in the world.
func GetObject ¶
GetObject If there is an object at these coordinates, returns it. Otherwise, returns nil.
func ReplaceObject ¶
ReplaceObject Replaces old with a new game object with all of the same characteristics, except it's ID set to newID.
func (*Object) Boundaries ¶
func (*Object) ClipType ¶
ClipType returns a unique identifier representing what kind of collisions with other entities to account for when it is used in-game.
Doors (incl. gates) cause directional blocking only, while open doors do not block, similar to how ferns and signs and portraits and etc; these type of objects cause no blocking of any directions. doors are types 2 for shut and 3 for open
The only other type is a solid object, e.g a chest or a stall or a table, which causes the entire tile(s) this object stands on to be blocked regardless of the origin of the other entity! solid objects are type 1
TODO: type 0 do anything or just a nil-like value?
func (*Object) Command1 ¶
Name checks if an object definition exists for this object, and if so returns the name associated with it.
func (*Object) Height ¶
Height The height measured in game tiles that this object takes up in the game world.
type ObjectTrigger ¶
type ObjectTrigger struct { // Check returns true if this handler should run. Check func(*Object, int) bool // Action is the function that will run if Check returned true. Action func(*Player, *Object, int) }
ObjectTrigger A type that defines a callback to run when certain object actions are performed, and a predicate to decide whether or not the callback should run
type Pathfinder ¶
type Pathfinder struct {
// contains filtered or unexported fields
}
func NewPathfinder ¶
func NewPathfinder(start, end entity.Location) *Pathfinder
NewPathfinder Returns a new A* pathfinder instance to derive an optimal path from start to end.
func (*Pathfinder) MakePath ¶
func (p *Pathfinder) MakePath() *Pathway
type Pathway ¶
type Pathway struct { sync.RWMutex StartX, StartY int WaypointsX []int WaypointsY []int CurrentWaypoint int }
Pathway Represents a path for a mobile entity to traverse across the virtual world.
func MakePath ¶
Returns an optimal path from start location to end location as decided by way of the AStar pathfinding algorithm. If a path isn't found within a certain constrained number of steps, the algorithm returns nil to free up the CPU.
func NewPathway ¶
NewPathway returns a new Pathway with the specified variables. destX and destY are a straight line, and waypoints define turns from that point.
func NewPathwayToCoords ¶
NewPathwayToCoords returns a new Pathway pointing to the specified location. Will attempt traversal to l via a simple algorithm: if curX < destX then increase, if curX > destX then decrease, same for y, until equal.
func NewPathwayToLocation ¶
NewPathwayToLocation returns a new Pathway pointing to the specified location. Will attempt traversal to l via a simple algorithm: if curX < destX then increase, if curX > destX then decrease, same for y, until equal.
type Plane ¶
type Plane = int
Direction represents directions that mobs can face within the game world. Ranges from 1-8
const ( //PlaneGround Represents the value for the ground-level plane PlaneGround Plane = 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 )
type Player ¶
type Player struct { context.Context LocalPlayers *MobList LocalNPCs *MobList LocalObjects *entityList LocalItems *entityList FriendList *social.FriendsList IgnoreList []uint64 Appearance entity.AppearanceTable KnownAppearances map[int]int AppearanceReq []*Player Socket stdnet.Conn Attributes *entity.AttributeList Inventory *Inventory TradeOffer *Inventory DuelOffer *Inventory Duel struct { Rules [4]bool Accepted [2]bool Target *Player Inventory } ActionLock sync.RWMutex ReplyMenuC chan int8 Cancel func() Websocket bool InQueue, OutQueue chan *net.Packet Reader *bufio.Reader Writer net.WriteFlusher DatabaseIndex int OpCiphers [2]*isaac.ISAAC Mob // contains filtered or unexported fields }
Player A player in our game world.
func NewPlayerCtx ¶
NewPlayerCtx Returns a reference to a new player with a parent context.
func (*Player) ActivatePrayer ¶
func (*Player) AddItem ¶
AddItem Adds amount of the item with specified id to the players inventory, if possible, and updates the client about it.
func (*Player) AppearanceTicket ¶
func (*Player) BoolAttribute ¶
func (*Player) Chat ¶
Chat sends a player NPC chat message packet to the player and all other players around it. If multiple msgs are provided, will sleep the goroutine for 3-4 ticks between each message, depending on length of message.
func (*Player) ChatBlocked ¶
ChatBlocked returns true if public chat is blocked for this player.
func (*Player) CloseBank ¶
func (p *Player) CloseBank()
CloseBank closes the bank screen for this player and sets the appropriate state variables
func (*Player) CloseOptionMenu ¶
func (p *Player) CloseOptionMenu()
CloseOptionMenu closes any open option menus.
func (*Player) CloseShop ¶
func (p *Player) CloseShop()
CloseBank closes the bank screen for this player and sets the appropriate state variables
func (*Player) CloseTradeScreens ¶
func (p *Player) CloseTradeScreens()
func (*Player) CombatDelta ¶
func (p *Player) CombatDelta(other entity.MobileEntity) int
CombatDelta returns the difference between our combat level and the other mobs combat level
func (*Player) CurrentShop ¶
func (*Player) Damage ¶
Damage sends a player damage bubble for this player to itself and any nearby players.
func (*Player) DamageFrom ¶
func (*Player) DeactivatePrayer ¶
func (*Player) DequipItem ¶
DequipItem removes an item from this players equips, and sends inventory and equipment bonuses.
func (*Player) Destroy ¶
func (p *Player) Destroy()
Destroy sends a kill signal to the underlying client to tear down all of the I/O routines and save the player. Note: This should probably be ran in its own goroutine as it saves the player to the database.
func (*Player) DistributeMeleeExp ¶
DistributeMeleeExp This is a helper method to distribute experience amongst the players melee stats according to its current fight stance.
If the player is in controlled stance, each melee skill gets (experience). Otherwise, whatever fight stance the player was in will get (experience)*3, and hits will get (experience).
func (*Player) DuelAccepted ¶
DuelAccepted returns the status of the specified duel negotiation screens accepted button for this player. Valid screens are 1 and 2.
func (*Player) DuelBlocked ¶
DuelBlocked returns true if duel requests are blocked for this player.
func (*Player) DuelEquipment ¶
func (*Player) DuelPrayer ¶
func (*Player) DuelRetreating ¶
func (*Player) EquipItem ¶
EquipItem equips an item to this player, and sends inventory and equipment bonuses.
func (*Player) FirstLogin ¶
FirstLogin returns true if this player has never logged in before, otherwise false.
func (*Player) FriendBlocked ¶
FriendBlocked returns true if private chat is blocked for this player.
func (*Player) FriendsWith ¶
FriendsWith returns true if specified username is in our friend entityList.
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) IncCurStat ¶
IncCurStat sets this players current stat at idx to Current(idx)+lvl and updates the client about it.
func (*Player) IncExp ¶
SetCurStat sets this players current stat at idx to lvl and updates the client about it.
func (*Player) Initialize ¶
func (p *Player) Initialize()
Initialize informs the client of all of the various attributes of this player, and starts the stat normalization routine.
func (*Player) IsDueling ¶
IsDueling returns true if this player is negotiating a duel, otherwise returns false.
func (*Player) IsPanelOpened ¶
func (*Player) IsTrading ¶
IsTrading returns true if this player is in a trade, otherwise returns false.
func (*Player) IsWebsocket ¶
func (*Player) ItemBubble ¶
ItemBubble sends an item action bubble for this player to itself and any nearby players.
func (*Player) Killed ¶
func (p *Player) Killed(killer entity.MobileEntity)
Killed kills this player, dropping all of its items where it stands.
func (*Player) NearbyNpcs ¶
NearbyNpcs Returns nearby NPCs.
func (*Player) NearbyObjects ¶
NearbyObjects Returns nearby objects.
func (*Player) NearbyPlayers ¶
NearbyPlayers Returns nearby players.
func (*Player) NewItems ¶
func (p *Player) NewItems() (items []*GroundItem)
NewItems Returns nearby ground items that this player is unaware of.
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) NextToCoords ¶
func (*Player) OpenAppearanceChanger ¶
func (p *Player) OpenAppearanceChanger()
OpenAppearanceChanger If the player is not fighting or trading, opens the appearance window.
func (*Player) OpenBank ¶
func (p *Player) OpenBank()
OpenBank opens a bank screen for the player and sets the appropriate state variables.
func (*Player) OpenDuelConfirm ¶
func (*Player) OpenDuelScreen ¶
func (*Player) OpenOptionMenu ¶
func (*Player) OpenShop ¶
OpenBank opens a shop screen for the player and sets the appropriate state variables.
func (*Player) OpenSleepScreen ¶
func (p *Player) OpenSleepScreen()
func (*Player) OpenTradeConfirmation ¶
func (*Player) OpenTradeScreen ¶
func (*Player) PlaySound ¶
PlaySound sends a command to the client to play a sound by its file name.
func (*Player) ProcPacketsIn ¶
func (p *Player) ProcPacketsIn()
func (*Player) ProcPacketsOut ¶
func (p *Player) ProcPacketsOut()
func (*Player) QuestBroadcast ¶
func (p *Player) QuestBroadcast(owner, target entity.MobileEntity, message string)
QuestBroadcast Broadcasts a string as a message posted into the players quest chat history to the player and any nearby players.
func (*Player) QueueHitsplat ¶
func (p *Player) QueueHitsplat(owner entity.MobileEntity, dmg int)
QueueHitsplat Adds a hit splat to a locked hit-splat queue
func (*Player) QueueItemBubble ¶
QueueItemBubble Adds an action item bubble to a locked item bubble queue
func (*Player) QueueNpcChat ¶
func (p *Player) QueueNpcChat(owner, target entity.MobileEntity, message string)
QueueNpcChat Adds a message to a locked quest-chat queue
func (*Player) QueueNpcSplat ¶
QueueNpcSplat Adds a message to a locked quest-chat queue
func (*Player) QueueProjectile ¶
func (p *Player) QueueProjectile(owner, target entity.MobileEntity, kind int)
QueueProjectile Adds a missile to a locked projectile queue
func (*Player) QueuePublicChat ¶
func (p *Player) QueuePublicChat(owner entity.MobileEntity, message string)
QueuePublicChat Adds a message to a locked public-chat queue
func (*Player) QueueQuestChat ¶
func (p *Player) QueueQuestChat(owner, _ entity.MobileEntity, message string)
QueueQuestChat Adds a message to a locked quest-chat queue Second arg reserved as target for message
func (*Player) Read ¶
Read implements an io.Reader that detects what type of connection the underlying socket is using, and interprets the network byte stream accordingly. Websockets require a lot of extra book-keeping to be used like this, and as such
func (*Player) Reconnecting ¶
Reconnecting returns true if the player is reconnecting, false otherwise.
func (*Player) RemoteAddress ¶
LocalAddress Returns the remote IP:port that this player connected from, or N/A if this player never connected somehow
func (*Player) RemoveCache ¶
func (*Player) ResetAll ¶
func (p *Player) ResetAll()
ResetAll in order, calls ResetFighting, ResetTrade, ResetTickAction, ResetFollowing, and CloseOptionMenu.
func (*Player) ResetAllExceptDueling ¶
func (p *Player) ResetAllExceptDueling()
func (*Player) ResetDuelAccepted ¶
func (p *Player) ResetDuelAccepted()
ResetDuelAccepted Resets receivers duel negotiation settings to indicate that neither screens are accepted.
func (*Player) ResetDuelRules ¶
func (p *Player) ResetDuelRules()
func (*Player) ResetDuelTarget ¶
func (p *Player) ResetDuelTarget()
ResetDuelTarget Removes receivers duel target, if any.
func (*Player) ResetFighting ¶
func (p *Player) ResetFighting()
func (*Player) ResetTickAction ¶
func (p *Player) ResetTickAction()
ResetTickAction clears the distanced action, if any is queued. Should be called any time the player is deliberately performing an action.
func (*Player) ResetTrade ¶
func (p *Player) ResetTrade()
ResetTrade resets trade-related variables.
func (*Player) SendEquipBonuses ¶
func (p *Player) SendEquipBonuses()
SendEquipBonuses sends the current equipment bonuses of this player.
func (*Player) SendInventory ¶
func (p *Player) SendInventory()
SendInventory sends inventory information to this player.
func (*Player) SendMessageBox ¶
func (*Player) SendPlane ¶
func (p *Player) SendPlane()
SendPlane sends the current plane of this player.
func (*Player) SendPrayers ¶
func (p *Player) SendPrayers()
func (*Player) SendStatExp ¶
SendStatExp sends the experience information for the stat at idx to the player.
func (*Player) SendStats ¶
func (p *Player) SendStats()
SendStats sends all stat information to this player.
func (*Player) SendUpdateTimer ¶
func (p *Player) SendUpdateTimer()
SendUpdateTimer sends a system update countdown timer to the client.
func (*Player) ServerSeed ¶
ServerSeed returns the seed for the ISAAC cipher provided by the game for this player, if set, otherwise returns 0
func (*Player) SetClientSetting ¶
SetClientSetting sets the specified client setting to flag.
func (*Player) SetConnected ¶
SetConnected sets the player's connected status to flag.
func (*Player) SetCurStat ¶
SetCurStat sets this players current stat at idx to lvl and updates the client about it.
func (*Player) SetDuelAccepted ¶
DuelAccepted returns the status of the specified duel negotiation screens accepted button for this player. Valid screens are 1 and 2.
func (*Player) SetDuelRule ¶
SetDuelRule sets the duel rule associated with the specified index to b. Valid rule indices are 0 through 3.
func (*Player) SetDuelTarget ¶
SetDuelTarget Sets p1 as the receivers dueling target.
func (*Player) SetFatigue ¶
SetFatigue Sets the players current fatigue to i.
func (*Player) SetFirstLogin ¶
SetFirstLogin sets the player's persistent logged in before status to flag.
func (*Player) SetMaxStat ¶
SetMaxStat sets this players maximum stat at idx to lvl and updates the client about it.
func (*Player) SetPrivacySettings ¶
SetPrivacySettings sets privacy settings to specified values.
func (*Player) SetReconnecting ¶
SetReconnecting sets the player's reconnection status to flag.
func (*Player) SetServerSeed ¶
SetServerSeed sets the player's stored game seed to seed for later comparison to ensure we decrypted the login block properly and the player received the proper seed.
func (*Player) SetSkulled ¶
func (*Player) SetStat ¶
SetStat sets the current, maximum, and experience levels of the skill at idx to lvl, and updates the client about it.
func (*Player) SetTickAction ¶
SetTickAction queues a distanced action to run every game engine tick before path traversal, if action returns true, it will be reset.
func (*Player) SetTradeTarget ¶
SetTradeTarget Sets the variable for the index of the player we are trying to trade
func (*Player) SetTradeTargetAccepted ¶
func (p *Player) SetTradeTargetAccepted()
func (*Player) StartCombat ¶
func (p *Player) StartCombat(defender entity.MobileEntity)
func (*Player) String ¶
String returns a string populated with the more identifying features of this player.
func (*Player) TickAction ¶
func (*Player) TogglePrayer ¶
func (*Player) TradeBlocked ¶
TradeBlocked returns true if trade requests are blocked for this player.
func (*Player) TradeTarget ¶
TradeTarget returns the game index of the player we are trying to trade with, or -1 if we have not made a trade request.
func (*Player) TraversePath ¶
func (p *Player) 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 (*Player) Unregister ¶
func (p *Player) Unregister()
func (*Player) UpdateAppearance ¶
func (p *Player) UpdateAppearance()
func (*Player) UpdateDuel ¶
func (p *Player) UpdateDuel()
func (*Player) UpdateDuelAccept ¶
func (*Player) UpdateDuelSettings ¶
func (p *Player) UpdateDuelSettings()
func (*Player) UpdateRegion ¶
UpdateRegion if this player is currently in a region, removes it from that region, and adds it to the region at x,y
func (*Player) UpdateStatus ¶
func (*Player) UpdateTradeOffer ¶
func (*Player) UpdatedRegions ¶
func (p *Player) UpdatedRegions()
func (*Player) UsernameHash ¶
func (*Player) ViewRadius ¶
func (*Player) WalkingArrivalAction ¶
func (p *Player) WalkingArrivalAction(t entity.MobileEntity, dist int, action func())
WalkingArrivalAction Runs `action` once arriving within dist (min 1 max 2 tiles) of `target` mob, with a straight line of sight, e.g no intersecting boundaries, large objects, walls, etc. Runs everything on game engine ticks, retries until catastrophic failure or success.
func (*Player) WalkingRangedAction ¶
func (p *Player) WalkingRangedAction(t entity.MobileEntity, fn func())
WalkingRangedAction Runs `fn` once arriving anywhere within 5 tiles in any direction of `t`, with a straight line of sight, e.g no intersecting boundaries, large objects, walls, etc. Runs everything on game engine ticks, retries until catastrophic failure or success.
func (*Player) WritePacket ¶
WritePacket sends a net to the client.
type PlayerList ¶
type PlayerList struct { sync.RWMutex PlayersList // contains filtered or unexported fields }
func (*PlayerList) AsyncRange ¶
func (m *PlayerList) AsyncRange(fn func(*Player))
func (*PlayerList) Contains ¶
func (m *PlayerList) Contains(player *Player) bool
Contains Returns true if this player is assigned to a slot in the set, otherwise returns false.
func (*PlayerList) ContainsHash ¶
func (m *PlayerList) ContainsHash(hash uint64) bool
ContainsHash Returns true if there is a client mapped to this username hash is in this collection, otherwise returns false.
func (*PlayerList) Find ¶
func (m *PlayerList) Find(player *Player) int
Find Returns the slot that this player occupies in the set.
func (*PlayerList) FindHash ¶
func (m *PlayerList) FindHash(hash uint64) (*Player, bool)
FindHash Returns the client with the base37 username `hash` if it exists and true, otherwise returns nil and false.
func (*PlayerList) FindIndex ¶
func (m *PlayerList) FindIndex(index int) (*Player, bool)
FromIndex Returns the client with the index `index` if it exists and true, otherwise returns nil and false.
func (*PlayerList) ForEach ¶
func (m *PlayerList) ForEach(action func(*Player) bool) int
Range Calls action for every active client in the collection.
func (*PlayerList) Put ¶
func (m *PlayerList) Put(player *Player)
Put Finds the lowest available empty slot in the list, and puts the player there. This will also assign the players server index variable (*Player.Index) to the assigned slot.
func (*PlayerList) Range ¶
func (m *PlayerList) Range(action func(*Player))
Range Calls action for every active client in the collection.
func (*PlayerList) Remove ¶
func (m *PlayerList) Remove(player *Player)
Remove Removes a client from the set.
func (*PlayerList) Set ¶
func (m *PlayerList) Set() []*Player
func (*PlayerList) Size ¶
func (m *PlayerList) Size() int
Size Returns the size of the active client collection.
type PlayerService ¶
type PlayerService interface {
PlayerSave(*Player)
}
var DefaultPlayerService PlayerService
type PlayersList ¶
type PlayersList map[*Player]struct{}
type Price ¶
type Price int
Price type alias for item prices
func (Price) Scale ¶
Scale Calculates and returns the value for the requested percentage of the receiver price.
In other words, for sleeping bag with basePrice=30
player.Inventory.GetByID(1263).PriceScaled(100)
would be 30 and is the same as calling Price(). Any percent that is higher than 100 will scale the price up. E.g:
player.Inventory.GetByID(1263).PriceScaled(130)
would be 39; since 130%(??) of the base price is the value we want, to reach that from the base price(100%(30)), we can add 30%(9) to the base price(100%(30)), which gives us 130%(39), the value we want.
This is the same way RSC general stores priced items they sold. Additionally, though,
Any percent that is lower than 100 will scale the price down. E.g:
player.Inventory.GetByID(1263).PriceScaled(40)
would be 12. Since 40%(??) of the base price is our target, to reach that from 100%(30), we subtract 60%(18) from it. This is the same percentage used for RSC general stores initial sale prices. , we'd. is how we mimic canonical RSClassic general store pricing.
Upper bound for percent intended to basically not exist; in practice it's limited by the data type of the argument. Lower bound for percent is 10, anything lower will be treated as if it were 10%.
type Projectile ¶
type Projectile struct { Kind int Owner entity.MobileEntity Target entity.MobileEntity }
func NewProjectile ¶
func NewProjectile(owner, target entity.MobileEntity, kind int) Projectile
type Sector ¶
type Sector struct {
Tiles [2304]CollisionMask
}
Sector Represents a sector of 48x48(2304) tiles in the game's landscape.
type Shop ¶
type Shop struct { // True if this shop deals in unstocked items the player wants to sell, otherwise false. BuysUnstocked bool // The shop's base percentage at which it buys items from players. BasePurchasePercent int // The shop's base percentage at which it sells items to players. BaseSalePercent int // Contains all of the initial shop items that are always restocked and available, and their initial amounts. // Never change the contents of this unless you want to add permanently restocking items to a shop or something like that. Stock *ShopItems // Contains all of the active shop items and may differ greatly from Stock, but it can never remove things that are // in Stock entirely from itself(they will remain with Amount=0), and occasionally it normalizes itself, referencing // Stock for the normal amounts to replenish toward, and the default IDs of what items to replenish. Inventory *ShopItems // Descriptive name for this shop. Name string // List of players actively using the shop Players *MobList }
func NewGeneralShop ¶
Creates a new general shop, and adds it automatically to the world-local ShopContainer instance before returning it
Returns: Shops.get(name), after building and adding a new general shop to it, using a generic general shop definition.
func NewShop ¶
NewShop creates a new Shop instance using the arguments provided, and returns it.
Returns: a new Shop instance, made with the given arguments
func (*Shop) AppraiseItem ¶
func (*Shop) DeltaPercentMod ¶
DeltaPercentMod calculates the percentage to scale the item's price up or down from its respective base percentage. The formula simply subtracts the shop's base stocked amount of item from item's amount, and multiplies the difference by ShopNormalDeltaRate.
func (*Shop) DeltaPercentModID ¶
type ShopContainer ¶
func (*ShopContainer) Add ¶
func (s *ShopContainer) Add(name string, shop *Shop)
func (*ShopContainer) Contains ¶
func (s *ShopContainer) Contains(name string) bool
func (*ShopContainer) Get ¶
func (s *ShopContainer) Get(name string) *Shop
func (*ShopContainer) Range ¶
func (s *ShopContainer) Range(fn func(*Shop))
func (*ShopContainer) Remove ¶
func (s *ShopContainer) Remove(name string)
type ShopItems ¶
func (*ShopItems) Clone ¶
Clone will make a new ShopItems collection populated with clones of the values in the existing collection set. Very useful to easily define an initial inventory and stock when defining a shop.
func (*ShopItems) Contains ¶
Ensures safe access when requesting whether this collection contains a specific item by ID.
Returns: true if this shop items collection has any items with the provided ID, otherwise returns false.
func (*ShopItems) Count ¶
Ensures safe access when requesting the current count of a specific item by ID in this shops inventory.
Returns: the inventorys amount of the specified item id, or 0 is no items matched this ID.