Page 1 of 1

IWAD detecting code?

Posted: Fri Sep 18, 2020 3:18 am
by HellBlade64
I am looking into making my mod (usually only playable on Doom 2 and Doom 2 derived IWADs and PWADs) compatible with Doom 1, but in order to do that I want to set it up so no enemies who drop Doom 2 or above weapons (SSG, Quad Shotgun) are not in the spawn list.

Is there someway I could code my mod to remove SuperShotgunners and QuadShotgunZombies from spawning when it detects it's being played on Doom 1?

I know I could make a patch file, I was just curious there was a way to do it internally.

Re: IWAD detecting code?

Posted: Fri Sep 18, 2020 9:22 pm
by TDRR
There's reliable ways to detect the game (Doom, Hexen, Heretic or Strife) but no real easy way to detect Doom 1 or Doom 2 specifically. The only way I can think off the top of my head, would be using an ACS OPEN script with Stricmp, StrMid and StrParam to get and compare the map lump name to the ExMx format, set a map variable and another script that sets this map var as it's result value. The check itself is separate so as to reduce the performance impact of doing it every time a monster needs to use it.

Like this:

Code: Select all

bool IsDoom1; //starts as false, set by "Setup_CheckIfDoom1"

Script "Setup_CheckIfDoom1" OPEN
{
	str name = StrParam(n:PRINTNAME_LEVEL);
	
	if(StrLen(name) == 4) //ExMx will always be 4 characters long
	{
		str 1stChar = StrLeft(name,1);
		str 2ndChar = StrMid(name,2,1);
		if( (StriCmp(1stChar, "E") == 0) &&
		(StriCmp(2ndChar, "M") == 0) ) //if first and third chars are E, and M
		{
			IsDoom1 = TRUE; //it is Doom1
		}
	}
}

//Use in DECORATE as ACS_NamedExecuteWithResult("IsDoom1"), like 
//A_JumpIf(ACS_NamedExecuteWithResult("IsDoom1") == TRUE, "stateifdoom1")
//or
//A_JumpIf(CallACS("IsDoom1") == TRUE, "stateifdoom1") for brevity
Script "IsDoom1" (void)
{
	SetResultValue(IsDoom1);
}
Note that the monsters should wait one tic before using CallACS, or else the map var may not be set (I think OPEN runs before any actor's spawn state is set, but just in case!).