[ZScript] Changing UDMF class filters through LevelPostProcessor?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!
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!)
Bledan
Posts: 2
Joined: Fri May 02, 2025 2:46 am
Preferred Pronouns: He/Him
Operating System Version (Optional): Windows 11
Graphics Processor: nVidia with Vulkan support

[ZScript] Changing UDMF class filters through LevelPostProcessor?

Post by Bledan »

Hi, I'm a long-time lurker that decided to finally make an account because all of my researches gave no result on how I should approach this problem...

In an Hexen mod I'm making, I've added 2 new classes which use Class4 and Class5 filters in map thing properties (UDMF format).
I'm trying to make the mod both able to be run with its own mapset and with vanilla or user-made maps.

The problem stands with vanilla maps: Things have not Class4 and Class5 properties defined and so the two new classes get empty levels with only geometry.
I have to specify that, due to the new classes' nature, I need class4 to spawn the same things as class1 (Fighter) and class5 to spawn class3's things (Mage).

I think I'm really close to a solution through the LevelPostProcessor class: by iterating through the entire map thing list it has to check whether the class1 spawner is active on the object and, if so, applies the class4 spawner as well (and same with class3 and class5).
However I'm not getting how I should write this kind of code: I'm not finding methods to modify UDMF map things and I've found no documentation that could help me.

Code: Select all

class HegemonyLevelPostProcessor : LevelPostProcessor 
{
    protected void Apply(Name checksum, String mapname)
    {
		name mapset = mapname.Left(6);
		if(mapset != 'hegmap')
		{
			for (int i = 0; i < GetThingCount(); i++)
			{
				int flag = GetThingFlags(i);
				Console.Printf(String.Format("%i",flag));
				if(flag & 0x0020)//level.things[i].class1 == true)
				{
					AddThing(GetThingEdNum(i), GetThingPos(i), GetThingAngle(i), GetThingSkills(i), MODES_ALL);
					SetThingFlags(i, 0x0020);
					Console.Printf("Changed class");
					//level.things[i].class1 = true;
					//SetThingFlags(i, "class4"); 
				}
				if(flag & 0x0080)//level.things[i].class3 == true)
				{
					AddThing(GetThingEdNum(i), GetThingPos(i), GetThingAngle(i), GetThingSkills(i), MODES_ALL);
					SetThingFlags(i, 0x0080);
					Console.Printf("Changed class");
					//level.things[i].class5 = true;
					//SetThingFlags(i, "class5"); 
				}
			}
		}
    }
}
This is my latest attempt to try to get a better understanding of map things, obviously utterly failed. I don't even know how to make zscript recognize the hexen classes thing flags! Any help in this direction would be appreciated, especially on how to reference and edit UDMF properties in map things as this is what I'm actually looking for. Thanks!

Return to “Scripting”