character

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: 11 Imported by: 0

Documentation

Overview

Package cooldown provides default implementation for SetCD, SetCDWithDelay, ResetActionCooldown, ReduceActionCooldown, ActionReady,

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Character

type Character struct {
	*character.CharWrapper
	Core     *core.Core
	ActionCD []int

	AvailableCDCharge []int
	// contains filtered or unexported fields
}

func New

func New(c *core.Core) *Character

func NewWithWrapper

func NewWithWrapper(c *core.Core, w *character.CharWrapper) *Character

func (*Character) ActionReady

func (c *Character) ActionReady(a action.Action, p map[string]int) (bool, action.ActionFailure)

func (*Character) ActionStam

func (c *Character) ActionStam(a action.Action, p map[string]int) float64

ActionStam provides default implementation for stam cost for charge and dash character should override this though

func (*Character) AdvanceNormalIndex added in v1.2.7

func (c *Character) AdvanceNormalIndex()

func (*Character) ApplyDashCD added in v1.8.6

func (c *Character) ApplyDashCD()

set the dash CD. If the dash was on CD when this dash executes, lockout dash

func (*Character) Charges

func (c *Character) Charges(a action.Action) int

func (*Character) Condition added in v1.1.0

func (c *Character) Condition(fields []string) (any, error)

func (*Character) Cooldown

func (c *Character) Cooldown(a action.Action) int

func (*Character) Dash

func (c *Character) Dash(p map[string]int) action.ActionInfo

func (*Character) DashLength added in v1.8.6

func (c *Character) DashLength() int

func (*Character) Jump

func (c *Character) Jump(p map[string]int) action.ActionInfo

func (*Character) NextNormalCounter added in v1.2.7

func (c *Character) NextNormalCounter() int

func (*Character) QueueDashStaminaConsumption added in v1.8.6

func (c *Character) QueueDashStaminaConsumption(p map[string]int)

func (*Character) ReduceActionCooldown

func (c *Character) ReduceActionCooldown(a action.Action, v int)

func (*Character) ResetActionCooldown

func (c *Character) ResetActionCooldown(a action.Action)

func (*Character) ResetNormalCounter added in v1.2.7

func (c *Character) ResetNormalCounter()

func (*Character) SetCD

func (c *Character) SetCD(a action.Action, dur int)

SetCD takes two parameters:

  • a action.Action: this is the action type we are triggering the cooldown for
  • dur: duration in frames that the cooldown should last for

It is assumed that AvailableCDCharges[a] > 0 (otherwise action should not have been allowed)

SetCD works by adding the cooldown duration to a queue. This is because when there are multiple charges, the game will first finish recharging the first charge before starting the full cooldown for the second charge.

When a cooldown is added to queue for the first time, a queue worker is started. This queue worker will check back at the cooldown specified for the first queued item, and if the queued cooldown did not change, it will increment the number of charges by 1, and reschedule itself to check back for the next item in queue

Sometimes, the queued cooldown gets adjusted via ReduceActionCooldown or ResetActionCooldown. When this happens, the initial queued worker will check back at the wrong time. To prevent this, we use cdQueueWorkerStartedAt[a] which tracks the frame the worker started at. So when ReduceActionCooldown or ResetActionCooldown gets called, we start a new worker, updating cdQueueWorkerStartedAt[a] to represent the new worker start frame. This way the old worker can check this value first and then gracefully exit if it no longer matches its starting frame

func (*Character) SetCDWithDelay

func (h *Character) SetCDWithDelay(a action.Action, dur int, delay int)

func (*Character) SetNumCharges

func (c *Character) SetNumCharges(a action.Action, num int)

func (*Character) Snapshot

func (c *Character) Snapshot(a *combat.AttackInfo) combat.Snapshot

func (*Character) Walk

func (c *Character) Walk(p map[string]int) action.ActionInfo

Jump to

Keyboard shortcuts

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