From 77f31fd86ccfdcc853a6f1b2945a5f93fe14abb3 Mon Sep 17 00:00:00 2001 From: MEEP of Faith <54301439+MEEPofFaith@users.noreply.github.com> Date: Tue, 19 Jan 2021 16:20:25 -0800 Subject: [PATCH] Movement Lightning Ability Improvements (#3901) * Movement Lightning Ability Improvements * `Core.atlas.find` Might not always be avalable * Default is null * Fix --- .../abilities/MoveLightningAbility.java | 39 +++++++++++++++++-- 1 file changed, 36 insertions(+), 3 deletions(-) diff --git a/core/src/mindustry/entities/abilities/MoveLightningAbility.java b/core/src/mindustry/entities/abilities/MoveLightningAbility.java index 17d3eaa23a..d03f08b01a 100644 --- a/core/src/mindustry/entities/abilities/MoveLightningAbility.java +++ b/core/src/mindustry/entities/abilities/MoveLightningAbility.java @@ -1,12 +1,15 @@ package mindustry.entities.abilities; +import arc.*; import arc.graphics.*; +import arc.graphics.g2d.*; import arc.math.*; import arc.util.*; import arc.audio.*; import mindustry.content.*; import mindustry.entities.*; import mindustry.gen.*; +import mindustry.graphics.*; public class MoveLightningAbility extends Ability{ //Lightning damage @@ -19,16 +22,32 @@ public class MoveLightningAbility extends Ability{ public float minSpeed = 0.8f, maxSpeed = 1.2f; //Lightning color public Color color = Color.valueOf("a9d8ff"); + //Shifts where the lightning spawns along the Y axis + public float offset = 0f; + //Jittering heat sprite like the shield on v5 Javelin + public String heatRegion = "error"; public Effect shootEffect = Fx.sparkShoot; public Sound shootSound = Sounds.spark; MoveLightningAbility(){} - public MoveLightningAbility(float damage, int length, float chance, float minSpeed, float maxSpeed, Color color){ + public MoveLightningAbility(float damage, int length, float chance, float offset, float minSpeed, float maxSpeed, Color color, String heatRegion){ this.damage = damage; this.length = length; this.chance = chance; + this.offset = offset; + this.minSpeed = minSpeed; + this.maxSpeed = maxSpeed; + this.color = color; + this.heatRegion = heatRegion; + } + + public MoveLightningAbility(float damage, int length, float chance, float offset, float minSpeed, float maxSpeed, Color color){ + this.damage = damage; + this.length = length; + this.chance = chance; + this.offset = offset; this.minSpeed = minSpeed; this.maxSpeed = maxSpeed; this.color = color; @@ -38,9 +57,23 @@ public class MoveLightningAbility extends Ability{ public void update(Unit unit){ float scl = Mathf.clamp((unit.vel().len() - minSpeed) / (maxSpeed - minSpeed)); if(Mathf.chance(Time.delta * chance * scl)){ - shootEffect.at(unit.x, unit.y, unit.rotation, color); - Lightning.create(unit.team, color, damage, unit.x + unit.vel.x, unit.y + unit.vel.y, unit.rotation, length); + float x = unit.x + Angles.trnsx(unit.rotation, offset, 0), y = unit.y + Angles.trnsy(unit.rotation, offset, 0); + shootEffect.at(x, y, unit.rotation, color); + Lightning.create(unit.team, color, damage, x + unit.vel.x, y + unit.vel.y, unit.rotation, length); shootSound.at(unit); } } + + @Override + public void draw(Unit unit){ + float scl = Mathf.clamp((unit.vel().len() - minSpeed) / (maxSpeed - minSpeed)); + TextureRegion region = Core.atlas.find(heatRegion); + if(Core.atlas.isFound(region) && scl > 0.00001f){ + Draw.color(color); + Draw.alpha(scl / 2f); + Draw.blend(Blending.additive); + Draw.rect(region, unit.x + Mathf.range(scl / 2f), unit.y + Mathf.range(scl / 2f), unit.rotation - 90); + Draw.blend(); + } + } }