From 0d8f95354f4dceb4e7a039bcae768b5223358238 Mon Sep 17 00:00:00 2001 From: MEEP of Faith <54301439+MEEPofFaith@users.noreply.github.com> Date: Sat, 10 Apr 2021 06:15:34 -0700 Subject: [PATCH] Move damage and knockback to `hitEntity` (#5000) * Move damge and knockback to `hitEntity` * b.damage, not damage --- core/src/mindustry/entities/bullet/BulletType.java | 9 ++++++++- core/src/mindustry/entities/bullet/RailBulletType.java | 1 + core/src/mindustry/entities/comp/BulletComp.java | 6 ------ 3 files changed, 9 insertions(+), 7 deletions(-) diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 202a73d7e0..a824c3a5ff 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -185,8 +185,15 @@ public abstract class BulletType extends Content{ } } - public void hitEntity(Bullet b, Hitboxc other, float initialHealth){ + public void hitEntity(Bullet b, Hitboxc entity, float initialHealth){ + if(entity instanceof Healthc h){ + h.damage(b.damage); + } + if(entity instanceof Unit unit){ + unit.impulse(Tmp.v3.set(unit).sub(b.x, b.y).nor().scl(knockback * 80f)); + unit.apply(status, statusDuration); + } } public void hit(Bullet b){ diff --git a/core/src/mindustry/entities/bullet/RailBulletType.java b/core/src/mindustry/entities/bullet/RailBulletType.java index a41d326bd8..bb833669ac 100644 --- a/core/src/mindustry/entities/bullet/RailBulletType.java +++ b/core/src/mindustry/entities/bullet/RailBulletType.java @@ -71,6 +71,7 @@ public class RailBulletType extends BulletType{ @Override public void hitEntity(Bullet b, Hitboxc entity, float initialHealth){ handle(b, entity, initialHealth); + super.hitEntity(b, entity, initialHealth); } @Override diff --git a/core/src/mindustry/entities/comp/BulletComp.java b/core/src/mindustry/entities/comp/BulletComp.java index 7f3d42d4e0..a61ecc4d39 100644 --- a/core/src/mindustry/entities/comp/BulletComp.java +++ b/core/src/mindustry/entities/comp/BulletComp.java @@ -93,12 +93,6 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw if(other instanceof Healthc h){ health = h.health(); - h.damage(damage); - } - - if(other instanceof Unit unit){ - unit.impulse(Tmp.v3.set(unit).sub(this.x, this.y).nor().scl(type.knockback * 80f)); - unit.apply(type.status, type.statusDuration); } //must be last.