Documentation ¶
Index ¶
- Constants
- Variables
- func Register(identifier string, obj ObjectLike)
- func RegisterSpawnFunc(f func(string) Visible)
- func ReleaseZone(z *Zone)
- func SaveAllZones()
- func SaveConvert(o ObjectLike) interface{}
- func Think()
- type ActionSchedule
- type AdminLike
- type BaseModule
- type Combat
- type CombatObject
- func (o *CombatObject) Actions(player PlayerLike) []string
- func (o *CombatObject) Die()
- func (o *CombatObject) Examine() (string, [][][2]string)
- func (o *CombatObject) Health() *big.Int
- func (o *CombatObject) Hurt(amount *big.Int, attacker Combat)
- func (o *CombatObject) Interact(player PlayerLike, action string)
- func (o *CombatObject) Load(version uint, data interface{}, attached []ObjectLike)
- func (o *CombatObject) MaxHealth() *big.Int
- func (o *CombatObject) MaxQuality() *big.Int
- func (o *CombatObject) Save() (uint, interface{}, []ObjectLike)
- func (o *CombatObject) SetHealth(health *big.Int)
- func (o *CombatObject) Stat(stat Stat) *big.Int
- func (o *CombatObject) Think()
- type CombatSchedule
- type DelaySchedule
- type GuardDogModule
- type Instance
- type InventoryLike
- type Item
- type Living
- type LivingObject
- func (o *LivingObject) Actions(player PlayerLike) []string
- func (o *LivingObject) ClearSchedule()
- func (o *LivingObject) HasSchedule() bool
- func (o *LivingObject) Interact(player PlayerLike, action string)
- func (o *LivingObject) Load(version uint, data interface{}, attached []ObjectLike)
- func (o *LivingObject) Save() (uint, interface{}, []ObjectLike)
- func (o *LivingObject) ScheduleTarget() ObjectLike
- func (o *LivingObject) SetSchedule(s Schedule)
- func (o *LivingObject) Think()
- type Module
- type NoSaveObject
- type Object
- type ObjectLike
- type PlayerLike
- type Schedule
- type ScheduleSchedule
- type SendMessageLike
- type SetHUDLike
- type Stat
- type StatLike
- type StationaryModule
- type Tile
- type Visible
- type VisibleObject
- func (o *VisibleObject) Actions(player PlayerLike) []string
- func (o *VisibleObject) AnimationType() string
- func (o *VisibleObject) Attached() []Visible
- func (o *VisibleObject) Blocking() bool
- func (o *VisibleObject) Colors() []string
- func (o *VisibleObject) Examine() (string, [][][2]string)
- func (o *VisibleObject) ExtraBlock() [][2]int8
- func (o *VisibleObject) Interact(player PlayerLike, action string)
- func (o *VisibleObject) Name() string
- func (o *VisibleObject) NetworkID() uint64
- func (o *VisibleObject) Scale() uint
- func (o *VisibleObject) Sprite() string
- func (o *VisibleObject) SpritePos() (uint, uint)
- func (o *VisibleObject) SpriteSize() (uint, uint)
- type WandererModule
- type Zone
- func (z *Zone) AddListener(l *ZoneListener)
- func (z *Zone) Chat(sender Visible, message string)
- func (z *Zone) Damage(attacker, victim Combat, amount *big.Int)
- func (z *Zone) Impersonate(player PlayerLike, o Visible)
- func (z *Zone) Path(start *Tile, end *Tile, stopEarly bool) [][2]uint8
- func (z *Zone) RemoveListener(l *ZoneListener)
- func (z *Zone) Tile(x, y uint8) *Tile
- func (z *Zone) Update(t *Tile, obj ObjectLike)
- type ZoneListener
Constants ¶
const MAX_BLOCK_RADIUS int8 = 2
const TuningEquipSlotCount = 14
Variables ¶
var ( DamageMissed = big.NewInt(0) DamageBlocked = big.NewInt(0) DamageResisted = big.NewInt(0) )
var ( TuningMaxStat = big.NewInt(1000) TuningMetaStatDivisor = big.NewInt(2) TuningMinCrit = big.NewInt(-5) TuningMaxCrit = big.NewInt(35) TuningCritDivisor = big.NewInt(20 * TuningEquipSlotCount) TuningResistDivisor = big.NewInt(4000 * TuningEquipSlotCount) TuningDamageMiss1 = int64(10) TuningDamageHit = int64(85) TuningDamageMiss2 = int64(95) TuningDamageMax = big.NewInt(100) TuningCritMultiplier = big.NewInt(3) TuningHealthMultiplier = big.NewInt(5) TuningHealthRegenDivisorCombat = big.NewInt(500) TuningHealthRegenDivisorNonCombat = big.NewInt(100) TuningManaMultiplier = big.NewInt(4) TuningManaRegenDivisorCombat = big.NewInt(500) TuningManaRegenDivisorNonCombat = big.NewInt(100) TuningDefaultStatQuality = big.NewInt(1) TuningDefaultStat = map[Stat]*big.Int{ StatMana: big.NewInt(500), StatManaRegen: big.NewInt(500), StatHealth: big.NewInt(1000), StatHealthRegen: big.NewInt(500), StatMeleeDamage: big.NewInt(500), StatMeleeArmor: big.NewInt(500), StatCritChance: big.NewInt(100), StatResistance: big.NewInt(100), } TuningNodeScoreMultiplier = big.NewInt(500) TuningMaxGatherVolume = big.NewInt(10000) )
Functions ¶
func Register ¶
func Register(identifier string, obj ObjectLike)
func RegisterSpawnFunc ¶
func ReleaseZone ¶
func ReleaseZone(z *Zone)
func SaveAllZones ¶
func SaveAllZones()
func SaveConvert ¶
func SaveConvert(o ObjectLike) interface{}
Types ¶
type ActionSchedule ¶
func (*ActionSchedule) ShouldSave ¶
func (s *ActionSchedule) ShouldSave() bool
func (*ActionSchedule) Target ¶
func (s *ActionSchedule) Target() ObjectLike
type BaseModule ¶
type BaseModule struct { Object // contains filtered or unexported fields }
BaseModule implements the Module interface.
func (*BaseModule) ChooseSchedule ¶
func (m *BaseModule) ChooseSchedule() Schedule
func (*BaseModule) NotifyOwner ¶
func (m *BaseModule) NotifyOwner(owner Living)
func (*BaseModule) Owner ¶
func (m *BaseModule) Owner() Living
type CombatObject ¶
type CombatObject struct { LivingObject // contains filtered or unexported fields }
func (*CombatObject) Actions ¶
func (o *CombatObject) Actions(player PlayerLike) []string
func (*CombatObject) Die ¶
func (o *CombatObject) Die()
func (*CombatObject) Examine ¶
func (o *CombatObject) Examine() (string, [][][2]string)
func (*CombatObject) Health ¶
func (o *CombatObject) Health() *big.Int
func (*CombatObject) Interact ¶
func (o *CombatObject) Interact(player PlayerLike, action string)
func (*CombatObject) Load ¶
func (o *CombatObject) Load(version uint, data interface{}, attached []ObjectLike)
func (*CombatObject) MaxHealth ¶
func (o *CombatObject) MaxHealth() *big.Int
func (*CombatObject) MaxQuality ¶
func (o *CombatObject) MaxQuality() *big.Int
func (*CombatObject) Save ¶
func (o *CombatObject) Save() (uint, interface{}, []ObjectLike)
func (*CombatObject) SetHealth ¶
func (o *CombatObject) SetHealth(health *big.Int)
func (*CombatObject) Think ¶
func (o *CombatObject) Think()
type CombatSchedule ¶
func (*CombatSchedule) ShouldSave ¶
func (s *CombatSchedule) ShouldSave() bool
func (*CombatSchedule) Target ¶
func (s *CombatSchedule) Target() ObjectLike
type DelaySchedule ¶
func (*DelaySchedule) ShouldSave ¶
func (s *DelaySchedule) ShouldSave() bool
func (*DelaySchedule) Target ¶
func (s *DelaySchedule) Target() ObjectLike
type GuardDogModule ¶
type GuardDogModule struct { BaseModule // contains filtered or unexported fields }
Guard dog - Move to a specific tile, which does not change location after it is set.
func (*GuardDogModule) ChooseSchedule ¶
func (m *GuardDogModule) ChooseSchedule() Schedule
func (*GuardDogModule) Load ¶
func (m *GuardDogModule) Load(version uint, data interface{}, attached []ObjectLike)
func (*GuardDogModule) Save ¶
func (m *GuardDogModule) Save() (uint, interface{}, []ObjectLike)
type InventoryLike ¶
type Living ¶
type Living interface { Visible HasSchedule() bool ScheduleTarget() ObjectLike SetSchedule(Schedule) ClearSchedule() }
type LivingObject ¶
type LivingObject struct { VisibleObject // contains filtered or unexported fields }
func SpawnModules ¶
func SpawnModules(s string) (LivingObject, string)
func (*LivingObject) Actions ¶
func (o *LivingObject) Actions(player PlayerLike) []string
func (*LivingObject) ClearSchedule ¶
func (o *LivingObject) ClearSchedule()
func (*LivingObject) HasSchedule ¶
func (o *LivingObject) HasSchedule() bool
func (*LivingObject) Interact ¶
func (o *LivingObject) Interact(player PlayerLike, action string)
func (*LivingObject) Load ¶
func (o *LivingObject) Load(version uint, data interface{}, attached []ObjectLike)
func (*LivingObject) Save ¶
func (o *LivingObject) Save() (uint, interface{}, []ObjectLike)
func (*LivingObject) ScheduleTarget ¶
func (o *LivingObject) ScheduleTarget() ObjectLike
func (*LivingObject) SetSchedule ¶
func (o *LivingObject) SetSchedule(s Schedule)
func (*LivingObject) Think ¶
func (o *LivingObject) Think()
type Module ¶
type Module interface { ObjectLike ChooseSchedule() Schedule Owner() Living NotifyOwner(Living) // contains filtered or unexported methods }
type NoSaveObject ¶
type NoSaveObject interface {
SaveSelf()
}
type Object ¶
type Object struct {
// contains filtered or unexported fields
}
Object implements ObjectLike.
func (*Object) Load ¶
func (o *Object) Load(version uint, data interface{}, attached []ObjectLike)
Load unserializes the data returned from a previous call to Save. On unrecoverable errors, it is recommended to panic.
func (*Object) NotifyPosition ¶
NotifyPosition is called whenever the tile containing the object changes. Either argument may be nil.
func (*Object) Outer ¶
func (o *Object) Outer() ObjectLike
Outer returns the object given as an argument to InitObject.
func (*Object) Save ¶
func (o *Object) Save() (uint, interface{}, []ObjectLike)
Save returns a serialized version of this object. The data may contain primitives, []interface{}, map[string]interface{}, time.Time, and *big.Int. Sub-objects and objects owned by this object should be returned in the third argument.
type ObjectLike ¶
type ObjectLike interface { // NotifyPosition is called whenever the tile containing the object // changes. Either argument may be nil. NotifyPosition(old, new *Tile) // Outer returns the object given as an argument to InitObject. Outer() ObjectLike // Position returns the tile containing this object. Position() *Tile // Think is called every tick (200ms) for objects that are in a zone. Think() // Save returns a serialized version of this object. The data may // contain primitives, []interface{}, map[string]interface{}, time.Time, // and *big.Int. Sub-objects and objects owned by this object should // be returned in the third argument. Save() (version uint, data interface{}, attached []ObjectLike) // Load unserializes the data returned from a previous call to Save. // On unrecoverable errors, it is recommended to panic. Load(version uint, data interface{}, attached []ObjectLike) // contains filtered or unexported methods }
ObjectLike is the base interface which all persistent game objects extend.
func InitObject ¶
func InitObject(obj ObjectLike) ObjectLike
InitObject sets the value returned by ObjectLike.Outer. Objects should only be initialized before they are inserted into the world.
func LoadConvert ¶
func LoadConvert(c interface{}) ObjectLike
type PlayerLike ¶
type PlayerLike interface { Combat InventoryLike SendMessageLike AdminLike SetHUDLike Instance(*Tile) Instance Weight() uint64 WeightMax() uint64 Volume() uint64 VolumeMax() uint64 }
type Schedule ¶
type Schedule interface { ObjectLike // Act returns the number of ticks the object should wait before // calling Act again. 0 means to call Act on the next tick. // Returning false for the second value cancels the schedule. Act(Living) (uint, bool) // ShouldSave returns false if this schedule is impossible to save (for // example if it requires a pointer to another object). ShouldSave() bool // Target returns the target of this schedule, or nil if this schedule // does not target an object. Target() ObjectLike }
type ScheduleSchedule ¶
func (*ScheduleSchedule) ShouldSave ¶
func (s *ScheduleSchedule) ShouldSave() bool
func (*ScheduleSchedule) Target ¶
func (s *ScheduleSchedule) Target() ObjectLike
type SendMessageLike ¶
type SetHUDLike ¶
type Stat ¶
type Stat uint16
const ( // combination StatPower Stat = 0<<8 + iota // melee damage, melee armor StatMagic // magic damage, magic armor StatAgility // attack speed, move speed StatLuck // crit chance, resist chance StatIntelligence // mana, mana regen StatStamina // health, health regen StatIntegrity // gathering, structure health // offensive StatMeleeDamage Stat = 1<<8 + iota // increases max hit (melee) StatMagicDamage // increases max hit (magic) StatMana // increases max mana StatManaRegen // increases mana gained per tick StatCritChance // increases the range considered critical and decreases the range considered noncritical StatAttackSpeed // decreases the number of ticks between auto-attacks // defensive StatMeleeArmor Stat = 2<<8 + iota // increases max damage soaking (melee) StatMagicArmor // increases max damage soaking (magic) StatHealth // increases max health StatHealthRegen // increases health gained per tick StatResistance // increases the chance of evading an incoming attack StatMovementSpeed // increases the weight cap // other StatGathering Stat = 3<<8 + iota // increases output from resource nodes StatStructureHealth // increases durability of structures )
type StationaryModule ¶
type StationaryModule struct {
BaseModule
}
Stationary - Do not move.
func (*StationaryModule) ChooseSchedule ¶
func (m *StationaryModule) ChooseSchedule() Schedule
type Tile ¶
type Tile struct {
// contains filtered or unexported fields
}
func (*Tile) Add ¶
func (t *Tile) Add(obj ObjectLike)
func (*Tile) Move ¶
func (t *Tile) Move(obj ObjectLike, to *Tile)
Move an object from this tile to another tile. Cross-zone movement is not performed by this function. Instead, Remove the object from this tile and Add it to the other.
func (*Tile) Objects ¶
func (t *Tile) Objects() []ObjectLike
func (*Tile) Remove ¶
func (t *Tile) Remove(obj ObjectLike) bool
Remove an object from this tile. Returns true if the object was found.
type Visible ¶
type Visible interface { ObjectLike NetworkID() uint64 // Name is the user-visible name of this object. Title Case is used for // important living objects. All other objects are fully lowercase. Name() string Examine() (string, [][][2]string) // Sprite is sent to the client as the name of the image (minus ".png" // extension) to use as a sprite sheet. Sprite() string // SpriteSize is the height and width of each sprite on this object's // sprite sheet. SpriteSize() (uint, uint) // AnimationType returns a string defined in client code. Empty string // means no animation. AnimationType() string // SpritePos is the position of the base sprite in the sprite sheet. // Each color increases the y value on the client, and each animation // frame increases the x value. SpritePos() (uint, uint) Scale() uint Colors() []string Attached() []Visible Blocking() bool ExtraBlock() [][2]int8 Actions(PlayerLike) []string Interact(PlayerLike, string) }
type VisibleObject ¶
type VisibleObject struct { Object // contains filtered or unexported fields }
func (*VisibleObject) Actions ¶
func (o *VisibleObject) Actions(player PlayerLike) []string
func (*VisibleObject) AnimationType ¶
func (o *VisibleObject) AnimationType() string
func (*VisibleObject) Attached ¶
func (o *VisibleObject) Attached() []Visible
func (*VisibleObject) Blocking ¶
func (o *VisibleObject) Blocking() bool
func (*VisibleObject) Colors ¶
func (o *VisibleObject) Colors() []string
func (*VisibleObject) Examine ¶
func (o *VisibleObject) Examine() (string, [][][2]string)
func (*VisibleObject) ExtraBlock ¶
func (o *VisibleObject) ExtraBlock() [][2]int8
func (*VisibleObject) Interact ¶
func (o *VisibleObject) Interact(player PlayerLike, action string)
func (*VisibleObject) Name ¶
func (o *VisibleObject) Name() string
func (*VisibleObject) NetworkID ¶
func (o *VisibleObject) NetworkID() uint64
func (*VisibleObject) Scale ¶
func (o *VisibleObject) Scale() uint
func (*VisibleObject) Sprite ¶
func (o *VisibleObject) Sprite() string
func (*VisibleObject) SpritePos ¶
func (o *VisibleObject) SpritePos() (uint, uint)
func (*VisibleObject) SpriteSize ¶
func (o *VisibleObject) SpriteSize() (uint, uint)
type WandererModule ¶
type WandererModule struct {
BaseModule
}
Wanderer - Target a random nearby tile and move to it, then wait a few ticks.
func (*WandererModule) ChooseSchedule ¶
func (m *WandererModule) ChooseSchedule() Schedule
type Zone ¶
type Zone struct {
X, Y int64 // unprotected by mutex; never changes
Z int8 // unprotected by mutex; never changes
// contains filtered or unexported fields
}
func (*Zone) AddListener ¶
func (z *Zone) AddListener(l *ZoneListener)
func (*Zone) Impersonate ¶
func (z *Zone) Impersonate(player PlayerLike, o Visible)
func (*Zone) RemoveListener ¶
func (z *Zone) RemoveListener(l *ZoneListener)
func (*Zone) Update ¶
func (z *Zone) Update(t *Tile, obj ObjectLike)
type ZoneListener ¶
type ZoneListener struct { Add func(*Tile, ObjectLike) Remove func(*Tile, ObjectLike) Move func(*Tile, *Tile, ObjectLike) Update func(*Tile, ObjectLike) Damage func(Combat, Combat, *big.Int) }