IWAD detecting code?

Discuss all aspects related to modding Zandronum here.
Post Reply
User avatar
HellBlade64
Forum Regular
Posts: 100
Joined: Mon Aug 13, 2012 9:03 pm
Contact:

IWAD detecting code?

#1

Post by HellBlade64 » Fri Sep 18, 2020 3:18 am

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.

User avatar
TDRR
Forum Regular
Posts: 214
Joined: Thu Jun 28, 2018 9:13 pm
Location: Venezuela

Re: IWAD detecting code?

#2

Post by TDRR » Fri Sep 18, 2020 9:22 pm

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!).
"I will find joy in Yahweh. I will delight in my Elohim. He has dressed me in the clothes of salvation. He has wrapped me in the robe of righteousness like a bridegroom with a priest’s turban, like a bride with her jewels."
-Isaiah 61:10 (Names of God Bible)

Post Reply