Event handler not working
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!)
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!)
-
- Posts: 226
- Joined: Fri Jan 30, 2015 10:32 pm
- Location: Pittman Center
- Contact:
Event handler not working
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
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.
The problem is that the way your MENUDEF is defined, you can only set that CVar to either 0 or 1.
-
- Posts: 226
- Joined: Fri Jan 30, 2015 10:32 pm
- Location: Pittman Center
- Contact:
Re: Event handler not working
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
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.
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.
-
- Posts: 226
- Joined: Fri Jan 30, 2015 10:32 pm
- Location: Pittman Center
- Contact:
Re: Event handler not working
So remove the 1 where it says "else if"? or the 1 where it's in the list check?
Re: Event handler not working
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:
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();
}
}
-
- Posts: 226
- Joined: Fri Jan 30, 2015 10:32 pm
- Location: Pittman Center
- Contact:
Re: Event handler not working
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.