world

package
v0.0.0-...-7279c54 Latest Latest
Warning

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

Go to latest
Published: Sep 26, 2013 License: BSD-3-Clause Imports: 18 Imported by: 0

Documentation

Index

Constants

View Source
const MAX_BLOCK_RADIUS int8 = 2
View Source
const TuningEquipSlotCount = 14

Variables

View Source
var (
	DamageMissed   = big.NewInt(0)
	DamageBlocked  = big.NewInt(0)
	DamageResisted = big.NewInt(0)
)
View Source
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 RegisterSpawnFunc(f func(string) Visible)

func ReleaseZone

func ReleaseZone(z *Zone)

func SaveAllZones

func SaveAllZones()

func SaveConvert

func SaveConvert(o ObjectLike) interface{}

func Think

func Think()

Types

type ActionSchedule

type ActionSchedule struct {
	Object

	Action  string
	Target_ Visible
}

func (*ActionSchedule) Act

func (s *ActionSchedule) Act(o Living) (uint, bool)

func (*ActionSchedule) ShouldSave

func (s *ActionSchedule) ShouldSave() bool

func (*ActionSchedule) Target

func (s *ActionSchedule) Target() ObjectLike

type AdminLike

type AdminLike interface {
	IsAdmin() bool
	Impersonate(Visible)
}

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 Combat

type Combat interface {
	Living

	Health() *big.Int
	SetHealth(*big.Int)
	MaxHealth() *big.Int

	MaxQuality() *big.Int
	StatLike

	Hurt(*big.Int, Combat)
	Die()
}

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) Hurt

func (o *CombatObject) Hurt(amount *big.Int, attacker Combat)

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) Stat

func (o *CombatObject) Stat(stat Stat) *big.Int

func (*CombatObject) Think

func (o *CombatObject) Think()

type CombatSchedule

type CombatSchedule struct {
	Object

	Target_ Combat
}

func (*CombatSchedule) Act

func (s *CombatSchedule) Act(o Living) (uint, bool)

func (*CombatSchedule) ShouldSave

func (s *CombatSchedule) ShouldSave() bool

func (*CombatSchedule) Target

func (s *CombatSchedule) Target() ObjectLike

type DelaySchedule

type DelaySchedule struct {
	Object

	Delay uint
}

func (*DelaySchedule) Act

func (s *DelaySchedule) Act(o Living) (uint, bool)

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 Instance

type Instance interface {
	Items(func([]Visible) []Visible)
	Last(func(time.Time) time.Time)
}

type InventoryLike

type InventoryLike interface {
	Inventory() []Visible
	GiveItem(Visible) bool
	RemoveItem(Visible) bool
}

type Item

type Item interface {
	Volume() uint64
	Weight() uint64
	AdminOnly() bool
}

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

func (o *Object) NotifyPosition(old, new *Tile)

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) Position

func (o *Object) Position() *Tile

Position returns the tile containing this object.

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.

func (*Object) Think

func (o *Object) Think()

Think is called every tick (200ms) for objects that are in a zone.

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
}

func NewWalkSchedule

func NewWalkSchedule(ex, ey uint8, stopEarly bool, delay uint) Schedule

type ScheduleSchedule

type ScheduleSchedule struct {
	Object

	Schedules []Schedule
}

func (*ScheduleSchedule) Act

func (s *ScheduleSchedule) Act(o Living) (uint, bool)

func (*ScheduleSchedule) ShouldSave

func (s *ScheduleSchedule) ShouldSave() bool

func (*ScheduleSchedule) Target

func (s *ScheduleSchedule) Target() ObjectLike

type SendMessageLike

type SendMessageLike interface {
	SendMessage(string)
	SendMessageColor(string, string)
}

type SetHUDLike

type SetHUDLike interface {
	SetHUD(string, map[string]interface{})
}

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 StatLike

type StatLike interface {
	Stat(Stat) *big.Int
}

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) Blocked

func (t *Tile) Blocked() bool

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) Position

func (t *Tile) Position() (x, y uint8)

func (*Tile) Remove

func (t *Tile) Remove(obj ObjectLike) bool

Remove an object from this tile. Returns true if the object was found.

func (*Tile) Zone

func (t *Tile) Zone() *Zone

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)
}

func Spawn

func Spawn(s string) Visible

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 GetZone

func GetZone(x, y int64, z int8) *Zone

func (*Zone) AddListener

func (z *Zone) AddListener(l *ZoneListener)

func (*Zone) Chat

func (z *Zone) Chat(sender Visible, message string)

func (*Zone) Damage

func (z *Zone) Damage(attacker, victim Combat, amount *big.Int)

func (*Zone) Impersonate

func (z *Zone) Impersonate(player PlayerLike, o Visible)

func (*Zone) Path

func (z *Zone) Path(start *Tile, end *Tile, stopEarly bool) [][2]uint8

func (*Zone) RemoveListener

func (z *Zone) RemoveListener(l *ZoneListener)

func (*Zone) Tile

func (z *Zone) Tile(x, y uint8) *Tile

Tile returns the Tile at a position in the Zone.

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)
}

Jump to

Keyboard shortcuts

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