player

package
v0.0.0-...-dff1495 Latest Latest
Warning

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

Go to latest
Published: Dec 9, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package player contains player related tracking and functionalities: - tracking characters on the team - handling animations state - handling normal attack state - handling character stats and attributes - handling shielding

Index

Constants

View Source
const (
	MaxStam      = 240
	StamCDFrames = 90
	SwapCDFrames = 60
)
View Source
const (
	XianyunAirborneBuff = "xianyun-airborne-buff"
)

Variables

View Source
var (
	// exec-specfic errors
	ErrActionNotReady        = errors.New("action is not ready yet; cannot be executed")
	ErrPlayerNotReady        = errors.New("player still in animation; cannot execute action")
	ErrInvalidAirborneAction = errors.New("player must use low_plunge or high_plunge while airborne")
	ErrActionNoOp            = errors.New("action is a noop")
	// shared character-specific errors
	ErrInvalidChargeAction = errors.New("need to use attack right before charge")
)

ErrActionNotReady is returned if the requested action is not ready; this could be due to any of the following:

  • Insufficient energy (burst only)
  • Ability on cooldown
  • Player currently in animation

Functions

This section is empty.

Types

type AirborneSource

type AirborneSource int
const (
	Grounded AirborneSource = iota
	AirborneXiao
	AirborneVenti
	AirborneKazuha
	AirborneXianyun
	TerminateAirborne
)

type Handler

type Handler struct {
	Opt
	// handlers
	*animation.AnimationHandler
	Shields *shield.Handler
	infusion.Handler

	// stam
	Stam        float64
	LastStamUse int

	// swap
	SwapCD int

	// dash: dash fails iff lockout && on CD
	DashCDExpirationFrame int
	DashLockout           bool

	// last action
	LastAction struct {
		UsedAt int
		Type   action.Action
		Param  map[string]int
		Char   int
	}
	// contains filtered or unexported fields
}

func New

func New(opt Opt) *Handler

func (*Handler) AbilStamCost

func (h *Handler) AbilStamCost(i int, a action.Action, p map[string]int) float64

func (*Handler) Active

func (h *Handler) Active() int

func (*Handler) ActiveChar

func (h *Handler) ActiveChar() *character.CharWrapper

func (*Handler) AddChar

func (h *Handler) AddChar(char *character.CharWrapper) int

func (*Handler) AddStamPercentMod

func (h *Handler) AddStamPercentMod(key string, dur int, f StamPercentModFunc)

TODO: not sure if this is affected by hitlag?

func (*Handler) Adjust

func (h *Handler) Adjust(src string, char int, amt float64)

func (*Handler) Airborne

func (h *Handler) Airborne() AirborneSource

func (*Handler) ApplyHitlag

func (h *Handler) ApplyHitlag(char int, factor, dur float64)

func (*Handler) ByIndex

func (h *Handler) ByIndex(i int) *character.CharWrapper

func (*Handler) ByKey

func (h *Handler) ByKey(k keys.Char) (*character.CharWrapper, bool)

func (*Handler) CharIsActive

func (h *Handler) CharIsActive(k keys.Char) bool

func (*Handler) Chars

func (h *Handler) Chars() []*character.CharWrapper

func (*Handler) CombatByIndex

func (h *Handler) CombatByIndex(i int) combat.Character

func (*Handler) DistributeParticle

func (h *Handler) DistributeParticle(p character.Particle)

func (*Handler) Drain

func (h *Handler) Drain(di info.DrainInfo) float64

func (*Handler) Exec

func (h *Handler) Exec(t action.Action, k keys.Char, param map[string]int) error

Exec will forcefully execute an action t regardless if t is ready or not. The assumption is that whatever caller of Exec would have first checked ReadyCheck where ever relevant before calling Exec.

The separation allows for forcefully execution of certain actions such as swap bypassing swapCD if any

func (*Handler) Heal

func (h *Handler) Heal(hi info.HealInfo)

func (*Handler) InitializeTeam

func (h *Handler) InitializeTeam() error

InitializeTeam will set up resonance event hooks and calculate all character base stats

func (*Handler) ReadyCheck

func (h *Handler) ReadyCheck(t action.Action, k keys.Char, param map[string]int) error

ReadyCheck returns nil action is ready, else returns error representing why action is not ready

func (*Handler) ResetAllNormalCounter

func (h *Handler) ResetAllNormalCounter()

func (*Handler) RestoreStam

func (h *Handler) RestoreStam(v float64)

func (*Handler) SetActive

func (h *Handler) SetActive(i int)

func (*Handler) SetAirborne

func (h *Handler) SetAirborne(src AirborneSource) error

func (*Handler) StamPercentMod

func (h *Handler) StamPercentMod(a action.Action) float64

func (*Handler) StamPercentModIsActive

func (h *Handler) StamPercentModIsActive(key string) bool

func (*Handler) Tick

func (h *Handler) Tick()

type Opt

type Opt struct {
	F            *int
	Log          glog.Logger
	Events       event.Eventter
	Tasks        task.Tasker
	Delays       info.Delays
	Debug        bool
	EnableHitlag bool
}

type StamPercentModFunc

type StamPercentModFunc func(action.Action) (float64, bool)

Directories

Path Synopsis
package animation provides a simple way of tracking the current animation state at any given frame, as well as if the current frame is in animation lock or not
package animation provides a simple way of tracking the current animation state at any given frame, as well as if the current frame is in animation lock or not
Package shield provide a handler to keep track of shields and add shields etc...
Package shield provide a handler to keep track of shields and add shields etc...

Jump to

Keyboard shortcuts

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