Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add back hurt syntax #1700

Merged
merged 7 commits into from
Sep 10, 2023
Merged

Add back hurt syntax #1700

merged 7 commits into from
Sep 10, 2023

Conversation

k0l11
Copy link
Collaborator

@k0l11 k0l11 commented Sep 10, 2023

closes #836

removed params in favor of only proccing via taking dmg:

  • remove vourukashasglow stacks param
    • fix drain part triggering on non-external drain
  • remove beaconofthereedsea damaged param
  • remove alleyflash lambda param
    • fix drain part triggering if someone other than holder is drained
  • adjust drain event sub active checks

@k0l11 k0l11 added kind: enhancement New feature or request area: pkg Related to core logic labels Sep 10, 2023
@k0l11 k0l11 marked this pull request as draft September 10, 2023 21:00
@k0l11
Copy link
Collaborator Author

k0l11 commented Sep 10, 2023

will remove params that were crutches for this not existing

- fix drain part triggering on non-external drain
- fix drain part triggering if someone other than holder is drained
@k0l11 k0l11 marked this pull request as ready for review September 10, 2023 21:31
@k0l11 k0l11 enabled auto-merge (squash) September 10, 2023 21:36
Comment on lines +355 to +377
ai := combat.AttackInfo{
ActorIndex: s.C.Player.Active(),
Abil: "Hurt",
AttackTag: attacks.AttackTagNone,
ICDTag: attacks.ICDTagNone,
ICDGroup: attacks.ICDGroupDefault,
StrikeType: attacks.StrikeTypeDefault,
Durability: 0,
Element: s.cfg.Hurt.Element,
FlatDmg: amt,
}
ap := combat.NewSingleTargetHit(s.C.Combat.Player().Key())
ap.SkipTargets[targets.TargettablePlayer] = false
ap.SkipTargets[targets.TargettableEnemy] = true
ap.SkipTargets[targets.TargettableGadget] = true

s.C.QueueAttack(ai, ap, -1, f) // -1 to avoid snapshot

s.C.Log.NewEventBuildMsg(glog.LogHurtEvent, -1, "hurt queued (once)").
Write("last", s.cfg.Hurt.LastHurt).
Write("cfg", s.cfg.Hurt).
Write("amt", amt).
Write("hurt_frame", s.C.F+f)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: should move to function since code between every and once is basically the same

Comment on lines +29 to +120
func parseHurtOnce(p *Parser) (parseFn, error) {
//hurt once interval=300 amount=1,300 element=phys #once at frame 300
var err error
p.res.Hurt.Active = true
p.res.Hurt.Once = true

for n := p.next(); n.Typ != itemEOF; n = p.next() {
switch n.Typ {
case itemIdentifier:
switch n.Val {
case "interval":
n, err = p.acceptSeqReturnLast(itemAssign, itemNumber)
if err == nil {
p.res.Hurt.Start, err = itemNumberToInt(n)
}
case "amount":
err := parseHurtAmount(p)
if err != nil {
return nil, err
}
case "element":
err := parseHurtElement(p)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("ln%v: unrecognized hurt event specified: %v", n.line, n.Val)
}
case itemTerminateLine:
return parseRows, nil
default:
return nil, fmt.Errorf("ln%v: unrecognized token parsing hurt event: %v", n.line, n)
}
if err != nil {
return nil, err
}
}
return nil, errors.New("unexpected end of line while parsing hurt event")
}

func parseHurtEvery(p *Parser) (parseFn, error) {
//hurt every interval=480,720 amount=1,300 element=phys #randomly 1 to 300 dmg every 480 to 720 frames
var err error
p.res.Hurt.Active = true
p.res.Hurt.Once = false

for n := p.next(); n.Typ != itemEOF; n = p.next() {
switch n.Typ {
case itemIdentifier:
switch n.Val {
case "interval":
n, err = p.acceptSeqReturnLast(itemAssign, itemNumber)
if err != nil {
return nil, err
}
p.res.Hurt.Start, err = itemNumberToInt(n)
if err != nil {
return nil, err
}

n, err = p.acceptSeqReturnLast(itemComma, itemNumber)
if err != nil {
return nil, err
}
p.res.Hurt.End, err = itemNumberToInt(n)
if err != nil {
return nil, err
}
case "amount":
err := parseHurtAmount(p)
if err != nil {
return nil, err
}
case "element":
err := parseHurtElement(p)
if err != nil {
return nil, err
}
default:
return nil, fmt.Errorf("ln%v: unrecognized hurt event specified: %v", n.line, n.Val)
}
case itemTerminateLine:
return parseRows, nil
default:
return nil, fmt.Errorf("ln%v: unrecognized token parsing hurt event: %v", n.line, n)
}
if err != nil {
return nil, err
}
}
return nil, errors.New("unexpected end of line while parsing hurt event")
}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: best to not have repeat code and simplify to one function and extend interval support being either a start and end or specific frame regardless of if once or every.

@k0l11 k0l11 merged commit 5b544c7 into genshinsim:main Sep 10, 2023
@k0l11 k0l11 deleted the add-back-hurt branch September 10, 2023 21:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: pkg Related to core logic kind: enhancement New feature or request
Projects
None yet
Development

Successfully merging this pull request may close these issues.

add hurt syntax from prehitlag
2 participants