combat

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 3, 2022 License: MIT Imports: 9 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

View Source
var ICDGroupDamageSequence = [][]float64{

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1},

	{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0},

	{1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},

	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},

	{1.0, 1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0, 1.0},
}
View Source
var ICDGroupEleApplicationSequence = [][]int{

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 0.0},

	{1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0, 1.0, 0.0, 0.0},

	{1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

	{1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 1.0, 0.0, 0.0, 0.0, 0.0},

	{1.0, 1.0},

	{1.0, 1.0},

	{1.0, 0, 0, 0, 0, 0, 0, 0},
}
View Source
var ICDGroupResetTimer = []int{
	150,
	60,
	60,
	300,
	300,
	30,
	6,
	18,
	120,
	180,
	150,
	30,
	30,
	120,
}

Functions

func WillCollide

func WillCollide(p AttackPattern, t Target, key TargetKey) bool

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
	Cancelled   bool //provide a way to cancel an attack event
	Snapshot    Snapshot
	SourceFrame int            //source frame
	Callbacks   []AttackCBFunc `json:"-"`
	Reacted     bool           // true if a reaction already took place - for purpose of attach/refill
	OnICD       bool           // set this to true if on ICD so we don't accidentally increment counter twice; icd check only happens once
}

type AttackInfo

type AttackInfo struct {
	ActorIndex       int       //character this attack belongs to
	DamageSrc        TargetKey //source of this attack; should be a unique key identifying the target
	Abil             string    //name of ability triggering the damage
	AttackTag        AttackTag
	ICDTag           ICDTag
	ICDGroup         ICDGroup
	Element          attributes.Element //element of ability
	Durability       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       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 ReactionType //melt or vape i guess
	// catalyze info
	Catalyzed     bool
	CatalyzedType 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    Shape
	Targets  [TargettableTypeCount]bool
	SelfHarm bool
}

func NewCircleHit

func NewCircleHit(trg Positional, r float64, self bool, targets ...TargettableType) AttackPattern

func NewDefSingleTarget

func NewDefSingleTarget(ind TargetKey, typ TargettableType) AttackPattern

type AttackTag

type AttackTag int //attacktag is used instead of actions etc..
const (
	AttackTagNone AttackTag = iota
	AttackTagNormal
	AttackTagExtra
	AttackTagPlunge
	AttackTagElementalArt
	AttackTagElementalArtHold
	AttackTagElementalBurst
	AttackTagWeaponSkill
	AttackTagMonaBubbleBreak
	AttackTagNoneStat
	ReactionAttackDelim
	AttackTagOverloadDamage
	AttackTagSuperconductDamage
	AttackTagECDamage
	AttackTagShatter
	AttackTagSwirlPyro
	AttackTagSwirlHydro
	AttackTagSwirlCryo
	AttackTagSwirlElectro
	AttackTagBurningDamage
	AttackTagBloom
	AttackTagBurgeon
	AttackTagHyperbloom
	AttackTagLength
)

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 Circle

type Circle struct {
	// contains filtered or unexported fields
}

func NewCircle

func NewCircle(x, y, r float64) *Circle

func (*Circle) IntersectCircle

func (c *Circle) IntersectCircle(c2 Circle) bool

func (*Circle) Pos

func (c *Circle) Pos() (float64, float64)

func (*Circle) SetPos

func (c *Circle) SetPos(x, y float64)

func (*Circle) String

func (c *Circle) String() string

type Durability

type Durability float64

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
	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) Enemies added in v1.2.0

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

func (*Handler) EnemiesWithinRadius

func (c *Handler) EnemiesWithinRadius(x, y, r float64) []int

EnemiesWithinRadius returns an array of indices of the enemies within radius r

func (*Handler) Enemy added in v1.2.0

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

func (*Handler) EnemyByDistance

func (c *Handler) EnemyByDistance(x, y float64, excl TargetKey) []int

EnemyByDistance returns an array of indices of the enemies sorted by distance

func (*Handler) EnemyCount added in v1.2.0

func (h *Handler) EnemyCount() int

func (*Handler) EnemyExcl

func (c *Handler) EnemyExcl(self int) []int

EnemyExcl returns array of indices of enemies, excluding self

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

func (c *Handler) RandomEnemyTarget() int

func (*Handler) RemoveGadget added in v1.2.0

func (h *Handler) RemoveGadget(key TargetKey)

func (*Handler) ReplaceGadget added in v1.2.0

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

func (*Handler) SetEnemyPos added in v1.2.0

func (h *Handler) SetEnemyPos(i int, x, y float64) 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(x, y float64)

func (*Handler) Tick

func (h *Handler) Tick()

type ICDGroup

type ICDGroup int //same ICD group shares the same timer

group dictate both the sequence and the reset timer

const (
	ICDGroupDefault ICDGroup = iota
	ICDGroupAmber
	ICDGroupVenti
	ICDGroupFischl
	ICDGroupDiluc
	ICDGroupPole
	ICDGroupXiaoDash
	ICDGroupYelanBreakthrough
	ICDGroupYelanBurst
	ICDGroupColleiBurst
	ICDGroupTighnari
	ICDGroupReactionA
	ICDGroupReactionB
	ICDGroupBurning
	ICDGroupLength
)

type ICDTag

type ICDTag int //same ICD tag shares the same counter
const (
	ICDTagNone ICDTag = iota
	ICDTagNormalAttack
	ICDTagExtraAttack
	ICDTagElementalArt
	ICDTagElementalArtAnemo
	ICDTagElementalArtPyro
	ICDTagElementalArtHydro
	ICDTagElementalArtCryo
	ICDTagElementalArtElectro
	ICDTagElementalBurst
	ICDTagElementalBurstAnemo
	ICDTagElementalBurstPyro
	ICDTagElementalBurstHydro
	ICDTagElementalBurstCryo
	ICDTagElementalBurstElectro
	ICDTagDash
	ICDTagLisaElectro
	ICDTagYanfeiFire
	ICDTagYelanBreakthrough
	ICDTagYelanBurst
	ICDTagMonaWaterDamage
	ICDTagTravelerWakeOfEarth
	ICDTagKleeFireDamage
	ICDTagTartagliaRiptideFlash
	ICDTagColleiSprout
	ICDReactionDamageDelim
	ICDTagOverloadDamage
	ICDTagSuperconductDamage
	ICDTagECDamage
	ICDTagShatter
	ICDTagSwirlPyro
	ICDTagSwirlHydro
	ICDTagSwirlCryo
	ICDTagSwirlElectro
	ICDTagBurningDamage
	ICDTagBloomDamage
	ICDTagBurgeonDamage
	ICDTagHyperbloomDamage
	ICDTagLength
)

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 TargetKey //index for default target
}

type Positional

type Positional interface {
	Pos() (x, y float64)
}

type ReactionType

type ReactionType string
const (
	Overload           ReactionType = "overload"
	Superconduct       ReactionType = "superconduct"
	Freeze             ReactionType = "freeze"
	Melt               ReactionType = "melt"
	Vaporize           ReactionType = "vaporize"
	CrystallizeElectro ReactionType = "crystallize-electro"
	CrystallizeHydro   ReactionType = "crystallize-hydro"
	CrystallizePyro    ReactionType = "crystallize-pyro"
	CrystallizeCryo    ReactionType = "crystallize-cryo"
	SwirlElectro       ReactionType = "swirl-electro"
	SwirlHydro         ReactionType = "swirl-hydro"
	SwirlPyro          ReactionType = "swirl-pyro"
	SwirlCryo          ReactionType = "swirl-cryo"
	ElectroCharged     ReactionType = "electrocharged"
	Shatter            ReactionType = "shatter"
	Burning            ReactionType = "burning"
	Quicken            ReactionType = "quicken"
	Aggravate          ReactionType = "aggravate"
	Spread             ReactionType = "spread"
	Bloom              ReactionType = "bloom"
	Burgeon            ReactionType = "burgeon"
	Hyperbloom         ReactionType = "hyperbloom"
	NoReaction         ReactionType = ""
	FreezeExtend       ReactionType = "freeze-extend"
)

type Rectangle

type Rectangle struct {
	// contains filtered or unexported fields
}

func (*Rectangle) IntersectCircle

func (r *Rectangle) IntersectCircle(c Circle) bool

func (*Rectangle) IntersectRectangle

func (r *Rectangle) IntersectRectangle(r2 Rectangle) bool

func (*Rectangle) Pos

func (r *Rectangle) Pos() (float64, float64)

func (*Rectangle) SetPos

func (r *Rectangle) SetPos(x, y float64)

func (*Rectangle) String

func (r *Rectangle) String() string

type SelfDamage

type SelfDamage struct{}

this is for attack that only hits self

func (*SelfDamage) IntersectCircle

func (c *SelfDamage) IntersectCircle(in Circle) bool

func (*SelfDamage) IntersectRectangle

func (c *SelfDamage) IntersectRectangle(in Rectangle) bool

type Shape

type Shape interface {
	Positional
	IntersectCircle(c Circle) bool
	IntersectRectangle(r Rectangle) bool
	String() string
}

type SingleTarget

type SingleTarget struct {
	Target TargetKey
}

func (*SingleTarget) IntersectCircle

func (s *SingleTarget) IntersectCircle(in Circle) bool

func (*SingleTarget) IntersectRectangle

func (s *SingleTarget) IntersectRectangle(in Rectangle) bool

func (*SingleTarget) Pos

func (s *SingleTarget) Pos() (float64, float64)

func (*SingleTarget) String

func (s *SingleTarget) String() string

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 StrikeType

type StrikeType int
const (
	StrikeTypeDefault StrikeType = iota
	StrikeTypePierce
	StrikeTypeBlunt
	StrikeTypeSlash
	StrikeTypeSpear
)

type Target

type Target interface {
	Index() int              //should correspond to index
	SetIndex(index int)      //update the current index
	Key() TargetKey          //unique key for the target
	SetKey(k TargetKey)      //update key
	Type() TargettableType   //type of target
	Shape() Shape            // shape of target
	Pos() (float64, float64) // center of target
	SetPos(x, y float64)     // move target
	IsAlive() bool
	AttackWillLand(a AttackPattern, src TargetKey) (bool, string)
	Attack(*AttackEvent, glog.Event) (float64, bool)
	ApplyDamage(*AttackEvent, float64)
	Tick() //called every tick
	Kill()
	//for collision check
	CollidableWith(TargettableType) bool
	CollidedWith(t Target)
	WillCollide(Shape) bool
}

type TargetKey added in v1.2.0

type TargetKey int
const InvalidTargetKey TargetKey = -1

type TargetWithAura added in v1.2.0

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

type TargettableType

type TargettableType int
const (
	TargettableEnemy TargettableType = iota
	TargettablePlayer
	TargettableGadget
	TargettableTypeCount
)

Jump to

Keyboard shortcuts

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