[Twinsen] [0.15] Area push-back effect not applied on all targets

This subforum contains all the issues which we already resolved.
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

[Twinsen] [0.15] Area push-back effect not applied on all targets

Post by Mooncat »

Bug:
When the "push-back" effect is applied under "area" action, a target is not pushed back while the others are.
(Edit: I forgot the vanilla push-back effect is already under an "area" action, so this summary is useless. But I think you can find the real cause.)

Steps to reproduce:
1) Download the following mod.
area-push-back-bug_0.1.0.zip
(1.26 KiB) Downloaded 165 times
What it does: it overrides the attacks of defender and destroyer by area push-back effect.
To show the effect is really applied to the targets, the destroyers also creates explosion entity on each target.
Here is the script:
data.lua
For easier testing, force.research_all_technologies() and player.cheat_mode=true are called in control.lua.

2) Start a new game.

3) Summon some defenders and/or destroyers and make a trip to attract some biters.

4) Observe when the robots "attack" the biters.
You will see something like this

Same result with or without "affects_target = true".
Could you also fix the algorithm of push-back so it doesn't calculate collision of the pushed entity against itself? Mentioned here :)
Twinsen
Factorio Staff
Factorio Staff
Posts: 1350
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: [Twinsen] [0.15] Area push-back effect not applied on all targets

Post by Twinsen »

If I understand this correctly, it's working as intended. The push back effect happens around the entity that generated the action.

You are changing the actions of the ammo. This means that Robot shoots projectile -> projectile hits biter -> biter creates area of effect that pushes all other biters around him.
even with affects_target = true it does not work because it tries to push the biter away from it's self, so it can not calculate a direction where it can be pushed.

Correct way is to make the robot push the biters directly.
User avatar
Ranakastrasz
Smart Inserter
Smart Inserter
Posts: 2173
Joined: Thu Jun 12, 2014 3:05 am
Contact:

Re: [Twinsen] [0.15] Area push-back effect not applied on all targets

Post by Ranakastrasz »

I assume the intent was for the effect to cause knockback from the point of impact. Since the point of impact was on an entity, that entity got ignored.

If it weren't for the inability to use cluster grenade effect for one target, I would suggest chaining a single cluster effect that travels 0.1 distance and then explodes with this effect, which should push every target.
Doing it with two might have unwanted behavior, even at half effect, but should still work.
My Mods:
Modular Armor Revamp - V16
Large Chests - V16
Agent Orange - V16
Flare - V16
Easy Refineries - V16
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [Twinsen] [0.15] Area push-back effect not applied on all targets

Post by Mooncat »

Twinsen wrote:If I understand this correctly, it's working as intended. The push back effect happens around the entity that generated the action.

You are changing the actions of the ammo. This means that Robot shoots projectile -> projectile hits biter -> biter creates area of effect that pushes all other biters around him.
even with affects_target = true it does not work because it tries to push the biter away from it's self, so it can not calculate a direction where it can be pushed.

Correct way is to make the robot push the biters directly.
Thanks for checking the report. :D

But I'm using source_effects rather than target_effects, so the push effect should be generated from the robot rather than the biter?

Edit: I have updated the sample mod.
Added create-entity: smake-fast to the attack, so you can see the effect is generated on the robot.
Also, for destroyer, I added target-effects: push-back as a workaround, in case this bug is not fixed. But you can see it becomes messy (biters are teleporting inside the circle).
area-push-back-bug_0.1.1.zip
(1.32 KiB) Downloaded 162 times

Code: Select all

-- Override destroyer's attack by area push-back effect, with explosion and extra push effect on the target.
local destroyer = data.raw["combat-robot"]["destroyer"]
destroyer.attack_parameters.ammo_type.action.action_delivery =
{
	type = "instant",
	source_effects =
	{
		{
			type = "create-entity",
			entity_name = "smoke-fast"
		},
		{
			type = "nested-result",
			affects_target = true,
			action =
			{
				type = "area",
				perimeter = 8,
				force = "enemy",
				action_delivery =
				{
					type = "instant",
					target_effects =
					{
						{
							type = "push-back",
							distance = 4,
						},
						{
							type = "create-entity",
							entity_name = "explosion"
						},
					}
				}
			}
		}
	},
	target_effects =
	{
		{
			type = "push-back",
			distance = 4,
		}
	}
}

-- Override defender's attack by area push-back effect, without explosion.
local defender = data.raw["combat-robot"]["defender"]
defender.attack_parameters.ammo_type.action.action_delivery =
{
	type = "instant",
	source_effects =
	{
		{
			type = "create-entity",
			entity_name = "smoke-fast"
		},
		{
			type = "nested-result",
			affects_target = true,
			action =
			{
				type = "area",
				perimeter = 8,
				force = "enemy",
				action_delivery =
				{
					type = "instant",
					target_effects =
					{
						{
							type = "push-back",
							distance = 4,
						},
						--[[
						{
							type = "create-entity",
							entity_name = "explosion"
						},
						--]]
					}
				}
			}
		}
	}
}
Twinsen
Factorio Staff
Factorio Staff
Posts: 1350
Joined: Tue Sep 23, 2014 7:10 am
Contact:

Re: [Twinsen] [0.15] Area push-back effect not applied on all targets

Post by Twinsen »

Ok, I found the problem. source_effects were applied from the target to the source, meaning the target would not get affected.

Fixed in Version: 0.15.22
User avatar
Mooncat
Smart Inserter
Smart Inserter
Posts: 1196
Joined: Wed May 18, 2016 4:55 pm
Contact:

Re: [Twinsen] [0.15] Area push-back effect not applied on all targets

Post by Mooncat »

Twinsen wrote:Ok, I found the problem. source_effects were applied from the target to the source, meaning the target would not get affected.

Fixed in Version: 0.15.22
Thanks! :D
Post Reply

Return to “Resolved Problems and Bugs”