combat

package
v0.0.0-...-84dbd67 Latest Latest
Warning

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

Go to latest
Published: Nov 18, 2024 License: MIT Imports: 13 Imported by: 0

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
	AdditionalTags   []attacks.AdditionalTag
	PoiseDMG         float64 // only needed on blunt attacks for frozen consumption before shatter for now
	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
	Alignment            attacks.AdditionalTag // this to to track Arkhe/Nightsoul trigger
	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

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

func NewBoxHitOnTarget

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

func NewCircleHit

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

func NewCircleHitFanAngle

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

func NewCircleHitOnTarget

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

func NewCircleHitOnTargetFanAngle

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

func NewSingleTargetHit

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

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

type Enemy

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

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

type GadgetTyp

type GadgetTyp int
const (
	GadgetTypUnknown GadgetTyp = iota
	StartGadgetTypEnemy
	GadgetTypDendroCore
	GadgetTypLeaLotus
	GadgetTypBogglecatBox
	EndGadgetTypEnemy
	GadgetTypGuoba
	GadgetTypYueguiThrowing
	GadgetTypYueguiJumping
	GadgetTypBaronBunny
	GadgetTypGrinMalkinHat
	GadgetTypSourcewaterDropletHydroTrav
	GadgetTypSourcewaterDropletNeuv
	GadgetTypSourcewaterDropletSigewinne
	GadgetTypCrystallizeShard
	GadgetTypReactableweapon
	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 (h *Handler) AbsorbCheck(idx int, p AttackPattern, prio ...attributes.Element) attributes.Element

func (*Handler) AddEnemy

func (h *Handler) AddEnemy(t Target)

func (*Handler) AddGadget

func (h *Handler) AddGadget(t Gadget)

func (*Handler) ApplyAttack

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

func (*Handler) ClosestEnemiesWithinArea

func (h *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

func (h *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

func (h *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) ClosestGadget

func (h *Handler) ClosestGadget(pos geometry.Point) Gadget

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

func (*Handler) ClosestGadgetWithinArea

func (h *Handler) ClosestGadgetWithinArea(a AttackPattern, filter func(t Gadget) bool) Gadget

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

func (*Handler) ClosestGadgetsWithinArea

func (h *Handler) ClosestGadgetsWithinArea(a AttackPattern, filter func(t Gadget) bool) []Gadget

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

func (*Handler) Enemies

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

func (*Handler) EnemiesWithinArea

func (h *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

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

func (*Handler) EnemyCount

func (h *Handler) EnemyCount() int

func (*Handler) Gadget

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

func (*Handler) GadgetCount

func (h *Handler) GadgetCount() int

func (*Handler) Gadgets

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

func (*Handler) GadgetsWithinArea

func (h *Handler) GadgetsWithinArea(a AttackPattern, filter func(t Gadget) bool) []Gadget

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

func (*Handler) KillEnemy

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

func (h *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

func (h *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) RandomGadgetWithinArea

func (h *Handler) RandomGadgetWithinArea(a AttackPattern, filter func(t Gadget) bool) Gadget

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

func (*Handler) RandomGadgetsWithinArea

func (h *Handler) RandomGadgetsWithinArea(a AttackPattern, filter func(t Gadget) bool, maxCount int) []Gadget

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

func (*Handler) RemoveGadget

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

func (*Handler) ReplaceGadget

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

func (*Handler) SetEnemyPos

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

func (*Handler) SetPlayer

func (h *Handler) SetPlayer(t Target)

func (*Handler) SetPlayerPos

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

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

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

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