player

package
v1.15.1 Latest Latest
Warning

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

Go to latest
Published: Jul 4, 2023 License: MIT Imports: 12 Imported by: 3

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
)

Variables

View Source
var ErrActionNoOp = errors.New("action is a noop")
View Source
var ErrActionNotReady = errors.New("action is not ready yet; cannot be executed")

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
View Source
var ErrPlayerNotReady = errors.New("player still in animation; cannot execute action")

Functions

This section is empty.

Types

type Delays

type Delays struct {
	Skill  int
	Burst  int
	Attack int
	Charge int
	Aim    int
	Dash   int
	Jump   int
	Swap   int
}

type DrainInfo

type DrainInfo struct {
	ActorIndex int
	Abil       string
	Amount     float64
	External   bool
}

type Handler

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

	//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) 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 DrainInfo)

func (*Handler) Exec

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

Exec mirrors the idea of the in game buttons where you can press the button but it may be greyed out. If grey'd out it will return ErrActionNotReady. Otherwise if action was executed successfully then it will return nil

The function takes 2 params:

  • ActionType
  • Param

Just like in game this will always try and execute on the currently active character

This function can be called as many times per frame as desired. However, it will only execute if the animation state allows for it

Note that although wait is not strictly a button in game, it is still a valid action. When wait is executed, it will simply put the player in a lock animation state for the requested number of frames

func (*Handler) Heal

func (h *Handler) Heal(info HealInfo)

func (*Handler) HealIndex

func (h *Handler) HealIndex(info *HealInfo, index int)

func (*Handler) InitializeTeam

func (h *Handler) InitializeTeam() error

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

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

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

func (*Handler) StamPercentModIsActive

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

func (*Handler) Tick

func (h *Handler) Tick()

type HealInfo

type HealInfo struct {
	Caller  int // index of healing character
	Target  int // index of char receiving the healing. use -1 to heal all characters
	Type    HealType
	Message string
	Src     float64 // depends on the type
	Bonus   float64
}

type HealType

type HealType int
const (
	HealTypeAbsolute HealType = iota // regular number
	HealTypePercent                  // percent of the target's max hp
)

type Opt

type Opt struct {
	F            *int
	Log          glog.Logger
	Events       event.Eventter
	Tasks        task.Tasker
	Delays       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