mirror of
https://github.com/Anuken/Mindustry.git
synced 2026-01-25 05:51:47 -08:00
Movement Lightning Ability Improvements (#3901)
* Movement Lightning Ability Improvements * `Core.atlas.find` Might not always be avalable * Default is null * Fix
This commit is contained in:
parent
18fe2a1737
commit
77f31fd86c
1 changed files with 36 additions and 3 deletions
|
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue