Skip to content

UnitType

UnitType

extends UnlockableContent

field type default notes
envRequired int 0 Environmental flags that are all required for this unit to function. 0 = any environment
envEnabled int 1 The environment flags that this unit can function in. If the env matches any of these, it will be enabled.
envDisabled int 16 The environment flags that this unit cannot function in. If the env matches any of these, it will explode or be disabled.
speed float 1.1 movement speed (world units/t)
boostMultiplier float 1.0 multiplier for speed when boosting
floorMultiplier float 1.0 how affected this unit is by terrain
rotateSpeed float 5.0 body rotation speed in degrees/t
baseRotateSpeed float 5.0 mech base rotation speed in degrees/t
drag float 0.3 movement drag as fraction
accel float 0.5 acceleration as fraction of speed
hitSize float 6.0 size of one side of the hitbox square
deathShake float -1.0 shake on unit death
stepShake float -1.0 shake on each step for leg/mech units
rippleScale float 1.0 ripple / dust size for legged units
riseSpeed float 0.08 boosting rise speed as fraction
fallSpeed float 0.018 how fast this unit falls when not boosting
missileAccelTime float 0.0 how many ticks it takes this missile to accelerate to full speed
health float 200.0 raw health amount
armor float 0.0 incoming damage is reduced by this amount
range float -1.0 minimum range of any weapon; used for approaching targets. can be overridden by setting a value > 0.
maxRange float -1.0 maximum range of any weapon
mineRange float 70.0 range at which this unit can mine ores
buildRange float 220.0 range at which this unit can build
crashDamageMultiplier float 1.0 multiplier for damage this (flying) unit deals when crashing on enemy things
wreckHealthMultiplier float 0.25 multiplier for health that this flying unit has for its wreck, based on its max health.
dpsEstimate float -1.0 a VERY ROUGH estimate of unit DPS; initialized in init()
clipSize float -1.0 graphics clipping size; <0 to calculate automatically
drownTimeMultiplier float 1.0 multiplier for how slowly this unit drowns - higher numbers, slower drowning.
strafePenalty float 0.5 fractional movement speed penalty for this unit when it is moving in the opposite direction that it is facing
researchCostMultiplier float 50.0 multiplier for cost of research in tech tree
groundLayer float 60.0 for ground units, the layer upon which this unit is drawn
flyingLayer float -1.0 For units that fly, the layer upon which this unit is drawn. If no value is set, defaults to Layer.flyingUnitLow or Layer.flyingUnit depending on lowAltitude
payloadCapacity float 8.0 Payload capacity of this unit in world units^2
buildSpeed float -1.0 building speed multiplier; <0 to disable.
aimDst float -1.0 Minimum distance from this unit that weapons can target. Prevents units from firing "inside" the unit.
buildBeamOffset float 3.8 Visual offset of the build beam from the front.
mineBeamOffset float -Infinity Visual offset of the mining beam from the front. Defaults to half the hitsize.
targetPriority float 0.0 WIP: Units of low priority will always be ignored in favor of those with higher priority, regardless of distance.
shadowElevation float -1.0 Elevation of shadow drawn under this (ground) unit. Visual only.
shadowElevationScl float 1.0 Scale for length of shadow drawn under this unit. Does nothing if this unit has no shadow.
engineOffset float 5.0 backwards engine offset from center of unit
engineSize float 2.5 main engine radius
engineLayer float -1.0 layer of all engines (<0 for default)
itemOffsetY float 3.0 visual backwards offset of items on unit
lightRadius float -1.0 radius of light emitted, <0 for default
lightOpacity float 0.6 light color opacity
softShadowScl float 1.0 scale of soft shadow - its size is calculated based off of region size
fogRadius float -1.0 fog view radius in tiles. <0 for automatic radius.
waveTrailX float 4.0 horizontal offset of wave trail in naval units
waveTrailY float -3.0 vertical offset of wave trail in naval units
trailScl float 1.0 width of all trails (including naval ones)
isEnemy boolean true if true, this unit counts as an enemy in the wave counter (usually false for support-only units)
flying boolean false if true, the unit is always at elevation 1
wobble boolean true whether this flying unit should wobble around
targetAir boolean true whether this unit tries to attack air units
targetGround boolean true whether this unit tries to attack ground units
faceTarget boolean true if true, this unit will attempt to face its target when shooting/aiming at it
circleTarget boolean false AI flag: if true, this flying unit circles around its target like a bomber
autoDropBombs boolean false AI flag: if true, this unit will drop bombs under itself even when it is not next to its 'real' target. used for carpet bombers
targetBuildingsMobile boolean true For the mobile version only: If false, this unit will not auto-target buildings to attach when a player controls it.
canBoost boolean false if true, this unit can boost into the air if a player/processors controls it
boostWhenBuilding boolean true if true, this unit will always boost when using builder AI
boostWhenMining boolean true if true, this unit will always boost when using miner AI
logicControllable boolean true if false, logic processors cannot control this unit
playerControllable boolean true if false, players cannot control this unit
controlSelectGlobal boolean true If true, the unit can be selected with the global selection hotkey (shift+g).
allowedInPayloads boolean true if false, this unit cannot be moved into payloads
hittable boolean true if false, this unit cannot be hit by bullets or explosions
killable boolean true if false, this unit does not take damage and cannot be kill() / destroy()-ed.
targetable boolean true if false, this unit is not targeted by anything.
vulnerableWithPayloads boolean false if true, this unit can be hit/targeted when it has payloads (assuming hittable/targetable is false)
pickupUnits boolean true if true, this payload unit can pick up units
physics boolean true if false, this unit does not physically collide with others.
canDrown boolean true if true, this ground unit will drown in deep liquids.
useUnitCap boolean true if false, this unit ignores the unit cap and can be spawned infinitely
coreUnitDock boolean false if true, this core unit will "dock" to other units, making it re-appear when "undocking".
createWreck boolean true if false, no falling "corpse" is created when this unit dies.
createScorch boolean true if false, no scorch marks are created when this unit dies
lowAltitude boolean false if true, this unit will be drawn under effects/bullets; this is a visual change only.
rotateToBuilding boolean true if true, this unit will look at whatever it is building
allowLegStep boolean false if true and this is a legged unit, this unit can walk over blocks.
legPhysicsLayer boolean true for legged units, setting this to false forces it to be on the ground physics layer.
hovering boolean false if true, this unit will not be affected by the floor under it.
omniMovement boolean true if true, this unit can move in any direction regardless of rotation. if false, this unit can only move in the direction it is facing.
rotateMoveFirst boolean false if true, the unit faces its moving direction before actually moving.
healFlash boolean true if true, this unit flashes when being healed
canHeal boolean false whether the unit can heal blocks. Initialized in init()
singleTarget boolean false if true, all weapons will attack the same target.
forceMultiTarget boolean false if true, this unit will be able to have multiple targets, even if it only has one mirrored weapon.
canAttack boolean true if false, this unit has no weapons that can attack.
hidden boolean false if true, this unit won't show up in the database or various other UIs.
internal boolean false if true, this unit is for internal use only and does not have a sprite generated.
internalGenerateSprites boolean false For certain units, generating sprites is still necessary, despite being internal.
bounded boolean true If false, this unit is not pushed away from map edges.
naval boolean false if true, this unit is detected as naval - do NOT assign this manually! Initialized in init()
autoFindTarget boolean true if false, RTS AI controlled units do not automatically attack things while moving. This is automatically assigned.
targetUnderBlocks boolean true If false, 'under' blocks like conveyors are not targeted.
alwaysShootWhenMoving boolean false if true, this unit will always shoot while moving regardless of slowdown
hoverable boolean true whether this unit has a hover tooltip
alwaysCreateOutline boolean false if true, this modded unit always has a -outline region generated for its base. Normally, outlines are ignored if there are no top = false weapons.
generateFullIcon boolean true for vanilla content only - if false, skips the full icon generation step.
squareShape boolean false if true, this unit has a square shadow.
drawBuildBeam boolean true if true, this unit will draw its building beam towards blocks.
drawMineBeam boolean true if true, this unit will draw its mining beam towards blocks
drawCell boolean true if false, the team indicator/cell is not drawn.
drawItems boolean true if false, carried items are not drawn.
drawShields boolean true if false, the unit shield (usually seen in waves) is not drawn.
drawBody boolean true if false, the unit body is not drawn.
drawSoftShadow boolean true if false, the soft shadow is not drawn.
drawMinimap boolean true if false, the unit is not drawn on the minimap.
aiController Prov of ? extends UnitController {code} The default AI controller to assign on creation.
controller Func of Unit, ? extends UnitController get() : new CommandAI() Function that chooses AI controller based on unit entity.
constructor Prov of ? extends Unit null Creates a new instance of this unit class.
abilities Seq of Ability [] list of "abilities", which are various behaviors that update each frame
weapons Seq of Weapon [] All weapons that this unit will shoot with.
immunities ObjectSet of StatusEffect new ObjectSet<>() None of the status effects in this set can be applied to this unit.
healColor Color 98ffa9ff color that this unit flashes when getting healed (if healFlash is true)
lightColor Color fbd367ff Color of light that this unit produces when lighting is enabled in the map.
shieldColor Color null override for unit shield colour.
deathSound Sound bang sound played when this unit explodes (not when it is shot down)
loopSound Sound none sound played on loop when this unit is around.
loopSoundVolume float 0.5 volume of loop sound
fallEffect Effect fallSmoke effect that this unit emits when falling
fallEngineEffect Effect fallSmoke effect created at engine when unit falls.
deathExplosionEffect Effect dynamicExplosion effect created when this unit dies
treadEffect Effect null optional effect created when this tank moves
parts Seq of DrawPart [] extra (usually animated) visual parts
engines Seq of UnitEngine [] list of engines, or "thrusters"
useEngineElevation boolean true if false, the thruster is always displayed at its normal size regardless of elevation
engineColor Color null override for all engine colors
engineColorInner Color ffffffff color for inner portions of engines
trailLength int 0 length of engine trail (if flying) or wave trail (if naval)
trailColor Color null override for engine trail color
flowfieldPathType int -1 Cost type ID for flow field/enemy AI pathfinding.
pathCost PathCost null Function used for calculating cost of moving with ControlPathfinder. Does not affect "normal" flow field pathfinding.
pathCostId int 0 ID for path cost, to be used in the control path finder. This is the value that actually matters; do not assign manually. Set in init().
sample Unit null A sample of the unit that this type creates. Do not modify!
targetFlags BlockFlag[] [null] Flags to target based on priority. Null indicates that the closest target should be found. The closest enemy core is used as a fallback.
allowChangeCommands boolean true A value of false is used to hide command changing UI in unit factories.
commands Seq of UnitCommand [] Commands available to this unit through RTS controls. An empty array means commands will be assigned based on unit capabilities in init().
defaultCommand UnitCommand null Command to assign to this unit upon creation. Null indicates the first command in the array.
stances Seq of UnitStance [] Stances this unit can have. An empty array means stances will be assigned based on unit capabilities in init().
outlineColor Color 565666ff color for outline generated around sprites
outlineRadius int 3 thickness for sprite outline
outlines boolean true if false, no sprite outlines are generated
itemCapacity int -1 amount of items this unit can carry; <0 to determine based on hitSize.
ammoCapacity int -1 amount of ammo this unit can hold (if the rule is enabled); <0 to determine based on weapon fire rate.
ammoType AmmoType copper) ammo this unit uses, if that system is enabled.
mineTier int -1 max hardness of ore that this unit can mine (<0 to disable)
mineSpeed float 1.0 mining speed in weird arbitrary units
mineWalls boolean false whether this unit can mine ores from floors/walls, respectively
mineFloor boolean true whether this unit can mine ores from floors/walls, respectively
mineHardnessScaling boolean true if true, harder materials will take longer to mine
mineSound Sound minebeam continuous sound emitted when mining.
mineSoundVolume float 0.6 volume of mining sound.
mineItems Seq of Item [Copper, Lead, Titanium, Thorium] Target items to mine. Used in MinerAI
legCount int 4 number of legs this unit has (must have the correct type to function!)
legGroupSize int 2 size of groups in which legs move. for example, insects (6 legs) usually move legs in groups of 3.
legLength float 10.0 total length of a leg (both segments)
legSpeed float 0.1 how fast individual legs move towards their destination (non-linear)
legForwardScl float 1.0 scale for how far in front (relative to unit velocity) legs try to place themselves; if legs lag behind a unit, increase this number
legBaseOffset float 0.0 leg offset from the center of the unit
legMoveSpace float 1.0 scaling for space between leg movements
legExtension float 0.0 for legs without "joints", this is how much the second leg sprite is moved "back" by, so it covers the joint region (it's hard to explain without an image)
legPairOffset float 0.0 Higher values of this field make groups of legs move less in-sync with each other.
legLengthScl float 1.0 scaling for how far away legs try to be from the body (not their actual length); e.g. if set to 0.5, legs will appear somewhat folded
legStraightLength float 1.0 if legStraightness > 0, this is the scale for how far away legs are from the body horizontally
legMaxLength float 1.75 maximum length of an individual leg as fraction of real length
legMinLength float 0.0 minimum length of an individual leg as fraction of real length
legSplashDamage float 0.0 splash damage dealt when a leg touches the ground
legSplashRange float 5.0 splash damage radius of legs
baseLegStraightness float 0.0 how straight the leg base/origin is (0 = circular, 1 = line)
legStraightness float 0.0 how straight the leg outward angles are (0 = circular, 1 = horizontal line)
legBaseUnder boolean false If true, the base (further away) leg region is drawn under instead of over.
lockLegBase boolean false If true, legs are locked to the base of the unit instead of being on an implicit rotating "mount".
legContinuousMove boolean false If true, legs always try to move around even when the unit is not moving (leads to more natural behavior)
flipBackLegs boolean true TODO neither of these appear to do much
flipLegSide boolean false TODO neither of these appear to do much
emitWalkSound boolean true Whether to emit a splashing noise in water.
emitWalkEffect boolean true Whether to emit a splashing effect in water (fasle implies emitWalkSound false).
mechLandShake float 0.0 screen shake amount for when this mech lands after boosting
mechSideSway float 0.54 parameters for mech swaying animation
mechFrontSway float 0.1 parameters for mech swaying animation
mechStride float -1.0 parameters for mech swaying animation
mechStepParticles boolean false whether particles are created when this mech takes a step
mechLegColor Color 6e7080ff color that legs change to when moving, to simulate depth
treadRects Rect[] [] list of treads as rectangles in IMAGE COORDINATES, relative to the center. these are mirrored.
treadFrames int 18 number of frames of movement in a tread
treadPullOffset int 0 how much of a top part of a tread sprite is "cut off" relative to the pattern; this is corrected for
segments int 0 number of independent segments
segmentUnits int 1 TODO wave support - for multi-unit segmented units, this is the number of independent units that are spawned
segmentUnit UnitType null unit spawned in segments; if null, the same unit is used
segmentEndUnit UnitType null unit spawned at the end; if null, the segment unit is used
segmentLayerOrder boolean true true - parent segments are on higher layers; false - parent segments are on lower layers than head
segmentMag float 2.0 magnitude of sine offset between segments
segmentScl float 4.0 scale of sine offset between segments
segmentPhase float 5.0 index multiplier of sine offset between segments
segmentRotSpeed float 1.0 how fast each segment moves towards the next one
segmentMaxRot float 30.0 maximum difference between segment angles
segmentSpacing float -1.0 spacing between separate unit segments (only used for multi-unit worms)
segmentRotationRange float 80.0 rotation between segments is clamped to this range
crawlSlowdown float 0.5 speed multiplier this unit will have when crawlSlowdownFrac is met.
crushDamage float 0.0 damage dealt to blocks under this tank/crawler every frame.
crawlSlowdownFrac float 0.55 the fraction of solids under this block necessary for it to reach crawlSlowdown.
lifetime float 300.0 lifetime of this missile.
homingDelay float 10.0 ticks that must pass before this missile starts homing.
baseRegion TextureRegion null
legRegion TextureRegion null
region TextureRegion null
previewRegion TextureRegion null
shadowRegion TextureRegion null
cellRegion TextureRegion null
itemCircleRegion TextureRegion null
softShadowRegion TextureRegion null
jointRegion TextureRegion null
footRegion TextureRegion null
legBaseRegion TextureRegion null
baseJointRegion TextureRegion null
outlineRegion TextureRegion null
treadRegion TextureRegion null
mineLaserRegion TextureRegion null
mineLaserEndRegion TextureRegion null
wreckRegions TextureRegion[] null
segmentRegions TextureRegion[] null
segmentCellRegions TextureRegion[] null
segmentOutlineRegions TextureRegion[] null
treadRegions TextureRegion[][] null