Hello. Is it possible to make an ACS script that removes everything within a certain radius?
Or, alternatively, make an Actor that does the same thing which then can be spawned through ACS?
Or, maybe a way to assign a TID to things within a radius and then remove them with Thing_Remove?
Or, maybe there's another way I'm not thinking of? Any ideas?
Class ActorRemover : Actor
{
double dist; property Distance : dist;
Override void PostBeginPlay()
{
Super.PostBeginPlay();
For(let i = BlockThingsIterator.Create(self,dist); i.Next();)
{
Actor other = i.thing;
If(other==self)
{Continue;}
double distance = Distance3D(other);
If(distance>dist)
{Continue;}
If(other is "PlayerPawn"||other.bNOBLOCKMAP)
{Continue;}
other.Destroy();
}
Destroy();
}
}
This actor will iterate through all actors within a radius from it and remove them.
Do note that this will not delete the player or anything with the NOBLOCKMAP flag to prevent it from deleting certain important actors.
Then in DECORATE you can inherit from this and set the radius you want to delete within:
ACTOR ActorRemover128 : ActorRemover
{
ActorRemover.Distance 128
}
ACTOR ActorRemover1024 : ActorRemover
{
ActorRemover.Distance 1024
}
Re: Remove everything within a radius?
Posted: Sun Aug 01, 2021 6:51 am
by Azagthoth
Jarewill wrote:With ZScript you can make such an actor:
Humm. Is there any chance that it could be doable without ZScript? I'm working on an addon for another mod that only works in Zandronum so I don't have much choice on the matter. Thanks for the answer, tho.
Re: Remove everything within a radius?
Posted: Sun Aug 01, 2021 6:56 am
by Jarewill
That complicates things....
If you can edit the actors, you could make them check for an inventory item and jump to a state where they disappear. For example the Null state.
Then you can spawn an actor that gives everything in it's radius the item using A_RadiusGive,
Re: Remove everything within a radius?
Posted: Sun Aug 01, 2021 8:17 am
by Azagthoth
Jarewill wrote:If you can edit the actors
I mean, I guess I could but there are about 10000 actors in total so, yeah... Kinda running out of ideas here.
Re: Remove everything within a radius?
Posted: Mon Aug 02, 2021 8:19 am
by Virathas
Extending Jarewill's solution, how about using the [wiki]A_RadiusGive[/wiki] to give some inventory item, that immediately runs an ACS script that uses [wiki]SetActorState[/wiki] to set the state to Null? Theoretically this should work, although i am not sure that all actors can even be affected by A_RadiusGive function.
Re: Remove everything within a radius?
Posted: Tue Aug 03, 2021 3:20 pm
by Azagthoth
Virathas wrote:How about using the [wiki]A_RadiusGive[/wiki] to give some inventory item, that immediately runs an ACS script that uses [wiki]SetActorState[/wiki] to set the state to Null?
That actually worked!... Almost anyways. The issue I'm having now is it only works sometimes and if it fails that "thing" becomes immune to the effect. I'm guessing it receives the item but it doesn't trigger the script for some reason and cant receive another item. Can you figure out what's wrong with my code?
Edit:
Actually, it seems like the problem is with A_RadiusGive after it fails one time it can no longer give items to any things. But this only happens when I use SpawnForced. If I use "Summon ThingRemover" through the console then it works agian. What could possibly be the explanation for this?
Unfortunately i am not sure why it won't work sometimes. The best thing i can suggest, is to add a TakeInventory in the ACS script, which would allow the item to be given again. One more thing that could be attempted is to add a delay to the ACS script, but i frankly don't believe it would help.