Visual scan: Difference between revisions

From The DarkMod Wiki
Jump to navigationJump to search
Angua (talk | contribs)
No edit summary
No edit summary
 
(7 intermediate revisions by 2 users not shown)
Line 5: Line 5:
The base probability, '''clampVal''' is calculated from the light gem value itself. The value should represent the probability to be seen within half a second (so with a clampVal of 0.1, you would be spotted approximately once in 5 seconds).
The base probability, '''clampVal''' is calculated from the light gem value itself. The value should represent the probability to be seen within half a second (so with a clampVal of 0.1, you would be spotted approximately once in 5 seconds).
I used a polynomial function for this, since the AI were not sensitive enough with a linear increase.  
I used a polynomial function for this, since the AI were not sensitive enough with a linear increase.  
Here is it (for the other math freaks):
clampVal = -0.03 + 0.03 * lgem + 1 * 10^-3 * lgem^2 + 1.3 * 10^-4 * lgem^3 - 1.1 * 10^-5 * lgem^4 + 1.892 * 10^-7 * lgem^5
(The grey curve shows the probability before tweaking.)
[[Image:clamp.jpg]]


The clampVal is scaled with the AI's visual acuity.
The clampVal is scaled with the AI's visual acuity.


Within the '''clampDistance''', the probability stays constant, and it decreases linearly towards zero at the '''saveDistance'''. Both distances are scaled with the clampVal, so that you have to be really close to the AI in ambient light to be spotted at all. The maximum values for full brightness are given by the Cvars "tdm_ai_sightmin" (default: 11 meters) and "tdm_ai_sightmax" (default: 60 m).
Within the '''clampDistance''', the probability stays constant, and it decreases linearly towards zero at the '''safeDistance'''. Both distances are scaled with the clampVal, so that you have to be really close to the AI in ambient light to be spotted at all. The maximum values for full brightness are given by the Cvars "tdm_ai_sightmin" (default: 11 meters) and "tdm_ai_sightmax" (default: 60 m).


'''returnVal''' is the resulting probability depending on the player distance. With this probability, a random check is performed each frame whether the AI has spotted the player. If this succeeds, the AI has caught a glance of the player and becomes alerted.
'''returnVal''' is the resulting probability depending on the player distance. With this probability, a random check is performed each frame whether the AI has spotted the player. If this succeeds, the AI has caught a glance of the player and becomes alerted.


The alert increase also depends on lightgem brightness, player distance and acuity and is currently between 4 and 10 units (currently hard coded, but will become a spawnarg soon). This means, that an idle AI should go to observant for a single low alert, but into searching if the player was spotted in bright light.
The alert increase also depends on lightgem brightness, player distance and acuity and is currently between 4 and 13 units (currently hard coded, but will become a spawnarg soon). This means, that an idle AI should go to observant for a single low alert, but into searching if the player was spotted in bright light.
 
 
For debugging, you can use the [[Cvars|Cvar]]
 
'''tdm_ai_visdist_show 1'''
 
 




{{ai}} {{coding}}
{{ai}} {{sdk}}

Latest revision as of 13:48, 12 April 2019

This article describes the routine used to detect whether the AI can see the player, and to alert it if this is the case.

Each frame, a probability check depending on lightgem brightness, player distance and the AI's visual acuity is used to detect whether the AI has spotted the player.

The base probability, clampVal is calculated from the light gem value itself. The value should represent the probability to be seen within half a second (so with a clampVal of 0.1, you would be spotted approximately once in 5 seconds). I used a polynomial function for this, since the AI were not sensitive enough with a linear increase. Here is it (for the other math freaks):

clampVal = -0.03 + 0.03 * lgem + 1 * 10^-3 * lgem^2 + 1.3 * 10^-4 * lgem^3 - 1.1 * 10^-5 * lgem^4 + 1.892 * 10^-7 * lgem^5

(The grey curve shows the probability before tweaking.)

The clampVal is scaled with the AI's visual acuity.

Within the clampDistance, the probability stays constant, and it decreases linearly towards zero at the safeDistance. Both distances are scaled with the clampVal, so that you have to be really close to the AI in ambient light to be spotted at all. The maximum values for full brightness are given by the Cvars "tdm_ai_sightmin" (default: 11 meters) and "tdm_ai_sightmax" (default: 60 m).

returnVal is the resulting probability depending on the player distance. With this probability, a random check is performed each frame whether the AI has spotted the player. If this succeeds, the AI has caught a glance of the player and becomes alerted.

The alert increase also depends on lightgem brightness, player distance and acuity and is currently between 4 and 13 units (currently hard coded, but will become a spawnarg soon). This means, that an idle AI should go to observant for a single low alert, but into searching if the player was spotted in bright light.


For debugging, you can use the Cvar

tdm_ai_visdist_show 1