Monster FadeIn Script

Archive of the old editing forum
Forum rules
Before asking on how to use a ZDoom feature, read the ZDoom wiki first. This forum is archived - please use this set of forums to ask new questions.
User avatar
Mav3r1ck
Posts: 262
Joined: Thu Jul 16, 2015 11:09 pm

Monster FadeIn Script

Post by Mav3r1ck »

I've been able to use scripting in ACS (being able to add colored lighting and some effects to a map) but I also want to have it where monsters spawn like in Doom 64. That being said, how do I properly implement the FadeIn script?

Code: Select all

script 120 (int thingID, int thingSpawn, int newTID) //Fade thing in from nothing (and alternatively spawn a monster)
{
	//Spawn a number if thingSpawn is greater than 0
	if(thingSpawn > 0)
	{
		Thing_SpawnFacing(thingID,thingSpawn,1,thingID);
	}

	int i = 0.1;
	int j = 0;
	ThingSound(thingID,"Respawn",127);
	Thing_Activate(thingID);
	SetActorProperty(thingID,APROP_RenderStyle,STYLE_Translucent);
	for(j = 1; j < 10; j++) //Fade Monster in
	{
		SetActorProperty(thingID,APROP_Alpha, i);
		i += 0.1;
		delay(2);
	} SetActorProperty(thingID,APROP_Alpha, 1.0);

	//Change thing TID? (not necessary, but helpful)
	if(newTID > 0)
	{
	Thing_ChangeTID(thingID,newTID);
	}
}

//Function for said script

Function void Thing_FadeIn (int thingID, int thingSpawn, int newTID)
{
	ACS_ExecuteAlways(120,0,thingID,thingSpawn,newTID);
}

script 121 (int thingID, int thingSpawn, int newTID) //Fade thing in from nothing (and alternatively spawn a monster)
{
	//Spawn a number if thingSpawn is greater than 0
	if(thingSpawn > 0)
	{
		Thing_SpawnFacing(thingID,thingSpawn,1,thingID);
	}

	int i = 0.1;
	int j = 0;
	ThingSound(thingID,"Respawn",127);
	Thing_Activate(thingID);
	SetActorProperty(thingID,APROP_RenderStyle,STYLE_Translucent);
	for(j = 1; j < 7; j++) //Fade Monster in
	{
		SetActorProperty(thingID,APROP_Alpha, i);
		i += 0.1;
		delay(2);
	} SetActorProperty(thingID,APROP_Alpha, 0.75);

	//Change thing TID? (not necessary, but helpful)
	if(newTID > 0)
	{
	Thing_ChangeTID(thingID,newTID);
	}
}

//Function for said script

Function void Thing_FadeInTranslucent (int thingID, int thingSpawn, int newTID)
{
	ACS_ExecuteAlways(121,0,thingID,thingSpawn,newTID);
}
EDIT: This is what I was using. The monsters will spawn whenever I enter the sector that has the linedef for it. The problem I'm having is that I run into the monster itself before it spawns and I can even shoot and kill it. This was a direct copy and paste from the Threshold of Pain TC made by the author Scalliano. And I'm using UDMF.
User avatar
scalliano
Posts: 2867
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Re: Monster FadeIn Script

Post by scalliano »

You need to call Thing_FadeIn or Thing_FadeInTranslucent from an ACS script. Make sure that your map script points towards the main array with the #include command.

For example:

Code: Select all

script FadeinImps (void)
{
    Thing_FadeIn (5, T_IMP, 6);
}
where the first value is the MapSpot tag, the second is the monster's SpawnID (yes, I know, but it's an old script) and the third is the new TID for the monster so that the array can do its thing.

Please note that the original script was actually created by Kaiser and AgentSpork, I just created the translucent/additive/subtractive variants. I can post those if you need them.
User avatar
Mav3r1ck
Posts: 262
Joined: Thu Jul 16, 2015 11:09 pm

Re: Monster FadeIn Script

Post by Mav3r1ck »

I added the code itself into the ACS script for the individual level, and that's how I got it working. should I just create a FadeIn.ACS inside the doom.wad itself like you did and go from there?

And yes go ahead and post those. I do better by seeing the code and even example coding.

I'm going to give it a try.

EDIT: I got it to work. I added the FadeIn.acs in my doom builder 2 compilers and inside my doom.wad as an ACS script. Though I still have a problem. In your TOP, you can go through the monsters and shoot as if nothing it there before they spawn but in my version I hit the monster like it's an invisible wall and my hit markers still target it. How do I solve this?
User avatar
scalliano
Posts: 2867
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Re: Monster FadeIn Script

Post by scalliano »

There are two ways to use the script:

1. having dormant invisible monsters on the map and activating the Thing_FadeIn script when you enter the room, in which case you would use:

Code: Select all

script FadeinImps (void)
    {
        Thing_FadeIn (5, 0, 0);
    }
giving the first tag directly to the monsters and leaving the rest as 0. This will result in the invisible solid obstacles you mentioned. Not recommended for open areas.

2. you can use MapSpots for spawn points and use the method in my first post. This should physically spawn the monsters into the area and start the fade process. This is by far and away the best method, but no. 1 has its uses too.

Here are the arrays for additive (PSX-style) and subtractive (Nightmare-style) rendering.

Code: Select all

script 122 (int thingID, int thingSpawn, int newTID) //Fade thing in from nothing (and alternatively spawn a monster)
{
	//Spawn a number if thingSpawn is greater than 0
	if(thingSpawn > 0)
	{
		Thing_SpawnFacing(thingID,thingSpawn,1,thingID);
	}

	int i = 0.1;
	int j = 0;
	ThingSound(thingID,"Respawn",127);
	Thing_Activate(thingID);
	SetActorProperty(thingID,APROP_RenderStyle,STYLE_Add);
	for(j = 1; j < 3; j++) //Fade Monster in
	{
		SetActorProperty(thingID,APROP_Alpha, i);
		i += 0.1;
		delay(2);
	} SetActorProperty(thingID,APROP_Alpha, 0.25);

	//Change thing TID? (not necessary, but helpful)
	if(newTID > 0)
	{
	Thing_ChangeTID(thingID,newTID);
	}
}

//Function for said script

Function void Thing_FadeInAdd (int thingID, int thingSpawn, int newTID)
{
	ACS_ExecuteAlways(122,0,thingID,thingSpawn,newTID);
}

script 123 (int thingID, int thingSpawn, int newTID) //Fade thing in from nothing (and alternatively spawn a monster)
{
	//Spawn a number if thingSpawn is greater than 0
	if(thingSpawn > 0)
	{
		Thing_SpawnFacing(thingID,thingSpawn,1,thingID);
	}

	int i = 0.1;
	int j = 0;
	ThingSound(thingID,"Respawn",127);
	Thing_Activate(thingID);
	SetActorProperty(thingID,APROP_RenderStyle,STYLE_Subtract);
	for(j = 1; j < 9; j++) //Fade Monster in
	{
		SetActorProperty(thingID,APROP_Alpha, i);
		i += 0.1;
		delay(2);
	} SetActorProperty(thingID,APROP_Alpha, 0.95);

	//Change thing TID? (not necessary, but helpful)
	if(newTID > 0)
	{
	Thing_ChangeTID(thingID,newTID);
	}
}

//Function for said script

Function void Thing_FadeInSub (int thingID, int thingSpawn, int newTID)
{
	ACS_ExecuteAlways(123,0,thingID,thingSpawn,newTID);
}
The commands are Thing_FadeInAdd and Thing_FadeInSub.
User avatar
Mav3r1ck
Posts: 262
Joined: Thu Jul 16, 2015 11:09 pm

Re: Monster FadeIn Script

Post by Mav3r1ck »

The way it looks it seems that the second method is what I would prefer in order to prevent encounters with invisible obstacles. So how do I use the mapspots? Does it need the same tag as the monsters or what?

EDIT: figured out how to use the map spots. Gave them the same tag as the T_SHOTGUY in my map ACS scripts and they spawned just like you did and there wasn't any invisible obstacles. This is awesome btw. :D

Now I have 2 more questions.

1. How do I get the monsters to use the same respawn sound as heard in Doom 64?

2. Is there a way to get my scripts to find the FadeIn.acs instead of having it in my Doom Builder 2 compilers folder?
User avatar
scalliano
Posts: 2867
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Re: Monster FadeIn Script

Post by scalliano »

Glad you got it working. I'd advise you to give the mapspots their own tag so as to avoid conflicts. As for your other questions:

1. Rip it from ToP or Doom64.

2. Not that I know of. Even I have to use the full pathname in my scripts.
User avatar
Mav3r1ck
Posts: 262
Joined: Thu Jul 16, 2015 11:09 pm

Re: Monster FadeIn Script

Post by Mav3r1ck »

This is awesome, I've even got it to where enemies spawn just by picking up a gun or Keycard. I found a preferable way for my game to find the FadeIn code is to just simply put it into the individual ACS script for the maps themselves, that way I don't need an outside ACS for the map to look for, especially if something happens to my doom builder 2. Which is easy since I just copy and paste.

I also found that attaching the spawn effect to things is better instead of sectors with multiple linedefs because I found out that by doing that enemies will spawn for every linedef my player passes over.

Thanks for your help. :D

I have another question. The third and last value for the Thing_FadeIn, do I actually need it? Or no?
User avatar
scalliano
Posts: 2867
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Re: Monster FadeIn Script

Post by scalliano »

You can put an extra single unavoidable linedef across the sector and use that. That's what I do.

As for the actual Thing_FadeIn command, the three values go (in order):

Thing ID for the mapspot/teleport destination, Spawn ID for the moster/object type and New Thing ID for the spawned monster/object in case you want to add another function to it eg killing the mosters tha fade in opens a door or something. Spawn ID numbers are listed on the Zdoom Wiki here. As an alternative you can use the T_*** monster names instead. For custom monsters you can pretty much make one up and add it to the DECORATE file.
User avatar
Mav3r1ck
Posts: 262
Joined: Thu Jul 16, 2015 11:09 pm

Re: Monster FadeIn Script

Post by Mav3r1ck »

So I could kill the fade in monsters and have another action activate like a door by using the third value. I'm a bit confused. Would you be able to show me an example code?

EDIT: I also have another question. What format is more preferable. Is UDMF better? Or Hexen format?
User avatar
scalliano
Posts: 2867
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Re: Monster FadeIn Script

Post by scalliano »

UDMF is objectively better as it is much more flexible and you can make much more changes to stuff directly. Neither makes any difference to how ACS works, other than not having a tag limit.

With regard to the third value, you would only really use it in certain circumstances. Normally you won't need it, but let's just say you have a ThingCount script where you have to kill a certain amount of enemies before a door opens. All of those enemies would have to be given the same tag number first. The ThingCount function needs to know that tag number before it will work. There's more about ThingCount and its derivatives on the wiki. Giving a tag to monsters already placed on the map is easy and can be done in GZDoom Builder, but where the third value in Thing_FadeIn comes into play is to give your newly-faded-in monsters the tag that ThingCount needs in order to check how many there are. In cases like this you would always fade the monsters in before executing the ThingCount script.

It does have other uses, but like I say, it's only really for specific events. Otherwise you can just leave it at 0.
User avatar
Mav3r1ck
Posts: 262
Joined: Thu Jul 16, 2015 11:09 pm

Re: Monster FadeIn Script

Post by Mav3r1ck »

So UDMF is better. I guess I'll use that from now on. The reason I asked was because I had converted the entire first Doom game into UDMF and I am modding it to where it has the horror based atmosphere and effect of the PSX and D64 versions. I've even combined your cloud skies with the D64 mountains and they clashed really well. I used the your clouds because the D64 clouds didn't really work well for some reason. I've even created lightning flashes in the sky like D64 did. :D

This is of course for personal use and modification considering it's the actual doom wad itself that I converted to UDMF. :)

EDIT: Thanks for all your help Scalliano! :)
User avatar
Mav3r1ck
Posts: 262
Joined: Thu Jul 16, 2015 11:09 pm

Re: Monster FadeIn Script

Post by Mav3r1ck »

I know I'm bumping and old topic but I have another question that's related. So I did this instead of creating a whole new topic.

My question is that, is there a way to make things fade out of the map like in Doom 64 using a code similar to this?
User avatar
scalliano
Posts: 2867
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Re: Monster FadeIn Script

Post by scalliano »

Theoretically possible, but I'll have to get back to you ...
User avatar
Mav3r1ck
Posts: 262
Joined: Thu Jul 16, 2015 11:09 pm

Re: Monster FadeIn Script

Post by Mav3r1ck »

I edited the code and changed the Thing_Activate to Thing_Remove and after some experimenting it worked, but the problem is that when the Thing is removed from the map it simply disappears without the fading effect like when the thing is faded into the map.
User avatar
scalliano
Posts: 2867
Joined: Tue Jun 21, 2005 1:16 pm
Location: Ireland

Re: Monster FadeIn Script

Post by scalliano »

The problem is that the original script is incrementally altering the thing's translucency until it is solid (or hits the desired maximum in the case of the Translucent/Add/Subtract scripts). The entire script needs to be modified/rewritten to work backwards.
Locked

Return to “Editing (Archive)”