[ACS] Doom 64 style fading spawning things (updated 4/25/17)

Sprites, textures, sounds, code, and other resources belong here. Share and share-alike!
Forum rules
Before posting your Resource, please make sure you can answer YES to any of the following questions:
  • Is the resource ENTIRELY my own work?
  • If no to the previous one, do I have permission from the original author?
  • If no to the previous one, did I put a reasonable amount of work into the resource myself, such that the changes are noticeably different from the source that I could take credit for them?
If you answered no to all three, maybe you should consider taking your stuff somewhere other than the Resources forum.

Consult the Resource/Request Posting Guidelines for more information.

Please don't put requests here! They have their own forum --> here. Thank you!

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Nevander » Mon Apr 24, 2017 9:12 pm

Could you post the script or at least the parts where you use Thing_FadeIn?

Sometimes you'd get the opposite result where the second set fades in right away. Usually I add a delay of one tic after each call of Thing_FadeIn so the game has time to register the things existing on the map. I've had problems before where doing a ThingCount immediately following the fade in would often skip the condition check altogether since they all ran in the same tic.
Nevander
Self-Banned User
 
Joined: 06 Jan 2014

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Mav3r1ck » Mon Apr 24, 2017 9:53 pm

Nevander wrote:Could you post the script or at least the parts where you use Thing_FadeIn?

Sometimes you'd get the opposite result where the second set fades in right away. Usually I add a delay of one tic after each call of Thing_FadeIn so the game has time to register the things existing on the map. I've had problems before where doing a ThingCount immediately following the fade in would often skip the condition check altogether since they all ran in the same tic.


It will be a little while before I can. It was for my remakes of Watch Your Step.

Basically what I did was copy and paste your spawning code for the part of the map where you step on one of the 12 squares and monsters spawn in. What I did was replace the Thing_SpawnFacing with thing_fadein and changed some of the values.
User avatar
Mav3r1ck
 
Joined: 17 Jul 2015

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Nevander » Mon Apr 24, 2017 10:58 pm

Here's one of the scripts for that area from the current version of my map, using the fade spawns:

Code: Select allExpand view
script 8 (void) // Spawns an ammo box and a Demon on the north side
{
   if(hasRun6 == 0)
   {
      hasRun6 = 1;
      
      Thing_FadeSpawn(12, T_AMMOBOX, 0);
      
      Thing_FadeSpawn(13, T_DEMON, 250);
      Delay(10);
      NoiseAlert(0, 0);
      
      While(ThingCount(T_NONE, 250) > 0) Delay(10);
      Delay(10);
      
      Thing_FadeSpawn(13, T_DEMON, 0);
      Delay(10);
      NoiseAlert(0, 0);
   }
   else if(hasRun6 == 1) Delay(1);
}

See I have a delay after FadeSpawn that gives the engine plenty of time to recognize a thing is on the map with TID 250 and it could even be 1 tic I think too, but I prefer at least 5 to be safe most of the time. There's no way you could kill the monster in 5 tics unless you timed it perfectly with a BFG blast or used the kill command, especially if the monster spawns somewhere else like in this case. Even if you did kill it, the thingcount condition would instantly pass and continue on anyway, so no harm done with scripts like these.
Nevander
Self-Banned User
 
Joined: 06 Jan 2014

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Mav3r1ck » Mon Apr 24, 2017 11:35 pm

Nevander wrote:Here's one of the scripts for that area from the current version of my map, using the fade spawns:

Code: Select allExpand view
script 8 (void) // Spawns an ammo box and a Demon on the north side
{
   if(hasRun6 == 0)
   {
      hasRun6 = 1;
      
      Thing_FadeSpawn(12, T_AMMOBOX, 0);
      
      Thing_FadeSpawn(13, T_DEMON, 250);
      Delay(10);
      NoiseAlert(0, 0);
      
      While(ThingCount(T_NONE, 250) > 0) Delay(10);
      Delay(10);
      
      Thing_FadeSpawn(13, T_DEMON, 0);
      Delay(10);
      NoiseAlert(0, 0);
   }
   else if(hasRun6 == 1) Delay(1);
}

See I have a delay after FadeSpawn that gives the engine plenty of time to recognize a thing is on the map with TID 250 and it could even be 1 tic I think too, but I prefer at least 5 to be safe most of the time. There's no way you could kill the monster in 5 tics unless you timed it perfectly with a BFG blast or used the kill command, especially if the monster spawns somewhere else like in this case. Even if you did kill it, the thingcount condition would instantly pass and continue on anyway, so no harm done with scripts like these.


This is what I did

Code: Select allExpand view
script 3 (void) // Spawns rockets and an Imp (skill 1-2) or Hell Knight (skill 3-5) in southwest corner
{
   if(hasRun1 == 0)
   {
      hasRun1 = 1;
      
      Thing_FadeIn(38, 140, 0);
      
      if(GameSkill() <= SKILL_EASY) Thing_FadeIn(39, 5, 255);
      else if(GameSkill() >= SKILL_NORMAL) Thing_FadeIn(39, 113, 255);
      Delay(10);
      NoiseAlert(0, 0);
      
      While(ThingCount(0, 255) > 0) Delay(10);
      Delay(10);
      
      if(GameSkill() <= SKILL_EASY) Thing_FadeIn(39, 5, 0);
      else if(GameSkill() >= SKILL_NORMAL) Thing_FadeIn(39, 113, 0);
      Delay(10);
      NoiseAlert(0, 0);
   }
   else if(hasRun1 == 1) Delay(1);
}


This just basically tells the game to spawn (fadein) the monsters as opposed to using Thing_SpawnFacing with the teleport flash effect. And to also fade in more monsters once the Imp or Hell Knight tagged 39 are killed. It works fine but it won't fade the monsters in after the monsters tagged 39 are dead.

And since I have NoiseAlert in the fadein code as well. I removed the NoiseAlert in this current code.

I'm using the other fadein code. Which your's is based upon.
User avatar
Mav3r1ck
 
Joined: 17 Jul 2015

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Nevander » Tue Apr 25, 2017 12:19 am

The newer version of the fade in/out code I split the functions up to allow you to just fade in which is the original Thing_FadeIn and then Thing_FadeSpawn. The new Thing_FadeSpawn is equivalent to the old Thing_FadeIn function. Assuming everything is the same except the function name, that script should be working fine.

With the old code, the ammo is faded in at spot 38 and given newTID 38. The monster is faded in at spot 39 and given newTID 255, then a delay of 10 tics. TID 255 should be present on the map, then after it's been killed it spawns again at the same spot and then given newTID 39. No newTIDs are shared and it looks ok to me. I can't tell what the problem could be unfortunately. Remember tag 39 is the tag of the destination and will only be the newTID if the third argument is 0 using the old code.

I would suggest using the new version of the code and make changes to that since the old code is really confusing to me now and has a lot of problems when trying to use it on monsters and thingcounts. I figured this out when I started converting all my monster spawns to fade ins and ended up refactoring the whole thing that is now on the first post of the thread.
Nevander
Self-Banned User
 
Joined: 06 Jan 2014

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Mav3r1ck » Tue Apr 25, 2017 12:30 am

I figured I did everything correctly.

Perhaps there is a flaw in this code that prevents it from being unable to work with certain setups. This being one of them as opposed to Thing_SpawnFacing which works perfectly fine with it.
User avatar
Mav3r1ck
 
Joined: 17 Jul 2015

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Nevander » Tue Apr 25, 2017 12:37 am

Could you post the exact code you currently have for the fading in? The problem could be there. The old code should still work but just not for every scenario, like spawning twice in the same place with no new TIDs or with monsters that are translucent for example. If used right on normal monsters the old code is still usable.
Nevander
Self-Banned User
 
Joined: 06 Jan 2014

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Mav3r1ck » Tue Apr 25, 2017 12:54 am

Nevander wrote:Could you post the exact code you currently have for the fading in? The problem could be there. The old code should still work but just not for every scenario, like spawning twice in the same place with no new TIDs or with monsters that are translucent for example. If used right on normal monsters the old code is still usable.


This is the same code Scalliano gave me.

Code: Select allExpand view
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);
}


All I did was add NoiseAlert to summon monsters in the alert status. This is the orginal code I was given.

In the Thing_FadeInTranslucent I changed STYLE_Translucent to STYLE_Add to summon some monsters with addictive translucency. Which to me looks cooler. Makes the lost souls look more ghost-like.
User avatar
Mav3r1ck
 
Joined: 17 Jul 2015

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Nevander » Tue Apr 25, 2017 1:15 am

Well I see one problem already, the spawn line spawns a thing at the destination but always sets the newTID to the destination TID. The third argument being passed into the script isn't being used at all until the end.

I'm assuming what's happening is that a thing with TID 39 is being spawned in at spot 39 and doesn't change to TID 255 until 16 tics later. At this point the ThingCount would immediately continue and try to fade in again at spot 39 once again with TID 39 but with a newTID of 0. Since newTID is checked if it's greater than 0, the condition fails and it stays at 39 which might be causing the spawning to happen back to back, they might potentially be getting spawn blocked instantly. This is just a hunch and I don't even know if I'm right but just looking at that code I see potential for disaster but only when ThingCounts are in play.

Try adding a longer delay before the ThingCount, at least a full second or 35 tics. See if it spawns the second group then. If it's still broke then I don't have any other advice except use the newer version and make your changes back to that. Adapting your current code on all your maps is quick with the new method, you never have to worry about conflicting TIDs unless you don't separate out different renderstyles and any newTIDs are assigned the moment the function is called.
Nevander
Self-Banned User
 
Joined: 06 Jan 2014

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Mav3r1ck » Tue Apr 25, 2017 1:57 am

Alright, I'll give it a go.

Another thing, is there a way to speed up or slow down the fade in and fade out effect?
User avatar
Mav3r1ck
 
Joined: 17 Jul 2015

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Nevander » Tue Apr 25, 2017 2:05 am

With the new code in the OP you only need to change the FADE_TICS constant to the duration of the fade.

In the version you are using, the best way would be to change the amount the alpha increases each iteration. Instead of 0.1 change it to something like 0.2. It will reach 1.0 alpha quicker this way but on the same number of tics. You might also want to change the number of times the for loop iterates.

The original Doom 64 effect is actually one second long or 30 tics in the original, 35 on PC Doom. The best thing about the method in the OP is that the fading is completely secondary to the spawning, so the fading always happens last so that nothing is waiting on the fading to finish that could hold up progression or break scripts. You just might be able to kill the thing before it finishes fading in with a long enough FADE_TICS amount. I use 20 tics personally so normally the thing will be faded in before you can kill it unless you pre-fire or something.
Nevander
Self-Banned User
 
Joined: 06 Jan 2014

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Mav3r1ck » Tue Apr 25, 2017 2:57 am

Would I also encounter the same problem with the Thing Count if I use your version?

And also, if I want to add the fading effect for translucent style monsters I just put more in the code with else if?
User avatar
Mav3r1ck
 
Joined: 17 Jul 2015

Re: [ACS] Doom 64 style fading spawning things (updated 4/13

Postby Nevander » Tue Apr 25, 2017 3:34 am

Mav3r1ck wrote:Would I also encounter the same problem with the Thing Count if I use your version?

And also, if I want to add the fading effect for translucent style monsters I just put more in the code with else if?

I highly doubt you will have the same problem as long as there's at least 1 tic delay between each Thing_FadeSpawn call and different monsters with different renderstyles get their own new TIDs. There's no way to overcome this with ACS, the user is responsible for separating the TIDs.

As far as fading translucent monsters, basically you need to check the actor which is about to spawn to see if should have an alpha value lower than 1.0 like the Spectre which is 0.5 or the Lost Soul which is variable depending on user cvar. The OP covers all this, but hold off on using my version right now.

I am making a small update and also will provide a sample WAD to show off how it works.
This will be ready in a few minutes. EDIT: Ready now, check OP.
Nevander
Self-Banned User
 
Joined: 06 Jan 2014

Previous

Return to Resources

Who is online

Users browsing this forum: No registered users and 2 guests