Page 1 of 1

Event handler not working

Posted: Mon May 06, 2024 8:03 pm
by Ultimate Freedoomer
So, I have a mod called "Works of the masters", which creates a "deluxe" edition of the master levels by (among other things) adding a bespoke soundtrack, organizing the maps into episodes based on author, & including the missing maps. Now, here's the issue: 1 of the features is supposed to be that you can set whether or not to pistol start between maps on a per-episode basis. The problem is that no matter what I set it to, it resets the inventory upon exit. Would somebody be so kind as to see if there's something going on in the Zscript syntax or some other text lump may be breaking this functionality? Here's a link to the mod: https://www.dropbox.com/scl/fi/czr65lbe ... lg2fh&dl=0

Re: Event handler not working

Posted: Tue May 07, 2024 1:12 pm
by Jarewill
The way your event handler is set up, it first reads a CVar value and then either: Consults a list before pistol starting if the CVar is set to 0, always pistol starts if the CVar is set to 1 and never pistol starts if it's set to 2.
The problem is that the way your MENUDEF is defined, you can only set that CVar to either 0 or 1.

Re: Event handler not working

Posted: Tue May 07, 2024 1:16 pm
by Ultimate Freedoomer
There’s nothing for a 2 setting in the event handler itself, is there? There’s just a 0 & 1. Maybe 2 might be mentioned in the commented-out code. I’ll have to look. Incidentally, the list consultation should apply to both 0 & 1. Also, the Cvar is a Boolean.

Re: Event handler not working

Posted: Tue May 07, 2024 1:35 pm
by Jarewill
Oh you are right, it is a boolean. The event handler reads it as an integer so I assumed it was one.
There's no mention of 2 in the code, but the comments state 2 was meant to be a "don't pistol start" value.
Currently the event handler checks for 0, then references the list and takes items away, and if that fails it checks for 1 and takes items away without referencing the list.
You will have to remove the second mention of StripAllPlayerInventory() in order for it to work with your bool CVar.

Re: Event handler not working

Posted: Tue May 07, 2024 2:19 pm
by Ultimate Freedoomer
So remove the 1 where it says "else if"? or the 1 where it's in the list check?

Re: Event handler not working

Posted: Tue May 07, 2024 2:40 pm
by Jarewill
That depends if you want the list to be considered or not.
If you do, just remove the second part and change the first part's check to 1, like so:

Code: Select all

	override void WorldUnloaded(WorldEvent e)
	{
		int pistolStartPref = CVar.FindCVar("mld_pistol_start_cabal").Getint();
		// 1 = pistol start, 0 = don't
		if ( pistolStartPref == 1 )
		{
			// get level name
			String levelName = level.MapName;
			levelName.ToLower();
			bool shouldPistolStart = true;
			// see if level name is in list
			// static arrays can't use dynarray.Find :(
			for ( int i = 0; i < nonPistolStartLevelNames.Size(); i++ )
			{
				if ( levelName == nonPistolStartLevelNames[i] )
				{
					shouldPistolStart = false;
					break;
				}
			}
			if ( shouldPistolStart ) StripAllPlayerInventory();
		}
	}

Re: Event handler not working

Posted: Tue May 07, 2024 2:46 pm
by Ultimate Freedoomer
Alright. & with this setup, it’ll still keep my inventory between levels when it’s set to 0? That's my main concern. "0" should be for checking the list & keeping inventory between levels, "1" is for clean-starting each map on a continuous run. UPDATE: it's STILL clean-starting when I have the pistol-start set to "no" for the episode being played.