From ba77f8e2aa41db388932289c94742408bfc17060 Mon Sep 17 00:00:00 2001 From: Leonwang4234 <62972692+Leonwang4234@users.noreply.github.com> Date: Thu, 15 Oct 2020 17:59:03 -0700 Subject: [PATCH 1/3] implement content --- core/src/mindustry/content/UnitTypes.java | 20 +++++++++++++++++++ core/src/mindustry/entities/Damage.java | 4 ++++ core/src/mindustry/entities/Lightning.java | 8 +++++++- .../mindustry/entities/bullet/BulletType.java | 2 ++ 4 files changed, 33 insertions(+), 1 deletion(-) diff --git a/core/src/mindustry/content/UnitTypes.java b/core/src/mindustry/content/UnitTypes.java index 9a1b851118..4849940423 100644 --- a/core/src/mindustry/content/UnitTypes.java +++ b/core/src/mindustry/content/UnitTypes.java @@ -330,6 +330,17 @@ public class UnitTypes implements ContentList{ lightningLength = 7; lightningLengthRand = 7; shootEffect = Fx.shootHeal; + + lightningHitter = new BulletType(0.0001f, 0f){{ + lifetime = Fx.lightning.lifetime; + hitEffect = Fx.hitLancer; + despawnEffect = Fx.none; + status = StatusEffects.shocked; + statusDuration = 10f; + hittable = false; + healPercent = 5f; + collidesTeam = true; + }}; }}; }}); }}; @@ -371,6 +382,8 @@ public class UnitTypes implements ContentList{ sideAngle = 45f; sideWidth = 1f; sideLength = 70f; + healPercent = 10f; + collidesTeam = true; colors = new Color[]{Pal.heal.cpy().a(0.4f), Pal.heal, Color.white}; }}; }}); @@ -430,6 +443,10 @@ public class UnitTypes implements ContentList{ incendSpread = 5f; incendAmount = 1; + //constant healing + healPercent = 0.5f; + collidesTeam = true; + colors = new Color[]{Pal.heal.cpy().a(.2f), Pal.heal.cpy().a(.5f), Pal.heal.cpy().mul(1.2f), Color.white}; }}; @@ -500,6 +517,9 @@ public class UnitTypes implements ContentList{ shootEffect = Fx.greenLaserCharge; + healPercent = 20f; + collidesTeam = true; + sideAngle = 15f; sideWidth = 0f; sideLength = 0f; diff --git a/core/src/mindustry/entities/Damage.java b/core/src/mindustry/entities/Damage.java index e22891eba5..04d0ad55c6 100644 --- a/core/src/mindustry/entities/Damage.java +++ b/core/src/mindustry/entities/Damage.java @@ -119,6 +119,10 @@ public class Damage{ collidedBlocks.add(tile.pos()); hitter.type.hit(hitter, tile.x, tile.y); } + //can heal? + if(tile != null && !collidedBlocks.contains(tile.pos()) && hitter.type.collides(hitter, tile)){ + hitter.type.hitTile(hitter, tile, 0f); + } }; if(hitter.type.collidesGround){ diff --git a/core/src/mindustry/entities/Lightning.java b/core/src/mindustry/entities/Lightning.java index 738bfa1f1e..300c151ef1 100644 --- a/core/src/mindustry/entities/Lightning.java +++ b/core/src/mindustry/entities/Lightning.java @@ -36,7 +36,13 @@ public class Lightning{ random.setSeed(seed); hit.clear(); - BulletType bulletType = hitter != null && !hitter.type.collidesAir ? Bullets.damageLightningGround : Bullets.damageLightning; + BulletType bulletType; + if(hitter != null && hitter.type.lightningHitter != null) { + bulletType = hitter.type.lightningHitter; + } else { + bulletType = hitter != null && !hitter.type.collidesAir ? Bullets.damageLightningGround : Bullets.damageLightning; + } + Seq lines = new Seq<>(); bhit = false; diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 0c3a605f1b..dd49a6c0a4 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -112,6 +112,8 @@ public abstract class BulletType extends Content{ public float lightningDamage = -1; public float lightningCone = 360f; public float lightningAngle = 0f; + /** The lighting "hitter"; Use when trying to implement special lightning. */ + public BulletType lightningHitter; public float weaveScale = 1f; public float weaveMag = -1f; From 9b95b975683d263ffa5477bb27bdc1a7d2cb9b42 Mon Sep 17 00:00:00 2001 From: Leonwang4234 <62972692+Leonwang4234@users.noreply.github.com> Date: Fri, 16 Oct 2020 08:54:29 -0700 Subject: [PATCH 2/3] (Should) prevent vela from setting fires to friendly tiles --- core/src/mindustry/entities/bullet/BulletType.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 87d6ceadd3..85bf80f7f5 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -161,11 +161,12 @@ public abstract class BulletType extends Content{ if(status == StatusEffects.burning) { Fires.create(tile.tile); } - 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()); + } else { + hit(b); } } From de483990ef9a7d6c4028d2b18d0a9485121f9ee5 Mon Sep 17 00:00:00 2001 From: Leonwang4234 <62972692+Leonwang4234@users.noreply.github.com> Date: Fri, 30 Oct 2020 09:04:44 -0700 Subject: [PATCH 3/3] formatting Why do I always make these mistakes? And I saw that I did the same thing in my incendiary-fire PR too... --- core/src/mindustry/entities/Lightning.java | 4 ++-- core/src/mindustry/entities/bullet/BulletType.java | 4 ++-- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/core/src/mindustry/entities/Lightning.java b/core/src/mindustry/entities/Lightning.java index 300c151ef1..9cb650aa8f 100644 --- a/core/src/mindustry/entities/Lightning.java +++ b/core/src/mindustry/entities/Lightning.java @@ -37,9 +37,9 @@ public class Lightning{ hit.clear(); BulletType bulletType; - if(hitter != null && hitter.type.lightningHitter != null) { + if(hitter != null && hitter.type.lightningHitter != null){ bulletType = hitter.type.lightningHitter; - } else { + }else{ bulletType = hitter != null && !hitter.type.collidesAir ? Bullets.damageLightningGround : Bullets.damageLightning; } diff --git a/core/src/mindustry/entities/bullet/BulletType.java b/core/src/mindustry/entities/bullet/BulletType.java index 85bf80f7f5..340ae14153 100644 --- a/core/src/mindustry/entities/bullet/BulletType.java +++ b/core/src/mindustry/entities/bullet/BulletType.java @@ -158,14 +158,14 @@ public abstract class BulletType extends Content{ } public void hitTile(Bullet b, Building tile, float initialHealth){ - if(status == StatusEffects.burning) { + if(status == StatusEffects.burning){ Fires.create(tile.tile); } 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()); - } else { + }else{ hit(b); } }