|
| 1 | +package varesa |
| 2 | + |
| 3 | +import ( |
| 4 | + "fmt" |
| 5 | + |
| 6 | + "github.com/genshinsim/gcsim/internal/frames" |
| 7 | + "github.com/genshinsim/gcsim/pkg/core/action" |
| 8 | + "github.com/genshinsim/gcsim/pkg/core/attacks" |
| 9 | + "github.com/genshinsim/gcsim/pkg/core/attributes" |
| 10 | + "github.com/genshinsim/gcsim/pkg/core/combat" |
| 11 | + "github.com/genshinsim/gcsim/pkg/core/geometry" |
| 12 | +) |
| 13 | + |
| 14 | +var ( |
| 15 | + attackFrames [][]int |
| 16 | + attackHitmarks = []int{23, 7, 33} |
| 17 | + attackHitlagHaltFrame = []float64{0, 0, 0.03} |
| 18 | + attackHitlagFactor = []float64{0, 0, 0.01} |
| 19 | + attackHitboxes = [][]float64{{2.5, 2.5}, {2.8, 3.5}, {2.5}} |
| 20 | + attackOffsets = []float64{-0.2, -0.2, 0} |
| 21 | + |
| 22 | + fieryAttackFrames [][]int |
| 23 | + fieryAttackHitmarks = []int{17, 29, 37} |
| 24 | + fieryAttackHitboxes = [][]float64{{2.5}, {4, 4}, {4, 4.5}} |
| 25 | + fieryAttackOffsets = []float64{1, -0.5, -0.5} |
| 26 | +) |
| 27 | + |
| 28 | +const normalHitNum = 3 |
| 29 | + |
| 30 | +func init() { |
| 31 | + attackFrames = make([][]int, normalHitNum) |
| 32 | + |
| 33 | + attackFrames[0] = frames.InitNormalCancelSlice(attackHitmarks[0], 49) // N1 -> Walk |
| 34 | + attackFrames[0][action.ActionAttack] = 33 |
| 35 | + attackFrames[0][action.ActionCharge] = 23 |
| 36 | + |
| 37 | + attackFrames[1] = frames.InitNormalCancelSlice(attackHitmarks[1], 30) // N2 -> N3 |
| 38 | + attackFrames[1][action.ActionCharge] = 17 |
| 39 | + attackFrames[1][action.ActionWalk] = 28 |
| 40 | + |
| 41 | + attackFrames[2] = frames.InitNormalCancelSlice(attackHitmarks[2], 59) // N3 -> Walk |
| 42 | + attackFrames[2][action.ActionAttack] = 45 |
| 43 | + attackFrames[2][action.ActionCharge] = 32 |
| 44 | + |
| 45 | + fieryAttackFrames = make([][]int, normalHitNum) |
| 46 | + |
| 47 | + fieryAttackFrames[0] = frames.InitNormalCancelSlice(fieryAttackHitmarks[0], 39) // N1 -> Walk |
| 48 | + fieryAttackFrames[0][action.ActionAttack] = 29 |
| 49 | + fieryAttackFrames[0][action.ActionCharge] = 31 |
| 50 | + |
| 51 | + fieryAttackFrames[1] = frames.InitNormalCancelSlice(fieryAttackHitmarks[1], 47) // N2 -> Walk |
| 52 | + fieryAttackFrames[1][action.ActionAttack] = 39 |
| 53 | + fieryAttackFrames[1][action.ActionCharge] = 25 |
| 54 | + |
| 55 | + fieryAttackFrames[2] = frames.InitNormalCancelSlice(fieryAttackHitmarks[2], 63) // N3 -> N4/Walk |
| 56 | + fieryAttackFrames[2][action.ActionCharge] = 37 |
| 57 | +} |
| 58 | + |
| 59 | +func (c *char) Attack(p map[string]int) (action.Info, error) { |
| 60 | + // OnRemoved is sometimes called after the next action is executed. so we need to exit nightsoul here too |
| 61 | + c.clearNightsoulCB(action.NormalAttackState) |
| 62 | + |
| 63 | + if c.StatusIsActive(skillStatus) { |
| 64 | + // TODO: or c.Core.Player.Exec(action.ActionCharge, c.Base.Key, nil) |
| 65 | + return c.ChargeAttack(p) |
| 66 | + } |
| 67 | + if c.nightsoulState.HasBlessing() { |
| 68 | + return c.fieryAttack(), nil |
| 69 | + } |
| 70 | + |
| 71 | + windup := 0 |
| 72 | + if c.NormalCounter == 0 { |
| 73 | + if c.Core.Player.CurrentState() == action.BurstState && c.usedShortBurst { |
| 74 | + windup = 4 |
| 75 | + } else { |
| 76 | + windup = 6 |
| 77 | + } |
| 78 | + } |
| 79 | + |
| 80 | + ai := combat.AttackInfo{ |
| 81 | + ActorIndex: c.Index, |
| 82 | + Abil: fmt.Sprintf("Normal %v", c.NormalCounter), |
| 83 | + AttackTag: attacks.AttackTagNormal, |
| 84 | + ICDTag: attacks.ICDTagNormalAttack, |
| 85 | + ICDGroup: attacks.ICDGroupDefault, |
| 86 | + StrikeType: attacks.StrikeTypeDefault, |
| 87 | + Element: attributes.Electro, |
| 88 | + Durability: 25, |
| 89 | + Mult: attack[c.NormalCounter][c.TalentLvlAttack()], |
| 90 | + HitlagFactor: attackHitlagFactor[c.NormalCounter], |
| 91 | + HitlagHaltFrames: attackHitlagHaltFrame[c.NormalCounter] * 60, |
| 92 | + CanBeDefenseHalted: true, |
| 93 | + } |
| 94 | + var ap combat.AttackPattern |
| 95 | + switch len(attackHitboxes[c.NormalCounter]) { |
| 96 | + case 1: // circle |
| 97 | + ap = combat.NewCircleHitOnTarget( |
| 98 | + c.Core.Combat.Player(), |
| 99 | + geometry.Point{Y: attackOffsets[c.NormalCounter]}, |
| 100 | + attackHitboxes[c.NormalCounter][0], |
| 101 | + ) |
| 102 | + case 2: // box |
| 103 | + ap = combat.NewBoxHitOnTarget( |
| 104 | + c.Core.Combat.Player(), |
| 105 | + geometry.Point{Y: attackOffsets[c.NormalCounter]}, |
| 106 | + attackHitboxes[c.NormalCounter][0], |
| 107 | + attackHitboxes[c.NormalCounter][1], |
| 108 | + ) |
| 109 | + } |
| 110 | + c.Core.QueueAttack(ai, ap, attackHitmarks[c.NormalCounter]-windup, attackHitmarks[c.NormalCounter]-windup) |
| 111 | + |
| 112 | + defer c.AdvanceNormalIndex() |
| 113 | + |
| 114 | + return action.Info{ |
| 115 | + Frames: func(next action.Action) int { return attackFrames[c.NormalCounter][next] - windup }, |
| 116 | + AnimationLength: attackFrames[c.NormalCounter][action.InvalidAction] - windup, |
| 117 | + CanQueueAfter: attackHitmarks[c.NormalCounter] - windup, |
| 118 | + State: action.NormalAttackState, |
| 119 | + }, nil |
| 120 | +} |
| 121 | + |
| 122 | +func (c *char) fieryAttack() action.Info { |
| 123 | + ai := combat.AttackInfo{ |
| 124 | + ActorIndex: c.Index, |
| 125 | + Abil: fmt.Sprintf("Fiery Passion %v", c.NormalCounter), |
| 126 | + AttackTag: attacks.AttackTagNormal, |
| 127 | + ICDTag: attacks.ICDTagNormalAttack, |
| 128 | + ICDGroup: attacks.ICDGroupDefault, |
| 129 | + StrikeType: attacks.StrikeTypeDefault, |
| 130 | + Element: attributes.Electro, |
| 131 | + Durability: 25, |
| 132 | + Mult: fieryAttack[c.NormalCounter][c.TalentLvlAttack()], |
| 133 | + HitlagFactor: 0.01, |
| 134 | + HitlagHaltFrames: 0.03 * 60, |
| 135 | + CanBeDefenseHalted: true, |
| 136 | + } |
| 137 | + |
| 138 | + windup := 6 |
| 139 | + switch c.Core.Player.CurrentState() { |
| 140 | + case action.NormalAttackState: |
| 141 | + windup = 0 |
| 142 | + case action.BurstState: |
| 143 | + if c.usedShortBurst { |
| 144 | + windup = 0 |
| 145 | + } else { |
| 146 | + windup = 4 |
| 147 | + } |
| 148 | + } |
| 149 | + |
| 150 | + var ap combat.AttackPattern |
| 151 | + switch len(fieryAttackHitboxes[c.NormalCounter]) { |
| 152 | + case 1: // circle |
| 153 | + ap = combat.NewCircleHitOnTarget( |
| 154 | + c.Core.Combat.Player(), |
| 155 | + geometry.Point{Y: fieryAttackOffsets[c.NormalCounter]}, |
| 156 | + fieryAttackHitboxes[c.NormalCounter][0], |
| 157 | + ) |
| 158 | + case 2: // box |
| 159 | + ap = combat.NewBoxHitOnTarget( |
| 160 | + c.Core.Combat.Player(), |
| 161 | + geometry.Point{Y: fieryAttackOffsets[c.NormalCounter]}, |
| 162 | + fieryAttackHitboxes[c.NormalCounter][0], |
| 163 | + fieryAttackHitboxes[c.NormalCounter][1], |
| 164 | + ) |
| 165 | + } |
| 166 | + c.Core.QueueAttack(ai, ap, fieryAttackHitmarks[c.NormalCounter]-windup, fieryAttackHitmarks[c.NormalCounter]-windup) |
| 167 | + |
| 168 | + defer c.AdvanceNormalIndex() |
| 169 | + |
| 170 | + return action.Info{ |
| 171 | + Frames: func(next action.Action) int { return fieryAttackFrames[c.NormalCounter][next] - windup }, |
| 172 | + AnimationLength: fieryAttackFrames[c.NormalCounter][action.InvalidAction] - windup, |
| 173 | + CanQueueAfter: fieryAttackHitmarks[c.NormalCounter] - windup, |
| 174 | + State: action.NormalAttackState, |
| 175 | + } |
| 176 | +} |
0 commit comments