Check if player sees the Actor
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.
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.
- Tormentor667
- Posts: 13556
- Joined: Wed Jul 16, 2003 3:52 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Germany
- Contact:
Check if player sees the Actor
Is there a way to check - DECORATE or ACS-side - if the player sees an actor at a specific moment?
or alternatively
Is there a way to produce a Flashbang kinda effect? For example if a player is viewing at a thing in a certain moment, the player's screen gets blended?
or alternatively
Is there a way to produce a Flashbang kinda effect? For example if a player is viewing at a thing in a certain moment, the player's screen gets blended?
Re: Check if player sees the Actor
Here's an idea: Change the TIDs of flashbangs to a number (for example 300) at spawn with Thing_ChangeTID(0,300), then have a flashbang_hater actor which is deaf, is relocated to where the player's head is every tick, and constantly tries to hate flashbangs in its spawn state with Thing_Hate(0,300,5) or Thing_Hate(0,300,6). When the player sees a flashbang, the flashbang_hater will enter the see state, and you can make it give the player a custom inventory item which will blind the player. You can put A_ClearTarget at the end of the see state then go back to spawn if you want the hate for the flashbang not to linger.
Re: Check if player sees the Actor
How about this:
A monster spawns an object similar to how the floating drones I sent you work, but just in front of the player. This object will be invisible, +SPECTRAL, and a deaf and blind monster. The flash grenade will also be +SPECTRAL, which means it will be the only thing that will affect it. Anything else will pass through as if it wasn't there. When the spectral monster is hit, it will wake up, turn on the player, and give the necessary blinding item.
A monster spawns an object similar to how the floating drones I sent you work, but just in front of the player. This object will be invisible, +SPECTRAL, and a deaf and blind monster. The flash grenade will also be +SPECTRAL, which means it will be the only thing that will affect it. Anything else will pass through as if it wasn't there. When the spectral monster is hit, it will wake up, turn on the player, and give the necessary blinding item.
Re: Check if player sees the Actor
A_checksight may have something your looking for. You may have to use it in reverse to achieve the effect your looking for (jump to a dummy state if the player is not in view, otherwise, execute a script) However, since multiplayer is what your after, i donno how well this would work out.
Re: Check if player sees the Actor
Won't that only work if the grenade hits the person? The object is to blind them if they just see the grenade.Ichor wrote:How about this:
A monster spawns an object similar to how the floating drones I sent you work, but just in front of the player. This object will be invisible, +SPECTRAL, and a deaf and blind monster. The flash grenade will also be +SPECTRAL, which means it will be the only thing that will affect it. Anything else will pass through as if it wasn't there. When the spectral monster is hit, it will wake up, turn on the player, and give the necessary blinding item.
Re: Check if player sees the Actor
Make two explosions then, one really large one for the sight check, and one for the actual damage. However, now that I think about it, A_Explode wouldn't work in this case, since it would just hit the object regardless of what direction you'd be facing. Instead, it would have to be a ring of projectiles that would die on impact.Spleen wrote:Won't that only work if the grenade hits the person? The object is to blind them if they just see the grenade.
Re: Check if player sees the Actor
The problem with the dummy actor solution and the use of A_checksight is that they both would trigger the effect as soon as the player is in line of sight (or in line of the spectral projectile), but it wouldn't check if the player is actually FACING the object that causes the flare... you would still be blinded although you turn your back towards the triggering object for example!
This is just theoretically, but maybe ACS could be used to achieve this effect.
It would work similar to what Ichor suggtested, only that the dummy actor, attached to the player, would execute a script when hit.
This script would check the angle (GetActorAngle!) of the player and if it's within a certain value (about the direction of the blinding thing) it would set a blend via Set_Fade.
Since I know what you're working on Torm, I also know that the things that are supposed to trigger the blinding effect, appear on fixed spots in the map, so it is a lot easier to determine where the flare is coming from!
Rather complicated and I don't know how to handle this in MP, but it could work I think!
This is just theoretically, but maybe ACS could be used to achieve this effect.
It would work similar to what Ichor suggtested, only that the dummy actor, attached to the player, would execute a script when hit.
This script would check the angle (GetActorAngle!) of the player and if it's within a certain value (about the direction of the blinding thing) it would set a blend via Set_Fade.
Since I know what you're working on Torm, I also know that the things that are supposed to trigger the blinding effect, appear on fixed spots in the map, so it is a lot easier to determine where the flare is coming from!
Rather complicated and I don't know how to handle this in MP, but it could work I think!
Re: Check if player sees the Actor
Vader - what about my idea of using hate. You completely overlooked it 
- Tormentor667
- Posts: 13556
- Joined: Wed Jul 16, 2003 3:52 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Germany
- Contact:
Re: Check if player sees the Actor
This obviously needs a feature request considering all that hackaround... hasn't been something like this suggested already?
- .+:icytux:+.
- Posts: 2661
- Joined: Thu May 17, 2007 1:53 am
- Location: Finland
Re: Check if player sees the Actor
erm, keksdose showed me some thing he did, if you had a thing in your fov, a message popped up on your screen, "you are looking at an archvile" for example.
might wanna ask him how he did it, might help you guys.
might wanna ask him how he did it, might help you guys.
Re: Check if player sees the Actor
You can use this example I made for Cutman a year or so ago as a starting point.
http://forum.zdoom.org/viewtopic.php?t= ... 91#p295191
http://forum.zdoom.org/viewtopic.php?t= ... 91#p295191
- Tormentor667
- Posts: 13556
- Joined: Wed Jul 16, 2003 3:52 am
- Preferred Pronouns: He/Him
- Operating System Version (Optional): Windows 11
- Graphics Processor: nVidia (Modern GZDoom)
- Location: Germany
- Contact:
Re: Check if player sees the Actor
Thanks, I will take a look at this and ask Keks as well.

