Jump to content
Search In
  • More options...
Find results that contain...
Find results in...
jdagenet

Trouble with a monster fade in script

Recommended Posts

I've been using this script to make a monster fade in from nothing like in DooM 64:

script 120 (int thingID, int thingSpawn, int newTID) 
{
   if(thingSpawn > 0)
   {
      Thing_SpawnFacing(thingID,thingSpawn,1,thingID);
   }

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

   if(newTID > 0)
   {
   Thing_ChangeTID(thingID,newTID);
   }
}

Function void Thing_FadeIn (int thingID, int thingSpawn, int newTID)
{
	ACS_ExecuteAlways(120,0,thingID,thingSpawn,newTID);
}
But When I perform a loop such as the UNTIL loop, it does not execute correctly, this is the script that I was testing this out on:
script 1 (void)
{
    Thing_FadeIn (1, T_Demon, 2);
    Delay (1);
    ACS_Execute (2, 0, 0, 0, 0);
}

script 2 (void)
{
    Until (!ThingCount (0, 2))
    {
        Delay (100);
    }
    Print (s:"Good Job!");
}
The monsters will spawn and fade in but right after they do, it prints the statement, "Good Job!" without the monsters even being dead. I'm not sure what I'm doing wrong here, could someone help please?

Share this post


Link to post

After much experimenting, for whatever reason -- a reason I simply can't understand -- your script (120) is resulting in TWO enemies being accounted for with an ID of 2 rather than just one despite only one being seen. As proof of this, you can use a debug script like this to constantly keep check of how many enemies with a particular ID are present:

script 5 ENTER
{
    While(True)
    {
        HUDMessage(d:ThingCount(0,2);
                   HUDMSG_Plain,1,CR_RED,0.5,0.5,0);
                   
    Delay(1);
    }
}
Notice that when the one enemy spawns, it claims there are actually two. And when you kill the one that spawned, the count drops to 1, but there are no other monsters to kill. I've never seen this happen before and to be completely honest, I'm not sure where to go from here. I'm completely dumbfounded by this. To make matters stranger, try replacing your Thing_FadeIn line of code with a Thing_SpawnFacing one and spawn a monster at the map spot of 1 with an ID of 2. Notice that if you spawn a monster that way rather than through your script, only one with an ID of 2 is accounted for like it should be.

Share this post


Link to post

I want to understand this:

jdagenet said:

script 120 (int thingID, int thingSpawn, int newTID) 
{
   if(thingSpawn > 0)
   {
      Thing_SpawnFacing(thingID,thingSpawn,1,thingID);
   }

<snip>
   for(j = 1; j < 10; j++)
   {
<snip>
      delay(2);
   }
<snip>

   if(newTID > 0)
   {
   Thing_ChangeTID(thingID,newTID);
   }
}

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

It seems to me that you'll only perform the Thing_ChangeTID after twenty tics of fade-in delay, but you're counting the new TID starting with a mere one tic of delay.

Why the heck aren't you using this?

script 120 (int thingID, int thingSpawn, int newTID) 
{
   if(thingSpawn > 0)
   {
      Thing_SpawnFacing(thingID,thingSpawn,1,newTID);
   }
Heck, you could have this if you wanted to:
script 120 (int thingID, int thingSpawn, int newTID) 
{
   if (newTID == 0) newTID = thingID;
   if(thingSpawn > 0)
   {
      Thing_SpawnFacing(thingID,thingSpawn,1,newTID);
   }

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
×