Swapping Things Based on Wad Detected - any way to do it?

Ask about ACS, DECORATE, ZScript, or any other scripting questions here!

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!)
Post Reply
User avatar
scalliano
Posts: 2866
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Swapping Things Based on Wad Detected - any way to do it?

Post by scalliano »

Hi guys, it's been a while, and I'm slowly getting back into modding again.

I am currently working on implementing ID24 support into Shuffle - I hadn't touched it for a while and was daunted by the prospect of trying to include the new assets in such a way that the mod could actually be played with Legacy of Rust. The mod will load fine, but I've hit a snag - while the old RandomSpawner class works for the new monsters when using the Deh_Actor_xxx, the way that the weapons are implemented means that even if I try to replace ID24Incinerator, ID24Fuel, etc. the mod will still use the RandomSpawner for the PlasmaRifle, Cell, etc meaning the only way I can spawn the new weapons is by adding them into the PlasmaRifle spawner and giving them a higher drop rate.

However, I have been able to load Shuffle with LoR properly via Doom Fusion thanks to this handy-dandy piece of ZScript included in the compiled .ipk3:

Code: Select all

class Id1WeaponHandler : EventHandler
{
	override void CheckReplacement (ReplaceEvent e)
	{
		int weapSwap = CVar.FindCVar("wf_id1_weapswap").GetInt();
		string mapName = level.MapName.MakeLower();
		if ( ( weapSwap == 1 && mapName.Left(3) == "lr_" ) || weapSwap >= 2 )
		{
			if ( Level.MapTime == 0 )
			{
				if (e.Replacee is "PlasmaRifle")
					e.Replacement = "Incinerator";
				if (e.Replacee is "BFG9000")
					e.Replacement = "Heatwave";
				if (e.Replacee is "Cell")
					e.Replacement = "Fuel";
				if (e.Replacee is "CellPack")
					e.Replacement = "FuelTank";
			}
		}
	}
}
My question is: is there a way of using ZScript to perform this swap upon .WAD load, for example, by detecting a string in GAMEINFO rather than map name, so that the original id1.wad can be used?

Any help would be appreciated.
User avatar
stainedofmind
Posts: 203
Joined: Sun Sep 01, 2019 10:59 am

Re: Swapping Things Based on Wad Detected - any way to do it?

Post by stainedofmind »

You should be able to. MOShuffle has a script to read the contents of any loaded WADS to determine which map sets are loaded. You could take a look at that:

viewtopic.php?t=72760

It's under "main.zscript" then "MOShuffleThinker.ScanLump().

Hope this helps.
User avatar
scalliano
Posts: 2866
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Re: Swapping Things Based on Wad Detected - any way to do it?

Post by scalliano »

Thanks, I'll take a look.
Post Reply

Return to “Scripting”