Hexen Wandering Monster script (repopulation script)

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!)
peewee_RotA
Posts: 276
Joined: Fri Feb 07, 2014 6:45 am

Hexen Wandering Monster script (repopulation script)

Post by peewee_RotA »

Does anyone have an official implementation of this script? I was able to track down all of the details in this doomwiki resource to recreate it, but I wanted to compare with a more official source.


Here's what I'm using. I have mapspots with tags in the 40's range. The Script runs at OPEN and only respawns a given set if all of the monsters from that TID group are dead. This lets me place several map spots with the same tag to spawn more monsters at once, and have them only repopulate if they are finished off.

Code: Select all

#Include "Zcommon.acs"

bool isWanderingMonsterActive;
int wMonster1 = 2901;
int wMonster2 = 2902;
int wMonster3 = 2903;
int wMonster4 = 2904;
int wMonster5 = 2905;
script 255 OPEN
{
	isWanderingMonsterActive = true;

	while (isWanderingMonsterActive)
	{
		Delay(8400);

		if (ThingCount(0, wMonster1) == 0)
		{
			SpawnSpot ("TeleportFog", 41);
			SpawnSpot ("Ettin", 41, wMonster1);
		}

		if (ThingCount(0, wMonster2) == 0)
		{
			SpawnSpot ("TeleportFog", 42);
			SpawnSpot ("FireDemon", 42, wMonster2);
		}

		if (ThingCount(0, wMonster3) == 0)
		{
			SpawnSpot ("TeleportFog", 43);
			SpawnSpot ("Centaur", 43, wMonster3);
		}

		if (ThingCount(0, wMonster4) == 0)
		{
			SpawnSpot ("TeleportFog", 44);
			SpawnSpot ("Ettin", 44, wMonster4);
		}

		if (ThingCount(0, wMonster5) == 0)
		{
			SpawnSpot ("TeleportFog", 45);
			SpawnSpot ("Bishop", 45, wMonster5);
		}
	}
}
I added in an exit condition in case I ever need to turn it off for a final boss room or anything.
Gez
 
 
Posts: 17633
Joined: Fri Jul 06, 2007 3:22 pm

Re: Hexen Wandering Monster script (repopulation script)

Post by Gez »

peewee_RotA wrote:Does anyone have an official implementation of this script? I was able to track down all of the details in this doomwiki resource to recreate it, but I wanted to compare with a more official source.
Cue Wiki quote that "The information above was obtained by using Descript on each map of both IWADs, hexen.wad and hexdd.wad, both in their 1.1 versions."

You will not find a "more official source" than that since the source code for the map scripts was never released by Raven Software.

If you really want, here's the pack with all the decompiled scripts for both Hexen and Deathkings. These are decompiled, so expect a total lack of any comment, and highly useful variable names such as "var0", "var1", "var2", etc. Structure is not guaranteed to be how Raven coded it because compilation and then decompilation can remove a lot of syntactic sugar, e.g. a switch/case block can turn into a series of if/else if blocks.

Also the original scripts did not have your fancy TID counting, monsters were just spawning regularly. If you kill them all then exit the map quick enough, you can leave with all monsters killed; inversely if you just hide in a safe place and leave the game running for a while while you go out and do stuff away from your computer it'll spawn a lot of monsters.
You do not have the required permissions to view the files attached to this post.
peewee_RotA
Posts: 276
Joined: Fri Feb 07, 2014 6:45 am

Re: Hexen Wandering Monster script (repopulation script)

Post by peewee_RotA »

Thanks for the resource!

I didn't realize that each monster spawn was its own mapspot location. That really helps with setting angles. In my example they'll all come out facing east. (I had originally thought they would get the angle of the thing they spawned too)

Also didn't realize that every individual monster spot has a 50/50 random chance. It's not for the whole script.
Spoiler:
I believe the Thing_Spawn function will fail if there is already a monsters. So if the wandering monsters are not alerted, they shouldn't keep spawning. I think that's why it looks like they are limited.

I made an updated script that has a much higher limit that is adjustable. The limit is per spot, so if one area is at its max, others can still respawn. The main reason I did this was inaccessible areas still get their new monsters after the timeout. I think those spots are on top of existing monster spawns in the original, so that even if the script runs in an unexplored area, the spawn will fail.
Spoiler:
User avatar
Enjay
 
 
Posts: 26403
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Hexen Wandering Monster script (repopulation script)

Post by Enjay »

If you want things to spawn facing the same direction as the map spot where they are spawning, you can use [wiki]SpawnSpotFacing[/wiki] instead of spawnspot.
peewee_RotA
Posts: 276
Joined: Fri Feb 07, 2014 6:45 am

Re: Hexen Wandering Monster script (repopulation script)

Post by peewee_RotA »

Enjay wrote:If you want things to spawn facing the same direction as the map spot where they are spawning, you can use [wiki]SpawnSpotFacing[/wiki] instead of spawnspot.
That exists?

YES! You are a miracle worker. Thank you!
User avatar
Enjay
 
 
Posts: 26403
Joined: Tue Jul 15, 2003 4:58 pm
Location: Scotland

Re: Hexen Wandering Monster script (repopulation script)

Post by Enjay »

I merely reported the miracle. ;) Randi or Graf are more likely to be the actual miracle workers in this case. :biggrin:

Return to “Scripting”