Results 1 to 10 of 10

Thread: AI visibility value

  1. #1

    AI visibility value

    Hi!

    I am looking for a way to find out how good visibility AI (and player) have in "current ciscumstances". What I want to do is reveal (script command "Reveal") player group to all enemy units within visual distance, but that distance is a variable distance, depending on current ligth/darkness and weather conditions. Is there an easy way to do that through some fancy script command, or do I have to test all possible conditions (different time of days, fog and rain) to se how good visibility there is?

  2. #2
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    well, there is the knowsabout command, wich you could use to determine if you want to fully reveal the group.
    My scripts:
    Spoiler:

    what to do when posting any kind of code dammit!!

    Any new mission editor or scripter in Arma2 should have read Mr Murrays Editing Guide Deluxe at least once, it still applies for A2 even though it was made for Armed Assault.

  3. #3
    Sergeant
    Join Date
    Nov 25 2010
    Location
    Örebro, Sweden
    Posts
    130
    Author of the Thread
    Thing is, I want to manually determine if the enemy units can see the player group before I reveal player group to them. Right now, upon detection, I reveal player group to all enemy groups within 350 meters. I want enemies to react, like they heard the sound, even if they were not in the group that actually detected the players. My solution works fine in daytime and clear weather, but as you understand it works badly in conditions of bad visibility (like heavy fog). So in my script, in some way, I need to know how far the visibility is. The game does this all the time, so I wonder if there is a way for me to get that "visibility value" too?

  4. #4
    Master Gunnery Sergeant Wiggum's Avatar
    Join Date
    Jun 17 2009
    Location
    Germany
    Posts
    1,138

    Lightbulb

    You could just do a simple knowsAbout check.

    PHP Code:
    _kv enemygroup knowsAbout (leader mygroup);

    if (
    _kv >= 1.5then {
    enemygroup reveal [(leader mygroup), 4];
    }; 
    The knowledge value can be 0-4, i think you need to try out differend values to get a optimal result.
    Visibility and other stuff should already affect knowsAbout.

  5. #5
    There's also aimedAtTarget which I've used in the past but right now seems to be messed up or I'm just not doing it right.

    http://community.bistudio.com/wiki/aimedAtTarget

  6. #6
    Sergeant
    Join Date
    Nov 25 2010
    Location
    Örebro, Sweden
    Posts
    130
    Author of the Thread
    Thanx for the replies! Please correct me if I'm wrong, but if a unit is 100 m away from me and facing the other direction, isn't its knowsAbout value 0 until he turns around and detects me? It's units like that I would like to reveal myself to immideately. And if its knowsAbout is 0 I cannot use knowsAbout. I want to find out if he potentially *can* detect me, not if he has already.

  7. #7
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    if its simply a distance you want to check for and reveal:
    Code:
    while {true} do {
    	{
    		_unit = _x;
    		if (alive _x AND side (group _x) == east) then {
    			{
    				if ({(_unit distance (vehicle _x)) < 100 AND side _x == west) then {_unit reveal [_x, 4]};
    			} foreach allUnits;
    		};
    	} foreach allUnits
    	sleep 5;
    };
    code will reveal all west units to all east units within 100 meter every 5 seconds.

  8. #8
    Sergeant
    Join Date
    Nov 25 2010
    Location
    Örebro, Sweden
    Posts
    130
    Author of the Thread
    I simply want "visibility distance". How far can you (or any unit) see in current weather and daytime conditions? The game itself must know that, so is there any script command I can use to fetch that value?

    Demonized: In your example, it's your "100" meters I want instead to be "visibility range". (So it will be say 50 meters in really heavy fog, or 300 meters in not so heavy fog.

    But I will try knowsAbout since you recommend it, I havn't tried it yet. Maybe it doesn't work the way I have assumed this far. Can a unit know anything about another unit without having seen it?

  9. #9
    Warrant Officer Demonized's Avatar
    Join Date
    Nov 16 2010
    Location
    Back from afk 2013
    Posts
    2,614
    Knowsabout 0, means unit have not seen or heard the unit.
    More than 0 means that its detected sound/sight of something.
    Above 1 means detected object, unsure what specific kind or side, but even in daylight will a unit standing with its back to you knowsabout you 0, so you will you if i sneak up behind you.

    viewDistance is the command to check your ingame viewdistance, but that is generally at 1500 to 10000, wich you can potentially spot something. you just needs to define yourself what range is considered spottable.

    you can check daytime and fogaswell i think, but daytime readings are useless if precision is desired as 04:00 in winter is not same as in summer (dark night/bright morning).

    this is a function created by CarlGustaffa wich calculates it somewhat but again, not 100% reliable:

    Spoiler:

  10. #10
    I remember someone made a LOS check function that sees if a unit has los to something (considers terrain obstruction and objects) you may want to look into that. But as far as I know, there isnt really a way of changing the spotting distance directly in terms of metres.

    you can however, try using setskill array, changing spottime and spotdistance:
    Code:
    AI setSkill ["spotDistance", 0.1] AI setSkill ["spotTime", 0.2]
    it takes a value from 0 to 1, poor to amazing respectively.

    that might be good for very foggy and no visibility.

    IF you want this to be something dynamic (as in always adjust ai spotting when weather changes) you would need to write a script that checks current forecast and fog levels, and adjust the spotting in levels of fog density, etc. Use the above function demonized posted to get a rough estimate of nighttime and adjust spotting if its nighttime.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •