Need Solution to Deadlock

Place to get help with not working mods / modding interface.
Post Reply
TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Need Solution to Deadlock

Post by TheSAguy »

Hi,

In my mod, NE Enemies, I have some enemies that are 100% immune to certain types of damage.
In my mod NE Buildings, I have ammo that can convert a unit to our side.

As a result, sometimes two units of the some type would get stuck shooting at each other forever.

Was wondering if some smart people could think of a solution around this.
I'd like to keep the 100% immunity. So just dropping that is not a solution I want to consider currently.

Please let me know if anyone has an idea how to prevent/resolve this problem.

Thanks.

danielbrauer
Long Handed Inserter
Long Handed Inserter
Posts: 93
Joined: Thu May 18, 2017 2:22 pm
Contact:

Re: Need Solution to Deadlock

Post by danielbrauer »

It sounds like the general problem is units shooting at things which are immune to their attacks. In this case it lasts forever and so it’s obviously silly, but even if you’re vulnerable to an enemy it doesn’t make sense to attack it for zero damage.

So if it’s possible to not attack enemies which are immune, I’d go for that. Otherwise some sort of special casing might work, but that sounds trickier.

TheSAguy
Smart Inserter
Smart Inserter
Posts: 1449
Joined: Mon Jan 13, 2014 6:17 pm
Contact:

Re: Need Solution to Deadlock

Post by TheSAguy »

Okay, so I solved most of the problem by just giving each enemy a very small secondary damage type. So if two Acid Immune enemies attack each other, there is a small amount of "physical" damage also, that will eventually kill the other unit.

This worked for all my attacks, except for the Fire Spitter units. I added a little physical damage to the fire, but for some reason, it's not doing any damage.



Shows the physical damage:
Image

Here is my code for the fire:

Code: Select all

  {
    type = "stream",
    name = "ne-fire-stream",
	force = "enemy",
    flags = {"not-on-map"},
    stream_light = {intensity = 1, size = 4},
    ground_light = {intensity = 0.8, size = 4},

    smoke_sources =
    {
      {
        name = "soft-fire-smoke",
        frequency = 0.05, --0.25,
        position = {0.0, 0}, -- -0.8},
        starting_frame_deviation = 60
      }
    },
    particle_buffer_size = 90,
    particle_spawn_interval = 2,
    particle_spawn_timeout = 8,
    particle_vertical_acceleration = 0.005 * 0.60,
    particle_horizontal_speed = 0.2* 0.75 * 1.5,
    particle_horizontal_speed_deviation = 0.005 * 0.70,
    particle_start_alpha = 0.5,
    particle_end_alpha = 1,
    particle_start_scale = 0.2,
    particle_loop_frame_count = 3,
    particle_fade_out_threshold = 0.9,
    particle_loop_exit_threshold = 0.25,
    action =
    {
      {
        type = "direct",
		force = "enemy",
        action_delivery =
        {
          type = "instant",
		  force = "enemy",
          target_effects =
          {
            {
              type = "create-fire",
			  force = "enemy",
              entity_name = "ne-fire-flame-2"
            },
            {
              type = "damage",
              damage = { amount = 1, type = "physical"},
            }
          }
        }
      },
      {
        type = "area",
		force = "enemy",
        radius = 2.5,
        action_delivery =
        {
          type = "instant",
		  force = "enemy",
          target_effects =
          {
            {
              type = "create-sticker",
			  force = "enemy",
              sticker = "ne-fire-sticker-2"
            },
            {
              type = "damage",
			  force = "enemy",
              damage = { amount = 3, type = "ne_fire", force = "enemy" },
              apply_damage_to_trees = true
            }
          }
        }
      }
    },

    spine_animation =
    {
      filename = "__base__/graphics/entity/flamethrower-fire-stream/flamethrower-fire-stream-spine.png",
      blend_mode = "additive",
      line_length = 4,
      width = 32,
      height = 18,
      frame_count = 32,
      axially_symmetrical = false,
      direction_count = 1,
      animation_speed = 2,
      shift = {0, 0}
    },

    shadow =
    {
      filename = "__Natural_Evolution_Enemies__/graphics/entity/acid-projectile-purple-shadow.png",
      line_length = 5,
      width = 28,
      height = 16,
      frame_count = 33,
      priority = "high",
      shift = {-0.09, 0.395}
    },

    particle =
    {
      filename = "__base__/graphics/entity/flamethrower-fire-stream/flamethrower-explosion.png",
      priority = "extra-high",
      width = 64,
      height = 64,
      frame_count = 32,
      line_length = 8
    }
  },

  
  
  
and the function I call:

Code: Select all

-- Stream Spitters - Fire Streams
function Spitter_Attack_Stream(data)
  return
  {
    type = "stream",
	force = "enemy",
    ammo_category = "flamethrower",
    cooldown = data.cooldown,
    range = data.range,
    projectile_creation_distance = 1.9,
    damage_modifier = data.damage_modifier or 1.0,
    warmup = 15,
	min_range = 6,
    turn_range = 1.0 / 3.0,
	fire_penalty = 15,	
	gun_barrel_length = 2 * data.scale,
	gun_center_shift = {
	    north = {0, -0.65 * data.scale},
	    east = {0, 0},
	    south = {0, 0},
	    west = {0, 0}
	},
    ammo_type =
	    {
        category = "flamethrower",
        action =
		    {
			type = "direct",
			force = "enemy",
			action_delivery =
			    {
				type = "stream",
				force = "enemy",
				stream = "ne-fire-stream",
				duration = 160,
			    }
		    }
	    },
      cyclic_sound =
      {
        begin_sound =
        {
          {
            filename = "__base__/sound/fight/flamethrower-start.ogg",
            volume = 0.7
          }
        },
        middle_sound =
        {
          {
            filename = "__base__/sound/fight/flamethrower-mid.ogg",
            volume = 0.7
          }
        },
        end_sound =
        {
          {
            filename = "__base__/sound/fight/flamethrower-end.ogg",
            volume = 0.7
          }
        }
      },
	sound = make_spitter_roars(data.roarvolume),  
    animation = spitterattackanimation(data.scale, data.tint1, data.tint2),
  }
end



Post Reply

Return to “Modding help”