More turret consistency / Power curve for recoil
This commit is contained in:
@@ -2811,7 +2811,6 @@ public class Blocks{
|
|||||||
|
|
||||||
shootY = 3f;
|
shootY = 3f;
|
||||||
reload = 20f;
|
reload = 20f;
|
||||||
restitution = 0.03f;
|
|
||||||
range = 110;
|
range = 110;
|
||||||
shootCone = 15f;
|
shootCone = 15f;
|
||||||
ammoUseEffect = Fx.casing1;
|
ammoUseEffect = Fx.casing1;
|
||||||
@@ -3024,7 +3023,6 @@ public class Blocks{
|
|||||||
|
|
||||||
recoil = 2f;
|
recoil = 2f;
|
||||||
reload = 80f;
|
reload = 80f;
|
||||||
cooldown = 0.03f;
|
|
||||||
shake = 2f;
|
shake = 2f;
|
||||||
shootEffect = Fx.lancerLaserShoot;
|
shootEffect = Fx.lancerLaserShoot;
|
||||||
smokeEffect = Fx.none;
|
smokeEffect = Fx.none;
|
||||||
@@ -3227,9 +3225,7 @@ public class Blocks{
|
|||||||
size = 2;
|
size = 2;
|
||||||
range = 190f;
|
range = 190f;
|
||||||
reload = 31f;
|
reload = 31f;
|
||||||
restitution = 0.03f;
|
|
||||||
ammoEjectBack = 3f;
|
ammoEjectBack = 3f;
|
||||||
cooldown = 0.03f;
|
|
||||||
recoil = 3f;
|
recoil = 3f;
|
||||||
shake = 1f;
|
shake = 1f;
|
||||||
shoot.shots = 4;
|
shoot.shots = 4;
|
||||||
@@ -3311,7 +3307,6 @@ public class Blocks{
|
|||||||
velocityRnd = 0.1f;
|
velocityRnd = 0.1f;
|
||||||
inaccuracy = 4f;
|
inaccuracy = 4f;
|
||||||
recoil = 1f;
|
recoil = 1f;
|
||||||
restitution = 0.04f;
|
|
||||||
shootCone = 45f;
|
shootCone = 45f;
|
||||||
liquidCapacity = 40f;
|
liquidCapacity = 40f;
|
||||||
shootEffect = Fx.shootLiquid;
|
shootEffect = Fx.shootLiquid;
|
||||||
@@ -3330,7 +3325,6 @@ public class Blocks{
|
|||||||
|
|
||||||
shoot = new ShootSpread(3, 20f);
|
shoot = new ShootSpread(3, 20f);
|
||||||
|
|
||||||
restitution = 0.1f;
|
|
||||||
shootCone = 30;
|
shootCone = 30;
|
||||||
size = 3;
|
size = 3;
|
||||||
envEnabled |= Env.space;
|
envEnabled |= Env.space;
|
||||||
@@ -3444,9 +3438,7 @@ public class Blocks{
|
|||||||
ammoEjectBack = 5f;
|
ammoEjectBack = 5f;
|
||||||
ammoUseEffect = Fx.casing3Double;
|
ammoUseEffect = Fx.casing3Double;
|
||||||
ammoPerShot = 2;
|
ammoPerShot = 2;
|
||||||
cooldown = 0.03f;
|
|
||||||
velocityRnd = 0.2f;
|
velocityRnd = 0.2f;
|
||||||
restitution = 0.02f;
|
|
||||||
recoil = 6f;
|
recoil = 6f;
|
||||||
shake = 2f;
|
shake = 2f;
|
||||||
range = 290f;
|
range = 290f;
|
||||||
@@ -3571,8 +3563,7 @@ public class Blocks{
|
|||||||
reload = 200f;
|
reload = 200f;
|
||||||
ammoUseEffect = Fx.casing3Double;
|
ammoUseEffect = Fx.casing3Double;
|
||||||
recoil = 5f;
|
recoil = 5f;
|
||||||
restitution = 0.009f;
|
cooldownTime = reload;
|
||||||
cooldown = 0.009f;
|
|
||||||
shake = 4f;
|
shake = 4f;
|
||||||
size = 4;
|
size = 4;
|
||||||
shootCone = 2f;
|
shootCone = 2f;
|
||||||
@@ -3627,8 +3618,8 @@ public class Blocks{
|
|||||||
}}
|
}}
|
||||||
);
|
);
|
||||||
reload = 7f;
|
reload = 7f;
|
||||||
|
recoilTime = reload * 2f;
|
||||||
coolantMultiplier = 0.5f;
|
coolantMultiplier = 0.5f;
|
||||||
restitution = 0.1f;
|
|
||||||
ammoUseEffect = Fx.casing3;
|
ammoUseEffect = Fx.casing3;
|
||||||
range = 260f;
|
range = 260f;
|
||||||
inaccuracy = 3f;
|
inaccuracy = 3f;
|
||||||
@@ -3736,7 +3727,6 @@ public class Blocks{
|
|||||||
envEnabled |= Env.space;
|
envEnabled |= Env.space;
|
||||||
reload = 40f;
|
reload = 40f;
|
||||||
recoil = 2f;
|
recoil = 2f;
|
||||||
restitution = 0.03f;
|
|
||||||
range = 190;
|
range = 190;
|
||||||
shootCone = 3f;
|
shootCone = 3f;
|
||||||
scaledHealth = 180;
|
scaledHealth = 180;
|
||||||
@@ -3794,7 +3784,6 @@ public class Blocks{
|
|||||||
envEnabled |= Env.space;
|
envEnabled |= Env.space;
|
||||||
reload = 30f;
|
reload = 30f;
|
||||||
recoil = 2f;
|
recoil = 2f;
|
||||||
restitution = 0.03f;
|
|
||||||
range = 125;
|
range = 125;
|
||||||
shootCone = 40f;
|
shootCone = 40f;
|
||||||
scaledHealth = 210;
|
scaledHealth = 210;
|
||||||
@@ -3952,7 +3941,6 @@ public class Blocks{
|
|||||||
}});
|
}});
|
||||||
}};
|
}};
|
||||||
|
|
||||||
restitution = 0.02f;
|
|
||||||
shootWarmupSpeed = 0.08f;
|
shootWarmupSpeed = 0.08f;
|
||||||
|
|
||||||
outlineColor = Pal.darkOutline;
|
outlineColor = Pal.darkOutline;
|
||||||
@@ -4034,7 +4022,6 @@ public class Blocks{
|
|||||||
targetGround = false;
|
targetGround = false;
|
||||||
inaccuracy = 8f;
|
inaccuracy = 8f;
|
||||||
|
|
||||||
restitution = 0.11f;
|
|
||||||
shootWarmupSpeed = 0.08f;
|
shootWarmupSpeed = 0.08f;
|
||||||
|
|
||||||
outlineColor = Pal.darkOutline;
|
outlineColor = Pal.darkOutline;
|
||||||
|
|||||||
@@ -399,6 +399,7 @@ public class ContentParser{
|
|||||||
case "itemFlammable" -> block.consume((Consume)parser.readValue(ConsumeItemFlammable.class, child));
|
case "itemFlammable" -> block.consume((Consume)parser.readValue(ConsumeItemFlammable.class, child));
|
||||||
case "itemRadioactive" -> block.consume((Consume)parser.readValue(ConsumeItemRadioactive.class, child));
|
case "itemRadioactive" -> block.consume((Consume)parser.readValue(ConsumeItemRadioactive.class, child));
|
||||||
case "itemExplosive" -> block.consume((Consume)parser.readValue(ConsumeItemExplosive.class, child));
|
case "itemExplosive" -> block.consume((Consume)parser.readValue(ConsumeItemExplosive.class, child));
|
||||||
|
case "itemExplode" -> block.consume((Consume)parser.readValue(ConsumeItemExplode.class, child));
|
||||||
case "items" -> block.consume((Consume)parser.readValue(ConsumeItems.class, child));
|
case "items" -> block.consume((Consume)parser.readValue(ConsumeItems.class, child));
|
||||||
case "liquidFlammable" -> block.consume((Consume)parser.readValue(ConsumeLiquidFlammable.class, child));
|
case "liquidFlammable" -> block.consume((Consume)parser.readValue(ConsumeLiquidFlammable.class, child));
|
||||||
case "liquid" -> block.consume((Consume)parser.readValue(ConsumeLiquid.class, child));
|
case "liquid" -> block.consume((Consume)parser.readValue(ConsumeLiquid.class, child));
|
||||||
|
|||||||
@@ -66,8 +66,10 @@ public class Weapon implements Cloneable{
|
|||||||
public float shake = 0f;
|
public float shake = 0f;
|
||||||
/** visual weapon knockback. */
|
/** visual weapon knockback. */
|
||||||
public float recoil = 1.5f;
|
public float recoil = 1.5f;
|
||||||
/** the time it returns back to its original position in ticks. uses reload time by default */
|
/** time taken for weapon to return to starting position in ticks. uses reload time by default */
|
||||||
public float recoilTime = -1f;
|
public float recoilTime = -1f;
|
||||||
|
/** power curve applied to visual recoil */
|
||||||
|
public float recoilPow = 1.8f;
|
||||||
/** ticks to cool down the heat region */
|
/** ticks to cool down the heat region */
|
||||||
public float cooldownTime = 20f;
|
public float cooldownTime = 20f;
|
||||||
/** projectile/effect offsets from center of weapon */
|
/** projectile/effect offsets from center of weapon */
|
||||||
@@ -164,9 +166,10 @@ public class Weapon implements Cloneable{
|
|||||||
|
|
||||||
float
|
float
|
||||||
rotation = unit.rotation - 90,
|
rotation = unit.rotation - 90,
|
||||||
|
realRecoil = Mathf.pow(mount.recoil, recoilPow) * recoil,
|
||||||
weaponRotation = rotation + (rotate ? mount.rotation : 0),
|
weaponRotation = rotation + (rotate ? mount.rotation : 0),
|
||||||
wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -mount.recoil),
|
wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -realRecoil),
|
||||||
wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -mount.recoil);
|
wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -realRecoil);
|
||||||
|
|
||||||
Draw.xscl = -Mathf.sign(flipSprite);
|
Draw.xscl = -Mathf.sign(flipSprite);
|
||||||
Draw.rect(outlineRegion, wx, wy, weaponRotation);
|
Draw.rect(outlineRegion, wx, wy, weaponRotation);
|
||||||
@@ -182,9 +185,10 @@ public class Weapon implements Cloneable{
|
|||||||
|
|
||||||
float
|
float
|
||||||
rotation = unit.rotation - 90,
|
rotation = unit.rotation - 90,
|
||||||
|
realRecoil = Mathf.pow(mount.recoil, recoilPow) * recoil,
|
||||||
weaponRotation = rotation + (rotate ? mount.rotation : baseRotation),
|
weaponRotation = rotation + (rotate ? mount.rotation : baseRotation),
|
||||||
wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -mount.recoil),
|
wx = unit.x + Angles.trnsx(rotation, x, y) + Angles.trnsx(weaponRotation, 0, -realRecoil),
|
||||||
wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -mount.recoil);
|
wy = unit.y + Angles.trnsy(rotation, x, y) + Angles.trnsy(weaponRotation, 0, -realRecoil);
|
||||||
|
|
||||||
if(shadow > 0){
|
if(shadow > 0){
|
||||||
Drawf.shadow(wx, wy, shadow);
|
Drawf.shadow(wx, wy, shadow);
|
||||||
@@ -247,7 +251,7 @@ public class Weapon implements Cloneable{
|
|||||||
boolean can = unit.canShoot();
|
boolean can = unit.canShoot();
|
||||||
float lastReload = mount.reload;
|
float lastReload = mount.reload;
|
||||||
mount.reload = Math.max(mount.reload - Time.delta * unit.reloadMultiplier, 0);
|
mount.reload = Math.max(mount.reload - Time.delta * unit.reloadMultiplier, 0);
|
||||||
mount.recoil = Mathf.approachDelta(mount.recoil, 0, (Math.abs(recoil) * unit.reloadMultiplier) / recoilTime);
|
mount.recoil = Mathf.approachDelta(mount.recoil, 0, unit.reloadMultiplier / recoilTime);
|
||||||
mount.warmup = Mathf.lerpDelta(mount.warmup, can && mount.shoot ? 1f : 0f, shootWarmupSpeed);
|
mount.warmup = Mathf.lerpDelta(mount.warmup, can && mount.shoot ? 1f : 0f, shootWarmupSpeed);
|
||||||
mount.smoothReload = Mathf.lerpDelta(mount.smoothReload, mount.reload / reload, smoothReloadSpeed);
|
mount.smoothReload = Mathf.lerpDelta(mount.smoothReload, mount.reload / reload, smoothReloadSpeed);
|
||||||
|
|
||||||
@@ -317,7 +321,7 @@ public class Weapon implements Cloneable{
|
|||||||
mount.bullet.rotation(weaponRotation + 90);
|
mount.bullet.rotation(weaponRotation + 90);
|
||||||
mount.bullet.set(bulletX, bulletY);
|
mount.bullet.set(bulletX, bulletY);
|
||||||
mount.reload = reload;
|
mount.reload = reload;
|
||||||
mount.recoil = recoil;
|
mount.recoil = 1f;
|
||||||
unit.vel.add(Tmp.v1.trns(unit.rotation + 180f, mount.bullet.type.recoil));
|
unit.vel.add(Tmp.v1.trns(unit.rotation + 180f, mount.bullet.type.recoil));
|
||||||
if(shootSound != Sounds.none && !headless){
|
if(shootSound != Sounds.none && !headless){
|
||||||
if(mount.sound == null) mount.sound = new SoundLoop(shootSound, 1f);
|
if(mount.sound == null) mount.sound = new SoundLoop(shootSound, 1f);
|
||||||
@@ -416,7 +420,7 @@ public class Weapon implements Cloneable{
|
|||||||
|
|
||||||
unit.vel.add(Tmp.v1.trns(shootAngle + 180f, bullet.recoil));
|
unit.vel.add(Tmp.v1.trns(shootAngle + 180f, bullet.recoil));
|
||||||
Effect.shake(shake, shake, bulletX, bulletY);
|
Effect.shake(shake, shake, bulletX, bulletY);
|
||||||
mount.recoil = recoil;
|
mount.recoil = 1f;
|
||||||
mount.heat = 1f;
|
mount.heat = 1f;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -58,7 +58,7 @@ public class PointDefenseWeapon extends Weapon{
|
|||||||
bullet.shootEffect.at(shootX, shootY, rotation, color);
|
bullet.shootEffect.at(shootX, shootY, rotation, color);
|
||||||
bullet.hitEffect.at(target.x, target.y, color);
|
bullet.hitEffect.at(target.x, target.y, color);
|
||||||
shootSound.at(shootX, shootY, Mathf.random(0.9f, 1.1f));
|
shootSound.at(shootX, shootY, Mathf.random(0.9f, 1.1f));
|
||||||
mount.recoil = recoil;
|
mount.recoil = 1f;
|
||||||
mount.heat = 1f;
|
mount.heat = 1f;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,10 +106,12 @@ public class Turret extends ReloadTurret{
|
|||||||
public boolean linearWarmup = false;
|
public boolean linearWarmup = false;
|
||||||
/** Visual amount by which the turret recoils back per shot. */
|
/** Visual amount by which the turret recoils back per shot. */
|
||||||
public float recoil = 1f;
|
public float recoil = 1f;
|
||||||
/** TODO rename */
|
/** ticks taken for turret to return to starting position in ticks. uses reload time by default */
|
||||||
public float restitution = 0.02f;
|
public float recoilTime = -1f;
|
||||||
/** TODO rename */
|
/** power curve applied to visual recoil */
|
||||||
public float cooldown = 0.02f;
|
public float recoilPow = 1.8f;
|
||||||
|
/** ticks to cool down the heat region */
|
||||||
|
public float cooldownTime = 20f;
|
||||||
/** Visual elevation of turret shadow, -1 to use defaults. */
|
/** Visual elevation of turret shadow, -1 to use defaults. */
|
||||||
public float elevation = -1f;
|
public float elevation = -1f;
|
||||||
/** How much the screen shakes per shot. */
|
/** How much the screen shakes per shot. */
|
||||||
@@ -159,6 +161,8 @@ public class Turret extends ReloadTurret{
|
|||||||
public void init(){
|
public void init(){
|
||||||
if(shootY == Float.NEGATIVE_INFINITY) shootY = size * tilesize / 2f;
|
if(shootY == Float.NEGATIVE_INFINITY) shootY = size * tilesize / 2f;
|
||||||
if(elevation < 0) elevation = size / 2f;
|
if(elevation < 0) elevation = size / 2f;
|
||||||
|
if(recoilTime < 0f) recoilTime = reload;
|
||||||
|
if(cooldownTime < 0f) cooldownTime = reload;
|
||||||
|
|
||||||
super.init();
|
super.init();
|
||||||
}
|
}
|
||||||
@@ -339,14 +343,13 @@ public class Turret extends ReloadTurret{
|
|||||||
|
|
||||||
wasShooting = false;
|
wasShooting = false;
|
||||||
|
|
||||||
//TODO do not lerp
|
curRecoil = Math.max(curRecoil - Time.delta / recoilTime , 0);
|
||||||
curRecoil = Mathf.lerpDelta(curRecoil, 0f, restitution);
|
heat = Math.max(heat - Time.delta / cooldownTime, 0);
|
||||||
heat = Mathf.lerpDelta(heat, 0f, cooldown);
|
|
||||||
|
|
||||||
unit.tile(this);
|
unit.tile(this);
|
||||||
unit.rotation(rotation);
|
unit.rotation(rotation);
|
||||||
unit.team(team);
|
unit.team(team);
|
||||||
recoilOffset.trns(rotation, -curRecoil);
|
recoilOffset.trns(rotation, -Mathf.pow(curRecoil, recoilPow) * recoil);
|
||||||
|
|
||||||
if(logicControlTime > 0){
|
if(logicControlTime > 0){
|
||||||
logicControlTime -= Time.delta;
|
logicControlTime -= Time.delta;
|
||||||
@@ -550,7 +553,7 @@ public class Turret extends ReloadTurret{
|
|||||||
Effect.shake(shake, shake, this);
|
Effect.shake(shake, shake, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
curRecoil = recoil;
|
curRecoil = 1f;
|
||||||
heat = 1f;
|
heat = 1f;
|
||||||
|
|
||||||
if(!consumeAmmoOnce){
|
if(!consumeAmmoOnce){
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ public class ConsumeItemExplode extends ConsumeItemFilter{
|
|||||||
public Effect explodeEffect = Fx.generatespark;
|
public Effect explodeEffect = Fx.generatespark;
|
||||||
|
|
||||||
public ConsumeItemExplode(float threshold){
|
public ConsumeItemExplode(float threshold){
|
||||||
super(item -> item.explosiveness >= threshold);
|
this.filter = item -> item.explosiveness >= this.threshold;
|
||||||
this.threshold = threshold;
|
this.threshold = threshold;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user