minRangeChange + draw min range (#7504)
Co-authored-by: Anuken <arnukren@gmail.com>
This commit is contained in:
@@ -147,6 +147,8 @@ public class BulletType extends Content implements Cloneable{
|
||||
public float extraRangeMargin = 0f;
|
||||
/** Range initialized in init(). */
|
||||
public float range = 0f;
|
||||
/** When used in a turret with multiple ammoo types, this can be set to a non-zero value to influence minRange */
|
||||
public float minRangeChange = 0f;
|
||||
/** % of block health healed **/
|
||||
public float healPercent = 0f;
|
||||
/** flat amount of block health healed */
|
||||
|
||||
@@ -62,6 +62,8 @@ public class Turret extends ReloadTurret{
|
||||
public float shootX = 0f, shootY = Float.NEGATIVE_INFINITY;
|
||||
/** Random spread on the X axis. */
|
||||
public float xRand = 0f;
|
||||
/** If true, a range ring is also drawn for minRange. */
|
||||
public boolean drawMinRange;
|
||||
/** Range at which it finds and locks on to the target, but does not shoot. */
|
||||
public float trackingRange = 0f;
|
||||
/** Minimum bullet range. Used for artillery only. */
|
||||
@@ -216,6 +218,15 @@ public class Turret extends ReloadTurret{
|
||||
bullet.lifetime = (realRange + margin + bullet.extraRangeMargin) / bullet.speed;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawPlace(int x, int y, int rotation, boolean valid){
|
||||
super.drawPlace(x, y, rotation, valid);
|
||||
|
||||
if(drawMinRange){
|
||||
Drawf.dashCircle(x * tilesize + offset, y * tilesize + offset, minRange, Pal.placing);
|
||||
}
|
||||
}
|
||||
|
||||
public static abstract class AmmoEntry{
|
||||
public int amount;
|
||||
|
||||
@@ -251,6 +262,13 @@ public class Turret extends ReloadTurret{
|
||||
return shoot.shots / reload * 60f * (peekAmmo() == null ? 0f : peekAmmo().estimateDPS()) * potentialEfficiency * timeScale;
|
||||
}
|
||||
|
||||
public float minRange(){
|
||||
if(peekAmmo() != null){
|
||||
return minRange + peekAmmo().minRangeChange;
|
||||
}
|
||||
return minRange;
|
||||
}
|
||||
|
||||
@Override
|
||||
public float range(){
|
||||
if(peekAmmo() != null){
|
||||
@@ -379,6 +397,15 @@ public class Turret extends ReloadTurret{
|
||||
drawer.draw(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void drawSelect(){
|
||||
super.drawSelect();
|
||||
|
||||
if(drawMinRange){
|
||||
Drawf.dashCircle(x, y, minRange(), team.color);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void updateTile(){
|
||||
if(!validateTarget()) target = null;
|
||||
@@ -643,7 +670,7 @@ public class Turret extends ReloadTurret{
|
||||
bulletY = y + Angles.trnsy(rotation - 90, shootX + xOffset + xSpread, shootY + yOffset),
|
||||
shootAngle = rotation + angleOffset + Mathf.range(inaccuracy + type.inaccuracy);
|
||||
|
||||
float lifeScl = type.scaleLife ? Mathf.clamp((1 + scaleLifetimeOffset) * Mathf.dst(bulletX, bulletY, targetPos.x, targetPos.y) / type.range, minRange / type.range, range() / type.range) : 1f;
|
||||
float lifeScl = type.scaleLife ? Mathf.clamp((1 + scaleLifetimeOffset) * Mathf.dst(bulletX, bulletY, targetPos.x, targetPos.y) / type.range, minRange() / type.range, range() / type.range) : 1f;
|
||||
|
||||
//TODO aimX / aimY for multi shot turrets?
|
||||
handleBullet(type.create(this, team, bulletX, bulletY, shootAngle, -1f, (1f - velocityRnd) + Mathf.random(velocityRnd), lifeScl, null, mover, targetPos.x, targetPos.y), xOffset, yOffset, shootAngle - rotation);
|
||||
|
||||
Reference in New Issue
Block a user