-------------------------------------------------------
Preface:
As this is the first post of its kind, I would like to add some info here:
Here is a test, to see if this kind of approach would fare better than my last approaches.
In this kind of threads, we can suggest our features as a cooperative event in which, we want to develop a feature ourselves (as teamwork) and when done, offer it to Randy to see if he would accept them.
It would require a volunteer programmer that has enough time to spend on it and likes the idea enough to decide to join in, and other people can join in with their ideas, solutions, or any other comments, but please lets keep them organized enough to be able to complete the features.
I know at first, it may look a bit daunting, but after that, it would find its pace, and hopefully would become promising enough for Randy to decide to join in and help us along.
Oh, yes, I will update this first post to include our progression of ideas and actions.
-------------------------------------------------------
Info:
With this feature, we want to infuse some stealth factor into our levels, i.e. if you stay in the dark areas it would be harder for monsters to see you than light places, and the nearer you go to them the more likely it is that you would be seen.
-------------------------------------------------------
Result:
If this feature is fully implemented:
There would be no change in the gameplay for current available levels, unless the player specifies in an options menu to activate it for all the levels.
There would be a MAPINFO entry, which would let us activate the stealth factor for our levels.
When activated for a level, monsters would see other actors depending on their distance and the light level of the target actors sector, and their Sight power, and the targets Visibility factor.
There would be two additional DECORATE parameters for each actor: Sight and Visibility.
Finally, Adding two additional actor properties to help us manage this feature, like decreasing the players visibility factor as he uses the cloaking device.
Optional: When a monster is still unaware, its sight power is decreased by a factor.
Optional: When an actor is moving, its visibility factor is increased, depending on the movement speed.
Optional: When an actor is in its Full Bright frames, its visibility factor is temporarily doubled, like lost souls or firing frames of normal actors.
Optional: When an actor is shown fuzzily, its visibility factor is temporarily halved, like specters, or blur-spheres.
Optional: When an actor is shown transparent, its visibility factor is decreased accordingly.
Optional: Stealth monsters, are totally hidden, when not shown, (I dont know if it is hard to implement, or if it is such a good idea)
Optional: Try to include Caligari_87s suggested chance percent in the visibility formula.
Complexity: low to moderate, but with each optional feature, a bit more complex.
P.S. Any suggestions for additional features?
-------------------------------------------------------
Detail:
Thanks Graf for the info:
We need to change the function "P_CheckSight", which is the place that all the LOS (Line of Sight) calculations are done.
It is called before the actors See their target and wake up, and before they attempt an attack on the target, and before A_Refire would decide to cease fire for chain gunners and the like, and when we want to search for an actor.
The LOS check would decide if the actor can see its target, i.e. whether it is blocked from the sight by the geometry or not, and would give the result of TRUE if the target can be seen.
Our task would be to add the Visibility check after the LOS check to decide if the target is close enough to the actor to be seen.
For this reason we can add the visibility check inside the P_CheckSight function but would only check it if the target is not already blocked from the actors sight.
Thus, if the functions result is already FLASE, then the target is already blocked from the view, so there is nothing to do, thus we would branch out of the function.
But if the target is not blocked, i.e. function result is TRUE, we should perform the visibility check, and after that if we decide that the target should not be seen, then we change the functions result back to FALSE, and that would do the job.
The end result would be that, if the target is further than the visible range, it is hidden from the actors sight, just as if it is blocked by a wall or something.
This means that the monster would not be awakened, or would not start an attack toward you, or the chain gunner would stop shooting toward you as you back away into the darkness.
However, at first, we would have to prepare the required parameters for the formula.
-------------------------------------------------------
Step 1:
We need to add two integer fields to our actors for their Sight power, and Visibility factor.
They would by default initialize to 100, unless defined differently in the DECORATE lumps, which as Graf says, is an easy task, so no problem here.
We would also need to add a global boolean variable that would toggle this feature ON or OFF. This variable should be defined from within the MAPINFO lump, but for now, we can initialize it to TRUE for the developments sake.
-------------------------------------------------------
Step 2:
As Graf says, the P_CheckSight function is called from any place that the code wants a LOS calculation, and some of these calls may need the additional visibility check.
Thus, we can change the function and add another boolean parameter to it, to trigger the additional visibility check inside it, and it would automatically force the compiler to give an error on all the calls to the function, so it would be easy for us to find their places.
After that we can check the place to decide if it needs the additional check and if so we pass the function a TRUE, and otherwise a FALSE.
Inside the function, and after the original LOS check, we can check this boolean value to decide if the additional visibility check is required, and if so then we need another check as well, to see if the visibility check is actually enabled for the level or not.
For this reason, we need to check the variable initialized in the MAPINFO, and (or) it with the CVAR that would be defined in the option menus, and if the result is FALSE we branch out of the function.
After that, we can calculate this formula:
D = ( Sqrt(L*L*L) * S * V )/DF
D: maximum visible distance (in map grid units)
L: target sector light value (0-255)
S: actor sight factor
V: target visibility factor
DF: distance factor
DF should by default be probably something around 25000 for this formula, but the level designers should be able to change it via the MAPINFO command, (more on that later), thus, we can initialize it to 25000 by default, but it might change later via MAPINFO.
After calculating the maximum visible distance of the target actor, we can calculate the distance between the two actors, (in map grid units), and check if it is more than the maximum visible distance, and if so then the target is not visible to the monster, so we would change the result back to FALSE.
P.S. Any suggestion for a better formula is gladly accepted.
-------------------------------------------------------
Step 3:
The next step would be:
Add a new CVAR to trigger this check for all the current maps.
Add the options menu-item to let the users toggle this CVAR.
Add this CVAR to list of CVARs that are saved to the configuration file, if it is not automatically done.
After this stage, we can test our newborn feature in any current level.
-------------------------------------------------------
Step 4:
Add two new actor properties to the current list, like: APROP_Sight and APROP_Visibility.
-------------------------------------------------------
The next steps are currently under construction.

-------------------------------------------------------
Action log:
OK, now is the critical part:
Is there any volunteer programmer who likes to join in, so that we can develop this new feature?
I am sure that it is worth the effort, and the time spent on it, would not be a wasted time.
I know at first, it may look a bit daunting, but after that, it would find its pace, and hopefully would become promising enough for Randy to decide to join in and help us along.
Hey pals, this is not that complicated, and would not take a lot of your time. Dont you want to say I added stealth factor to ZDoom.?

Thanks in advance.