combat

package
v1.8.2 Latest Latest
Warning

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

Go to latest
Published: Jan 27, 2023 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, 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, 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, 0},

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

	{1, 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, 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, 1},

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

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

	{1, 0, 0, 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, 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, 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},

	{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1},
}
View Source
var ICDGroupEleApplicationSequence = [][]float64{

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

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

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

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

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

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

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

	{1, 0, 0, 0},

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

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

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

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

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

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

	{1, 1},

	{1, 1},

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

	{1.5, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},

	{1, 0, 0, 0, 0, 0, 0, 1, 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, 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, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0},
}
View Source
var ICDGroupResetTimer = []int{
	150,
	60,
	60,
	300,
	300,
	30,
	6,
	18,
	120,
	180,
	150,
	150,
	180,
	114,
	30,
	30,
	120,
	60,
	180,
	120,
	60,
	720,
	120,
}

Functions

func AABBTest added in v1.6.0

func AABBTest(a, b []Point) 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
	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        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
	SkipTargets [TargettableTypeCount]bool
	IgnoredKeys []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 TargetKey) 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(center Point, r float64, dir Point, fanAngle float64) *Circle

func (*Circle) IntersectCircle

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

func (*Circle) IntersectRectangle

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

func (*Circle) PointInShape added in v1.7.0

func (c *Circle) PointInShape(p Point) bool

func (*Circle) Pos

func (c *Circle) Pos() Point

func (*Circle) Radius added in v1.6.0

func (c *Circle) Radius() float64

func (*Circle) SetPos

func (c *Circle) SetPos(p Point)

func (*Circle) String

func (c *Circle) String() string

type DefMod added in v1.7.0

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

type Durability

type Durability float64

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
	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 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 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, p 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 Point)

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
	ICDGroupPoleExtraAttack
	ICDGroupXiaoDash
	ICDGroupYelanBreakthrough
	ICDGroupYelanBurst
	ICDGroupColleiBurst
	ICDGroupTighnari
	ICDGroupCynoBolt
	ICDGroupDoriBurst
	ICDGroupNilou
	ICDGroupReactionA
	ICDGroupReactionB
	ICDGroupBurning
	ICDGroupNahidaSkill
	ICDGroupLayla
	ICDGroupWandererC6
	ICDGroupWandererA4
	ICDGroupAlhaithamProjectionAttack
	ICDGroupAlhaithamExtraAttack //CA
	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
	ICDTagCynoBolt
	ICDTagMonaWaterDamage
	ICDTagTravelerWakeOfEarth
	ICDTagKleeFireDamage
	ICDTagTartagliaRiptideFlash
	ICDTagColleiSprout
	ICDTagDoriC2
	ICDTagDoriChargingStation
	ICDTagNilouTranquilityAura
	ICDTagWandererC6
	ICDReactionDamageDelim
	ICDTagOverloadDamage
	ICDTagSuperconductDamage
	ICDTagECDamage
	ICDTagShatter
	ICDTagSwirlPyro
	ICDTagSwirlHydro
	ICDTagSwirlCryo
	ICDTagSwirlElectro
	ICDTagBurningDamage
	ICDTagBloomDamage
	ICDTagBurgeonDamage
	ICDTagHyperbloomDamage
	ICDTagNahidaSkill
	ICDTagNahidaC6
	ICDTagWandererA4
	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 Point added in v1.6.0

type Point struct {
	X, Y float64
}

func CalcDirection added in v1.6.0

func CalcDirection(src, trg Point) Point

https://wumbo.net/formulas/angle-between-two-vectors-2d/

func CalcOffsetPoint added in v1.6.0

func CalcOffsetPoint(pos, offset, dir Point) Point

dir needs to be magnitude of 1 if passing custom dir; returns a new Point which is pos + rotated offset

func CalcRandomPointFromCenter added in v1.6.0

func CalcRandomPointFromCenter(center Point, minRadius float64, maxRadius float64, rand *rand.Rand) Point

generates a random point that is between minRadius and maxRadius distance away from the provided center

func DefaultDirection added in v1.6.0

func DefaultDirection() Point

func DegreesToDirection added in v1.7.0

func DegreesToDirection(angle float64) Point

converts the given angle in degrees into a direction vector; + means clockwise

func (Point) Add added in v1.6.0

func (p1 Point) Add(p2 Point) Point

func (Point) Cross added in v1.6.0

func (p1 Point) Cross(p2 Point) float64

func (Point) Distance added in v1.6.0

func (p1 Point) Distance(p2 Point) float64

func (Point) Dot added in v1.6.0

func (p1 Point) Dot(p2 Point) float64

func (Point) Magnitude added in v1.6.0

func (p Point) Magnitude() float64

func (Point) MagnitudeSquared added in v1.6.0

func (p Point) MagnitudeSquared() float64

func (Point) Mul added in v1.6.0

func (p1 Point) Mul(p2 Point) Point

func (Point) Normalize added in v1.6.0

func (p Point) Normalize() Point

func (Point) Perp added in v1.6.0

func (p1 Point) Perp() Point

func (Point) Pos added in v1.6.0

func (p Point) Pos() Point

func (Point) Rotate added in v1.6.0

func (p Point) Rotate(dir Point) Point

dir needs to be magnitude of 1 if passing custom dir; https://gamedev.stackexchange.com/a/97586 https://en.wikipedia.org/wiki/Rotation_matrix

func (Point) String added in v1.6.0

func (p Point) String() string

func (Point) Sub added in v1.6.0

func (p1 Point) Sub(p2 Point) Point

type Projection added in v1.6.0

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

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
}

center = true center of rect spawn = point rect extends outward from (centered on x, on y edge)

func NewRectangle added in v1.6.0

func NewRectangle(spawn Point, w, h float64, dir Point) *Rectangle

func (*Rectangle) IntersectCircle

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

func (*Rectangle) IntersectRectangle

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

this exists but is unused because targets are all circles other interesting links: https://stackoverflow.com/a/115520 https://gist.github.com/shamansir/3007244 https://stackoverflow.com/a/6016515

func (*Rectangle) PointInShape added in v1.7.0

func (r *Rectangle) PointInShape(p Point) bool

func (*Rectangle) Pos

func (r *Rectangle) Pos() Point

func (*Rectangle) SetPos

func (r *Rectangle) SetPos(p Point)

func (*Rectangle) String

func (r *Rectangle) String() string

type ResistMod added in v1.7.0

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

type Shape

type Shape interface {
	PointInShape(p Point) bool
	IntersectCircle(c Circle) bool
	IntersectRectangle(r Rectangle) bool
	String() string
	// contains filtered or unexported methods
}

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) PointInShape added in v1.7.0

func (s *SingleTarget) PointInShape(p Point) bool

func (*SingleTarget) Pos

func (s *SingleTarget) Pos() Point

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 Status added in v1.7.0

type Status struct {
	modifier.Base
}

type StrikeType

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

type Target

type Target interface {
	Key() TargetKey        // unique key for the target
	SetKey(k TargetKey)    // update key
	Type() TargettableType // type of target
	Shape() Shape          // shape of target
	Pos() Point            // center of target
	SetPos(p 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(TargettableType) bool
	CollidedWith(t Target)
	WillCollide(Shape) bool
	// direction related
	Direction() Point                  // returns viewing direction as a Point
	SetDirection(trg Point)            // calculates viewing direction relative to default direction (0, 1)
	SetDirectionToClosestEnemy()       // looks for closest enemy
	CalcTempDirection(trg Point) Point // used for stuff like Bow CA
}

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