Remove everything within a radius?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

Moderator: GZDoom Developers

Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. If you still don't understand how to use a feature, then ask here.

Please bear in mind that the people helping you do not automatically know how much you know. You may be asked to upload your project file to look at. Don't be afraid to ask questions about what things mean, but also please be patient with the people trying to help you. (And helpers, please be patient with the person you're trying to help!)
Post Reply
Azagthoth
Posts: 63
Joined: Wed Jan 20, 2021 4:06 pm

Remove everything within a radius?

Post by Azagthoth »

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?
Jarewill
 
 
Posts: 1768
Joined: Sun Jul 21, 2019 8:54 am

Re: Remove everything within a radius?

Post by Jarewill »

With ZScript you can make such an actor:
Spoiler:
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:
Spoiler:
Azagthoth
Posts: 63
Joined: Wed Jan 20, 2021 4:06 pm

Re: Remove everything within a radius?

Post 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.
Jarewill
 
 
Posts: 1768
Joined: Sun Jul 21, 2019 8:54 am

Re: Remove everything within a radius?

Post 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,
Azagthoth
Posts: 63
Joined: Wed Jan 20, 2021 4:06 pm

Re: Remove everything within a radius?

Post 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.
User avatar
Virathas
Posts: 249
Joined: Thu Aug 10, 2017 9:38 am

Re: Remove everything within a radius?

Post 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.
Azagthoth
Posts: 63
Joined: Wed Jan 20, 2021 4:06 pm

Re: Remove everything within a radius?

Post 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?

Code: Select all

ACTOR ThingRemover
{
	States 
	{
		Spawn:  
			TNT1 A 0 NoDelay A_RadiusGive ("ThingRemoverItem", 1000.0, RGF_MONSTERS|RGF_OBJECTS)
			stop
	}
}

ACTOR ThingRemoverItem : CustomInventory  
{
	Inventory.Maxamount 0 
	+INVENTORY.AUTOACTIVATE 
	States 
	{
		Use:
			TNT1 A 0 ACS_NamedExecuteAlways("RemoveThing")
			stop
	}
}

Code: Select all

script "RemoveThing" (void)
{
	SetActorState(0, "null");
}
Last edited by Azagthoth on Tue Aug 03, 2021 4:54 pm, edited 1 time in total.
User avatar
Logan MTM
Posts: 678
Joined: Mon Jan 16, 2006 8:53 pm
Location: Rio de Janeiro - Brazil

Re: Remove everything within a radius?

Post by Logan MTM »

1 - Select the BFG9000 (7)
2 - Press Fire
User avatar
Virathas
Posts: 249
Joined: Thu Aug 10, 2017 9:38 am

Re: Remove everything within a radius?

Post by Virathas »

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.
Post Reply

Return to “Scripting”