Documentation ¶
Overview ¶
Package combat handles all combat related functionalities including
- target tracking
- target selection
- hitbox collision checking
- attack queueing
Index ¶
- Variables
- func AABBTest(a, b []Point) bool
- func IntersectRectangle(r Rectangle, c Circle) bool
- type AttackCB
- type AttackCBFunc
- type AttackEvent
- type AttackInfo
- type AttackPattern
- func NewBoxHit(src, center, offset positional, w, h float64) AttackPattern
- func NewBoxHitOnTarget(trg, offset positional, w, h float64) AttackPattern
- func NewCircleHit(src, center, offset positional, r float64) AttackPattern
- func NewCircleHitFanAngle(src, center, offset positional, r, fanAngle float64) AttackPattern
- func NewCircleHitOnTarget(trg, offset positional, r float64) AttackPattern
- func NewCircleHitOnTargetFanAngle(trg, offset positional, r, fanAngle float64) AttackPattern
- func NewSingleTargetHit(ind TargetKey) AttackPattern
- type AttackTag
- type CharHandler
- type Character
- type Circle
- type DefMod
- type Durability
- type Enemy
- type Gadget
- type GadgetTyp
- type Handler
- func (c *Handler) AbsorbCheck(p AttackPattern, prio ...attributes.Element) attributes.Element
- func (h *Handler) AddEnemy(t Target)
- func (h *Handler) AddGadget(t Gadget)
- func (h *Handler) ApplyAttack(a *AttackEvent) float64
- func (c *Handler) ClosestEnemiesWithinArea(a AttackPattern, filter func(t Enemy) bool) []Enemy
- func (c *Handler) ClosestEnemy(pos Point) Enemy
- func (c *Handler) ClosestEnemyWithinArea(a AttackPattern, filter func(t Enemy) bool) Enemy
- func (h *Handler) Enemies() []Target
- func (c *Handler) EnemiesWithinArea(a AttackPattern, filter func(t Enemy) bool) []Enemy
- func (h *Handler) Enemy(i int) Target
- func (h *Handler) EnemyCount() int
- func (h *Handler) Gadget(i int) Gadget
- func (h *Handler) GadgetCount() int
- func (h *Handler) Gadgets() []Gadget
- func (h *Handler) KillEnemy(i int)
- func (h *Handler) Player() Target
- func (h *Handler) PrimaryTarget() Target
- func (c *Handler) RandomEnemiesWithinArea(a AttackPattern, filter func(t Enemy) bool, maxCount int) []Enemy
- func (c *Handler) RandomEnemyWithinArea(a AttackPattern, filter func(t Enemy) bool) Enemy
- func (h *Handler) RemoveGadget(key TargetKey)
- func (h *Handler) ReplaceGadget(key TargetKey, t Gadget)
- func (h *Handler) SetEnemyPos(i int, p Point) bool
- func (h *Handler) SetPlayer(t Target)
- func (h *Handler) SetPlayerPos(p Point)
- func (h *Handler) Tick()
- type ICDGroup
- type ICDTag
- type Opt
- type Point
- func (p1 Point) Add(p2 Point) Point
- func (p1 Point) Cross(p2 Point) float64
- func (p1 Point) Distance(p2 Point) float64
- func (p1 Point) Dot(p2 Point) float64
- func (p Point) Magnitude() float64
- func (p Point) MagnitudeSquared() float64
- func (p1 Point) Mul(p2 Point) Point
- func (p Point) Normalize() Point
- func (p1 Point) Perp() Point
- func (p Point) Pos() Point
- func (p Point) Rotate(dir Point) Point
- func (p Point) String() string
- func (p1 Point) Sub(p2 Point) Point
- type Projection
- type ReactionType
- type Rectangle
- type ResistMod
- type Shape
- type SingleTarget
- type Snapshot
- type Status
- type StrikeType
- type Target
- type TargetKey
- type TargetWithAura
- type TargettableType
Constants ¶
This section is empty.
Variables ¶
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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, 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},
}
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 IntersectRectangle ¶ added in v1.6.0
shared between Circle and Rectangle https://stackoverflow.com/questions/401847/circle-rectangle-collision-detection-intersection https://yal.cc/rot-rect-vs-circle-intersection/
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 Character ¶
type Character interface {
ApplyAttackMods(a *AttackEvent, t Target) []interface{}
}
type Circle ¶
type Circle struct {
// contains filtered or unexported fields
}
func (*Circle) IntersectCircle ¶
func (*Circle) IntersectRectangle ¶
func (*Circle) PointInShape ¶ added in v1.7.0
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 Handler ¶
func (*Handler) AbsorbCheck ¶
func (c *Handler) AbsorbCheck(p AttackPattern, prio ...attributes.Element) attributes.Element
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
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) 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) EnemyCount ¶ added in v1.2.0
func (*Handler) GadgetCount ¶ added in v1.2.0
func (*Handler) PrimaryTarget ¶
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 (*Handler) ReplaceGadget ¶ added in v1.2.0
func (*Handler) SetPlayerPos ¶ added in v1.2.0
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 Point ¶ added in v1.6.0
type Point struct {
X, Y float64
}
func CalcDirection ¶ added in v1.6.0
func CalcOffsetPoint ¶ added in v1.6.0
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
converts the given angle in degrees into a direction vector; + means clockwise
func (Point) MagnitudeSquared ¶ added in v1.6.0
func (Point) Rotate ¶ added in v1.6.0
dir needs to be magnitude of 1 if passing custom dir; https://gamedev.stackexchange.com/a/97586 https://en.wikipedia.org/wiki/Rotation_matrix
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 (*Rectangle) IntersectCircle ¶
func (*Rectangle) IntersectRectangle ¶
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
type ResistMod ¶ added in v1.7.0
type ResistMod struct { Ele attributes.Element Value float64 modifier.Base }
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 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 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 )