diff --git a/core/src/mindustry/content/Bullets.java b/core/src/mindustry/content/Bullets.java index 9b7e5f8805..514a9d9518 100644 --- a/core/src/mindustry/content/Bullets.java +++ b/core/src/mindustry/content/Bullets.java @@ -379,12 +379,18 @@ public class Bullets implements ContentList{ JsonIO.copy(damageLightning, damageLightningGround); damageLightningGround.collidesAir = false; - healBullet = new HealBulletType(5.2f, 13){{ + healBullet = new LaserBoltBulletType(5.2f, 13){{ healPercent = 3f; + collidesTeam = true; + backColor = Pal.heal; + frontColor = Color.white; }}; - healBulletBig = new HealBulletType(5.2f, 15){{ + healBulletBig = new LaserBoltBulletType(5.2f, 15){{ healPercent = 5.5f; + collidesTeam = true; + backColor = Pal.heal; + frontColor = Color.white; }}; fireball = new BulletType(1f, 4){ diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 5cae2c66bb..c676c3fefd 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -1191,6 +1191,10 @@ public class UnitTypes implements ContentList{ smokeEffect = Fx.hitLaser; frontColor = Color.white; + healPercent = 5.5f; + collidesTeam = true; + backColor = Pal.heal; + frontColor = Color.white; backColor = Pal.heal; trailColor = Pal.heal; }}; @@ -1292,6 +1296,7 @@ public class UnitTypes implements ContentList{ speed = 0.001f; collides = false; + healPercent = 10f; splashDamage = 240f; splashDamageRadius = 115f; }}; diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 238a09f75c..55ab9de42f 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -13,6 +13,7 @@ import mindustry.gen.*; import mindustry.graphics.*; import mindustry.type.*; import mindustry.world.*; +import mindustry.world.blocks.*; import static mindustry.Vars.*; @@ -77,6 +78,8 @@ public abstract class BulletType extends Content{ public boolean backMove = true; /** Bullet range override. */ public float range = -1f; + /** Heal Bullet Percent **/ + public float healPercent = 0f; //additional effects @@ -139,11 +142,16 @@ public abstract class BulletType extends Content{ } public boolean collides(Bullet bullet, Building tile){ - return true; + return healPercent == 0f ? true : (tile.team != bullet.team || tile.healthf() < 1f); } public void hitTile(Bullet b, Building tile, float initialHealth){ hit(b); + + if(healPercent > 0f && tile.team == b.team && !(tile.block instanceof ConstructBlock)){ + Fx.healBlockFull.at(tile.x, tile.y, tile.block.size, Pal.heal); + tile.heal(healPercent / 100f * tile.maxHealth()); + } } public void hitEntity(Bullet b, Hitboxc other, float initialHealth){ @@ -185,6 +193,13 @@ public abstract class BulletType extends Content{ if(status != StatusEffects.none){ Damage.status(b.team, x, y, splashDamageRadius, status, statusDuration, collidesAir, collidesGround); } + + if(healPercent >= 0f) { + indexer.eachBlock(b.team, x, y, splashDamageRadius, other -> other.damaged(), other -> { + Fx.healBlockFull.at(other.x, other.y, other.block.size, Pal.heal); + other.heal(healPercent / 100f * other.maxHealth()); + }); + } } for(int i = 0; i < lightning; i++){ diff --git a/core/src/mindustry/entities/bullet/HealBulletType.java b/core/src/mindustry/entities/bullet/HealBulletType.java deleted file mode 100644 index b811790000..0000000000 --- a/core/src/mindustry/entities/bullet/HealBulletType.java +++ /dev/null @@ -1,55 +0,0 @@ -package mindustry.entities.bullet; - -import arc.graphics.*; -import arc.graphics.g2d.*; -import mindustry.content.*; -import mindustry.gen.*; -import mindustry.graphics.*; -import mindustry.world.blocks.*; - -public class HealBulletType extends BulletType{ - protected float healPercent = 3f; - protected float height = 7f, width = 2f; - protected Color backColor = Pal.heal, frontColor = Color.white; - - public HealBulletType(float speed, float damage){ - super(speed, damage); - - shootEffect = Fx.shootHeal; - smokeEffect = Fx.hitLaser; - hitEffect = Fx.hitLaser; - despawnEffect = Fx.hitLaser; - collidesTeam = true; - hittable = false; - reflectable = false; - } - - public HealBulletType(){ - this(1f, 1f); - } - - @Override - public boolean collides(Bullet b, Building tile){ - return tile.team != b.team || tile.healthf() < 1f; - } - - @Override - public void draw(Bullet b){ - Draw.color(backColor); - Lines.stroke(width); - Lines.lineAngleCenter(b.x, b.y, b.rotation(), height); - Draw.color(frontColor); - Lines.lineAngleCenter(b.x, b.y, b.rotation(), height / 2f); - Draw.reset(); - } - - @Override - public void hitTile(Bullet b, Building tile, float initialHealth){ - super.hit(b); - - if(tile.team == b.team && !(tile.block instanceof ConstructBlock)){ - Fx.healBlockFull.at(tile.x, tile.y, tile.block.size, Pal.heal); - tile.heal(healPercent / 100f * tile.maxHealth()); - } - } -} diff --git a/core/src/mindustry/entities/bullet/LaserBoltBulletType.java b/core/src/mindustry/entities/bullet/LaserBoltBulletType.java new file mode 100644 index 0000000000..bd1332443f --- /dev/null +++ b/core/src/mindustry/entities/bullet/LaserBoltBulletType.java @@ -0,0 +1,34 @@ +package mindustry.entities.bullet; + +import arc.graphics.*; +import arc.graphics.g2d.*; +import mindustry.gen.*; +import mindustry.content.*; + +public class LaserBoltBulletType extends BasicBulletType{ + protected float height = 7f, width = 2f; + + public LaserBoltBulletType(float speed, float damage){ + super(speed, damage); + + smokeEffect = Fx.hitLaser; + hitEffect = Fx.hitLaser; + despawnEffect = Fx.hitLaser; + hittable = false; + reflectable = false; + } + + public LaserBoltBulletType(){ + this(1f, 1f); + } + + @Override + public void draw(Bullet b){ + Draw.color(backColor); + Lines.stroke(width); + Lines.lineAngleCenter(b.x, b.y, b.rotation(), height); + Draw.color(frontColor); + Lines.lineAngleCenter(b.x, b.y, b.rotation(), height / 2f); + Draw.reset(); + } +} diff --git a/core/src/mindustry/type/UnitType.java b/core/src/mindustry/type/UnitType.java index f927bc83d5..ff5d3658b0 100644 --- a/core/src/mindustry/type/UnitType.java +++ b/core/src/mindustry/type/UnitType.java @@ -230,7 +230,7 @@ public class UnitType extends UnlockableContent{ mechStepParticles = hitSize > 15f; } - canHeal = weapons.contains(w -> w.bullet instanceof HealBulletType); + canHeal = weapons.contains(w -> w.bullet.healPercent > 0f); //add mirrored weapon variants Seq mapped = new Seq<>();