[ZScript] Kind of Actors seen by BlockThingsIterator ?

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
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

[ZScript] Kind of Actors seen by BlockThingsIterator ?

Post by vsonnier »

Hello all, I have the following kind of Handler code, to lookup for some types of actors close to the player and do things accordingly :

Code: Select all

const LOOKUP_MAX_DISTANCE = 60;

class MyHandler : EventHandler
{
	override void WorldTick(void)
	{ 
		PlayerInfo p = players[consoleplayer];
		if (!p) return;

		// look for Things around the player, but no more than LOOKUP_MAX_DISTANCE away
		BlockThingsIterator it = BlockThingsIterator.Create(p.mo, LOOKUP_MAX_DISTANCE );
		while (it.Next())
		{
			Actor mo = it.thing;
			
			Console.PrintF("MyHandler::WorldTick ENTER, found Thing = %s ",mo.GetClassName());
			
			// do stuff...
		}//end while.
	}
}
The handler works and the BlockThingsIterator iterates over some types of actors: monsters, monster corpses, ammo, ...etc.. around the player, but not the kind I'm interested in in my particular case.
So I wonder what kind of flags a particular Actor class needs, to be "discovered" by the BlockThingsIterator ?
I've explored the GZDoom code for BlockThingsIterator but I didn't manage to guess what was needed.
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: [ZScript] Kind of Actors seen by BlockThingsIterator ?

Post by Accensus »

It needs to not have +NOBLOCKMAP (or +NOINTERACTION, which implies +NOBLOCKMAP). That's about it.
User avatar
vsonnier
Posts: 80
Joined: Wed Apr 10, 2019 11:22 pm
Graphics Processor: nVidia with Vulkan support
Contact:

Re: [ZScript] Kind of Actors seen by BlockThingsIterator ?

Post by vsonnier »

Thanks Accensus, it works :)
Accensus
Posts: 2383
Joined: Thu Feb 11, 2016 9:59 am

Re: [ZScript] Kind of Actors seen by BlockThingsIterator ?

Post by Accensus »

You're welcome!
Post Reply

Return to “Scripting”