Problem with explosion having momentum/moving away from player if fire while moving

Place to get help with not working mods / modding interface.
User avatar
GeneralEcchi
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Dec 21, 2020 2:58 pm
Contact:

Problem with explosion having momentum/moving away from player if fire while moving

Post by GeneralEcchi »

If I fire the weapon and keep moving in the direction I was then it wont get thrown away, but if I move, then stop and then fire, the explosion will continue moving foward (as if it has inertia)

Image
Image

It's less noticable if the explosion has only 2 - 3 frames, because it disappear as soon as the animation is done playing (obviously)
This also occurs on "beam" type explosion:
Image
The code were almost exact copy of every other weapon which doesnt have this problem:

Code: Select all

{
        type = "gun",
        name = "grenade-launcher",
        localised_name = "Grenade Launcher",
        icon = "__gore__/graphics/weapons/grenade-launcher.png",
        icon_size = 64, icon_mipmaps = 1,
        subgroup = "gun",
        order = "c1[grenade-launcher]",
        attack_parameters =
        {
            type = "projectile",
            ammo_category = "grenade",
            cooldown = 30,
            movement_slow_down_factor = 0.1,
            projectile_creation_distance = 1,
            fire_penalty = 0,
            range = 60,
            sound = grenade_launcher_sound
        },
        stack_size = 1
    },
Muzzleflash anim is also like other's:

Code: Select all

{
        type = "explosion",
        name = "muzzle-black",
        flags = {"not-on-map"},
        subgroup = "explosions",
        animations = {
        
            filename = "__base__/graphics/entity/artillery-cannon-muzzle-flash/muzzle-flash.png",
            draw_as_glow = true,
            line_length = 7,
            width = 138,
            height = 192,
            frame_count = 21,
            animation_speed = 0.75,
            scale = 0.4,
        },
        
        rotate = true,
        light = {intensity = 1, size = 4, color = {r=1, g=0.55, b=0.1}}
},
And this weird thing also happened recently where the explosion that appear on unit caught in the blast radius continue flying away from player:
Image
with the projectile's code here:

Use "create-entity" instead of "create-explosion" fix this problem.

Code: Select all

{
    type = "projectile",
    name = "contact-gren-proj",
    flags = {"not-on-map"},
    acceleration = 0.025,
    action =
    {
      {
        type = "direct",
        action_delivery =
        {
          type = "instant",
          target_effects =
          {
            {
				type = "create-entity",
				entity_name = "yellow-explosion",
				repeat_count = 3,
				repeat_count_deviation = 2,
				offset_deviation = { { -1, -1.5 }, { 1, 1.5 } }
			},
			{
				type = "create-entity",
				entity_name = "yellow-explosion-big",
				repeat_count = 1,
				repeat_count_deviation = 1,
				offset_deviation = { { -1, -1.2 }, { 1, 1.2 } }
			},
			{
              type = "create-entity",
              entity_name = "medium-scorchmark-tintable",
              check_buildability = true
            },
            {
              type = "destroy-decoratives",
              from_render_layer = "decorative",
              to_render_layer = "object",
              include_soft_decoratives = true,
              include_decals = false,
              invoke_decorative_trigger = true,
              decoratives_with_trigger_only = false,
              radius = 5
            },
			{
			  type = "create-fire",
			  entity_name = "fire-flame",
			  probability = 0.75,
			  show_in_tooltip = false,
			  initial_ground_flame_count = 3,
			  offset_deviation = { { -1.75, -1.75 }, { 1.75, 1.75 } }
			},
		  {
            type = "nested-result",
            action =
            {
              type = "area",
              radius = 5,
              action_delivery =
              {
                type = "instant",
                target_effects =
                {
                  {
                    type = "damage",
                    damage = {amount = 125, type = "explosion"}
                  },
				  {
					type = "create-explosion",
					entity_name = "fire-exp", <-------- THIS IS THE ONE THAT FLEW AWAY
					repeat_count = 1,
					repeat_count_deviation = 1,
					offset_deviation = { { -0.25, -0.15 }, { 0.25, 0.15 } }
				  },
				  {
					type = "create-explosion",
					entity_name = "fire-burst",
					probability = 0.5,
					repeat_count = 1,
					offset_deviation = { { -0.25, -0.15 }, { 0.25, 0.15 } }
				  }
                }
              }
            }
          }
          }
        }
      }
    },
	
    animation =
    {
      filename = "__gore__/graphics/weapons/c-gren-proj.png",
      frame_count = 1,
      animation_speed = 0.1,
      width = 26,
      height = 64,
      priority = "high",
      scale = 0.3
    },
	smoke =
    {
      {
        name = "smoke-fast",
        deviation = {0.1, 0.1},
        frequency = 0.75,
        position = {0, 1},
        slow_down_factor = 0.05,
        starting_frame = 3,
        starting_frame_deviation = 3,
        starting_frame_speed = 0,
        starting_frame_speed_deviation = 5
      }
    }
},
Last edited by GeneralEcchi on Fri Dec 25, 2020 2:28 pm, edited 4 times in total.
User avatar
Klonan
Factorio Staff
Factorio Staff
Posts: 5410
Joined: Sun Jan 11, 2015 2:09 pm
Contact:

Re: Problem with explosion having momentum/moving away from player if fire while moving

Post by Klonan »

Can you post the whole code, not just select snippets
User avatar
GeneralEcchi
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Dec 21, 2020 2:58 pm
Contact:

Re: Problem with explosion having momentum/moving away from player if fire while moving

Post by GeneralEcchi »

Here's the weapon and ammo that uses the beam explosion:

Code: Select all


{
		type = "gun",
		name = "railgun",
		icon = "__gore__/graphics/weapons/icons/rail128.png",
		icon_size = 128, icon_mipmaps = 4,
		subgroup = "gun",
		order = "c4[rail]",
		attack_parameters =
		{
			type = "projectile",
			ammo_category = "rail-slug",
			cooldown = 60,
			movement_slow_down_factor = 0.55,
			projectile_creation_distance = 0.9,
			fire_penalty = 0,
			range = 69,
			sound = railgun_sound
		},
		stack_size = 10
	},
	
----------------------------------------------------------------------------------------------------------------------------------------------

	{
		type = "ammo",
		name = "rail-slug",
		localised_description = "Ammunition for the Railgun",
		icon = "__gore__/graphics/weapons/icons/slug128.png",
		icon_size = 128,
		icon_mipmaps = 4,
		ammo_type =
		{
			category = "rail-slug",
			target_type = "position",
			clamp_position = true,
			action =
			{
				type = "line",
				range = 69,
				width = 2,
				range_effects =
				{
				  {
					type = "create-explosion",
					entity_name = "rail-beam"
				  },
				  {
					type = "create-explosion",
					entity_name = "plasma-muzzle",
					probability = 1
				  }
				},
				action_delivery =
				{
					{
						type = "instant",
						source_effects =
							{
							type = "create-explosion",
							entity_name = "plasma-muzzle",
							probability = 1
							}
					},
					{
						type = "instant",
						target_effects =
					{
						{
						type = "damage",
						damage = { amount = 300, type="physical"}
						},
						{
						type = "damage",
						damage = { amount = 300, type="electric"}
						},
						{
						type = "create-explosion",
						entity_name = "blue-arc-small",
						repeat_count = 3,
						repeat_count_deviation = 2,
						offset_deviation = {{-1.5, -1.5}, {1.5, 1.5}}
						},
						{
						type = "create-explosion",
						entity_name = "plasma-impact",
						probability = 1
						},
						{
						type = "create-sticker",
						sticker = "stasis",
						probability = 1,
						show_in_tooltip = false
						}
					}
					}
				}
			}
		},
		magazine_size = 1,
		subgroup = "ammo",
		order = "c[rail-slug]",
		stack_size = 200
    },
Weapon and ammo with the regular explosion:

Code: Select all


{
		type = "gun",
		name = "grenade-launcher",
		localised_name = "Grenade Launcher",
		icon = "__gore__/graphics/weapons/icons/grenade-launcher.png",
		icon_size = 64, icon_mipmaps = 1,
		subgroup = "gun",
		order = "c1[grenade-launcher]",
		attack_parameters =
		{
			type = "projectile",
			ammo_category = "grenade",
			cooldown = 30,
			movement_slow_down_factor = 0.1,
			projectile_creation_distance = 1,
			fire_penalty = 0,
			range = 60,
			sound = grenade_launcher_sound
		},
		stack_size = 1
	}
	
--------------------------------------------------------------------------------

{
		type = "ammo",
		name = "contact-gren",
		localised_name = "Contact Grenade",
		localised_description = "High explosive grenade",
		icon = "__gore__/graphics/weapons/icons/cgren.png",
		icon_size = 64,
		icon_mipmaps = 1,
		ammo_type = 
		{
			category = "grenade",
			target_type = "position",
			clamp_position = true,
			action =
			{
				{	type = "direct",
					action_delivery =
					{
						{
						type = "instant",
						source_effects =
							{
							type = "create-explosion",
							entity_name = "artillery-muzzle"
							}
						}
					}
				},
				{	type = "direct",
					action_delivery =
					{
						{
						type = "projectile",
						projectile = "contact-gren-proj",
						starting_speed = 0.8,
						direction_deviation = 0.1,
						max_range = 60,
						}
					}	
				}
			}
		},
		magazine_size = 1,
		subgroup = "ammo",
		order = "d20[tc-gren]",
		stack_size = 150
	},
		
	
And the explosion used as muzzleflash (were almost 1-1 copy of Artillery's)

Code: Select all


{
    type = "explosion",
    name = "artillery-muzzle",
    localised_name = {"entity-name.artillery-cannon-muzzle-flash"},
    flags = {"not-on-map", "hidden"},
    subgroup = "explosions",
    animations = 
    {
      filename = "__base__/graphics/entity/artillery-cannon-muzzle-flash/muzzle-flash.png",
      draw_as_glow = true,
      line_length = 7,
      width = 138,
      height = 192,
      frame_count = 21,
      shift = util.by_pixel(1, -82),
      animation_speed = 0.75,
      scale = 0.4
      },
      
    rotate = true,
    height = 0,
    correct_rotation = true,
    --light = {intensity = 1, size = 10, color = {r=1.0, g=1.0, b=1.0}},
    smoke = "smoke-fast",
    smoke_count = 1,
    smoke_slow_down_factor = 1
  },
  
  
User avatar
GeneralEcchi
Manual Inserter
Manual Inserter
Posts: 3
Joined: Mon Dec 21, 2020 2:58 pm
Contact:

Re: Problem with explosion having momentum/moving away from player if fire while moving

Post by GeneralEcchi »

In case you meant the entire lua file:
exp_anim.lua
(49.27 KiB) Downloaded 98 times
wep.lua
(24.12 KiB) Downloaded 96 times
Post Reply

Return to “Modding help”