Feature #2016

Re-implement script command "findCover"

Added by Solus about 6 years ago. Updated almost 2 years ago.

Status:Assigned Start date:06/11/2009
Priority:Normal Due date:
Assignee:- % Done:

0%

Category:AI Issues
Target version:-
Affected ArmA II version: First affected ArmA II version:
Reproduced by another DH user:No Single / Multi Player?:
I am using some Mods:No BIForumURL:
I am using: NGUrl:
Reproducible for you:No WIKIurl:
Related to content of DLC:

Description

The AI commands for finding cover don't work.

RPT says:
"MicroAI: Command findCover not implemented (unit name)" and "MicroAI: Command setHideBehind not implemented (unit name)".

To test:

Try commanding a squad of AI's to take cover. Select all people (~ key), press 1 for the move menu, then 8 to command them to "take cover" and they will go into a wedge formation facing position [0,0,0]. This happens even when there is an enemy known about and visible. What should happen is like in ArmA 1 where the AIs will take cover behind map objects like trees, bushes, and buildings when told to take cover.

Also the findcover and sethidebehind commands don't work. When using them properly in ArmA 1 they work correctly.

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

find_cover.Chernarus.7z (1.8 kB) kju, 02/18/2012 17:09


Related issues

related to ARMA2 Community Issue Tracker - Feature #2557: AI Movement not Suppressable Assigned 07/04/2009

History

Updated by kju about 6 years ago

  • Status changed from New to Assigned
  • Affected ArmA II version changed from 1.01.57751 to 1.02.58134

Updated by kju about 6 years ago

  • Subject changed from Cover finding AI disabled to Cover finding AI disabled: "MicroAI: Command findCover not implemented (unit name)" and "MicroAI: Command setHideBehind not implemented (unit name)"

Updated by alef almost 6 years ago

  • Due date set to 09/28/2009

Updated by Fireball almost 6 years ago

  • Due date changed from 09/28/2009 to 08/24/2009
  • Status changed from Assigned to Resolved
  • Target version set to 1.03.58627

Updated by Xeno almost 6 years ago

From 1.03 RPT:

MicroAI: Command findCover not implemented (B 1-1-B:9)

So not resolved!

Updated by Xeno almost 6 years ago

Same for setHideBehind:

MicroAI: Command setHideBehind not implemented (B 1-1-B:13)

Updated by alef almost 6 years ago

  • Due date changed from 08/24/2009 to 11/16/2009
  • Status changed from Resolved to Assigned
  • Target version deleted (1.03.58627)
  • Affected ArmA II version changed from 1.02.58134 to 1.03.58627

Updated by Solus almost 6 years ago

To test, run:

AI findCover [getpos player,(vehicle player) getHideFrom (vehicle (player findNearestEnemy player)),100]

Then check the ArmA2.RPT

Updated by Dwarden almost 6 years ago

  • Assignee set to Dwarden

Updated by Solus almost 6 years ago

To test, set up an AI rifleman named "AI_guy", and an enemy tank facing the other direction and run:

AI_guy FindCover [getpos AI_guy,(vehicle AI_guy) getHideFrom (vehicle (AI_guy findNearestEnemy AI_guy)),100];

The command returns a null object.

Then check the arma2.RPT:

MicroAI: Command findCover not implemented (AI_guy)

Updated by Dwarden almost 6 years ago

  • Target version set to 1.05 BETA
  • Reproduced by another DH user set to No

Updated by Dwarden almost 6 years ago

  • Status changed from Assigned to Feedback

Updated by Dwarden almost 6 years ago

  • Priority changed from Normal to Low

Updated by Xeno almost 6 years ago

Latest beta 59323:

MicroAI: Command findCover not implemented (abc)
MicroAI: Command setHideBehind not implemented (abc)

Just place a playable unit and another unit (name it abc) in the editor.

trigger, condition true, on act:
bla = abc findCover [position abc, position player, 100];abc setHideBehind [position player, position player]

Updated by Fireball almost 6 years ago

  • Status changed from Feedback to Assigned

Thanks Xeno - if you could attach that mission, it would be most formidable.

Updated by Fireball almost 6 years ago

  • Affected ArmA II version changed from 1.03.58627 to 1.04.59026

Updated by fabrizioT almost 6 years ago

I can confirm what Xeno said.
Both "findCover" and "setHideBehind" are still not working in build 59323-
.RPT file shows the error.

Updated by Suma almost 6 years ago

A simple fix of "findCover" and "setHideBehind" is not possible, because a cover is no longer an object, it is a position instead (there are multiple cover points connected with one object).

Updated by Solus almost 6 years ago

Thank you for the explanation Suma! So it looks like this is indeed just a part of the new features, not a bug.

If these commands are not used anymore, are there other ones that can make up for their functionality?

Is there a way to find the nearest object for hiding? The findcover command would return the nearest object of any kind, even the bushes and small things. I don't think any of the other commands can find these things the same way.

Is there a way to get these new cover positions from an object?

Updated by Vic almost 6 years ago

@Solus: From what I've seen, we have no scripting commands, only functions in native FSMs which are a blackbox, probably hardcoded in engine. Equivalents for "findCover" and "setHideBehind" would be, from what I can figure out from the CfgFSM in characters.pbo's config, "searchPath" and "formationHideInCover". You'd probably have to write your own native FSM to use them. A small example can be found in HeliJunkie's Wiki Sandbox

Updated by Solus almost 6 years ago

I found that (nearestObjects [position, [], 100]) will return all of the objects, although sorting them can be difficult but it works for finding cover. And the default AI is not too bad at hiding behind the objects once they get near them. So this should be sufficient although not exactly optimal for cover finding.

Updated by Fireball almost 6 years ago

  • Reproduced by another DH user changed from No to Yes

Well, while the script commands are non-functional (by design), I think what the original poster described, that issuing order 1-8 (Take Cover) does work already for a while and no errors show up in RPT.

Should this ticket be kept open until the script commands are removed (maybe replaced) and documentation fixed?

Updated by fabrizioT over 5 years ago

Hmm ... how are we actually supposed to code AI taking cover behind objects ?
We can simply "domove" units to some "nearobjects" location and engine will take care of assigning a proper cover "position" ?
I doubt that ...

Updated by kju over 5 years ago

  • Target version changed from 1.05 BETA to Upcoming version

Updated by Solus over 5 years ago

That's what it looks like. It seems to work somewhat effectively, at least as well as in A1, although it's much more of a hassle.

Thanks for the info Vic, I looked into it and to me it seems like it's too complicated and of limited value to do the native FSM stuff for now.

Updated by Fireball over 5 years ago

  • Status changed from Assigned to Resolved

Can you make that a new Feature request please? I think this ticket, as a bug ticket, does not longer suit your needs.

Updated by kju over 5 years ago

  • Due date deleted (11/16/2009)
  • Assignee deleted (Dwarden)

Updated by kju over 5 years ago

  • Status changed from Resolved to Closed
  • Target version changed from Upcoming version to 1.05.62017

Updated by Fireball over 4 years ago

  • Tracker changed from Bug to Feature
  • Subject changed from Cover finding AI disabled: "MicroAI: Command findCover not implemented (unit name)" and "MicroAI: Command setHideBehind not implemented (unit name)" to Re-implement script command "findCover"
  • Status changed from Closed to Assigned
  • Target version deleted (1.05.62017)
  • Affected ArmA II version deleted (1.04.59026)
  • Reproduced by another DH user changed from Yes to No

Updated by Fireball over 4 years ago

  • Priority changed from Low to Normal

Updated by maturin over 4 years ago

My two cents: Let the Find Cover command override other behavior when you really need your guys behind objects, but stationary.
http://forums.bistudio.com/showthread.php?t=108752

Updated by kju over 3 years ago

Here is a nice script that simulates it well I think.
fabrizioT or mr-g.c. posted it in the BIF forum if I recall correctly.

code:

fnc_find_cover=
{

    private ["_unit","_cover","_dist","_objects"];
    _unit = _this select 0;

    _cover = [];
    _dist = 50;

    _unit disableAI "FSM";

    _objects = (nearestObjects [(position _unit),[],_dist ]) - ((position _unit) nearObjects _dist) - ((position _unit) nearRoads _dist);

    {
        _bbox = boundingBox _x;

        _dx = ((_bbox select 1) select 0) - ((_bbox select 0) select 0);
        _dy = ((_bbox select 1) select 1) - ((_bbox select 0) select 1);
        _dz = ((_bbox select 1) select 2) - ((_bbox select 0) select 2);

        if (!(_x isKindOf "Man")) then
        {
            if (((getPosATL _x) select 2) < 0.2) then
            {
                if ((_dz > 1.5) && (_dz < 20) && ((_dx min _dy) > 0.3) && ((_dx max _dy) > 1.5)) then
                {
                    _cover set [count _cover,_x];
                };
            };
        };
    } forEach _objects;

    if ((count _cover) > 0) then
    {
        [_unit,(_cover select (random (count _cover - 1)))] spawn
        {
            private ["_unit","_cover","_coverPosition"];
            _unit = _this select 0;
            _cover = _this select 1;

            _coverPosition = position _cover;

            player globalChat format["%1 go to cover: %2 (%3)",_unit,_cover,_coverPosition];

            _unit forceSpeed -1;
            _unit doMove _coverPosition;

            sleep 1;

            waitUntil {unitReady _unit};

            _unit forceSpeed -1;
            _unit doMove position _cover;

            sleep 1;

            waitUntil {unitReady _unit};

            doStop _unit;
            _unit setUnitPos "down";

            player globalChat format["%1 cover reached",_unit];
        }
    };
};

Updated by fabrizioT about 3 years ago

Above code is from here: #28311

Also available in: Atom PDF