Ground support unit implementations

This commit is contained in:
Anuken 2020-07-10 12:14:24 -04:00
parent f39702e1cc
commit baa9f22a0b
35 changed files with 1267 additions and 1106 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 663 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 663 B

After

Width:  |  Height:  |  Size: 796 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 729 B

After

Width:  |  Height:  |  Size: 792 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 373 B

After

Width:  |  Height:  |  Size: 422 B

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1008 KiB

After

Width:  |  Height:  |  Size: 1020 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 182 KiB

After

Width:  |  Height:  |  Size: 184 KiB

File diff suppressed because it is too large Load Diff

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.6 MiB

After

Width:  |  Height:  |  Size: 1.6 MiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 183 KiB

After

Width:  |  Height:  |  Size: 185 KiB

View File

@ -1535,7 +1535,7 @@ public class Blocks implements ContentList{
@Override @Override
public void init(Bullet b){ public void init(Bullet b){
for(int i = 0; i < rays; i++){ for(int i = 0; i < rays; i++){
Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), rayLength - Math.abs(i - (rays / 2)) * 20f); Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rotation(), rayLength - Math.abs(i - (rays / 2)) * 20f);
} }
} }
@ -1547,11 +1547,11 @@ public class Blocks implements ContentList{
for(int i = 0; i < 7; i++){ for(int i = 0; i < 7; i++){
Tmp.v1.trns(b.rotation(), i * 8f); Tmp.v1.trns(b.rotation(), i * 8f);
float sl = Mathf.clamp(b.fout() - 0.5f) * (80f - i * 10); float sl = Mathf.clamp(b.fout() - 0.5f) * (80f - i * 10);
Drawf.tri(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, 4f, sl, b.rotation() + 90); Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rotation() + 90);
Drawf.tri(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, 4f, sl, b.rotation() - 90); Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, 4f, sl, b.rotation() - 90);
} }
Drawf.tri(b.x(), b.y(), 20f * b.fout(), (rayLength + 50), b.rotation()); Drawf.tri(b.x, b.y, 20f * b.fout(), (rayLength + 50), b.rotation());
Drawf.tri(b.x(), b.y(), 20f * b.fout(), 10f, b.rotation() + 180f); Drawf.tri(b.x, b.y, 20f * b.fout(), 10f, b.rotation() + 180f);
Draw.reset(); Draw.reset();
} }
}); });

View File

@ -437,31 +437,31 @@ public class Bullets implements ContentList{
@Override @Override
public void init(Bullet b){ public void init(Bullet b){
b.vel().setLength(0.6f + Mathf.random(2f)); b.vel.setLength(0.6f + Mathf.random(2f));
} }
@Override @Override
public void draw(Bullet b){ public void draw(Bullet b){
Draw.color(Pal.lightFlame, Pal.darkFlame, Color.gray, b.fin()); Draw.color(Pal.lightFlame, Pal.darkFlame, Color.gray, b.fin());
Fill.circle(b.x(), b.y(), 3f * b.fout()); Fill.circle(b.x, b.y, 3f * b.fout());
Draw.reset(); Draw.reset();
} }
@Override @Override
public void update(Bullet b){ public void update(Bullet b){
if(Mathf.chance(0.04 * Time.delta())){ if(Mathf.chance(0.04 * Time.delta())){
Tile tile = world.tileWorld(b.x(), b.y()); Tile tile = world.tileWorld(b.x, b.y);
if(tile != null){ if(tile != null){
Fires.create(tile); Fires.create(tile);
} }
} }
if(Mathf.chance(0.1 * Time.delta())){ if(Mathf.chance(0.1 * Time.delta())){
Fx.fireballsmoke.at(b.x(), b.y()); Fx.fireballsmoke.at(b.x, b.y);
} }
if(Mathf.chance(0.1 * Time.delta())){ if(Mathf.chance(0.1 * Time.delta())){
Fx.ballfire.at(b.x(), b.y()); Fx.ballfire.at(b.x, b.y);
} }
} }
}; };

View File

@ -6,6 +6,7 @@ import mindustry.ai.types.*;
import mindustry.annotations.Annotations.*; import mindustry.annotations.Annotations.*;
import mindustry.ctype.*; import mindustry.ctype.*;
import mindustry.entities.bullet.*; import mindustry.entities.bullet.*;
import mindustry.entities.units.*;
import mindustry.gen.*; import mindustry.gen.*;
import mindustry.graphics.*; import mindustry.graphics.*;
import mindustry.type.*; import mindustry.type.*;
@ -55,7 +56,7 @@ public class UnitTypes implements ContentList{
dagger = new UnitType("dagger"){{ dagger = new UnitType("dagger"){{
speed = 0.5f; speed = 0.5f;
hitsize = 8f; hitsize = 8f;
health = 130; health = 140;
weapons.add(new Weapon("large-weapon"){{ weapons.add(new Weapon("large-weapon"){{
reload = 14f; reload = 14f;
x = 4f; x = 4f;
@ -69,7 +70,8 @@ public class UnitTypes implements ContentList{
speed = 0.4f; speed = 0.4f;
hitsize = 9f; hitsize = 9f;
range = 10f; range = 10f;
health = 460; health = 500;
armor = 1f;
immunities.add(StatusEffects.burning); immunities.add(StatusEffects.burning);
@ -88,7 +90,9 @@ public class UnitTypes implements ContentList{
hitsize = 13f; hitsize = 13f;
rotateSpeed = 3f; rotateSpeed = 3f;
targetAir = false; targetAir = false;
health = 750; health = 790;
armor = 4f;
weapons.add(new Weapon("artillery"){{ weapons.add(new Weapon("artillery"){{
y = 1f; y = 1f;
x = 9f; x = 9f;
@ -104,7 +108,7 @@ public class UnitTypes implements ContentList{
width = height = 14f; width = height = 14f;
collides = true; collides = true;
collidesTiles = true; collidesTiles = true;
splashDamageRadius = 20f; splashDamageRadius = 24f;
splashDamage = 38f; splashDamage = 38f;
backColor = Pal.bulletYellowBack; backColor = Pal.bulletYellowBack;
frontColor = Pal.bulletYellow; frontColor = Pal.bulletYellow;
@ -119,10 +123,11 @@ public class UnitTypes implements ContentList{
itemCapacity = 60; itemCapacity = 60;
canBoost = true; canBoost = true;
boostMultiplier = 1.5f; boostMultiplier = 1.5f;
speed = 0.5f; speed = 0.52f;
hitsize = 8f; hitsize = 8f;
health = 100f; health = 110f;
buildSpeed = 0.8f; buildSpeed = 0.8f;
armor = 1f;
weapons.add(new Weapon("heal-weapon"){{ weapons.add(new Weapon("heal-weapon"){{
shootY = 2f; shootY = 2f;
@ -140,35 +145,63 @@ public class UnitTypes implements ContentList{
itemCapacity = 60; itemCapacity = 60;
canBoost = true; canBoost = true;
boostMultiplier = 1.5f; boostMultiplier = 1.5f;
speed = 0.5f; speed = 0.48f;
hitsize = 8f; hitsize = 10f;
health = 100f; health = 300f;
buildSpeed = 0.8f; buildSpeed = 0.9f;
armor = 3f;
weapons.add(new Weapon("heal-weapon"){{ mineTier = 2;
shootY = 2f; mineSpeed = 5f;
reload = 24f; commandLimit = 8;
x = 4.5f;
alternate = false; abilities.add(new HealFieldAbility(10f, 200f, 60f));
weapons.add(new Weapon("heal-shotgun-weapon"){{
x = 5f;
shake = 2.2f;
y = 0.5f;
shootY = 5f;
shootY = 2.5f;
reload = 38f;
shots = 3;
inaccuracy = 35;
shotDelay = 0.5f;
spacing = 0f;
ejectEffect = Fx.none; ejectEffect = Fx.none;
recoil = 2f; recoil = 2.5f;
bullet = Bullets.healBullet;
shootSound = Sounds.pew; shootSound = Sounds.pew;
bullet = new LightningBulletType(){{
lightningColor = hitColor = Pal.heal;
damage = 11f;
lightningLength = 7;
lightningLengthRand = 7;
shootEffect = Fx.shootHeal;
}};
}}); }});
}}; }};
quasar = new UnitType("quasar"){{ quasar = new UnitType("quasar"){{
mineTier = 1; mineTier = 1;
hitsize = 9f; hitsize = 12f;
boostMultiplier = 2f; boostMultiplier = 2f;
itemCapacity = 20; itemCapacity = 80;
health = 230f; health = 640f;
buildSpeed = 1.5f; buildSpeed = 1.7f;
canBoost = true; canBoost = true;
armor = 6f;
landShake = 2f;
speed = 0.4f; speed = 0.4f;
hitsize = 10f; hitsize = 10f;
mineTier = 2;
mineSpeed = 7f;
abilities.add(new HealFieldAbility(15f, 170f, 60f));
weapons.add(new Weapon("beam-weapon"){{ weapons.add(new Weapon("beam-weapon"){{
shake = 2f; shake = 2f;
shootY = 4f; shootY = 4f;
@ -178,7 +211,7 @@ public class UnitTypes implements ContentList{
shootSound = Sounds.laser; shootSound = Sounds.laser;
bullet = new LaserBulletType(){{ bullet = new LaserBulletType(){{
damage = 20f; damage = 27f;
recoil = 1f; recoil = 1f;
sideAngle = 45f; sideAngle = 45f;
sideWidth = 1f; sideWidth = 1f;

View File

@ -28,7 +28,7 @@ public class ArtilleryBulletType extends BasicBulletType{
super.update(b); super.update(b);
if(b.timer(0, 3 + b.fslope() * 2f)){ if(b.timer(0, 3 + b.fslope() * 2f)){
trailEffect.at(b.x(), b.y(), b.fslope() * 4f, backColor); trailEffect.at(b.x, b.y, b.fslope() * 4f, backColor);
} }
} }
@ -40,9 +40,9 @@ public class ArtilleryBulletType extends BasicBulletType{
float height = this.height * ((1f - shrinkY) + shrinkY * b.fout()); float height = this.height * ((1f - shrinkY) + shrinkY * b.fout());
Draw.color(backColor); Draw.color(backColor);
Draw.rect(backRegion, b.x(), b.y(), width * scale, height * scale, b.rotation() - 90); Draw.rect(backRegion, b.x, b.y, width * scale, height * scale, b.rotation() - 90);
Draw.color(frontColor); Draw.color(frontColor);
Draw.rect(frontRegion, b.x(), b.y(), width * scale, height * scale, b.rotation() - 90); Draw.rect(frontRegion, b.x, b.y, width * scale, height * scale, b.rotation() - 90);
Draw.color(); Draw.color();
} }
} }

View File

@ -44,9 +44,9 @@ public class BasicBulletType extends BulletType{
float width = this.width * ((1f - shrinkX) + shrinkX * b.fout()); float width = this.width * ((1f - shrinkX) + shrinkX * b.fout());
Draw.color(backColor); Draw.color(backColor);
Draw.rect(backRegion, b.x(), b.y(), width, height, b.rotation() - 90); Draw.rect(backRegion, b.x, b.y, width, height, b.rotation() - 90);
Draw.color(frontColor); Draw.color(frontColor);
Draw.rect(frontRegion, b.x(), b.y(), width, height, b.rotation() - 90); Draw.rect(frontRegion, b.x, b.y, width, height, b.rotation() - 90);
Draw.color(); Draw.color();
} }
} }

View File

@ -15,7 +15,7 @@ import mindustry.graphics.*;
import mindustry.type.*; import mindustry.type.*;
public abstract class BulletType extends Content{ public abstract class BulletType extends Content{
public float lifetime; public float lifetime = 40f;
public float speed; public float speed;
public float damage; public float damage;
public float hitSize = 4; public float hitSize = 4;
@ -100,7 +100,6 @@ public abstract class BulletType extends Content{
public BulletType(float speed, float damage){ public BulletType(float speed, float damage){
this.speed = speed; this.speed = speed;
this.damage = damage; this.damage = damage;
lifetime = 40f;
hitEffect = Fx.hitBulletSmall; hitEffect = Fx.hitBulletSmall;
despawnEffect = Fx.hitBulletSmall; despawnEffect = Fx.hitBulletSmall;
} }
@ -183,12 +182,12 @@ public abstract class BulletType extends Content{
if(homingPower > 0.0001f){ if(homingPower > 0.0001f){
Teamc target = Units.closestTarget(b.team(), b.getX(), b.getY(), homingRange, e -> (e.isGrounded() && collidesGround) || (e.isFlying() && collidesAir), t -> collidesGround); Teamc target = Units.closestTarget(b.team(), b.getX(), b.getY(), homingRange, e -> (e.isGrounded() && collidesGround) || (e.isFlying() && collidesAir), t -> collidesGround);
if(target != null){ if(target != null){
b.vel().setAngle(Mathf.slerpDelta(b.rotation(), b.angleTo(target), homingPower)); b.vel.setAngle(Mathf.slerpDelta(b.rotation(), b.angleTo(target), homingPower));
} }
} }
if(weaveMag > 0){ if(weaveMag > 0){
b.vel().rotate(Mathf.sin(Time.time() + b.id() * 3, weaveScale, weaveMag) * Time.delta()); b.vel.rotate(Mathf.sin(Time.time() + b.id() * 3, weaveScale, weaveMag) * Time.delta());
} }
} }
@ -226,8 +225,8 @@ public abstract class BulletType extends Content{
bullet.type(this); bullet.type(this);
bullet.owner(owner); bullet.owner(owner);
bullet.team(team); bullet.team(team);
bullet.vel().trns(angle, speed * velocityScl); bullet.vel.trns(angle, speed * velocityScl);
bullet.set(x - bullet.vel().x * Time.delta(), y - bullet.vel().y * Time.delta()); bullet.set(x - bullet.vel.x * Time.delta(), y - bullet.vel.y * Time.delta());
bullet.lifetime(lifetime * lifetimeScl); bullet.lifetime(lifetime * lifetimeScl);
bullet.data(data); bullet.data(data);
bullet.drag(drag); bullet.drag(drag);
@ -235,7 +234,7 @@ public abstract class BulletType extends Content{
bullet.damage(damage < 0 ? this.damage : damage); bullet.damage(damage < 0 ? this.damage : damage);
bullet.add(); bullet.add();
if(keepVelocity && owner instanceof Hitboxc) bullet.vel().add(((Hitboxc)owner).deltaX(), ((Hitboxc)owner).deltaY()); if(keepVelocity && owner instanceof Hitboxc) bullet.vel.add(((Hitboxc)owner).deltaX(), ((Hitboxc)owner).deltaY());
return bullet; return bullet;
} }

View File

@ -48,7 +48,7 @@ public class ContinuousLaserBulletType extends BulletType{
//damage every 5 ticks //damage every 5 ticks
if(b.timer(1, 5f)){ if(b.timer(1, 5f)){
Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), length, true); Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rotation(), length, true);
} }
if(shake > 0){ if(shake > 0){
@ -60,19 +60,19 @@ public class ContinuousLaserBulletType extends BulletType{
public void draw(Bullet b){ public void draw(Bullet b){
float baseLen = length * b.fout(); float baseLen = length * b.fout();
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen); Lines.lineAngle(b.x, b.y, b.rotation(), baseLen);
for(int s = 0; s < colors.length; s++){ for(int s = 0; s < colors.length; s++){
Draw.color(Tmp.c1.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f))); Draw.color(Tmp.c1.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f)));
for(int i = 0; i < tscales.length; i++){ for(int i = 0; i < tscales.length; i++){
Tmp.v1.trns(b.rotation() + 180f, (lenscales[i] - 1f) * 35f); Tmp.v1.trns(b.rotation() + 180f, (lenscales[i] - 1f) * 35f);
Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]); Lines.stroke((9f + Mathf.absin(Time.time(), 0.8f, 1.5f)) * b.fout() * strokes[s] * tscales[i]);
Lines.lineAngle(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, b.rotation(), baseLen * lenscales[i], CapStyle.none); Lines.lineAngle(b.x + Tmp.v1.x, b.y + Tmp.v1.y, b.rotation(), baseLen * lenscales[i], CapStyle.none);
} }
} }
Tmp.v1.trns(b.rotation(), baseLen * 1.1f); Tmp.v1.trns(b.rotation(), baseLen * 1.1f);
Drawf.light(b.team(), b.x(), b.y(), b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, 40, Color.orange, 0.7f); Drawf.light(b.team(), b.x, b.y, b.x + Tmp.v1.x, b.y + Tmp.v1.y, 40, Color.orange, 0.7f);
Draw.reset(); Draw.reset();
} }

View File

@ -28,7 +28,7 @@ public class FlakBulletType extends BasicBulletType{
if(b.data() instanceof Integer) return; if(b.data() instanceof Integer) return;
if(b.timer(2, 6)){ if(b.timer(2, 6)){
Units.nearbyEnemies(b.team(), Tmp.r1.setSize(explodeRange * 2f).setCenter(b.x(), b.y()), unit -> { Units.nearbyEnemies(b.team(), Tmp.r1.setSize(explodeRange * 2f).setCenter(b.x, b.y), unit -> {
if(b.data() instanceof Float || !unit.checkTarget(collidesAir, collidesGround)) return; if(b.data() instanceof Float || !unit.checkTarget(collidesAir, collidesGround)) return;
if(unit.dst(b) < explodeRange){ if(unit.dst(b) < explodeRange){

View File

@ -9,7 +9,7 @@ import mindustry.world.blocks.*;
public class HealBulletType extends BulletType{ public class HealBulletType extends BulletType{
protected float healPercent = 3f; protected float healPercent = 3f;
protected float bulletHeight = 7f, bulletWidth = 2f; protected float height = 7f, width = 2f;
protected Color backColor = Pal.heal, frontColor = Color.white; protected Color backColor = Pal.heal, frontColor = Color.white;
public HealBulletType(float speed, float damage){ public HealBulletType(float speed, float damage){
@ -35,10 +35,10 @@ public class HealBulletType extends BulletType{
@Override @Override
public void draw(Bullet b){ public void draw(Bullet b){
Draw.color(backColor); Draw.color(backColor);
Lines.stroke(bulletWidth); Lines.stroke(width);
Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight); Lines.lineAngleCenter(b.x, b.y, b.rotation(), height);
Draw.color(frontColor); Draw.color(frontColor);
Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight / 2f); Lines.lineAngleCenter(b.x, b.y, b.rotation(), height / 2f);
Draw.reset(); Draw.reset();
} }

View File

@ -53,15 +53,15 @@ public class LaserBulletType extends BulletType{
furthest = null; furthest = null;
world.raycast(b.tileX(), b.tileY(), world.toTile(b.x() + Tmp.v1.x), world.toTile(b.y() + Tmp.v1.y), world.raycast(b.tileX(), b.tileY(), world.toTile(b.x + Tmp.v1.x), world.toTile(b.y + Tmp.v1.y),
(x, y) -> (furthest = world.tile(x, y)) != null && furthest.team() != b.team() && furthest.block().absorbLasers); (x, y) -> (furthest = world.tile(x, y)) != null && furthest.team() != b.team() && furthest.block().absorbLasers);
float resultLength = furthest != null ? Math.max(6f, b.dst(furthest.worldx(), furthest.worldy())) : length; float resultLength = furthest != null ? Math.max(6f, b.dst(furthest.worldx(), furthest.worldy())) : length;
Damage.collideLine(b, b.team(), hitEffect, b.x(), b.y(), b.rotation(), resultLength); Damage.collideLine(b, b.team(), hitEffect, b.x, b.y, b.rotation(), resultLength);
if(furthest != null) b.data(resultLength); if(furthest != null) b.data(resultLength);
laserEffect.at(b.x(), b.y(), b.rotation(), resultLength * 0.75f); laserEffect.at(b.x, b.y, b.rotation(), resultLength * 0.75f);
} }
@Override @Override
@ -73,18 +73,18 @@ public class LaserBulletType extends BulletType{
float cwidth = width; float cwidth = width;
float compound = 1f; float compound = 1f;
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen); Lines.lineAngle(b.x, b.y, b.rotation(), baseLen);
Lines.precise(true); Lines.precise(true);
for(Color color : colors){ for(Color color : colors){
Draw.color(color); Draw.color(color);
Lines.stroke((cwidth *= lengthFalloff) * b.fout()); Lines.stroke((cwidth *= lengthFalloff) * b.fout());
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen, CapStyle.none); Lines.lineAngle(b.x, b.y, b.rotation(), baseLen, CapStyle.none);
Tmp.v1.trns(b.rotation(), baseLen); Tmp.v1.trns(b.rotation(), baseLen);
Drawf.tri(b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, Lines.getStroke() * 1.22f, cwidth * 2f + width / 2f, b.rotation()); Drawf.tri(b.x + Tmp.v1.x, b.y + Tmp.v1.y, Lines.getStroke() * 1.22f, cwidth * 2f + width / 2f, b.rotation());
Fill.circle(b.x(), b.y(), 1f * cwidth * b.fout()); Fill.circle(b.x, b.y, 1f * cwidth * b.fout());
for(int i : Mathf.signs){ for(int i : Mathf.signs){
Drawf.tri(b.x(), b.y(), sideWidth * b.fout() * cwidth, sideLength * compound, b.rotation() + sideAngle * i); Drawf.tri(b.x, b.y, sideWidth * b.fout() * cwidth, sideLength * compound, b.rotation() + sideAngle * i);
} }
compound *= lengthFalloff; compound *= lengthFalloff;
@ -93,7 +93,7 @@ public class LaserBulletType extends BulletType{
Draw.reset(); Draw.reset();
Tmp.v1.trns(b.rotation(), baseLen * 1.1f); Tmp.v1.trns(b.rotation(), baseLen * 1.1f);
Drawf.light(b.team(), b.x(), b.y(), b.x() + Tmp.v1.x, b.y() + Tmp.v1.y, width * 1.4f * b.fout(), colors[0], 0.6f); Drawf.light(b.team(), b.x, b.y, b.x + Tmp.v1.x, b.y + Tmp.v1.y, width * 1.4f * b.fout(), colors[0], 0.6f);
} }
@Override @Override

View File

@ -1,6 +1,7 @@
package mindustry.entities.bullet; package mindustry.entities.bullet;
import arc.graphics.*; import arc.graphics.*;
import arc.math.*;
import mindustry.content.*; import mindustry.content.*;
import mindustry.entities.*; import mindustry.entities.*;
import mindustry.gen.*; import mindustry.gen.*;
@ -8,7 +9,7 @@ import mindustry.graphics.*;
public class LightningBulletType extends BulletType{ public class LightningBulletType extends BulletType{
protected Color lightningColor = Pal.lancerLaser; protected Color lightningColor = Pal.lancerLaser;
protected int lightningLength = 25; protected int lightningLength = 25, lightningLengthRand = 0;
public LightningBulletType(){ public LightningBulletType(){
super(0.0001f, 1f); super(0.0001f, 1f);
@ -22,7 +23,7 @@ public class LightningBulletType extends BulletType{
@Override @Override
public float range(){ public float range(){
return lightningLength * 2.33f; return (lightningLength + lightningLengthRand/2f) * 6f;
} }
@Override @Override
@ -31,6 +32,6 @@ public class LightningBulletType extends BulletType{
@Override @Override
public void init(Bullet b){ public void init(Bullet b){
Lightning.create(b.team(), lightningColor, damage, b.x(), b.y(), b.rotation(), lightningLength); Lightning.create(b.team(), lightningColor, damage, b.x, b.y, b.rotation(), lightningLength + Mathf.random(lightningLengthRand));
} }
} }

View File

@ -48,7 +48,7 @@ public class LiquidBulletType extends BulletType{
super.update(b); super.update(b);
if(liquid.canExtinguish()){ if(liquid.canExtinguish()){
Tile tile = world.tileWorld(b.x(), b.y()); Tile tile = world.tileWorld(b.x, b.y);
if(tile != null && Fires.has(tile.x, tile.y)){ if(tile != null && Fires.has(tile.x, tile.y)){
Fires.extinguish(tile, 100f); Fires.extinguish(tile, 100f);
b.remove(); b.remove();
@ -61,14 +61,14 @@ public class LiquidBulletType extends BulletType{
public void draw(Bullet b){ public void draw(Bullet b){
Draw.color(liquid.color, Color.white, b.fout() / 100f); Draw.color(liquid.color, Color.white, b.fout() / 100f);
Fill.circle(b.x(), b.y(), 3f); Fill.circle(b.x, b.y, 3f);
} }
@Override @Override
public void despawned(Bullet b){ public void despawned(Bullet b){
super.despawned(b); super.despawned(b);
hit(b, b.x(), b.y()); hit(b, b.x, b.y);
} }
@Override @Override

View File

@ -26,10 +26,10 @@ public class MassDriverBolt extends BulletType{
float w = 11f, h = 13f; float w = 11f, h = 13f;
Draw.color(Pal.bulletYellowBack); Draw.color(Pal.bulletYellowBack);
Draw.rect("shell-back", b.x(), b.y(), w, h, b.rotation() + 90); Draw.rect("shell-back", b.x, b.y, w, h, b.rotation() + 90);
Draw.color(Pal.bulletYellow); Draw.color(Pal.bulletYellow);
Draw.rect("shell", b.x(), b.y(), w, h, b.rotation() + 90); Draw.rect("shell", b.x, b.y, w, h, b.rotation() + 90);
Draw.reset(); Draw.reset();
} }
@ -92,7 +92,7 @@ public class MassDriverBolt extends BulletType{
int amountDropped = Mathf.random(0, data.items[i]); int amountDropped = Mathf.random(0, data.items[i]);
if(amountDropped > 0){ if(amountDropped > 0){
float angle = b.rotation() + Mathf.range(100f); float angle = b.rotation() + Mathf.range(100f);
Fx.dropItem.at(b.x(), b.y(), angle, Color.white, content.item(i)); Fx.dropItem.at(b.x, b.y, angle, Color.white, content.item(i));
} }
} }
} }

View File

@ -26,7 +26,7 @@ public class MissileBulletType extends BasicBulletType{
super.update(b); super.update(b);
if(Mathf.chanceDelta(0.2)){ if(Mathf.chanceDelta(0.2)){
Fx.missileTrail.at(b.x(), b.y(), 2f, trailColor); Fx.missileTrail.at(b.x, b.y, 2f, trailColor);
} }
} }
} }

View File

@ -113,14 +113,14 @@ abstract class BulletComp implements Timedc, Damagec, Hitboxc, Teamc, Posc, Draw
Building tile = world.ent(x, y); Building tile = world.ent(x, y);
if(tile == null) return false; if(tile == null) return false;
if(tile.collide(base()) && type.collides(base(), tile) && !tile.dead() && (type.collidesTeam || tile.team() != team())){ if(tile.collide(base()) && type.collides(base(), tile) && !tile.dead() && (type.collidesTeam || tile.team != team)){
boolean remove = false; boolean remove = false;
if(tile.team() != team()){ if(tile.team != team){
remove = tile.collision(base()); remove = tile.collision(base());
} }
if(remove){ if(remove || type.collidesTeam){
type.hitTile(base(), tile); type.hitTile(base(), tile);
remove(); remove();
} }

View File

@ -93,8 +93,14 @@ abstract class HealthComp implements Entityc{
health = Mathf.clamp(health, 0, maxHealth); health = Mathf.clamp(health, 0, maxHealth);
} }
/** Heals by a flat amount. */
void heal(float amount){ void heal(float amount){
health += amount; health += amount;
clampHealth(); clampHealth();
} }
/** Heals by a 0-1 fraction of max health. */
void healFract(float amount){
heal(amount * maxHealth);
}
} }

View File

@ -33,6 +33,8 @@ abstract class UnitComp implements Healthc, Physicsc, Hitboxc, Statusc, Teamc, I
private UnitType type; private UnitType type;
boolean spawnedByCore; boolean spawnedByCore;
transient float timer1, timer2;
public void moveAt(Vec2 vector){ public void moveAt(Vec2 vector){
moveAt(vector, type.accel); moveAt(vector, type.accel);
} }

View File

@ -0,0 +1,8 @@
package mindustry.entities.units;
import mindustry.gen.*;
public interface Ability{
default void update(Unit unit){}
default void draw(Unit unit){}
}

View File

@ -0,0 +1,45 @@
package mindustry.entities.units;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
public class HealFieldAbility implements Ability{
public float amount = 1, reload = 100, range = 60;
public Effect healEffect = Fx.heal;
public Effect activeEffect = Fx.healWave;
private boolean wasHealed = false;
HealFieldAbility(){}
public HealFieldAbility(float amount, float reload, float range){
this.amount = amount;
this.reload = reload;
this.range = range;
}
@Override
public void update(Unit unit){
unit.timer1 += Time.delta();
if(unit.timer1 >= reload){
wasHealed = false;
Units.nearby(unit.team, unit.x, unit.y, range, other -> {
if(other.damaged()){
healEffect.at(unit);
wasHealed = true;
}
other.heal(amount);
});
if(wasHealed){
activeEffect.at(unit);
}
unit.timer1 = 0f;
}
}
}

View File

@ -0,0 +1,40 @@
package mindustry.entities.units;
import arc.util.ArcAnnotate.*;
import arc.util.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
import mindustry.type.*;
public class StatusFieldAbility implements Ability{
public @NonNull StatusEffect effect;
public float duration = 60, reload = 100, range = 20;
public Effect applyEffect = Fx.heal;
public Effect activeEffect = Fx.healWave;
StatusFieldAbility(){}
public StatusFieldAbility(@NonNull StatusEffect effect, float duration, float reload, float range){
this.duration = duration;
this.reload = reload;
this.range = range;
this.effect = effect;
}
@Override
public void update(Unit unit){
unit.timer2 += Time.delta();
if(unit.timer2 >= reload){
Units.nearby(unit.team, unit.x, unit.y, range, other -> {
other.apply(effect, duration);
});
activeEffect.at(unit);
unit.timer2 = 0f;
}
}
}

View File

@ -50,6 +50,7 @@ public class UnitType extends UnlockableContent{
public float deathShake = 2f; public float deathShake = 2f;
public Effect fallEffect = Fx.fallSmoke; public Effect fallEffect = Fx.fallSmoke;
public Effect fallThrusterEffect = Fx.fallSmoke; public Effect fallThrusterEffect = Fx.fallSmoke;
public Seq<Ability> abilities = new Seq<>();
//TODO document //TODO document
public int legCount = 4, legGroupSize = 2; public int legCount = 4, legGroupSize = 2;
@ -103,7 +104,13 @@ public class UnitType extends UnlockableContent{
return weapons.size > 0; return weapons.size > 0;
} }
public void update(Unit unit){} public void update(Unit unit){
if(abilities.size > 0){
for(Ability a : abilities){
a.update(unit);
}
}
}
public void landed(Unit unit){} public void landed(Unit unit){}
@ -252,6 +259,12 @@ public class UnitType extends UnlockableContent{
drawShield(unit); drawShield(unit);
} }
if(abilities.size > 0){
for(Ability a : abilities){
a.draw(unit);
}
}
if(legs != null){ if(legs != null){
unit.trns(-legOffset.x, -legOffset.y); unit.trns(-legOffset.x, -legOffset.y);
} }

View File

@ -32,7 +32,7 @@ public class Weapon{
/** amount of shots per fire */ /** amount of shots per fire */
public int shots = 1; public int shots = 1;
/** spacing in degrees between multiple shots, if applicable */ /** spacing in degrees between multiple shots, if applicable */
public float spacing = 12f; public float spacing = 0;
/** inaccuracy of degrees of each shot */ /** inaccuracy of degrees of each shot */
public float inaccuracy = 0f; public float inaccuracy = 0f;
/** intensity and duration of each shot's screen shake */ /** intensity and duration of each shot's screen shake */

View File

@ -124,7 +124,7 @@ public abstract class Weather extends MappableContent{
if(life < fadeTime){ if(life < fadeTime){
opacity = life / fadeTime; opacity = life / fadeTime;
}else{ }else{
opacity = Mathf.lerpDelta(opacity, 1f, 0.01f); opacity = Mathf.lerpDelta(opacity, 1f, 0.004f);
} }
life -= Time.delta(); life -= Time.delta();

View File

@ -90,7 +90,7 @@ public class PointDefenseTurret extends Block{
beamEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, color, new Vec2().set(target)); beamEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, color, new Vec2().set(target));
shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, color); shootEffect.at(x + Tmp.v1.x, y + Tmp.v1.y, rotation, color);
hitEffect.at(target.x(), target.y(), color); hitEffect.at(target.x, target.y, color);
reload = reloadTime; reload = reloadTime;
} }
}else{ }else{

View File

@ -101,14 +101,14 @@ public class Wall extends Block{
if(bullet.damage() > maxDamageDeflect) return true; if(bullet.damage() > maxDamageDeflect) return true;
//translate bullet back to where it was upon collision //translate bullet back to where it was upon collision
bullet.trns(-bullet.vel().x, -bullet.vel().y); bullet.trns(-bullet.vel.x, -bullet.vel.y);
float penX = Math.abs(x - bullet.x()), penY = Math.abs(y - bullet.y()); float penX = Math.abs(x - bullet.x), penY = Math.abs(y - bullet.y);
if(penX > penY){ if(penX > penY){
bullet.vel().x *= -1; bullet.vel.x *= -1;
}else{ }else{
bullet.vel().y *= -1; bullet.vel.y *= -1;
} }
bullet.owner(this); bullet.owner(this);