Types/BaseAttackParameters: Difference between revisions

From Official Factorio Wiki
Jump to navigation Jump to search
(CyclicSound -> table)
m (→‎ammo_categories: improved wording)
 
(22 intermediate revisions by 6 users not shown)
Line 1: Line 1:
The abstract base of all attack parameters.
The abstract base of all [[Types/AttackParameters|attack parameters]].


== Extensions ==
== Extensions ==
Line 9: Line 9:
=== range ===
=== range ===
'''Type''': [[Types/float]]
'''Type''': [[Types/float]]
Before an entity can attack, the distance (in tiles) between the entity and target must be less than or equal to this.


=== cooldown ===
=== cooldown ===
Line 20: Line 22:


'''Default''': 0
'''Default''': 0
The minimum distance (in tiles) between an entity and target. If a unit's target is less than this, the unit will attempt to move away before attacking. A [[Flamethrower turret]] does not move, but has a minimum range. Less than this, it is unable to target an enemy.


=== turn_range ===
=== turn_range ===
Line 26: Line 30:
'''Default''': 1
'''Default''': 1


If this is <= 0, it is set to 1.
If this is <= 0, it is set to 1. Arc from 0 to 1, so for example 0.25 is 90°. Used by the [[flamethrower turret]] in the base game. Arcs greater than 0.5 but less than 1 will be clamped to 0.5 as targeting in arcs larger than half circle is not implemented.[https://forums.factorio.com/94654]


=== fire_penalty ===
=== fire_penalty ===
Line 33: Line 37:
'''Default''': 0
'''Default''': 0


Used when searching for the nearest enemy, when this is > 0, enemies that aren't burning are preferred over burning enemies. Definition of "burning" for this: Entity has sticker attached to it, and the sticker has a [[Prototype/Sticker#spread_fire_entity|fire_spread_entity]] set.
Used when searching for the nearest enemy, when this is > 0, enemies that aren't burning are preferred over burning enemies. Definition of "burning" for this: Entity has sticker attached to it, and the sticker has a [[Prototype/Sticker#spread_fire_entity|spread_fire_entity]] set.
 
=== rotate_penalty ===
'''Type''': [[Types/float]]
 
'''Default''': 0
 
A higher penalty will discourage turrets from targeting units that would take longer to turn to face.
 
=== health_penalty ===
'''Type''': [[Types/float]]
 
'''Default''': 0
 
A higher penalty will discourage turrets from targeting units with higher health. A negative penalty will encourage turrets to target units with higher health.
 
=== range_mode ===
'''Type''': [[Types/string]]
 
'''Default''': "center-to-center"
 
Either "center-to-center" or "bounding-box-to-bounding-box".


=== min_attack_distance ===
=== min_attack_distance ===
Line 46: Line 71:


'''Default''': 1
'''Default''': 1
=== ammo_consumption_modifier ===
'''Type''': [[Types/float]]
'''Default''': 1
Must be greater than or equal to 0.
=== cooldown_deviation ===
'''Type''': [[Types/float]]
'''Default''': 0
Must be between 0 and 1.


=== warmup ===
=== warmup ===
Line 54: Line 93:
Number of ticks it takes for the weapon to actually shoot after the order for shooting has been made. This also allows to "adjust" the shooting animation to the effect of shooting.
Number of ticks it takes for the weapon to actually shoot after the order for shooting has been made. This also allows to "adjust" the shooting animation to the effect of shooting.


=== movement_slow_down_factor ===
[[Types/CapsuleAction]]s cannot have attack_parameters with non-zero warmup.
'''Type''': [[Types/double]]
 
=== lead_target_for_projectile_speed ===
'''Type''': [[Types/float]]
 
'''Default''': 0
 
Setting this to anything but zero causes homing projectiles to aim for the predicted location based on enemy movement instead of the current enemy location.


'''Default''': 1
Example from the base game flamethrower:
<syntaxhighlight lang="lua">lead_target_for_projectile_speed = 0.2* 0.75 * 1.5, -- this is same as particle horizontal speed of flamethrower fire stream</syntaxhighlight>


=== movement_slow_down_cooldown ===
=== movement_slow_down_cooldown ===
Line 63: Line 109:


'''Default''': <code>cooldown</code>
'''Default''': <code>cooldown</code>
=== movement_slow_down_factor ===
'''Type''': [[Types/double]]
'''Default''': 1


=== ammo_type ===
=== ammo_type ===
Line 69: Line 120:
Can be mandatory.
Can be mandatory.


=== ammo_category ===
=== activation_type ===
'''Type''': [[Types/string]]
'''Type''': [[Types/string]]


The name of a [[Prototype/AmmoCategory]]. Mandatory if <code>ammo_type</code> is not given, otherwise ignored.
'''Default''': "shoot"
 
One of "shoot", "throw", "consume" or "activate". Used in tooltips to set the tooltip category. It is also used to get the locale keys for activation instructions and speed of the action for the tooltip.
 
For example, an activation_type of "throw" will result in the tooltip category "thrown" and the tooltip locale keys "gui.instruction-to-throw" and "description.throwing-speed".


=== sound ===
=== sound ===
'''Type''': [[Types/Sound]]
'''Type''': [[Types/LayeredSound]]
 
Played once at the start of the attack if this is a [[Types/ProjectileAttackParameters]].


=== animation ===
=== animation ===
Line 81: Line 138:


=== cyclic_sound ===
=== cyclic_sound ===
'''Type''': [[Types/table]]
'''Type''': [[Types/CyclicSound]]
 
Played during the attack.
 
=== use_shooter_direction ===
'''Type''': [[Types/bool]]
 
'''Default''': false
 
=== ammo_categories ===
'''Type''': [[Types/table]] (array) of [[Types/string]]
 
Names of [[Prototype/AmmoCategory]].
 
=== ammo_category ===
'''Type''': [[Types/string]]


Table with the following mandatory key/value pairs:
The name of a [[Prototype/AmmoCategory]]. Mandatory if <code>ammo_type</code> and <code>ammo_categories</code> is not given, otherwise ignored.
* begin_sound - [[Types/Sound]]
* middle_sound - [[Types/Sound]]
* end_sound - [[Types/Sound]]

Latest revision as of 05:51, 17 January 2023

The abstract base of all attack parameters.

Extensions

Mandatory properties

range

Type: Types/float

Before an entity can attack, the distance (in tiles) between the entity and target must be less than or equal to this.

cooldown

Type: Types/float

Number of ticks in which it will be possible to shoot again. If < 1, multiple shots can be performed in one tick.

Optional properties

min_range

Type: Types/float

Default: 0

The minimum distance (in tiles) between an entity and target. If a unit's target is less than this, the unit will attempt to move away before attacking. A Flamethrower turret does not move, but has a minimum range. Less than this, it is unable to target an enemy.

turn_range

Type: Types/float

Default: 1

If this is <= 0, it is set to 1. Arc from 0 to 1, so for example 0.25 is 90°. Used by the flamethrower turret in the base game. Arcs greater than 0.5 but less than 1 will be clamped to 0.5 as targeting in arcs larger than half circle is not implemented.[1]

fire_penalty

Type: Types/float

Default: 0

Used when searching for the nearest enemy, when this is > 0, enemies that aren't burning are preferred over burning enemies. Definition of "burning" for this: Entity has sticker attached to it, and the sticker has a spread_fire_entity set.

rotate_penalty

Type: Types/float

Default: 0

A higher penalty will discourage turrets from targeting units that would take longer to turn to face.

health_penalty

Type: Types/float

Default: 0

A higher penalty will discourage turrets from targeting units with higher health. A negative penalty will encourage turrets to target units with higher health.

range_mode

Type: Types/string

Default: "center-to-center"

Either "center-to-center" or "bounding-box-to-bounding-box".

min_attack_distance

Type: Types/float

Default: range

If less than range, the entity will choose a random distance between range and min_attack_distance and attack from that distance.

damage_modifier

Type: Types/float

Default: 1

ammo_consumption_modifier

Type: Types/float

Default: 1

Must be greater than or equal to 0.

cooldown_deviation

Type: Types/float

Default: 0

Must be between 0 and 1.

warmup

Type: Types/uint32

Default: 0

Number of ticks it takes for the weapon to actually shoot after the order for shooting has been made. This also allows to "adjust" the shooting animation to the effect of shooting.

Types/CapsuleActions cannot have attack_parameters with non-zero warmup.

lead_target_for_projectile_speed

Type: Types/float

Default: 0

Setting this to anything but zero causes homing projectiles to aim for the predicted location based on enemy movement instead of the current enemy location.

Example from the base game flamethrower:

lead_target_for_projectile_speed = 0.2* 0.75 * 1.5, -- this is same as particle horizontal speed of flamethrower fire stream

movement_slow_down_cooldown

Type: Types/float

Default: cooldown

movement_slow_down_factor

Type: Types/double

Default: 1

ammo_type

Type: Types/AmmoType

Can be mandatory.

activation_type

Type: Types/string

Default: "shoot"

One of "shoot", "throw", "consume" or "activate". Used in tooltips to set the tooltip category. It is also used to get the locale keys for activation instructions and speed of the action for the tooltip.

For example, an activation_type of "throw" will result in the tooltip category "thrown" and the tooltip locale keys "gui.instruction-to-throw" and "description.throwing-speed".

sound

Type: Types/LayeredSound

Played once at the start of the attack if this is a Types/ProjectileAttackParameters.

animation

Type: Types/RotatedAnimation

cyclic_sound

Type: Types/CyclicSound

Played during the attack.

use_shooter_direction

Type: Types/bool

Default: false

ammo_categories

Type: Types/table (array) of Types/string

Names of Prototype/AmmoCategory.

ammo_category

Type: Types/string

The name of a Prototype/AmmoCategory. Mandatory if ammo_type and ammo_categories is not given, otherwise ignored.