Class Weapon

java.lang.Object
mindustry.type.Weapon
All Implemented Interfaces:
Cloneable
Direct Known Subclasses:
BuildWeapon, PointDefenseWeapon, RepairBeamWeapon

public class Weapon extends Object implements Cloneable
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    boolean
    whether this weapon can be automatically aimed by the unit
    boolean
    whether to shoot the weapons in different arms one after another, rather than all at once; only valid when mirror = true
    boolean
    whether this weapon uses continuous fire without reloading; implies continuous = true
    boolean
    whether this weapon is always shooting, regardless of targets ore cone
    boolean
    whether to automatically target relevant units in update(); only works when controllable = false.
    float
    rotation at which this weapon starts at.
    bullet shot
    cell region, must be same size as region (optional)
    sound used for weapons that have a delay
    boolean
    whether to hold the bullet in place while firing; it will still require reload.
    boolean
    whether this weapon can be aimed manually by players
    float
    ticks to cool down the heat region
    boolean
    whether weapon should appear in the stats of a unit with this weapon
    shell ejection effect
    boolean
    whether to flip the weapon's sprite when rendering.
    heat region tint
    heat region, must be same size as region (optional)
    boolean
    whether shooter rotation is ignored when shooting.
    float
    inaccuracy of degrees of each shot
    float
    draw Z offset relative to the default value
    boolean
    If true, shoot warmup is linear instead of a curve.
    float
    min velocity required for this weapon to shoot
    float
    minimum weapon warmup before firing (this is not linear, do NOT use 1!)
    boolean
    whether to create a flipped copy of this weapon upon initialization.
    type of weapon mount to be used
    displayed weapon region
    sound played when there is nothing to shoot
    boolean
    If true, this weapon cannot be used to attack targets.
    int
    internal value used for alternation - do not change!
    outline region to display if top is false
    boolean
    should the shoot effects follow the unit (effects need followParent set to true for this to work)
    extra animated parts
    boolean
    whether to perform target trajectory prediction
    float
    visual weapon knockback.
    float
    power curve applied to visual recoil
    int
    Number of additional counters for recoil.
    float
    time taken for weapon to return to starting position in ticks.
    displayed region (autoloaded)
    float
    weapon reload in frames
    boolean
    whether to rotate toward the target independently of unit
    float
    rotation speed of weapon when rotation is enabled, in degrees/t
    float
    Cone in which the weapon can rotate relative to its mount.
    float
    radius of shadow drawn under the weapon; <0 to disable
    float
    intensity and duration of each shot's screen shake
    pattern used for bullets
    float
    The half-radius of the cone in which shooting will start.
    boolean
    whether this weapon should fire when its owner dies
    sound used for shooting
    status effect applied when shooting
    float
    status effect duration when shot
    float
    lerp speed for shoot warmup, only used for parts
    float
    projectile/effect offsets from center of weapon
    float
    projectile/effect offsets from center of weapon
    boolean
    Whether to show the sprite of the weapon in the database.
    float
    lerp speed for shoot warmup, only used for parts
    float
    random sound pitch range
    float
    random sound pitch range
    float
    ticks to wait in-between targets
    float
    ticks to wait in-between targets
    boolean
    whether to draw the outline on top.
    boolean
    whether to consume ammo when ammo is enabled in rules
    boolean
    if true, this weapon is used for attack range calculations
    float
    fraction of velocity that is random
    float
    offsets of weapon position on unit
    float
    Random spread on the X axis.
    float
    offsets of weapon position on unit
  • Constructor Summary

    Constructors
    Constructor
    Description
     
    Weapon(String name)
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected void
    bullet(mindustry.gen.Unit unit, WeaponMount mount, float xOffset, float yOffset, float angleOffset, Mover mover)
     
    protected float
    bulletRotation(mindustry.gen.Unit unit, WeaponMount mount, float bulletX, float bulletY)
     
    protected boolean
    checkTarget(mindustry.gen.Unit unit, mindustry.gen.Teamc target, float x, float y, float range)
     
     
    float
    dps()
     
    void
    draw(mindustry.gen.Unit unit, WeaponMount mount)
     
    void
    drawOutline(mindustry.gen.Unit unit, WeaponMount mount)
     
    protected mindustry.gen.Teamc
    findTarget(mindustry.gen.Unit unit, float x, float y, float range, boolean air, boolean ground)
     
    void
     
    protected void
    handleBullet(mindustry.gen.Unit unit, WeaponMount mount, mindustry.gen.Bullet bullet)
     
    boolean
     
    void
     
    void
     
    float
     
    protected void
    shoot(mindustry.gen.Unit unit, WeaponMount mount, float shootX, float shootY, float rotation)
     
    float
     
     
    void
    update(mindustry.gen.Unit unit, WeaponMount mount)
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Field Details

    • name

      public String name
      displayed weapon region
    • bullet

      public BulletType bullet
      bullet shot
    • ejectEffect

      public Effect ejectEffect
      shell ejection effect
    • display

      public boolean display
      whether weapon should appear in the stats of a unit with this weapon
    • useAmmo

      public boolean useAmmo
      whether to consume ammo when ammo is enabled in rules
    • mirror

      public boolean mirror
      whether to create a flipped copy of this weapon upon initialization. default: true
    • flipSprite

      public boolean flipSprite
      whether to flip the weapon's sprite when rendering. internal use only - do not set!
    • alternate

      public boolean alternate
      whether to shoot the weapons in different arms one after another, rather than all at once; only valid when mirror = true
    • rotate

      public boolean rotate
      whether to rotate toward the target independently of unit
    • showStatSprite

      public boolean showStatSprite
      Whether to show the sprite of the weapon in the database.
    • baseRotation

      public float baseRotation
      rotation at which this weapon starts at. TODO buggy!
    • top

      public boolean top
      whether to draw the outline on top.
    • continuous

      public boolean continuous
      whether to hold the bullet in place while firing; it will still require reload.
    • alwaysContinuous

      public boolean alwaysContinuous
      whether this weapon uses continuous fire without reloading; implies continuous = true
    • controllable

      public boolean controllable
      whether this weapon can be aimed manually by players
    • aiControllable

      public boolean aiControllable
      whether this weapon can be automatically aimed by the unit
    • alwaysShooting

      public boolean alwaysShooting
      whether this weapon is always shooting, regardless of targets ore cone
    • autoTarget

      public boolean autoTarget
      whether to automatically target relevant units in update(); only works when controllable = false.
    • predictTarget

      public boolean predictTarget
      whether to perform target trajectory prediction
    • useAttackRange

      public boolean useAttackRange
      if true, this weapon is used for attack range calculations
    • targetInterval

      public float targetInterval
      ticks to wait in-between targets
    • targetSwitchInterval

      public float targetSwitchInterval
      ticks to wait in-between targets
    • rotateSpeed

      public float rotateSpeed
      rotation speed of weapon when rotation is enabled, in degrees/t
    • reload

      public float reload
      weapon reload in frames
    • inaccuracy

      public float inaccuracy
      inaccuracy of degrees of each shot
    • shake

      public float shake
      intensity and duration of each shot's screen shake
    • recoil

      public float recoil
      visual weapon knockback.
    • recoils

      public int recoils
      Number of additional counters for recoil.
    • recoilTime

      public float recoilTime
      time taken for weapon to return to starting position in ticks. uses reload time by default
    • recoilPow

      public float recoilPow
      power curve applied to visual recoil
    • cooldownTime

      public float cooldownTime
      ticks to cool down the heat region
    • shootX

      public float shootX
      projectile/effect offsets from center of weapon
    • shootY

      public float shootY
      projectile/effect offsets from center of weapon
    • x

      public float x
      offsets of weapon position on unit
    • y

      public float y
      offsets of weapon position on unit
    • xRand

      public float xRand
      Random spread on the X axis.
    • shoot

      public ShootPattern shoot
      pattern used for bullets
    • shadow

      public float shadow
      radius of shadow drawn under the weapon; <0 to disable
    • velocityRnd

      public float velocityRnd
      fraction of velocity that is random
    • shootCone

      public float shootCone
      The half-radius of the cone in which shooting will start.
    • rotationLimit

      public float rotationLimit
      Cone in which the weapon can rotate relative to its mount.
    • minWarmup

      public float minWarmup
      minimum weapon warmup before firing (this is not linear, do NOT use 1!)
    • shootWarmupSpeed

      public float shootWarmupSpeed
      lerp speed for shoot warmup, only used for parts
    • smoothReloadSpeed

      public float smoothReloadSpeed
      lerp speed for shoot warmup, only used for parts
    • linearWarmup

      public boolean linearWarmup
      If true, shoot warmup is linear instead of a curve.
    • soundPitchMin

      public float soundPitchMin
      random sound pitch range
    • soundPitchMax

      public float soundPitchMax
      random sound pitch range
    • ignoreRotation

      public boolean ignoreRotation
      whether shooter rotation is ignored when shooting.
    • noAttack

      public boolean noAttack
      If true, this weapon cannot be used to attack targets.
    • minShootVelocity

      public float minShootVelocity
      min velocity required for this weapon to shoot
    • parentizeEffects

      public boolean parentizeEffects
      should the shoot effects follow the unit (effects need followParent set to true for this to work)
    • otherSide

      public int otherSide
      internal value used for alternation - do not change!
    • layerOffset

      public float layerOffset
      draw Z offset relative to the default value
    • shootSound

      public Sound shootSound
      sound used for shooting
    • chargeSound

      public Sound chargeSound
      sound used for weapons that have a delay
    • noAmmoSound

      public Sound noAmmoSound
      sound played when there is nothing to shoot
    • region

      public TextureRegion region
      displayed region (autoloaded)
    • heatRegion

      public TextureRegion heatRegion
      heat region, must be same size as region (optional)
    • cellRegion

      public TextureRegion cellRegion
      cell region, must be same size as region (optional)
    • outlineRegion

      public TextureRegion outlineRegion
      outline region to display if top is false
    • heatColor

      public Color heatColor
      heat region tint
    • shootStatus

      public StatusEffect shootStatus
      status effect applied when shooting
    • mountType

      public Func<Weapon,WeaponMount> mountType
      type of weapon mount to be used
    • shootStatusDuration

      public float shootStatusDuration
      status effect duration when shot
    • shootOnDeath

      public boolean shootOnDeath
      whether this weapon should fire when its owner dies
    • parts

      public Seq<DrawPart> parts
      extra animated parts
  • Constructor Details

    • Weapon

      public Weapon(String name)
    • Weapon

      public Weapon()
  • Method Details

    • hasStats

      public boolean hasStats(UnitType u)
    • addStats

      public void addStats(UnitType u, Table t)
    • dps

      public float dps()
    • shotsPerSec

      public float shotsPerSec()
    • drawOutline

      public void drawOutline(mindustry.gen.Unit unit, WeaponMount mount)
    • draw

      public void draw(mindustry.gen.Unit unit, WeaponMount mount)
    • range

      public float range()
    • update

      public void update(mindustry.gen.Unit unit, WeaponMount mount)
    • findTarget

      protected mindustry.gen.Teamc findTarget(mindustry.gen.Unit unit, float x, float y, float range, boolean air, boolean ground)
    • checkTarget

      protected boolean checkTarget(mindustry.gen.Unit unit, mindustry.gen.Teamc target, float x, float y, float range)
    • bulletRotation

      protected float bulletRotation(mindustry.gen.Unit unit, WeaponMount mount, float bulletX, float bulletY)
    • shoot

      protected void shoot(mindustry.gen.Unit unit, WeaponMount mount, float shootX, float shootY, float rotation)
    • bullet

      protected void bullet(mindustry.gen.Unit unit, WeaponMount mount, float xOffset, float yOffset, float angleOffset, Mover mover)
    • handleBullet

      protected void handleBullet(mindustry.gen.Unit unit, WeaponMount mount, mindustry.gen.Bullet bullet)
    • flip

      public void flip()
    • copy

      public Weapon copy()
    • init

      public void init()
    • load

      public void load()
    • toString

      public String toString()
      Overrides:
      toString in class Object