Fading Spectre

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!)

Post a reply

Smilies
:D :) :( :o :shock: :? 8-) :lol: :x :P :oops: :cry: :evil: :twisted: :roll: :wink: :geek: :ugeek: :!: :?: :idea: :arrow: :| :mrgreen: :3: :wub: >:( :blergh:
View more smilies

BBCode is OFF
Smilies are ON

Topic review
   

Expand view Topic review: Fading Spectre

Re: Fading Spectre

by Boondorl » Tue Jan 08, 2019 12:46 am

Nash wrote:Granted, the REAL way to do this is to make sure only the client-side actor's alpha is affected, but GZDoom does not run on client/server architecture yet, so consoleplayer is the closest you'll get for now.
Ah, this was more along the lines of what I was looking for. Glad to know there's still an easy enough workaround that offers similar functionality.

Re: Fading Spectre

by Nash » Tue Jan 08, 2019 12:17 am

The solution phantombeta posted already does exactly what you wanted - the alpha is affected only for the current consoleplayer, which means you. Other players will not see the effect.

Granted, the REAL way to do this is to make sure only the client-side actor's alpha is affected, but GZDoom does not run on client/server architecture yet, so consoleplayer is the closest you'll get for now.

Re: Fading Spectre

by Boondorl » Mon Jan 07, 2019 6:35 pm

Apeirogon wrote:He need change spectre alpha for EVERY player in game, so that player from 1 meter from specter see it fully opaque, while player from 100 see same spectre fully transparent.
Or I understand it wrong?!
That is correct. Finding the distance to any player is easy, but I'm not sure if there's a way to set it so it only changes client-side. I suspect that might be beyond simple modding. :lol:

Re: Fading Spectre

by phantombeta » Mon Jan 07, 2019 3:53 pm

They want it to be more visible the closer it is to the local player - so no, there's nothing about checking the distance to all players here.

Re: Fading Spectre

by Apeirogon » Mon Jan 07, 2019 3:49 pm

He need change spectre alpha for EVERY player in game, so that player from 1 meter from specter see it fully opaque, while player from 100 see same spectre fully transparent.
Or I understand it wrong?!

Re: Fading Spectre

by phantombeta » Mon Jan 07, 2019 3:39 pm

That's wrong, actually. You can set the alpha based on the distance to the consoleplayer quite easily.

Code: Select all

class FadingSpectre : Demon {
    default {
        // We HAVE to set the renderstyle here, because GZDoom defaults to "Normal", which ignores alpha.
        RenderStyle "Translucent";
    }

    override void Tick () {
        Super.Tick ();

        // Set the actor's alpha here. We have to subtract the value from 1.
        // to invert it so it gets more visible the closer it is to the player.
        // It also restricts it to 25% alpha minimum so the spectre doesn't become completely invisible
        alpha = clamp (1. - (Distance3D (players [consoleplayer].camera) / 512.), .25, 1.);
    }
} 
You just can't combine it with something like A_FadeOut with the FTF_REMOVE flag, which removes the actor if it reaches 0 alpha, or it can cause desyncs.
(There are ways to combine with such things without desyncs, but it's not something you should do or even attempt if you don't know how GZDoom's internals work in detail)

EDIT: Added a small change to make it work if the player is looking through the "eyes" of another player or actor.

Re: Fading Spectre

by Apeirogon » Mon Jan 07, 2019 3:28 pm

You can check distance directly to player, if you know how find pointer to it.

And no, it cant be done as localized thing. Renderer "guts" of gzdoom is out of control of modders. Because its a source port, not a standalone game (engine), I think.

Re: Fading Spectre

by Boondorl » Mon Jan 07, 2019 1:36 pm

Unfortunately it would still be global. Multiplayer isn't too big of a concern, but it does still exist and I'm interested if there's a way to make the Spectre's transparency level localized to only players that are close by instead of everyone in the game.

Re: Fading Spectre

by Apeirogon » Mon Jan 07, 2019 8:43 am

You can check distance to player actor using distance2d/3d function, to change decide on what value script must change transparency of spectre.

Fading Spectre

by Boondorl » Mon Jan 07, 2019 2:38 am

Currently I'm rewriting how the Spectre's invisibility works. As it gets further away from its target, it becomes more invisible and vice versa. The issue is that this change in transparency is global so, if next to its target, it'll be fully visible at all ranges, even if it's attacking something other than the player. I want to make it a more localized effect so that a player will only ever see it when close by, regardless of what target the Spectre has. In other words, I need the visibility to be proximity based to any actor as opposed to target based, and it needs to be localized to that actor in close range. Is there a way to do this via ZScript?

Top