combat

package
v1.11.0 Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2023 License: MIT Imports: 13 Imported by: 15

Documentation

Overview

Package combat handles all combat related functionalities including

  • target tracking
  • target selection
  • hitbox collision checking
  • attack queueing

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AttackCB

type AttackCB struct {
	Target      Target
	AttackEvent *AttackEvent
	Damage      float64
	IsCrit      bool
}

type AttackCBFunc

type AttackCBFunc func(AttackCB)

type AttackEvent

type AttackEvent struct {
	Info    AttackInfo
	Pattern AttackPattern
	// Timing        AttackTiming
	Snapshot    Snapshot
	SourceFrame int            //source frame
	Callbacks   []AttackCBFunc `json:"-"`
	Reacted     bool           // true if a reaction already took place - for purpose of attach/refill
}

type AttackInfo

type AttackInfo struct {
	ActorIndex       int               //character this attack belongs to
	DamageSrc        targets.TargetKey //source of this attack; should be a unique key identifying the target
	Abil             string            //name of ability triggering the damage
	AttackTag        attacks.AttackTag
	ICDTag           attacks.ICDTag
	ICDGroup         attacks.ICDGroup
	Element          attributes.Element   //element of ability
	Durability       reactions.Durability //durability of aura, 0 if nothing applied
	NoImpulse        bool
	HitWeakPoint     bool
	Mult             float64 //ability multiplier. could set to 0 from initial Mona dmg
	StrikeType       attacks.StrikeType
	UseDef           bool    //we use this instead of flatdmg to make sure stat snapshotting works properly
	FlatDmg          float64 //flat dmg;
	IgnoreDefPercent float64 //by default this value is 0; if = 1 then the attack will ignore defense; raiden c2 should be set to 0.6 (i.e. ignore 60%)
	IgnoreInfusion   bool
	//amp info
	Amped   bool                   //new flag used by new reaction system
	AmpMult float64                //amplier
	AmpType reactions.ReactionType //melt or vape i guess
	// catalyze info
	Catalyzed     bool
	CatalyzedType reactions.ReactionType
	//special flag for sim generated attack
	SourceIsSim bool
	DoNotLog    bool
	//hitlag stuff
	HitlagHaltFrames     float64 //this is the number of frames to pause by
	HitlagFactor         float64 //this is factor to slow clock by
	CanBeDefenseHalted   bool    //for whacking ruin gaurds
	IsDeployable         bool    //if this is true, then hitlag does not affect owner
	HitlagOnHeadshotOnly bool    //if this is true, will only apply if HitWeakpoint is also true
}

type AttackPattern

type AttackPattern struct {
	Shape       geometry.Shape
	SkipTargets [targets.TargettableTypeCount]bool
	IgnoredKeys []targets.TargetKey
}

func NewBoxHit added in v1.6.0

func NewBoxHit(src, center, offset positional, w, h float64) AttackPattern

func NewBoxHitOnTarget added in v1.6.0

func NewBoxHitOnTarget(trg, offset positional, w, h float64) AttackPattern

func NewCircleHit

func NewCircleHit(src, center, offset positional, r float64) AttackPattern

func NewCircleHitFanAngle added in v1.6.0

func NewCircleHitFanAngle(src, center, offset positional, r, fanAngle float64) AttackPattern

func NewCircleHitOnTarget added in v1.6.0

func NewCircleHitOnTarget(trg, offset positional, r float64) AttackPattern

func NewCircleHitOnTargetFanAngle added in v1.6.0

func NewCircleHitOnTargetFanAngle(trg, offset positional, r, fanAngle float64) AttackPattern

func NewSingleTargetHit added in v1.6.0

func NewSingleTargetHit(ind targets.TargetKey) AttackPattern

type CharHandler

type CharHandler interface {
	CombatByIndex(int) Character
	ApplyHitlag(char int, factor, dur float64)
}

type Character

type Character interface {
	ApplyAttackMods(a *AttackEvent, t Target) []interface{}
}

type DefMod added in v1.7.0

type DefMod struct {
	Value float64
	Dur   int
	modifier.Base
}

type Enemy added in v1.7.0

type Enemy interface {
	Target
	// hp related
	MaxHP() float64
	HP() float64
	// hitlag related
	ApplyHitlag(factor, dur float64)
	QueueEnemyTask(f func(), delay int)
	// modifier related
	// add
	AddStatus(key string, dur int, hitlag bool)
	AddResistMod(mod ResistMod)
	AddDefMod(mod DefMod)
	// delete
	DeleteStatus(key string)
	DeleteResistMod(key string)
	DeleteDefMod(key string)
	// active
	StatusIsActive(key string) bool
	ResistModIsActive(key string) bool
	DefModIsActive(key string) bool
	StatusExpiry(key string) int
}

type Gadget added in v1.2.0

type Gadget interface {
	Target
	Src() int
	GadgetTyp() GadgetTyp
}

type GadgetTyp added in v1.2.0

type GadgetTyp int
const (
	GadgetTypUnknown GadgetTyp = iota
	GadgetTypDendroCore
	GadgetTypGuoba
	GadgetTypLeaLotus
	GadgetTypYueguiThrowing
	GadgetTypYueguiJumping
	GadgetTypTest
	EndGadgetTyp
)

type Handler

type Handler struct {
	Opt

	TotalDamage float64
	// contains filtered or unexported fields
}

func New

func New(opt Opt) *Handler

func (*Handler) AbsorbCheck

func (c *Handler) AbsorbCheck(p AttackPattern, prio ...attributes.Element) attributes.Element

func (*Handler) AddEnemy added in v1.2.0

func (h *Handler) AddEnemy(t Target)

func (*Handler) AddGadget added in v1.2.0

func (h *Handler) AddGadget(t Gadget)

func (*Handler) ApplyAttack

func (h *Handler) ApplyAttack(a *AttackEvent) float64

func (*Handler) ClosestEnemiesWithinArea added in v1.7.0

func (c *Handler) ClosestEnemiesWithinArea(a AttackPattern, filter func(t Enemy) bool) []Enemy

returns enemies within the given area, sorted from closest to furthest, pass nil for no filter

func (*Handler) ClosestEnemy added in v1.7.0

func (c *Handler) ClosestEnemy(pos geometry.Point) Enemy

returns the closest enemy to the given position without any range restrictions; SHOULD NOT be used outside of pkg

func (*Handler) ClosestEnemyWithinArea added in v1.7.0

func (c *Handler) ClosestEnemyWithinArea(a AttackPattern, filter func(t Enemy) bool) Enemy

returns the closest enemy within the given area, pass nil for no filter

func (*Handler) Enemies added in v1.2.0

func (h *Handler) Enemies() []Target

func (*Handler) EnemiesWithinArea added in v1.7.0

func (c *Handler) EnemiesWithinArea(a AttackPattern, filter func(t Enemy) bool) []Enemy

returns enemies within the given area, no sorting, pass nil for no filter

func (*Handler) Enemy added in v1.2.0

func (h *Handler) Enemy(i int) Target

func (*Handler) EnemyCount added in v1.2.0

func (h *Handler) EnemyCount() int

func (*Handler) Gadget added in v1.2.0

func (h *Handler) Gadget(i int) Gadget

func (*Handler) GadgetCount added in v1.2.0

func (h *Handler) GadgetCount() int

func (*Handler) Gadgets added in v1.2.0

func (h *Handler) Gadgets() []Gadget

func (*Handler) KillEnemy added in v1.2.0

func (h *Handler) KillEnemy(i int)

func (*Handler) Player

func (h *Handler) Player() Target

func (*Handler) PrimaryTarget

func (h *Handler) PrimaryTarget() Target

func (*Handler) RandomEnemiesWithinArea added in v1.7.0

func (c *Handler) RandomEnemiesWithinArea(a AttackPattern, filter func(t Enemy) bool, maxCount int) []Enemy

returns a list of random enemies within the given area, pass nil for no filter

func (*Handler) RandomEnemyWithinArea added in v1.7.0

func (c *Handler) RandomEnemyWithinArea(a AttackPattern, filter func(t Enemy) bool) Enemy

returns a random enemy within the given area, pass nil for no filter

func (*Handler) RemoveGadget added in v1.2.0

func (h *Handler) RemoveGadget(key targets.TargetKey)

func (*Handler) ReplaceGadget added in v1.2.0

func (h *Handler) ReplaceGadget(key targets.TargetKey, t Gadget)

func (*Handler) SetEnemyPos added in v1.2.0

func (h *Handler) SetEnemyPos(i int, p geometry.Point) bool

func (*Handler) SetPlayer added in v1.2.0

func (h *Handler) SetPlayer(t Target)

func (*Handler) SetPlayerPos added in v1.2.0

func (h *Handler) SetPlayerPos(p geometry.Point)

func (*Handler) Tick

func (h *Handler) Tick()

type Opt

type Opt struct {
	Events        event.Eventter
	Tasks         task.Tasker
	Team          CharHandler
	Rand          *rand.Rand
	Debug         bool
	Log           glog.Logger
	DamageMode    bool
	DefHalt       bool
	EnableHitlag  bool
	DefaultTarget targets.TargetKey //index for default target
}

type ResistMod added in v1.7.0

type ResistMod struct {
	Ele   attributes.Element
	Value float64
	modifier.Base
}

type Snapshot

type Snapshot struct {
	CharLvl    int
	ActorEle   attributes.Element
	ExtraIndex int                             //this is currently purely for Kaeya icicle ICD
	Cancelled  bool                            //set to true if this snap should be ignored
	Stats      [attributes.EndStatType]float64 //total character stats including from artifact, bonuses, etc...
	BaseAtk    float64                         //base attack used in calc
	BaseDef    float64
	BaseHP     float64

	SourceFrame int           // frame snapshot was generated at
	Logs        []interface{} // logs for the snapshot
}

type Status added in v1.7.0

type Status struct {
	modifier.Base
}

type Target

type Target interface {
	Key() targets.TargetKey        // unique key for the target
	SetKey(k targets.TargetKey)    // update key
	Type() targets.TargettableType // type of target
	Shape() geometry.Shape         // geometry.Shape of target
	Pos() geometry.Point           // center of target
	SetPos(p geometry.Point)       // move target
	IsAlive() bool
	SetTag(key string, val int)
	GetTag(key string) int
	RemoveTag(key string)
	HandleAttack(*AttackEvent) float64
	AttackWillLand(a AttackPattern) (bool, string) // hurtbox collides with AttackPattern
	IsWithinArea(a AttackPattern) bool             // center is in AttackPattern
	Tick()                                         // called every tick
	Kill()
	// for collision check
	CollidableWith(targets.TargettableType) bool
	CollidedWith(t Target)
	WillCollide(geometry.Shape) bool
	// direction related
	Direction() geometry.Point                           // returns viewing direction as a geometry.Point
	SetDirection(trg geometry.Point)                     // calculates viewing direction relative to default direction (0, 1)
	SetDirectionToClosestEnemy()                         // looks for closest enemy
	CalcTempDirection(trg geometry.Point) geometry.Point // used for stuff like Bow CA
}

type TargetWithAura added in v1.2.0

type TargetWithAura interface {
	Target
	AuraContains(e ...attributes.Element) bool
}

Jump to

Keyboard shortcuts

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