Package mindustry.type
Class Weapon
java.lang.Object
mindustry.type.Weapon
- All Implemented Interfaces:
Cloneable
- Direct Known Subclasses:
BuildWeapon
,PointDefenseWeapon
,RepairBeamWeapon
-
Field Summary
Modifier and TypeFieldDescriptionboolean
whether this weapon can be automatically aimed by the unitboolean
whether to shoot the weapons in different arms one after another, rather than all at once; only valid when mirror = trueboolean
whether this weapon uses continuous fire without reloading; implies continuous = trueboolean
whether this weapon is always shooting, regardless of targets ore coneboolean
whether to automatically target relevant units in update(); only works when controllable = false.float
rotation at which this weapon starts at.bullet shotcell region, must be same size as region (optional)sound used for weapons that have a delayboolean
whether to hold the bullet in place while firing; it will still require reload.boolean
whether this weapon can be aimed manually by playersfloat
ticks to cool down the heat regionboolean
whether weapon should appear in the stats of a unit with this weaponshell ejection effectboolean
whether to flip the weapon's sprite when rendering.heat region tintheat region, must be same size as region (optional)boolean
whether shooter rotation is ignored when shooting.float
inaccuracy of degrees of each shotfloat
draw Z offset relative to the default valueboolean
If true, shoot warmup is linear instead of a curve.float
min velocity required for this weapon to shootfloat
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 useddisplayed weapon regionsound played when there is nothing to shootboolean
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 falseboolean
should the shoot effects follow the unit (effects need followParent set to true for this to work)extra animated partsboolean
whether to perform target trajectory predictionfloat
visual weapon knockback.float
power curve applied to visual recoilint
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 framesboolean
whether to rotate toward the target independently of unitfloat
rotation speed of weapon when rotation is enabled, in degrees/tfloat
Cone in which the weapon can rotate relative to its mount.float
radius of shadow drawn under the weapon; <0 to disablefloat
intensity and duration of each shot's screen shakepattern used for bulletsfloat
The half-radius of the cone in which shooting will start.boolean
whether this weapon should fire when its owner diessound used for shootingstatus effect applied when shootingfloat
status effect duration when shotfloat
lerp speed for shoot warmup, only used for partsfloat
projectile/effect offsets from center of weaponfloat
projectile/effect offsets from center of weaponboolean
Whether to show the sprite of the weapon in the database.float
lerp speed for shoot warmup, only used for partsfloat
random sound pitch rangefloat
random sound pitch rangefloat
ticks to wait in-between targetsfloat
ticks to wait in-between targetsboolean
whether to draw the outline on top.boolean
whether to consume ammo when ammo is enabled in rulesboolean
if true, this weapon is used for attack range calculationsfloat
fraction of velocity that is randomfloat
offsets of weapon position on unitfloat
Random spread on the X axis.float
offsets of weapon position on unit -
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
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) copy()
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
flip()
protected void
handleBullet
(mindustry.gen.Unit unit, WeaponMount mount, mindustry.gen.Bullet bullet) boolean
void
init()
void
load()
float
range()
protected void
shoot
(mindustry.gen.Unit unit, WeaponMount mount, float shootX, float shootY, float rotation) float
toString()
void
update
(mindustry.gen.Unit unit, WeaponMount mount)
-
Field Details
-
name
displayed weapon region -
bullet
bullet shot -
ejectEffect
shell ejection effect -
display
public boolean displaywhether weapon should appear in the stats of a unit with this weapon -
useAmmo
public boolean useAmmowhether to consume ammo when ammo is enabled in rules -
mirror
public boolean mirrorwhether to create a flipped copy of this weapon upon initialization. default: true -
flipSprite
public boolean flipSpritewhether to flip the weapon's sprite when rendering. internal use only - do not set! -
alternate
public boolean alternatewhether to shoot the weapons in different arms one after another, rather than all at once; only valid when mirror = true -
rotate
public boolean rotatewhether to rotate toward the target independently of unit -
showStatSprite
public boolean showStatSpriteWhether to show the sprite of the weapon in the database. -
baseRotation
public float baseRotationrotation at which this weapon starts at. TODO buggy! -
top
public boolean topwhether to draw the outline on top. -
continuous
public boolean continuouswhether to hold the bullet in place while firing; it will still require reload. -
alwaysContinuous
public boolean alwaysContinuouswhether this weapon uses continuous fire without reloading; implies continuous = true -
controllable
public boolean controllablewhether this weapon can be aimed manually by players -
aiControllable
public boolean aiControllablewhether this weapon can be automatically aimed by the unit -
alwaysShooting
public boolean alwaysShootingwhether this weapon is always shooting, regardless of targets ore cone -
autoTarget
public boolean autoTargetwhether to automatically target relevant units in update(); only works when controllable = false. -
predictTarget
public boolean predictTargetwhether to perform target trajectory prediction -
useAttackRange
public boolean useAttackRangeif true, this weapon is used for attack range calculations -
targetInterval
public float targetIntervalticks to wait in-between targets -
targetSwitchInterval
public float targetSwitchIntervalticks to wait in-between targets -
rotateSpeed
public float rotateSpeedrotation speed of weapon when rotation is enabled, in degrees/t -
reload
public float reloadweapon reload in frames -
inaccuracy
public float inaccuracyinaccuracy of degrees of each shot -
shake
public float shakeintensity and duration of each shot's screen shake -
recoil
public float recoilvisual weapon knockback. -
recoils
public int recoilsNumber of additional counters for recoil. -
recoilTime
public float recoilTimetime taken for weapon to return to starting position in ticks. uses reload time by default -
recoilPow
public float recoilPowpower curve applied to visual recoil -
cooldownTime
public float cooldownTimeticks to cool down the heat region -
shootX
public float shootXprojectile/effect offsets from center of weapon -
shootY
public float shootYprojectile/effect offsets from center of weapon -
x
public float xoffsets of weapon position on unit -
y
public float yoffsets of weapon position on unit -
xRand
public float xRandRandom spread on the X axis. -
shoot
pattern used for bullets -
shadow
public float shadowradius of shadow drawn under the weapon; <0 to disable -
velocityRnd
public float velocityRndfraction of velocity that is random -
shootCone
public float shootConeThe half-radius of the cone in which shooting will start. -
rotationLimit
public float rotationLimitCone in which the weapon can rotate relative to its mount. -
minWarmup
public float minWarmupminimum weapon warmup before firing (this is not linear, do NOT use 1!) -
shootWarmupSpeed
public float shootWarmupSpeedlerp speed for shoot warmup, only used for parts -
smoothReloadSpeed
public float smoothReloadSpeedlerp speed for shoot warmup, only used for parts -
linearWarmup
public boolean linearWarmupIf true, shoot warmup is linear instead of a curve. -
soundPitchMin
public float soundPitchMinrandom sound pitch range -
soundPitchMax
public float soundPitchMaxrandom sound pitch range -
ignoreRotation
public boolean ignoreRotationwhether shooter rotation is ignored when shooting. -
noAttack
public boolean noAttackIf true, this weapon cannot be used to attack targets. -
minShootVelocity
public float minShootVelocitymin velocity required for this weapon to shoot -
parentizeEffects
public boolean parentizeEffectsshould the shoot effects follow the unit (effects need followParent set to true for this to work) -
otherSide
public int otherSideinternal value used for alternation - do not change! -
layerOffset
public float layerOffsetdraw Z offset relative to the default value -
shootSound
sound used for shooting -
chargeSound
sound used for weapons that have a delay -
noAmmoSound
sound played when there is nothing to shoot -
region
displayed region (autoloaded) -
heatRegion
heat region, must be same size as region (optional) -
cellRegion
cell region, must be same size as region (optional) -
outlineRegion
outline region to display if top is false -
heatColor
heat region tint -
shootStatus
status effect applied when shooting -
mountType
type of weapon mount to be used -
shootStatusDuration
public float shootStatusDurationstatus effect duration when shot -
shootOnDeath
public boolean shootOnDeathwhether this weapon should fire when its owner dies -
parts
extra animated parts
-
-
Constructor Details
-
Weapon
-
Weapon
public Weapon()
-
-
Method Details
-
hasStats
-
addStats
-
dps
public float dps() -
shotsPerSec
public float shotsPerSec() -
drawOutline
-
draw
-
range
public float range() -
update
-
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
-
init
public void init() -
load
public void load() -
toString
-