Documentation
¶
Index ¶
- Constants
- func AddSkillBuff(skillID int32, bits ...int)
- func GenerateCashID() int64
- func LoadBuffs()
- func NewCharacterBuffs(p *Player)
- func StopSaver()
- type BuffSnapshot
- type CharacterBuffs
- func (cb *CharacterBuffs) AddBuff(charId, skillID int32, level byte, foreign bool, delay int16)
- func (cb *CharacterBuffs) AddBuffFromCC(charId, skillID int32, expiresAtMs int64, level byte, foreign bool, ...)
- func (cb *CharacterBuffs) AddItemBuff(meta nx.Item, sourceID int32)
- func (cb *CharacterBuffs) AddItemBuffFromCC(itemID int32, expiresAtMs int64)
- func (cb *CharacterBuffs) AddMobDebuff(skillID, level byte, durationSec int16)
- func (cb *CharacterBuffs) AuditAndExpireStaleBuffs()
- func (cb *CharacterBuffs) HasGMHide() bool
- func (cb *CharacterBuffs) HasHolySymbol(memberCount int) (bool, int)
- func (cb *CharacterBuffs) RestoreFromSnapshot(snaps []BuffSnapshot)
- func (cb *CharacterBuffs) Snapshot() []BuffSnapshot
- type DirtyBits
- type Flag
- type Item
- func (v Item) GetAmount() int16
- func (v Item) GetCashID() int64
- func (v Item) GetCashSN() int32
- func (v Item) GetExpireTime() int64
- func (v Item) InventoryBytes() []byte
- func (v Item) SaveToCashShopStorage(tx *sql.Tx, accountID int32, slotNumber int16) error
- func (v *Item) SetCashID(cashID int64)
- func (v *Item) SetCashSN(sn int32)
- func (v Item) ShortBytes() []byte
- func (v Item) StorageBytes() []byte
- type Player
- func (p *Player) CanReceiveItems(items []Item) bool
- func (d *Player) FlushNow()
- func (d *Player) GetAccountName() string
- func (d *Player) GetItem(invID byte, slotID int16) (Item, error)
- func (d *Player) GetItemByCashID(invID byte, cashID int64) (Item, int16, error)
- func (d *Player) GetMaplePoints() int32
- func (d *Player) GetNX() int32
- func (d *Player) GetSlotSize(invID byte) int16
- func (d *Player) GiveItem(newItem Item) (error, Item)
- func (d *Player) IncreaseSlotSize(invID, amount byte) error
- func (d Player) Logout()
- func (d *Player) MarkDirty(bits DirtyBits, debounce time.Duration)
- func (d *Player) SeedRNGDeterministic()
- func (d *Player) Send(packet mpacket.Packet)
- func (d *Player) SetMaplePoints(points int32)
- func (d *Player) SetNX(nx int32)
- func (d *Player) SetPos(pos pos)
- func (d *Player) TakeItemForStorage(id int32, slot int16, amount int16, invID byte) (Item, error)
- func (d *Player) UpdateMovement(frag movementFrag)
- func (plr *Player) WriteCharacterInfoPacket(p *mpacket.Packet)
- type Players
- type Server
- func (server *Server) CheckpointAll()
- func (server *Server) ClientDisconnected(conn mnet.Client)
- func (server *Server) HandleClientPacket(conn mnet.Client, reader mpacket.Reader)
- func (server *Server) HandleServerPacket(conn mnet.Server, reader mpacket.Reader)
- func (server *Server) Initialise(work chan func(), ...)
- func (server *Server) RegisterWithWorld(conn mnet.Server, ip []byte, port int16, maxPop int16)
- func (server *Server) SendCountdownToPlayers(t int32)
- func (server *Server) SendLostWorldConnectionMessage()
- func (server *Server) StartAutosave(ctx context.Context)
Constants ¶
const ( // Byte 1 (bits 0..7) BuffWeaponAttack = 0 BuffWeaponDefense = 1 BuffMagicAttack = 2 BuffMagicDefense = 3 BuffAccuracy = 4 BuffAvoidability = 5 BuffHands = 6 BuffSpeed = 7 // Byte 2 (bits 8..15) BuffJump = 8 BuffMagicGuard = 9 BuffDarkSight = 10 BuffBooster = 11 BuffPowerGuard = 12 BuffMaxHP = 13 BuffMaxMP = 14 BuffInvincible = 15 // Byte 3 (bits 16..23) BuffSoulArrow = 16 BuffStun = 17 BuffPoison = 18 BuffSeal = 19 BuffDarkness = 20 BuffComboAttack = 21 BuffCharges = 22 BuffDragonBlood = 23 // Byte 4 (bits 24..31) BuffHolySymbol = 24 BuffMesoUP = 25 BuffShadowPartner = 26 BuffPickPocketMesoUP = 27 BuffMesoGuard = 28 BuffThaw = 29 BuffWeakness = 30 BuffCurse = 31 )
BuffValueTypes now represent bit positions, not bitmasks.
const ( Ver_1 = 32 Ver_14 = 64 Default = Ver_14 // Most common versions used are UINT128. )
Version/collection bit lengths
Variables ¶
This section is empty.
Functions ¶
func AddSkillBuff ¶
AddSkillBuff registers one or more Flag bit positions for a skill.
func GenerateCashID ¶ added in v0.0.38
func GenerateCashID() int64
GenerateCashID generates a unique cash ID using crypto/rand
func NewCharacterBuffs ¶
func NewCharacterBuffs(p *Player)
Types ¶
type BuffSnapshot ¶
type CharacterBuffs ¶
type CharacterBuffs struct {
// contains filtered or unexported fields
}
func (*CharacterBuffs) AddBuff ¶
func (cb *CharacterBuffs) AddBuff(charId, skillID int32, level byte, foreign bool, delay int16)
func (*CharacterBuffs) AddBuffFromCC ¶
func (*CharacterBuffs) AddItemBuff ¶
func (cb *CharacterBuffs) AddItemBuff(meta nx.Item, sourceID int32)
durationSec is the client-visible remaining time in seconds. Source ID is encoded as -Item.ID.
func (*CharacterBuffs) AddItemBuffFromCC ¶
func (cb *CharacterBuffs) AddItemBuffFromCC(itemID int32, expiresAtMs int64)
func (*CharacterBuffs) AddMobDebuff ¶
func (cb *CharacterBuffs) AddMobDebuff(skillID, level byte, durationSec int16)
AddMobDebuff applies a debuff from a mob skill to the player
func (*CharacterBuffs) AuditAndExpireStaleBuffs ¶
func (cb *CharacterBuffs) AuditAndExpireStaleBuffs()
func (*CharacterBuffs) HasGMHide ¶
func (cb *CharacterBuffs) HasGMHide() bool
func (*CharacterBuffs) HasHolySymbol ¶ added in v0.0.20
func (cb *CharacterBuffs) HasHolySymbol(memberCount int) (bool, int)
func (*CharacterBuffs) RestoreFromSnapshot ¶
func (cb *CharacterBuffs) RestoreFromSnapshot(snaps []BuffSnapshot)
func (*CharacterBuffs) Snapshot ¶
func (cb *CharacterBuffs) Snapshot() []BuffSnapshot
type DirtyBits ¶
type DirtyBits uint64
DirtyBits mark which character columns need persisting.
const ( DirtyAP DirtyBits = 1 << iota DirtySP DirtyMesos DirtyHP DirtyMP DirtyMaxHP DirtyMaxMP DirtyEXP DirtyMap DirtyPrevMap DirtyJob DirtyLevel DirtyStr DirtyDex DirtyInt DirtyLuk DirtyFame DirtyInvSlotSizes DirtyMiniGame DirtyBuddySize DirtySkills DirtyNX DirtyMaplePoints DirtyPet DirtyTeleportRocks )
type Flag ¶
type Flag []uint32
Flag is a bitset stored as 32-bit words (most significant bits at lower indices).
func NewFlagBits ¶
NewFlagBits constructs a Flag with exactly uBits capacity.
func (*Flag) SetBitNumber ¶
SetBitNumber sets a specific bit to 0 or 1. Bits are addressed MSB-first per 32-bit word.
func (*Flag) SetValue ¶
SetValue assigns a scalar 32-bit value to the least significant word, zeroing all higher words (mirrors Java).
func (*Flag) ToByteArray ¶
ToByteArray returns the byte representation identical to the Java code. If bNewVer is false, it writes bytes in a "reverse fill" big-endian order across the entire array (matching Java's decrementing uLen fill). If bNewVer is true, it writes each 32-bit word in little-endian order, from last word to first.
func (*Flag) ToByteArrayEx ¶
ToByteArrayEx is the "reverse" of ToByteArray: it outputs per-word little-endian bytes, iterating from the end towards the beginning.
type Item ¶
type Item struct {
ID int32
// contains filtered or unexported fields
}
func CreateItemFromDBValues ¶ added in v0.0.38
func CreateItemFromDBValues(itemID int32, slotID int16, amount int16, flag int16, upgradeSlots, scrollLevel byte, str, dex, intt, luk, hp, mp, watk, matk, wdef, mdef, accuracy, avoid, hands, speed, jump int16, expireTime int64, creatorName string) (Item, error)
CreateItemFromDBValues creates an Item from database values, used for loading saved items This preserves all stat modifications, scrolls, etc. from the database
func (Item) GetExpireTime ¶ added in v0.0.38
func (Item) InventoryBytes ¶
InventoryBytes to display in character inventory window
func (Item) SaveToCashShopStorage ¶ added in v0.0.38
func (*Item) SetCashID ¶ added in v0.0.38
SetCashID sets the cash shop storage ID for tracking items from cash shop
func (*Item) SetCashSN ¶ added in v0.0.38
SetCashSN sets the commodity serial number for cash shop items
func (Item) ShortBytes ¶ added in v0.0.38
ShortBytes e.g. inventory operation, storage window
func (Item) StorageBytes ¶ added in v0.0.38
type Player ¶
type Player struct {
Conn mnet.Client
ID int32 // Unique identifier of the character
ChannelID byte
Name string
UpdatePartyInfo updatePartyInfoFunc
// contains filtered or unexported fields
}
func (*Player) CanReceiveItems ¶ added in v0.0.31
CanReceiveItems reports whether the player has enough free slots for all given items.
func (*Player) GetAccountName ¶
func (*Player) GetItem ¶ added in v0.0.38
GetItem retrieves an item from the player's inventory (exported for use by other packages)
func (*Player) GetItemByCashID ¶ added in v0.0.38
GetItemByCashID finds an item in the specified inventory by its cash shop ID
func (*Player) GetMaplePoints ¶
func (*Player) GetSlotSize ¶ added in v0.0.15
func (*Player) IncreaseSlotSize ¶ added in v0.0.15
func (Player) Logout ¶
func (d Player) Logout()
Logout flushes coalesced state and does a full checkpoint save.
func (*Player) SeedRNGDeterministic ¶
func (d *Player) SeedRNGDeterministic()
SeedRNGDeterministic seeds the per-Player RNG using stable identifiers so gain sequences are reproducible across restarts and processes.
func (*Player) SetMaplePoints ¶
func (*Player) TakeItemForStorage ¶ added in v0.0.38
func (*Player) UpdateMovement ¶
func (d *Player) UpdateMovement(frag movementFrag)
UpdateMovement - update Data from position data
func (*Player) WriteCharacterInfoPacket ¶
type Players ¶ added in v0.0.5
type Players struct {
// contains filtered or unexported fields
}
func NewPlayers ¶ added in v0.0.5
func NewPlayers() Players
func (Players) GetFromConn ¶ added in v0.0.5
func (Players) GetFromName ¶ added in v0.0.5
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server state
func (*Server) CheckpointAll ¶
func (server *Server) CheckpointAll()
CheckpointAll now uses the saver to flush debounced/coalesced deltas for every Player.
func (*Server) ClientDisconnected ¶
ClientDisconnected from server
func (*Server) HandleClientPacket ¶
func (*Server) HandleServerPacket ¶
func (*Server) Initialise ¶
func (server *Server) Initialise(work chan func(), dbuser, dbpassword, dbaddress, dbport, dbdatabase, dropsJson, reactorJson, reactorDropsJson string)
Initialise the server
func (*Server) RegisterWithWorld ¶
RegisterWithWorld server
func (*Server) SendCountdownToPlayers ¶
SendCountdownToPlayers - Send a countdown to players that appears as a clock
func (*Server) SendLostWorldConnectionMessage ¶
func (server *Server) SendLostWorldConnectionMessage()
SendLostWorldConnectionMessage - Send message to players alerting them of whatever they do it won't be saved
func (*Server) StartAutosave ¶
startAutosave periodically flushes deltas via the saver.