I've made a custom turret for a mod that has limited firing arc. It has a flag "building-direction-8-way" that allows for 8 angles of rotation when placing it.
When biters come within its prepare range, game throws an exception if that turret was placed aiming diagonally.
Log file: Turret prototype:
Code: Select all
{
type = "ammo-turret",
name = "w93-dcannon-turret",
icon = "__scattergun_turret__/graphics/icons/dcannon-turret.png",
icon_size = 64,
flags = {"placeable-player", "player-creation", "building-direction-8-way"},
minable = {mining_time = 0.5, result = "w93-dcannon-turret"},
max_health = 1500,
corpse = "medium-remnants",
collision_box = {{-1.2, -1.2 }, {1.2, 1.2}},
selection_box = {{-1.3, -1.3 }, {1.3, 1.3}},
rotation_speed = 0.003,
preparing_speed = 0.8,
folding_speed = 0.8,
dying_explosion = "medium-explosion",
inventory_size = 1,
automated_ammo_count = 5,
turret_base_has_direction = true,
resistances =
{
{
type = "physical",
decrease = 5,
percent = 15
},
{
type = "explosion",
decrease = 80,
percent = 50,
},
{
type = "acid",
decrease = 0,
percent = 35,
},
{
type = "fire",
decrease = 0,
percent = 80,
}
},
folded_animation = cannon_turret_attack{},
preparing_animation = cannon_turret_attack{},
prepared_animation = cannon_turret_attack{},
attacking_animation = cannon_turret_attack{},
folding_animation = cannon_turret_attack{run_mode = "backward"},
base_picture =
{
layers =
{
{
filename = "__scattergun_turret__/graphics/entity/modular-turret-base.png",
priority = "high",
width = 88,
height = 68,
axially_symmetrical = false,
direction_count = 1,
frame_count = 1,
shift = {0.0, 0.0},
},
{
filename = "__scattergun_turret__/graphics/entity/modular-turret-base-mask.png",
flags = { "mask" },
line_length = 1,
width = 88,
height = 68,
frame_count = 1,
axially_symmetrical = false,
direction_count = 1,
shift = {0.0, 0.0},
apply_runtime_tint = true
}
}
},
vehicle_impact_sound = { filename = "__base__/sound/car-metal-impact.ogg", volume = 0.65 },
prepare_range = 35,
shoot_in_prepare_state = false,
attack_parameters =
{
type = "projectile",
ammo_category = "cannon-shell",
cooldown = 30,
projectile_creation_distance = 1.5,
projectile_center = {0.0, 0.4},
min_range = 12,
range = 30,
turn_range = 0.25,
sound =
{
{
filename = "__scattergun_turret__/sound/lcannon-turret-fire.wav",
volume = 1.25
}
}
},
call_for_help_radius = 40
},