Skip to content

Commit

Permalink
player/player.go: Fix explosion damage (#869)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flonja authored Nov 17, 2024
1 parent 6a5c2fd commit 77eb52b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions server/block/explosion.go
Original file line number Diff line number Diff line change
Expand Up @@ -95,12 +95,12 @@ func (c ExplosionConfig) Explode(w *world.World, explosionPos mgl64.Vec3) {
if !e.Type().BBox(e).Translate(pos).IntersectsWith(box) {
continue
}
dist := pos.Sub(pos).Len()
if dist >= d {
dist := pos.Sub(explosionPos).Len()
if dist > d || dist == 0 {
continue
}
if explodable, ok := e.(ExplodableEntity); ok {
impact := (1 - dist/d) * exposure(pos, e)
impact := (1 - dist/d) * exposure(explosionPos, e)
explodable.Explode(explosionPos, impact, c)
}
}
Expand Down
2 changes: 1 addition & 1 deletion server/player/player.go
Original file line number Diff line number Diff line change
Expand Up @@ -708,7 +708,7 @@ func (p *Player) FinalDamageFrom(dmg float64, src world.DamageSource) float64 {
// Explode ...
func (p *Player) Explode(explosionPos mgl64.Vec3, impact float64, c block.ExplosionConfig) {
diff := p.Position().Sub(explosionPos)
p.Hurt(math.Floor((impact*impact+impact)*3.5*c.Size+1), entity.ExplosionDamageSource{})
p.Hurt(math.Floor((impact*impact+impact)/2*7*c.Size*2+1), entity.ExplosionDamageSource{})
p.knockBack(explosionPos, impact, diff[1]/diff.Len()*impact)
}

Expand Down

0 comments on commit 77eb52b

Please sign in to comment.