Fading Spectre
Moderator: GZDoom Developers
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!)
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!)
Fading Spectre
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?
Re: Fading Spectre
You can check distance to player actor using distance2d/3d function, to change decide on what value script must change transparency of spectre.
Re: Fading Spectre
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
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.
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.
- phantombeta
- Posts: 2089
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Fading Spectre
That's wrong, actually. You can set the alpha based on the distance to the consoleplayer quite easily.
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.
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.);
}
}
(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.
Last edited by phantombeta on Mon Jan 07, 2019 3:55 pm, edited 1 time in total.
Re: Fading Spectre
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?!
Or I understand it wrong?!
- phantombeta
- Posts: 2089
- Joined: Thu May 02, 2013 1:27 am
- Operating System Version (Optional): Windows 10
- Graphics Processor: nVidia with Vulkan support
- Location: Brazil
Re: Fading Spectre
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
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.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?!
Re: Fading Spectre
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.
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
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.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.