-
Notifications
You must be signed in to change notification settings - Fork 96
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
Add back hurt syntax #1700
Conversation
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
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) |
There was a problem hiding this comment.
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
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") | ||
} |
There was a problem hiding this comment.
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
.
closes #836
removed params in favor of only proccing via taking dmg: