Weapon support for "always-continuous" bullets

This commit is contained in:
Anuken
2022-07-03 14:32:21 -04:00
parent 4d5f16e75d
commit 3e4b754a60

View File

@@ -45,8 +45,10 @@ public class Weapon implements Cloneable{
public float baseRotation = 0f; public float baseRotation = 0f;
/** whether to draw the outline on top. */ /** whether to draw the outline on top. */
public boolean top = true; public boolean top = true;
/** whether to hold the bullet in place while firing */ /** whether to hold the bullet in place while firing; it will still require reload. */
public boolean continuous; public boolean continuous;
/** whether this weapon uses continuous fire without reloading; implies continuous = true */
public boolean alwaysContinuous;
/** whether this weapon can be aimed manually by players */ /** whether this weapon can be aimed manually by players */
public boolean controllable = true; public boolean controllable = true;
/** whether to automatically target relevant units in update(); only works when controllable = false. */ /** whether to automatically target relevant units in update(); only works when controllable = false. */
@@ -328,10 +330,9 @@ public class Weapon implements Cloneable{
mount.sound.update(bulletX, bulletY, true); mount.sound.update(bulletX, bulletY, true);
} }
//TODO: how do continuous flame bullets work here? a new system is needed if(alwaysContinuous && mount.shoot){
if(mount.bullet.type.optimalLifeFract > 0){ mount.bullet.time = mount.bullet.lifetime * mount.bullet.type.optimalLifeFract * mount.warmup;
// mount.bullet.time = mount.bullet.lifetime * mount.bullet.type.optimalLifeFract * mount.warmup; mount.bullet.keepAlive = true;
// mount.bullet.keepAlive = true;
} }
} }
}else{ }else{
@@ -357,7 +358,7 @@ public class Weapon implements Cloneable{
(!alternate || wasFlipped == flipSprite) && (!alternate || wasFlipped == flipSprite) &&
mount.warmup >= minWarmup && //must be warmed up mount.warmup >= minWarmup && //must be warmed up
unit.vel.len() >= minShootVelocity && //check velocity requirements unit.vel.len() >= minShootVelocity && //check velocity requirements
mount.reload <= 0.0001f && //reload has to be 0 (mount.reload <= 0.0001f || (alwaysContinuous && mount.bullet == null)) && //reload has to be 0, or it has to be an always-continuous weapon
Angles.within(rotate ? mount.rotation : unit.rotation + baseRotation, mount.targetRotation, shootCone) //has to be within the cone Angles.within(rotate ? mount.rotation : unit.rotation + baseRotation, mount.targetRotation, shootCone) //has to be within the cone
){ ){
shoot(unit, mount, bulletX, bulletY, shootAngle); shoot(unit, mount, bulletX, bulletY, shootAngle);
@@ -458,7 +459,9 @@ public class Weapon implements Cloneable{
@CallSuper @CallSuper
public void init(){ public void init(){
if(alwaysContinuous){
continuous = true;
}
} }
public void load(){ public void load(){