Skip to content

Commit ec8c0c8

Browse files
committed
EMP cloud instead of weird sparking orbs
1 parent 558dc61 commit ec8c0c8

File tree

4 files changed

+153
-45
lines changed

4 files changed

+153
-45
lines changed

src/progressed/content/bullets/PayloadBullets.java

+5-33
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ public static void load(){
341341

342342
hitSound = PMSounds.nuclearExplosion;
343343
hitShake = 30f;
344-
despawnEffect = MissileFx.nuclearExplosion;
344+
despawnEffect = Fx.none;
345345
absorbEffect = Pseudo3DFx.absorbedLarge;
346346

347347
zoneRadius = 8f * 8f;
@@ -352,41 +352,13 @@ public static void load(){
352352

353353
accel = 0.01f;
354354
gravity = 0.02f;
355-
fragBullets = 60;
355+
fragBullets = 1;
356356
fragRandomSpread = 0;
357-
fragSpread = 360f / fragBullets;
358-
fragVelocityMin = fragVelocityMax = fragLifeMin = fragLifeMax = 1f;
359-
fragBullet = new SparkingBulletType(2.5f, 0, "large-orb"){{
360-
//Distance to travel... ~40 tiles?
361-
lifetime = (40 * 8) / speed * 4f;
362-
drag = 0.01f;
363-
364-
empRadius = 6f * 8f;
365-
empDamage = 150f;
366-
367-
width = height = 15f;
368-
shrinkX = shrinkY = 0f;
369-
frontColor = hitColor = Pal.lancerLaser;
370-
backColor = trailColor = PMPal.lancerlaserDark;
371-
//trailWidth = 3.25f;
372-
//trailLength = 24;
373-
hitEffect = Fx.none;
374-
357+
fragBullet = new EMPCloudBulletType(150f){{
358+
lifetime = 15f * 60f;
375359
status = PMStatusEffects.empStun;
376-
suppressionRange = 10f * 8f;
360+
radius = suppressionRange = 40f * tilesize;
377361
statusDuration = suppressionDuration = 7f * 60f;
378-
collides = false;
379-
hittable = absorbable = false;
380-
381-
trailInterval = 2f;
382-
trailEffect = MissileFx.hitEmpSpark;
383-
//hitSound = Sounds.spark;
384-
385-
despawnEffect = new WaveEffect(){{
386-
lifetime = 10f;
387-
sizeTo = 30f;
388-
colorFrom = colorTo = Pal.lancerLaser;
389-
}};
390362
}};
391363
}};
392364

src/progressed/content/effects/LightningFx.java

+6-12
Original file line numberDiff line numberDiff line change
@@ -9,19 +9,13 @@ public class LightningFx{
99

1010
groundCrack = new LightningEffect(20f, 500f, 1.5f).layer(Layer.debris - 0.01f).extend(true).width(10f),
1111

12-
staticLightning = new LightningEffect(10f, 500f, 2f){{
13-
colorFrom = Color.white;
14-
}}.layer(Layer.bullet + 0.01f).width(5f),
12+
staticLightning = new LightningEffect(10f, 500f, 2f).colorFrom(Color.white).layer(Layer.bullet + 0.01f).width(5f),
1513

16-
teslaLightning = new LightningEffect(10f, 500f, 3.5f){{
17-
colorFrom = Color.white;
18-
}}.layer(Layer.bullet + 0.01f).shrink(true),
14+
teslaLightning = new LightningEffect(10f, 500f, 3.5f).colorFrom(Color.white).layer(Layer.bullet + 0.01f).shrink(true),
1915

20-
flameBeam = new LightningEffect(10f, 500f, 3f){{
21-
colorFrom = Color.white;
22-
}}.layer(Layer.bullet + 0.01f).width(16f).shrink(true),
16+
flameBeam = new LightningEffect(10f, 500f, 3f).colorFrom(Color.white).layer(Layer.bullet + 0.01f).width(16f).shrink(true),
2317

24-
blazeBeam = new LightningEffect(10f, 500f, 4f){{
25-
colorFrom = Color.white;
26-
}}.layer(Layer.bullet + 0.01f).width(20f).shrink(true);
18+
blazeBeam = new LightningEffect(10f, 500f, 4f).colorFrom(Color.white).layer(Layer.bullet + 0.01f).width(20f).shrink(true),
19+
20+
empLightning = new LightningEffect(60f, 500f, 2f).colorFrom(Color.white).width(12f).extend(true);
2721
}

src/progressed/entities/LightningEffect.java

+10
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,16 @@ public LightningEffect(){
3535
followParent = false;
3636
}
3737

38+
public LightningEffect colorFrom(Color colorFrom){
39+
this.colorFrom = colorFrom;
40+
return this;
41+
}
42+
43+
public LightningEffect colorTo(Color colorTo){
44+
this.colorTo = colorTo;
45+
return this;
46+
}
47+
3848
public LightningEffect shrink(boolean s){
3949
shrink = s;
4050
return this;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,132 @@
1+
package progressed.entities.bullet.energy;
2+
3+
import arc.graphics.*;
4+
import arc.graphics.g2d.*;
5+
import arc.math.*;
6+
import arc.util.*;
7+
import mindustry.*;
8+
import mindustry.content.*;
9+
import mindustry.entities.*;
10+
import mindustry.entities.bullet.*;
11+
import mindustry.gen.*;
12+
import mindustry.graphics.*;
13+
import progressed.content.effects.*;
14+
import progressed.entities.*;
15+
import progressed.util.*;
16+
17+
import static mindustry.Vars.*;
18+
19+
public class EMPCloudBulletType extends BulletType{
20+
protected static Rand cloudRand = new Rand();
21+
22+
public float radius = 20f * tilesize;
23+
public float growTime = 6f * 60f;
24+
public float empInterval = 20f;
25+
public float timeDuration = 60f * 10f;
26+
public float powerDamageScl = 2f, powerSclDecrease = 0.2f;
27+
public boolean hitUnits = true;
28+
public float unitDamageScl = 0.5f;
29+
public Color cloudColor = Pal.lancerLaser.cpy().a(0.125f);
30+
public int cloudGroups = 15, cloudsPerGroup = 6;
31+
public float cloudLifeMin = 0.9f;
32+
public float cloudRad = 9f * tilesize, cloudRadRand = -1f;
33+
public Effect hitPowerEffect = MissileFx.hitEmpSpark;
34+
public float lightningEffectChance = 0.5f;
35+
public LightningEffect lightningEffect = LightningFx.empLightning;
36+
37+
public EMPCloudBulletType(float damage){
38+
super(0f, damage);
39+
collides = hittable = absorbable = false;
40+
hitEffect = despawnEffect = Fx.none;
41+
hitColor = Pal.lancerLaser;
42+
layer = Layer.effect + 0.021f;
43+
}
44+
45+
@Override
46+
public void init(){
47+
super.init();
48+
drawSize = Math.max(drawSize, (radius + cloudRad + cloudRadRand) * 2);
49+
if(cloudRadRand < 0f) cloudRadRand = cloudRad / 2f;
50+
}
51+
52+
@Override
53+
public void draw(Bullet b){
54+
Draw.color(cloudColor);
55+
float scl = scl(b);
56+
for(int i = 0; i < cloudGroups; i++){
57+
cloudRand.setSeed(b.id + i);
58+
float lifeScl = cloudRand.random(cloudLifeMin, 1f);
59+
60+
float fin = b.fin() / lifeScl;
61+
if(fin >= 1) continue;
62+
63+
Angles.randLenVectors(b.id + i + cloudGroups, Interp.pow5Out.apply(Mathf.curve(b.time / lifeScl, 0f, growTime)), cloudsPerGroup, scl * radius, (x, y, in, out) -> {
64+
float fout = Interp.pow5Out.apply(1f - fin);
65+
float rad = scl * fout * (cloudRad + cloudRand.range(cloudRadRand));
66+
Fill.circle(b.x + x, b.y + y, rad);
67+
});
68+
}
69+
}
70+
71+
@Override
72+
public void drawLight(Bullet b){
73+
if(lightOpacity <= 0f || lightRadius <= 0f) return;
74+
float scl = Interp.pow3Out.apply(Mathf.curve(b.time, 0f, growTime));
75+
Drawf.light(b, lightRadius * scl, lightColor, lightOpacity);
76+
}
77+
78+
@Override
79+
public void update(Bullet b){
80+
super.update(b);
81+
updateLightningEffects(b);
82+
updateEmp(b);
83+
}
84+
85+
public void updateLightningEffects(Bullet b){
86+
if(lightningEffectChance > 0.01f &&
87+
b.time < b.lifetime - lightningEffect.lifetime &&
88+
Mathf.chanceDelta(lightningEffectChance * b.fout(Interp.pow5Out))
89+
){
90+
float rad = rad(b);
91+
PMMathf.randomCirclePoint(Tmp.v1, rad);
92+
Tmp.v1.add(b);
93+
float x1 = Tmp.v1.x, y1 = Tmp.v1.y;
94+
PMMathf.randomCirclePoint(Tmp.v1, rad);
95+
Tmp.v1.add(b);
96+
lightningEffect.at(x1, y1, Tmp.v1.x, Tmp.v1.y, hitColor);
97+
}
98+
}
99+
100+
public void updateEmp(Bullet b){
101+
if(!b.timer(3, empInterval)) return;
102+
103+
float rad = rad(b);
104+
Vars.indexer.allBuildings(b.x, b.y, rad, other -> {
105+
if(other.team != b.team && other.power != null){
106+
if(other.power.graph.getLastPowerProduced() > 0f){
107+
other.applySlowdown(powerSclDecrease, timeDuration);
108+
other.damage(b.damage * powerDamageScl);
109+
hitPowerEffect.at(other.x, other.y, b.angleTo(other), hitColor);
110+
}
111+
}
112+
});
113+
114+
if(hitUnits){
115+
Units.nearbyEnemies(b.team, b.x, b.y, radius, other -> {
116+
if(other.team != b.team && other.hittable()){
117+
hitPowerEffect.at(other.x, other.y, b.angleTo(other), hitColor);
118+
other.damage(damage * unitDamageScl);
119+
other.apply(status, statusDuration);
120+
}
121+
});
122+
}
123+
}
124+
125+
public float scl(Bullet b){
126+
return Interp.pow5Out.apply(Mathf.curve(b.time, 0f, growTime));
127+
}
128+
129+
public float rad(Bullet b){
130+
return scl(b) * radius;
131+
}
132+
}

0 commit comments

Comments
 (0)