Special 'Fade-out' effect

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.
Locked
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Special 'Fade-out' effect

Post by Ed the Bat »

I need a little bit of advice on something I'm trying to do. I have some characters who, when 'killed', I wanted to turn pure white and then fade out, to simulate a 'teleporting-away' effect. Here's basically what I'm using:

Code: Select all

ACTOR FadePlayer : DoomPlayer
{
	StencilColor White
	States
	{
	XDeath:
	Death:
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 A_GiveInventory("PowerStencil")
		PLAY A 20
		PLAY AAAAAAAAAA 2 A_FadeOut(.1,0)
		TNT1 A -1
		Stop
	}
}
ACTOR PowerStencil : PowerInvisibility
{
	Powerup.Duration 50
	Powerup.Mode Stencil
}
When I do this, though, the player doesn't actually fade out. Each call to A_FadeOut simply makes the player flicker for a moment, but never affects the translucency. I'm thinking this may be because the translucency of PowerInvisibility is supposed to work differently. But, simply put, my method isn't doing what I hope to achieve. Anyone have any suggestions for a better method? Do I simply need to make extra sprites of the player in pure white and use those instead of the Stencil power? If I have to, I'll go that route, but if I can skip it by using code, I'd prefer the faster method.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Special 'Fade-out' effect

Post by Blue Shadow »

You could make a custom inventory that calls a script to change the player's render style to stencil, and use it instead of the power up you have there.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Special 'Fade-out' effect

Post by Ed the Bat »

Good thought, but it might lead to a few complications, such as the stencil still being present after a resurrection.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Special 'Fade-out' effect

Post by Blue Shadow »

Run a script that would "restore" the player's render style to normal at the end of the Death state.

Oh, and to think of it, you don't need a medium (in this case the custom inventory item) to execute the script, in the first place. You can execute the script directly by calling it from the Death state (I don't know why I suggested that you use an item, stupid me :P ).
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Special 'Fade-out' effect

Post by Ed the Bat »

Good thinking. I'll give it a try when I have a free moment and report back.:)

Addendum: Looks like I'm stuck, again. I haven't found an ACS function that allows me to set the render style to Stencil...
Double Addendum: Nope, scratch that. Looks like it does work with SetActorProperty. The wiki is just disgustingly out of date.:P
Third: Things work on the first one, but now after resurrecting, there's no fade effect at all. Not sure what's wrong.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Special 'Fade-out' effect

Post by Blue Shadow »

Ed the Bat wrote:Things work on the first one, but now after resurrecting, there's no fade effect at all. Not sure what's wrong.
The alpha needs to be restored as well.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Special 'Fade-out' effect

Post by Ed the Bat »

Aha! I knew I was overlooking something. Thanks much.:)
Addendum: Getting closer, but I'm still having a few glitches in extraneous circumstances (like if resurrection interrupts the death sequence). I may be able to cover the contingency by putting the A_FadeIn command in the Spawn state. Either way, you've been very helpful in steering me in the right direction. Thank you.:)
Addendum: Adding A_FadeIn to the Spawn state seems to somehow prevent the fading effect of the death sequence entirely. I thought maybe I could just use the ACS script to handle the fade-out, but it turns out that SetActorProperty(0,APROP_Alpha,value) only affects the translucent renderstyle. So I need to find another solution.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Special 'Fade-out' effect

Post by Blue Shadow »

Ed the Bat wrote:Getting closer, but I'm still having a few glitches in extraneous circumstances (like if resurrection interrupts the death sequence). I may be able to cover the contingency by putting the A_FadeIn command in the Spawn state.
Well, I admit, restoring the render style and alpha at the end of the death state probably wasn't an ideal solution. Having it in the spawn state might be better, though.
Spoiler: Some code
Adding A_FadeIn to the Spawn state seems to somehow prevent the fading effect of the death sequence entirely. I thought maybe I could just use the ACS script to handle the fade-out, but it turns out that SetActorProperty(0,APROP_Alpha,value) only affects the translucent renderstyle. So I need to find another solution.
Personally, I'd simply restore the render style and alpha (like I did in the code above) with no special effects and such. I don't see it worth the hassle. The important thing is that these properties are restored upon using the cheat to avoid weird "effects".
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Special 'Fade-out' effect

Post by Ed the Bat »

This is what I tried most recently. I thought that, maybe, consolidating all of the fading and render-style stuff into one script would help make sure things run exactly once when dying, and I wouldn't need to worry about the respawning or resurrecting issues. Sadly, this doesn't seem to work, as APROP_Alpha will only affect Translucency, not Stencils.

Code: Select all

ACTOR FadePlayer : DoomPlayer
{
	StencilColor White
	States
	{
	Death:
		TNT1 A 0 A_Stop
		TNT1 A 0 A_NoGravity
		TNT1 A 0 A_NoBlocking
		TNT1 A 0 ACS_NamedExecute("FadeScript")
		PLAY A 40
		TNT1 A -1
		Stop
	}
}

Code: Select all

script "FadeScript"(void)
{
	SetActorProperty(0,APROP_RenderStyle,STYLE_Stencil);
	Delay(20);
	//This chunk would normally be written in a loop, but
	//I wrote it out the long way for the quick 'n dirty test
	SetActorProperty(0,APROP_Alpha,0.9);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.8);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.7);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.6);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.5);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.4);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.3);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.2);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.1);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,0.0);
	Delay(2);
	SetActorProperty(0,APROP_Alpha,1.0);
	SetActorProperty(0,APROP_RenderStyle,STYLE_Normal);
}
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Special 'Fade-out' effect

Post by Blue Shadow »

Try STYLE_TranslucentStencil as the render style instead.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Special 'Fade-out' effect

Post by Ed the Bat »

It is perfect. That is exactly what I needed to flush out the final glitches (except I forgot I should be using ExecuteAlways instead of just Execute).
You, my friend, have my sincerest thanks for all of this help.:D
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Special 'Fade-out' effect

Post by Blue Shadow »

You're welcome. But what about this issue...
Ed the Bat wrote:like if resurrection interrupts the death sequence
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Special 'Fade-out' effect

Post by Ed the Bat »

No longer an issue. Since it's all run by an ACS script now, the sequence will run its course without interruption, and ExecuteAlways makes sure the script starts from the beginning the next time it's called, no matter what.
Blue Shadow
Posts: 4949
Joined: Sun Nov 14, 2010 12:59 am

Re: Special 'Fade-out' effect

Post by Blue Shadow »

Yes, using ACS will ensure the continuation of the effect with no interruptions. But, if the cheat was used in the middle of the death sequence, the player will keep fading out when resurrected, because the sequence was cut short, and then they will suddenly "appear" (once the fading out part of the script ends), and that seems a bit weird, to me anyway.
User avatar
Ed the Bat
Posts: 3060
Joined: Thu May 03, 2012 1:18 pm
Graphics Processor: nVidia with Vulkan support
Location: Maryland, US
Contact:

Re: Special 'Fade-out' effect

Post by Ed the Bat »

A fair point, but one could argue that since they're supposed to be teleporting out, one could surmise that they simply warped back in.:)
And frankly, it looks strange enough when most other characters use the cheat and suddenly stand upright in the blink of an eye from their corpse/gore. It would be nice if something akin to a RESPAWN script type could be used upon resurrection.
Locked

Return to “Editing (Archive)”