How to remove the collision field from the turret and make it invisible to enemies until the attack?

Place to get help with not working mods / modding interface.
Keysivi
Burner Inserter
Burner Inserter
Posts: 19
Joined: Mon Feb 07, 2022 5:29 pm
Contact:

How to remove the collision field from the turret and make it invisible to enemies until the attack?

Post by Keysivi »

Good day? I'm trying to revive my mod for Factorio 2

Specifically, there was a problem with poisonous barbed barriers

The parameters "collision_mask" and "hidden" stopped working

The task: so that the Character and Enemies can freely pass through the barriers, but during the passage through the barrier, the enemies take damage.

Here is the code that was originally:

Code: Select all

-- require("__My_add_pack__.prototype.barbed-spikes-wooden.effects")	

data:extend(
{
	{
		type = "sticker",
		name = "wooden-barbed-spike-slowdown-sticker_ke",
		flags = { "not-on-map" },
		flags = {},
		animation =
		{
			filename = "__My_add_pack__/graphics/barbed-spikes-wooden/clear.png",
			priority = "extra-high",
			width = 2,
			height = 2,
			frame_count = 1
		},
		duration_in_ticks = 100,
		target_movement_modifier = 0.5
	}
})

function data_sheet(inputs)
return
	{
		layers = 
		{
			{
				  filename = "__My_add_pack__/graphics/barbed-spikes-wooden/base.png",
				  priority = "high",
				  width = 172,
				  height = 172,
				  direction_count = 1,
				  frame_count = 1,
				  line_length = 0,
				  run_mode = inputs.run_mode or "forward",
				  axially_symmetrical = false,
				  shift = { 0, 0 },
				  scale = 0.5
			}
		}
	}
end
data:extend(
{
  
  {
    type = "turret",
    name = "wooden-barbed-spike",
    icon = "__My_add_pack__/graphics/barbed-spikes-wooden/icon.png",
    icon_size = 64, icon_mipmaps = 4,
    flags = {"placeable-player","not-rotatable","player-creation","not-flammable","hidden"},
    minable = {mining_time = 1, result = "wooden-barbed-spike"},
    max_health = 56,
    corpse = "wooden-barbed-spike-remnants",
    dying_explosion = "wall-explosion",
    selection_box = {{-1, -1 }, {1, 1}},
	collision_box = {{-0.8, -0.8}, {0.8, 0.8}},
    collision_mask = {"object-layer","water-tile","resource-layer"},
    rotation_speed = 1,
    preparing_speed = 1,
	walking_speed_modifier = 1.0,
    folding_speed = 1.0,
    starting_attack_speed = 0.01,
    attacking_speed = 1.0,
    alert_when_attacking = true,
	alert_when_damaged = true,
	create_ghost_on_death = true,
	folded_animation = data_sheet{direction_count = 8, line_length = 0},

	preparing_animation = data_sheet{frame_count=1, line_length = 0},
    prepared_animation = data_sheet{},
    attacking_animation = data_sheet{},
	folding_animation = data_sheet{frame_count=1, line_length = 0, run_mode = "backward"},
	resistances = {
      {
        type = "fire",
        percent = 4.0
      },
      {
        type = "physical",
        percent = 4.0
      },
	  {
        type = "poison",
        percent = 100
      },
	  {
        type = "explosion",
        percent = 4.0
      },
	  {
        type = "laser",
        percent = 4.0
      },
	  {
        type = "acid",
        percent = 4.0
      },
	  {
        type = "electric",
        percent = 100
      },
	}, 
    base_picture =
    {
      layers =
      {
        {
          filename = "__My_add_pack__/graphics/barbed-spikes-wooden/base.png",
          priority = "high",
          width = 86,
          height = 86,
          axially_symmetrical = false,
          direction_count = 1,
          frame_count = 1,
          shift = { 0, 0 },
          hr_version =
          {
            filename = "__My_add_pack__/graphics/barbed-spikes-wooden/hr-base.png",
            priority = "high",
            width = 172,
            height = 172,
            axially_symmetrical = false,
            direction_count = 1,
            frame_count = 1,
            shift = { 0, 0 },
            scale = 0.5
          }
        },
      }
    },
	attack_parameters =
		{
		  type = "projectile",
		  ammo_category = "bullet",
		  cooldown = 0.01,
		  projectile_creation_distance = 0,
		  projectile_center = {0, 0},
		  damage_modifier = 1,
		  ammo_type =
		  {
			category = "biological",
			action =
			{
				type = "area",
				radius = 2.0,
				action_delivery = 
				{
					type = "instant",
					target_effects =
					{
						{
							type = "damage",
							damage = {amount = 2.1, type = "physical"}
						},
						{
							type = "damage",
							damage = {amount = 2.1, type = "poison"}
						},
						{
							type = "create-sticker",
							sticker = "slowdown-sticker"
						},
						{
							type = "create-sticker",
							sticker = "wooden-barbed-spike-slowdown-sticker_ke"
						},
					}
				
				},
			}
		  },
		  range = 2.00,
		  min_range = 0,
		},
    call_for_help_radius = 0,
  },
})

Here are the lines that stopped working correctly with Factorio 2:

Code: Select all

 
flags = {"placeable-player","not-rotatable","player-creation","not-flammable","hidden"},
collision_mask = {"object-layer","water-tile","resource-layer"},
I tried to replace them with the lines:

Code: Select all

 
flags = {"placeable-player","not-rotatable","player-creation","not-flammable"},
hidden = true,
collision_mask = {layers = {item = true, meltable = true, object = true, player = true, water_tile = true, is_object = true, is_lower_object = true}},	
It doesn't work!

It also shows an error:
4.822 Error ModManager.cpp:1738: Error while loading entity prototype "wooden-barbed-spike" (turret): Value must be a dictionary in property tree at ROOT.turret.wooden-barbed-spike.collision_mask
Modifications: My_add_pack
Post Reply

Return to “Modding help”