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
@@ -28,7 +28,7 @@ public class ArtilleryBulletType extends BasicBulletType{
super.update(b);
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());
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.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();
}
}
@@ -44,9 +44,9 @@ public class BasicBulletType extends BulletType{
float width = this.width * ((1f - shrinkX) + shrinkX * b.fout());
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.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();
}
}
@@ -15,7 +15,7 @@ import mindustry.graphics.*;
import mindustry.type.*;
public abstract class BulletType extends Content{
public float lifetime;
public float lifetime = 40f;
public float speed;
public float damage;
public float hitSize = 4;
@@ -100,7 +100,6 @@ public abstract class BulletType extends Content{
public BulletType(float speed, float damage){
this.speed = speed;
this.damage = damage;
lifetime = 40f;
hitEffect = Fx.hitBulletSmall;
despawnEffect = Fx.hitBulletSmall;
}
@@ -183,12 +182,12 @@ public abstract class BulletType extends Content{
if(homingPower > 0.0001f){
Teamc target = Units.closestTarget(b.team(), b.getX(), b.getY(), homingRange, e -> (e.isGrounded() && collidesGround) || (e.isFlying() && collidesAir), t -> collidesGround);
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){
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.owner(owner);
bullet.team(team);
bullet.vel().trns(angle, speed * velocityScl);
bullet.set(x - bullet.vel().x * Time.delta(), y - bullet.vel().y * Time.delta());
bullet.vel.trns(angle, speed * velocityScl);
bullet.set(x - bullet.vel.x * Time.delta(), y - bullet.vel.y * Time.delta());
bullet.lifetime(lifetime * lifetimeScl);
bullet.data(data);
bullet.drag(drag);
@@ -235,7 +234,7 @@ public abstract class BulletType extends Content{
bullet.damage(damage < 0 ? this.damage : damage);
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;
}
@@ -48,7 +48,7 @@ public class ContinuousLaserBulletType extends BulletType{
//damage every 5 ticks
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){
@@ -60,19 +60,19 @@ public class ContinuousLaserBulletType extends BulletType{
public void draw(Bullet b){
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++){
Draw.color(Tmp.c1.set(colors[s]).mul(1f + Mathf.absin(Time.time(), 1f, 0.1f)));
for(int i = 0; i < tscales.length; i++){
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.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);
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();
}
@@ -28,7 +28,7 @@ public class FlakBulletType extends BasicBulletType{
if(b.data() instanceof Integer) return;
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(unit.dst(b) < explodeRange){
@@ -9,7 +9,7 @@ import mindustry.world.blocks.*;
public class HealBulletType extends BulletType{
protected float healPercent = 3f;
protected float bulletHeight = 7f, bulletWidth = 2f;
protected float height = 7f, width = 2f;
protected Color backColor = Pal.heal, frontColor = Color.white;
public HealBulletType(float speed, float damage){
@@ -35,10 +35,10 @@ public class HealBulletType extends BulletType{
@Override
public void draw(Bullet b){
Draw.color(backColor);
Lines.stroke(bulletWidth);
Lines.lineAngleCenter(b.x(), b.y(), b.rotation(), bulletHeight);
Lines.stroke(width);
Lines.lineAngleCenter(b.x, b.y, b.rotation(), height);
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();
}
@@ -53,15 +53,15 @@ public class LaserBulletType extends BulletType{
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);
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);
laserEffect.at(b.x(), b.y(), b.rotation(), resultLength * 0.75f);
laserEffect.at(b.x, b.y, b.rotation(), resultLength * 0.75f);
}
@Override
@@ -73,18 +73,18 @@ public class LaserBulletType extends BulletType{
float cwidth = width;
float compound = 1f;
Lines.lineAngle(b.x(), b.y(), b.rotation(), baseLen);
Lines.lineAngle(b.x, b.y, b.rotation(), baseLen);
Lines.precise(true);
for(Color color : colors){
Draw.color(color);
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);
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){
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;
@@ -93,7 +93,7 @@ public class LaserBulletType extends BulletType{
Draw.reset();
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
@@ -1,6 +1,7 @@
package mindustry.entities.bullet;
import arc.graphics.*;
import arc.math.*;
import mindustry.content.*;
import mindustry.entities.*;
import mindustry.gen.*;
@@ -8,7 +9,7 @@ import mindustry.graphics.*;
public class LightningBulletType extends BulletType{
protected Color lightningColor = Pal.lancerLaser;
protected int lightningLength = 25;
protected int lightningLength = 25, lightningLengthRand = 0;
public LightningBulletType(){
super(0.0001f, 1f);
@@ -22,7 +23,7 @@ public class LightningBulletType extends BulletType{
@Override
public float range(){
return lightningLength * 2.33f;
return (lightningLength + lightningLengthRand/2f) * 6f;
}
@Override
@@ -31,6 +32,6 @@ public class LightningBulletType extends BulletType{
@Override
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));
}
}
@@ -48,7 +48,7 @@ public class LiquidBulletType extends BulletType{
super.update(b);
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)){
Fires.extinguish(tile, 100f);
b.remove();
@@ -61,14 +61,14 @@ public class LiquidBulletType extends BulletType{
public void draw(Bullet b){
Draw.color(liquid.color, Color.white, b.fout() / 100f);
Fill.circle(b.x(), b.y(), 3f);
Fill.circle(b.x, b.y, 3f);
}
@Override
public void despawned(Bullet b){
super.despawned(b);
hit(b, b.x(), b.y());
hit(b, b.x, b.y);
}
@Override
@@ -26,10 +26,10 @@ public class MassDriverBolt extends BulletType{
float w = 11f, h = 13f;
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.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();
}
@@ -92,7 +92,7 @@ public class MassDriverBolt extends BulletType{
int amountDropped = Mathf.random(0, data.items[i]);
if(amountDropped > 0){
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));
}
}
}
@@ -26,7 +26,7 @@ public class MissileBulletType extends BasicBulletType{
super.update(b);
if(Mathf.chanceDelta(0.2)){
Fx.missileTrail.at(b.x(), b.y(), 2f, trailColor);
Fx.missileTrail.at(b.x, b.y, 2f, trailColor);
}
}
}