-
Notifications
You must be signed in to change notification settings - Fork 141
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
Implemented shields #643
base: master
Are you sure you want to change the base?
Implemented shields #643
Conversation
server/entity/arrow.go
Outdated
@@ -191,6 +191,11 @@ func (a *Arrow) Rotation() (float64, float64) { | |||
return a.yaw, a.pitch | |||
} | |||
|
|||
// blocker represents an entity that can block attacks with a shield. | |||
type blocker interface { | |||
Blocking() (bool, bool) |
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.
I would document this method and probably add named return types here, because it's unclear what this should return.
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.
note: resolved
server/player/player.go
Outdated
if ok, _ := p.Blocking(); ok && source.ReducedByArmour() { | ||
affected := true | ||
if src, ok := source.(damage.SourceEntityAttack); ok { | ||
diff := p.Position().Sub(src.Attacker.Position()) | ||
diff[1] = 0 | ||
if diff.Dot(entity.DirectionVector(p)) >= 0.0 { | ||
affected = false | ||
} | ||
} | ||
if affected { | ||
w.PlaySound(pos, sound.ShieldBlock{}) | ||
p.SetBlockingDelay(time.Millisecond * 250) | ||
|
||
if src, ok := source.(damage.SourceEntityAttack); ok { | ||
if l, ok := src.Attacker.(entity.Living); ok { | ||
l.KnockBack(pos, 0.5, 0.4) | ||
} | ||
if a, ok := src.Attacker.(*Player); ok { | ||
held, _ := a.HeldItems() | ||
if _, ok := held.Item().(item.Axe); ok { | ||
p.SetBlockingDelay(time.Second * 5) | ||
} | ||
} | ||
} | ||
if dmg >= 3.0 { | ||
i := int(math.Ceil(totalDamage)) | ||
held, other := p.HeldItems() | ||
if _, ok := held.Item().(item.Shield); ok { | ||
p.SetHeldItems(p.damageItem(held, i), other) | ||
} else { | ||
p.SetHeldItems(held, p.damageItem(other, i)) | ||
} | ||
} | ||
return 0, false | ||
} | ||
} |
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.
Could you pull this out in its own method and add some documentation (if and where relevant)? This is a massive block of code and Player.Hurt() is already a pretty big function as it is.
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.
any method name suggestions?
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.
this has been resolved, once the conflicts are resolved, are we ready to merge?
# Conflicts: # server/entity/arrow.go # server/player/player.go # server/session/entity_metadata.go
Anything about this? |
# Conflicts: # server/entity/arrow.go
) * Update player.go * various changes --------- Co-authored-by: RestartFU <[email protected]>
No description provided.