More unit progress
This commit is contained in:
@@ -2,12 +2,10 @@ package mindustry.entities.bullet;
|
||||
|
||||
import arc.graphics.g2d.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.entities.*;
|
||||
import mindustry.gen.*;
|
||||
|
||||
//TODO scale velocity depending on fslope()
|
||||
public class ArtilleryBulletType extends BasicBulletType{
|
||||
protected Effect trailEffect = Fx.artilleryTrail;
|
||||
|
||||
public ArtilleryBulletType(float speed, float damage, String bulletSprite){
|
||||
super(speed, damage, bulletSprite);
|
||||
@@ -17,6 +15,7 @@ public class ArtilleryBulletType extends BasicBulletType{
|
||||
scaleVelocity = true;
|
||||
hitShake = 1f;
|
||||
hitSound = Sounds.explosion;
|
||||
trailEffect = Fx.artilleryTrail;
|
||||
}
|
||||
|
||||
public ArtilleryBulletType(){
|
||||
|
||||
@@ -75,6 +75,11 @@ public abstract class BulletType extends Content{
|
||||
public BulletType fragBullet = null;
|
||||
public Color hitColor = Color.white;
|
||||
|
||||
public Color trailColor = Pal.missileYellowBack;
|
||||
public float trailChance = -0.0001f;
|
||||
public Effect trailEffect = Fx.missileTrail;
|
||||
public float trailParam = 2f;
|
||||
|
||||
/** Use a negative value to disable splash damage. */
|
||||
public float splashDamageRadius = -1f;
|
||||
|
||||
@@ -118,7 +123,7 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
|
||||
public void hit(Bullet b){
|
||||
hit(b, b.getX(), b.getY());
|
||||
hit(b, b.x, b.y);
|
||||
}
|
||||
|
||||
public void hit(Bullet b, float x, float y){
|
||||
@@ -140,20 +145,20 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
|
||||
if(splashDamageRadius > 0){
|
||||
Damage.damage(b.team(), x, y, splashDamageRadius, splashDamage * b.damageMultiplier(), collidesAir, collidesGround);
|
||||
Damage.damage(b.team, x, y, splashDamageRadius, splashDamage * b.damageMultiplier(), collidesAir, collidesGround);
|
||||
|
||||
if(status != StatusEffects.none){
|
||||
Damage.status(b.team(), x, y, splashDamageRadius, status, statusDuration, collidesAir, collidesGround);
|
||||
Damage.status(b.team, x, y, splashDamageRadius, status, statusDuration, collidesAir, collidesGround);
|
||||
}
|
||||
}
|
||||
|
||||
for(int i = 0; i < lightning; i++){
|
||||
Lightning.create(b.team(), Pal.surge, lightningDamage < 0 ? damage : lightningDamage, b.getX(), b.getY(), Mathf.random(360f), lightningLength);
|
||||
Lightning.create(b.team, Pal.surge, lightningDamage < 0 ? damage : lightningDamage, b.x, b.y, Mathf.random(360f), lightningLength);
|
||||
}
|
||||
}
|
||||
|
||||
public void despawned(Bullet b){
|
||||
despawnEffect.at(b.getX(), b.getY(), b.rotation());
|
||||
despawnEffect.at(b.x, b.y, b.rotation());
|
||||
hitSound.at(b);
|
||||
|
||||
if(fragBullet != null || splashDamageRadius > 0 || lightning > 0){
|
||||
@@ -165,7 +170,7 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
|
||||
public void drawLight(Bullet b){
|
||||
Drawf.light(b.team(), b, lightRadius, lightColor, lightOpacity);
|
||||
Drawf.light(b.team, b, lightRadius, lightColor, lightOpacity);
|
||||
}
|
||||
|
||||
public void init(Bullet b){
|
||||
@@ -180,14 +185,20 @@ public abstract class BulletType extends Content{
|
||||
|
||||
public void update(Bullet b){
|
||||
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.x, b.y, homingRange, e -> (e.isGrounded() && collidesGround) || (e.isFlying() && collidesAir), t -> collidesGround);
|
||||
if(target != null){
|
||||
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(Mathf.randomSeed(b.id, 10f) + b.time, weaveScale, weaveMag) * Time.delta());
|
||||
}
|
||||
|
||||
if(trailChance > 0){
|
||||
if(Mathf.chanceDelta(trailChance)){
|
||||
trailEffect.at(b.x, b.y, trailParam, trailColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -213,11 +224,11 @@ public abstract class BulletType extends Content{
|
||||
}
|
||||
|
||||
public Bullet create(Bullet parent, float x, float y, float angle){
|
||||
return create(parent.owner(), parent.team(), x, y, angle);
|
||||
return create(parent.owner(), parent.team, x, y, angle);
|
||||
}
|
||||
|
||||
public Bullet create(Bullet parent, float x, float y, float angle, float velocityScl){
|
||||
return create(parent.owner(), parent.team(), x, y, angle, velocityScl);
|
||||
return create(parent.owner(), parent.team, x, y, angle, velocityScl);
|
||||
}
|
||||
|
||||
public Bullet create(@Nullable Entityc owner, Team team, float x, float y, float angle, float damage, float velocityScl, float lifetimeScl, Object data){
|
||||
|
||||
@@ -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){
|
||||
@@ -72,7 +72,7 @@ public class ContinuousLaserBulletType extends BulletType{
|
||||
|
||||
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){
|
||||
|
||||
@@ -29,7 +29,7 @@ public class HealBulletType extends BulletType{
|
||||
|
||||
@Override
|
||||
public boolean collides(Bullet b, Building tile){
|
||||
return tile.team() != b.team() || tile.healthf() < 1f;
|
||||
return tile.team() != b.team || tile.healthf() < 1f;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -46,7 +46,7 @@ public class HealBulletType extends BulletType{
|
||||
public void hitTile(Bullet b, Building tile){
|
||||
super.hit(b);
|
||||
|
||||
if(tile.team() == b.team() && !(tile.block() instanceof BuildBlock)){
|
||||
if(tile.team() == b.team && !(tile.block() instanceof BuildBlock)){
|
||||
Fx.healBlockFull.at(tile.x, tile.y, tile.block().size, Pal.heal);
|
||||
tile.heal(healPercent / 100f * tile.maxHealth());
|
||||
}
|
||||
|
||||
@@ -54,11 +54,11 @@ 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),
|
||||
(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;
|
||||
|
||||
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);
|
||||
@@ -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
|
||||
|
||||
@@ -32,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 + Mathf.random(lightningLengthRand));
|
||||
Lightning.create(b.team, lightningColor, damage, b.x, b.y, b.rotation(), lightningLength + Mathf.random(lightningLengthRand));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,27 @@
|
||||
package mindustry.entities.bullet;
|
||||
|
||||
import arc.graphics.*;
|
||||
import arc.math.*;
|
||||
import mindustry.content.*;
|
||||
import mindustry.gen.*;
|
||||
import mindustry.graphics.*;
|
||||
|
||||
public class MissileBulletType extends BasicBulletType{
|
||||
protected Color trailColor = Pal.missileYellowBack;
|
||||
|
||||
public MissileBulletType(float speed, float damage, String bulletSprite){
|
||||
super(speed, damage, bulletSprite);
|
||||
backColor = Pal.missileYellowBack;
|
||||
frontColor = Pal.missileYellow;
|
||||
homingPower = 0.08f;
|
||||
shrinkY = 0f;
|
||||
width = 8f;
|
||||
height = 8f;
|
||||
hitSound = Sounds.explosion;
|
||||
trailChance = 0.2f;
|
||||
}
|
||||
|
||||
public MissileBulletType(float speed, float damage){
|
||||
this(speed, damage, "missile");
|
||||
}
|
||||
|
||||
public MissileBulletType(){
|
||||
this(1f, 1f, "missile");
|
||||
}
|
||||
|
||||
@Override
|
||||
public void update(Bullet b){
|
||||
super.update(b);
|
||||
|
||||
if(Mathf.chanceDelta(0.2)){
|
||||
Fx.missileTrail.at(b.x, b.y, 2f, trailColor);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user