Destroy effect in radius?

Can we please have this? Is there reasoning behind why it is seemingly immposible to destroy specific effects? I either have the option to destroy all of them, or the last one. What i want to do is be able to place down independent traps and once activated it destroys the effects assocaited with that trap… but there is no way to do so, I have to just destroy all effects or the last one.

You can store effects in variables, and then destroy the effects in variables.

2 Likes

Spacejester’s answer helps a lot but I don’t exactly know what you mean by destroying the effects associated with the trap, do you mean like around the trap?, if so you need to make a lot of rules with conditions wherein if the variable (where an effect is stored in) is close to the trap, and an another condition detecting if its activated, and then you can proceed to adding the destroy effect action with the value being the variable with the effect stored (You have to make these for each effect is what I know :/)

Wait, what? How do I do that?

You need an array for all the trap positions and an array for their IDs. When you place a new trap you do it like this:

create effect(..., *position*, ...)
modify global variable(IDs, append to array, last created entity)
modify global variable(positions, append to array, *position*)

The rule to activate a trap and destroy its effect looks like this:

Variables
{
	global:
		0: positions
		1: IDs

	player:
		0: currentTraps
		1: loopCounter
}

rule("Activate Trap")
{
	event
	{
		Ongoing - Each Player;
		All;
		All;
	}

	conditions
	{
		Is Alive(Event Player) == True;
		Is True For Any(Global.positions, Distance Between(Event Player, Current Array Element) <= 1.500) == True;
	}

	actions
	{
		Event Player.currentTraps = Filtered Array(Global.positions, Distance Between(Event Player, Current Array Element) <= 1.500);
		For Player Variable(loopCounter, 0, Count Of(Event Player.currentTraps), 1);
			Destroy Effect(Global.IDs[Index Of Array Value(Global.positions, Event Player.currentTraps[Event Player.loopCounter])]);
			Modify Global Variable(Global.IDs, Remove From Array By Index, Index Of Array Value(Global.positions, Event Player.currentTraps[Event Player.loopCounter]));
			Modify Global Variable(Global.positions, Remove From Array By Value, Event Player.currentTraps[Event Player.loopCounter]);
		End;
		Set Status(Event Player, Null, Rooted, 3);
	}
}

I used 1.5 as radius here, but you need to replace it with the actual radius of your traps.

In short, you do it this way:

  • create the effect
  • immidiatly afterwards you store the “last created entity” in variable V
  • whenever you want to destroy the effect you use “Destroy Effect(V)”
1 Like

Since when have you been able to do this? I remeber I tried to store an effect in a variable using “last created entity” a long time ago and it didn’t work.

I think its possible since workshops release :wink: