ItemTurrets - game-stuff-official/exampledustry GitHub Wiki
Item turrets take items as input to shoot.
- Examples
- Exampledustry's Char
- Resources
- Official Mindustry wiki for ItemTurret Mindustry's Source Code
ItemTurret
extends Turret
When one thing extends the other, it inherits all the properties and functions. Even though ammoTypes:
is the only unique property, we can still use all of Turret
's properties.
Use type: ItemTurret
to make your block an ItemTurret
.
type: ItemTurret
name: Char
scaledHealth: 240
size: 2
Turret
Next you will use the properties from Turret
to add more properties.
Go to Turret.java and use the properties that you need.
type: ItemTurret
name: Char
scaledHealth: 240
size: 2
range: 120 // 8 = 1 block
targetAir: false
reload: 6 // In ticks. 60 ticks = 1 second. This turret shoots once per 0.1 seconds.
recoil: 2 // How much the turret kicks back when
inaccuracy: 20 // How bad your turret is at aiming.
shootCone: 10 // How many degrees close to your turret it's target has to be before it starts firing.
shootSound: flame2 // The sound your turret makes when shooting.
[!tip] These are not the only values for turrets. Check out the Mindustry Source Code for more properties.
ammoTypes
ammoTypes
is an object that holds information about all the items your turret can shoot, and what each of those ammo does in your turret.
ammoTypes
is arranged like this.
ammoTypes: {
coal: {
// Properties for coal ammo
}
pyratite: {
// Properties for pyratite ammo
}
}
For this tutorial we will focus solely on one ammo type.
BulletType
BulletType
is the type:
of each object held in your ammo.
Use type: BulletType
to create a bullet. Fill in the fields from BulletType.java
coal: {
type: BulletType
damage: 34
ammoMultiplier: 3 // How many times less ammo is used. For every 3 bullets shot only 1 coal is consumed.
hitSize: 14 // How large the bullet is
lifetime: 17 // How long the bullet flies for. Time is measured in 60ths of a second.
speed: 7 // How many 1/8ths of a block the bullet goes per tick.
pierce: true // If bullet goes through enemies.
collidesAir: false
statusDuration: 240 // How long the status applied by the bullet lasts for in ticks.
hitEffect: hitFlameSmall // Effect played when a bullet hits an enemy.
despawnEffect: none
status: burning // Status applied when an enemy is hit by this bullet
keepVelocity: false
}
Your first ammo is now complete. You can repeat this for any ammo you can use.
drawer:
The drawer
is an object that holds all the information on how to draw your turret. This includes anywhere from making a simple part move when shooting, to making a turret have an impressive reload animation.
drawer:
s are arranged as such
drawer: {
type: drawTurret // Type used when drawing turrets.
parts: [
{
// Part information
}
{
// Part information
}
]
}
parts:
is an array that contains all the part objects. It can contain any number of parts.
RegionPart
s
Each part has a type:
which specifies the kind of part it is. For this example we will focus on RegionPart
A RegionPart
takes a sprite that is specified with suffix:
and animates it based on progress:
, moveX/Y:
and scaling properties.
suffix:
Suffixes are the file name of your sprite.
turret-char.hjson
suffix: -barrel-r
Would look for a sprite called
turret-char-barrel-r
progress:
The progress is when the animation will play. warmup
will play as the weapon shoots and stay at the final position until shooting has stopped. reload
will repeat over and over again each time the weapon is fired. There are other warmup:
options for you to use.
{
type: RegionPart
suffix: -barrel-r // I used 2 barrels for char. A right barrel and a left one.
progress: warmup
mirror: false // If the region will be copied on both sides of the turret. Usually off as both sides of a turret have different shading.
under: false // If the region is rendered under the turret.
moveX: 1.5 // How far the region will move on the x axis during the animation. moveY is also avaliable.
}
shootEffect:
shootEffect:
is the property that makes your turrets have pretty particles. shootEffect:
is an array that contains objects.
shoot effect: [
{
// Effect information
}
{
// Effect information
}
]
The effects
{
length: 30 // How large the effect will be
lifetime: 30 // How long the effect will last for in ticks.
particles: 2
cone: 40 // How wide of a cone the particles will be shot from.
interp: pow5Out // How the animation moves.
sizeInterp: linear // How the particle's size moves.
region: circle // What shape the particles will be
sizeFrom: 3
sizeTo: 0
colorFrom: 454545ff // Grey
colorTo: 45454500 // Grey, but its invisible
}