Skip to content

Commit b8db7e1

Browse files
committed
fixup! Fixed emit OnEnemyHit to occur before pre damage mods
1 parent 4af46e9 commit b8db7e1

File tree

2 files changed

+15
-20
lines changed

2 files changed

+15
-20
lines changed

pkg/enemy/attack.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,11 @@ var particleIDToElement = []attributes.Element{
2424
}
2525

2626
func (e *Enemy) HandleAttack(atk *info.AttackEvent) float64 {
27-
grp_mult := 1.0
28-
27+
grpMult := 1.0
2928
if !atk.Info.SourceIsSim {
30-
grp_mult = e.GroupTagDamageMult(atk.Info.ICDTag, atk.Info.ICDGroup, atk.Info.ActorIndex)
29+
grpMult = e.GroupTagDamageMult(atk.Info.ICDTag, atk.Info.ICDGroup, atk.Info.ActorIndex)
3130
}
32-
33-
if grp_mult > 0 {
31+
if grpMult > 0 {
3432
e.Core.Combat.Events.Emit(event.OnEnemyHit, e, atk)
3533
}
3634

@@ -59,7 +57,7 @@ func (e *Enemy) HandleAttack(atk *info.AttackEvent) float64 {
5957
evt.Write("pre_damage_mods", preDmgModDebug)
6058
}
6159

62-
dmg, crit = e.attack(atk, evt, grp_mult)
60+
dmg, crit = e.attack(atk, evt, grpMult)
6361

6462
// delay damage event to end of the frame
6563
e.Core.Combat.Tasks.Add(func() {
@@ -91,7 +89,7 @@ func (e *Enemy) HandleAttack(atk *info.AttackEvent) float64 {
9189
return dmg
9290
}
9391

94-
func (e *Enemy) attack(atk *info.AttackEvent, evt glog.Event, grp_mult float64) (float64, bool) {
92+
func (e *Enemy) attack(atk *info.AttackEvent, evt glog.Event, grpMult float64) (float64, bool) {
9593
// if target is frozen prior to attack landing, set impulse to 0
9694
// let the break freeze attack to trigger actual impulse
9795
if e.GetAuraDurability(info.ReactionModKeyFrozen) > info.ZeroDur {
@@ -142,7 +140,7 @@ func (e *Enemy) attack(atk *info.AttackEvent, evt glog.Event, grp_mult float64)
142140
}
143141
}
144142

145-
damage, isCrit := e.calc(atk, evt, grp_mult)
143+
damage, isCrit := e.calc(atk, evt, grpMult)
146144

147145
// check for hitlag
148146
if e.Core.Combat.EnableHitlag {

pkg/enemy/damage.go

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@ import (
77
"github.com/genshinsim/gcsim/pkg/core/info"
88
)
99

10-
func (e *Enemy) calc(atk *info.AttackEvent, evt glog.Event, grp_mult float64) (float64, bool) {
10+
func (e *Enemy) calc(atk *info.AttackEvent, evt glog.Event, grpMult float64) (float64, bool) {
1111
var isCrit bool
1212

1313
if atk.Info.AttackTag == attacks.AttackTagDirectLunarCharged ||
1414
atk.Info.AttackTag == attacks.AttackTagDirectLunarBloom {
15-
e.calcDirectLunar(atk, evt)
15+
e.calcDirectLunar(atk, evt, grpMult)
1616
}
1717

1818
elePer := 0.0
@@ -111,19 +111,20 @@ func (e *Enemy) calc(atk *info.AttackEvent, evt glog.Event, grp_mult float64) (f
111111
damage *= (atk.Info.AmpMult * (1 + emBonus + reactBonus))
112112
}
113113

114+
// reduce damage by damage group
115+
damage *= grpMult
116+
114117
elevation := atk.Info.Elevation
115118
damage *= 1 + elevation
116119

117-
damage *= grp_mult
118-
119120
if e.Core.Flags.LogDebug {
120121
e.Core.Log.NewEvent(
121122
atk.Info.Abil,
122123
glog.LogCalc,
123124
atk.Info.ActorIndex,
124125
).
125126
Write("src_frame", atk.SourceFrame).
126-
Write("damage_grp_mult", grp_mult).
127+
Write("damage_grp_mult", grpMult).
127128
Write("damage", damage).
128129
Write("abil", atk.Info.Abil).
129130
Write("talent", atk.Info.Mult).
@@ -179,7 +180,7 @@ func (e *Enemy) calc(atk *info.AttackEvent, evt glog.Event, grp_mult float64) (f
179180
return damage, isCrit
180181
}
181182

182-
func (e *Enemy) calcDirectLunar(atk *info.AttackEvent, evt glog.Event) (float64, bool) {
183+
func (e *Enemy) calcDirectLunar(atk *info.AttackEvent, evt glog.Event, grpMult float64) (float64, bool) {
183184
var isCrit bool
184185

185186
// no DMG% for direct lunar damage
@@ -241,11 +242,7 @@ func (e *Enemy) calcDirectLunar(atk *info.AttackEvent, evt glog.Event) (float64,
241242
damage *= resmod
242243

243244
// reduce damage by damage group
244-
x := 1.0
245-
if !atk.Info.SourceIsSim {
246-
x = e.GroupTagDamageMult(atk.Info.ICDTag, atk.Info.ICDGroup, atk.Info.ActorIndex)
247-
damage *= x
248-
}
245+
damage *= grpMult
249246

250247
elevation := atk.Info.Elevation
251248
damage *= 1 + elevation
@@ -276,7 +273,7 @@ func (e *Enemy) calcDirectLunar(atk *info.AttackEvent, evt glog.Event) (float64,
276273
atk.Info.ActorIndex,
277274
).
278275
Write("src_frame", atk.SourceFrame).
279-
Write("damage_grp_mult", x).
276+
Write("damage_grp_mult", grpMult).
280277
Write("damage", damage).
281278
Write("abil", atk.Info.Abil).
282279
Write("talent", atk.Info.Mult).

0 commit comments

Comments
 (0)