Make MoveLightningAbility alternating a boolean (#6390)

* Revert "BlueWolf does not want MoveLightningAbility to mirror (#6376)"

This reverts commit e1685ef46c.

* boolean `alternate`

* Better Javadoc description
This commit is contained in:
Matthew (or Maya) Peng
2021-11-29 20:05:35 -08:00
committed by GitHub
parent 3819e327e9
commit 8cb830ba41

View File

@@ -14,7 +14,7 @@ import mindustry.gen.*;
public class MoveLightningAbility extends Ability{ public class MoveLightningAbility extends Ability{
/** Lightning damage */ /** Lightning damage */
public float damage = 35f; public float damage = 35f;
/** Chance of firing every tick. Set >= 1 to always fire lightning every tick at max speed. */ /** Chance of firing every tick. Set >= 1 to always fire lightning every tick at max speed */
public float chance = 0.15f; public float chance = 0.15f;
/** Length of the lightning. <= 0 to disable */ /** Length of the lightning. <= 0 to disable */
public int length = 12; public int length = 12;
@@ -24,8 +24,10 @@ public class MoveLightningAbility extends Ability{
public Color color = Color.valueOf("a9d8ff"); public Color color = Color.valueOf("a9d8ff");
/** Shifts where the lightning spawns along the Y axis */ /** Shifts where the lightning spawns along the Y axis */
public float offset = 0f; public float offset = 0f;
/** Offset along the X axis. */ /** Offset along the X axis */
public float width = 0f; public float width = 0f;
/** Whether the spawn side alternates */
public boolean alternate = true;
/** Jittering heat sprite like the shield on v5 Javelin */ /** Jittering heat sprite like the shield on v5 Javelin */
public String heatRegion = "error"; public String heatRegion = "error";
/** Bullet type that is fired. Can be null */ /** Bullet type that is fired. Can be null */
@@ -37,6 +39,8 @@ public class MoveLightningAbility extends Ability{
public boolean parentizeEffects; public boolean parentizeEffects;
public Sound shootSound = Sounds.spark; public Sound shootSound = Sounds.spark;
protected float side = 1f;
MoveLightningAbility(){} MoveLightningAbility(){}
public MoveLightningAbility(float damage, int length, float chance, float offset, float minSpeed, float maxSpeed, Color color, String heatRegion){ public MoveLightningAbility(float damage, int length, float chance, float offset, float minSpeed, float maxSpeed, Color color, String heatRegion){
@@ -64,10 +68,10 @@ public class MoveLightningAbility extends Ability{
public void update(Unit unit){ public void update(Unit unit){
float scl = Mathf.clamp((unit.vel().len() - minSpeed) / (maxSpeed - minSpeed)); float scl = Mathf.clamp((unit.vel().len() - minSpeed) / (maxSpeed - minSpeed));
if(Mathf.chance(Time.delta * chance * scl)){ if(Mathf.chance(Time.delta * chance * scl)){
float x = unit.x + Angles.trnsx(unit.rotation, offset, width), y = unit.y + Angles.trnsy(unit.rotation, offset, width); float x = unit.x + Angles.trnsx(unit.rotation, offset, width * side), y = unit.y + Angles.trnsy(unit.rotation, offset, width * side);
shootEffect.at(x, y, unit.rotation, color, parentizeEffects ? unit : null); shootEffect.at(x, y, unit.rotation, color, parentizeEffects ? unit : null);
shootSound.at(unit); shootSound.at(x, y);
if(length > 0){ if(length > 0){
Lightning.create(unit.team, color, damage, x + unit.vel.x, y + unit.vel.y, unit.rotation, length); Lightning.create(unit.team, color, damage, x + unit.vel.x, y + unit.vel.y, unit.rotation, length);
@@ -76,6 +80,8 @@ public class MoveLightningAbility extends Ability{
if(bullet != null){ if(bullet != null){
bullet.create(unit, unit.team, x, y, unit.rotation + bulletAngle + Mathf.range(bulletSpread)); bullet.create(unit, unit.team, x, y, unit.rotation + bulletAngle + Mathf.range(bulletSpread));
} }
if(alternate) side *= -1f;
} }
} }