combat

package
v1.1.4 Latest Latest
Warning

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

Go to latest
Published: Aug 25, 2022 License: MIT Imports: 8 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.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},
}
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, 1.0},

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

Functions

func WillCollide

func WillCollide(p AttackPattern, t Target, index int) 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:"-"`
}

type AttackInfo

type AttackInfo struct {
	ActorIndex       int    //character this attack belongs to
	DamageSrc        int    //source of this attack (i.e. index of core.Targets); always 0 for player, 1+ for the rest
	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
	//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 NewDefBoxHit

func NewDefBoxHit(w, h float64, self bool, targets ...TargettableType) AttackPattern

func NewDefCircHit

func NewDefCircHit(r float64, self bool, targets ...TargettableType) AttackPattern

func NewDefSingleTarget

func NewDefSingleTarget(ind int, 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
	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 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) AddTarget

func (h *Handler) AddTarget(t Target)

func (*Handler) ApplyAttack

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

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

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

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

func (*Handler) EnemyExcl

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

EnemyExcl returns array of indices of enemies, excluding self

func (*Handler) KillTarget added in v1.1.2

func (h *Handler) KillTarget(i int) bool

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

func (c *Handler) RandomTargetIndex(typ TargettableType) int

func (*Handler) SetTargetPos

func (h *Handler) SetTargetPos(i int, x, y float64) bool

func (*Handler) Target

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

func (*Handler) Targets

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

func (*Handler) TargetsCount

func (h *Handler) TargetsCount() int

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
	ICDGroupReactionA
	ICDGroupReactionB
	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
	ICDReactionDamageDelim
	ICDTagOverloadDamage
	ICDTagSuperconductDamage
	ICDTagECDamage
	ICDTagShatter
	ICDTagSwirlPyro
	ICDTagSwirlHydro
	ICDTagSwirlCryo
	ICDTagSwirlElectro
	ICDTagLength
)

type Opt

type Opt struct {
	Events        event.Eventter
	Team          CharHandler
	Rand          *rand.Rand
	Debug         bool
	Log           glog.Logger
	DamageMode    bool
	DefHalt       bool
	EnableHitlag  bool
	DefaultTarget int //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"
	NoReaction         ReactionType = ""
	FreezeExtend       ReactionType = "FreezeExtend"
)

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 int
}

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
	IsAlive() bool
	MaxHP() float64
	HP() float64

	Type() TargettableType   //type of target
	Shape() Shape            // shape of target
	Pos() (float64, float64) // center of target
	SetPos(x, y float64)     // move target

	//apply attack to target
	Attack(*AttackEvent, glog.Event) (float64, bool)

	//aura checks
	AuraContains(e ...attributes.Element) bool

	Tick() //called every tick

	//getting rid of
	Kill()
}

type TargettableType

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

Jump to

Keyboard shortcuts

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