Page 1 of 1

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

Posted: Sun Jun 11, 2017 4:53 pm
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 146 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 :)

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

Posted: Tue Jun 20, 2017 3:32 pm
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.

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

Posted: Tue Jun 20, 2017 3:36 pm
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.

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

Posted: Tue Jun 20, 2017 6:17 pm
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 141 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"
						},
						--]]
					}
				}
			}
		}
	}
}

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

Posted: Wed Jun 21, 2017 1:19 pm
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

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

Posted: Wed Jun 21, 2017 1:21 pm
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