Skip to content

Commit

Permalink
Added scaleLifetimeOffset
Browse files Browse the repository at this point in the history
Changed ripple to have its shot centered, calculated by: (1 - velocityRnd/2)^-1
  • Loading branch information
SomeonesShade committed Oct 26, 2024
1 parent f12085e commit 3406382
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
1 change: 1 addition & 0 deletions core/src/mindustry/content/Blocks.java
Original file line number Diff line number Diff line change
Expand Up @@ -3723,6 +3723,7 @@ Items.plastanium, new ArtilleryBulletType(3.4f, 20, "shell"){{
ammoUseEffect = Fx.casing3Double;
ammoPerShot = 2;
velocityRnd = 0.2f;
scaleLifetimeOffset = 1f / 9f;
recoil = 6f;
shake = 2f;
range = 290f;
Expand Down
4 changes: 3 additions & 1 deletion core/src/mindustry/world/blocks/defense/turrets/Turret.java
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@ public class Turret extends ReloadTurret{
public float inaccuracy = 0f;
/** Fraction of bullet velocity that is random. */
public float velocityRnd = 0f;
/** Fraction of lifetime that is added. */
public float scaleLifetimeOffset = 0f;
/** Maximum angle difference in degrees at which turret will still try to shoot. */
public float shootCone = 8f;
/** Turret shoot point. */
Expand Down Expand Up @@ -615,7 +617,7 @@ protected void bullet(BulletType type, float xOffset, float yOffset, float angle
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(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);
Expand Down

0 comments on commit 3406382

Please sign in to comment.