OFPEC Forum
Editors Depot - Mission Editing and Scripting => ArmA - Editing/Scripting General => Topic started by: The-Architect on 25 Feb 2009, 03:05:26
-
How do I use this?
object findCover [position, hidePosition, maxDist, minDist, visibilityPosition, ignoreObject]
Specifically what do I need to put for the following?
Position, HidePosition (Object or Object ID?), maxdist, mindist, visibilityposition, ignoreobject.
-
Here is an example of the basic usage:
object = lamb findCover [getPos lamb, getPos wolf, 50];
This will return an object within 50m where the lamb can hide behind from the wolf. The function will return objNull (http://community.bistudio.com/wiki/objNull) if no suitable object was found [1].
I can't tell much about the last three parameters except that they are optional. Maybe someone else knows more about them.
HTH
[1] This case can be detected by comparing the position of the returned object with [0,0,0].
-
Just a hunch, but I'd assume it'd be this:
Max distance - look for a distance not more than this far away
min distance - look for a distance between max distance and this distance for the object to hide behind
visibilityPosition - dunno about this one, maybe a position where the unit can hide, but still see the target like a low wall or shrub. This may be 0 = no visibility to 1 = full visiblity
ignoreObject - if this object is detected within the range given, do not hide behind it
Am I just stating the blatently obvious here?
-
Well, the last two parameters are said to be connected. To quote the corresponding BIKI article (http://community.bistudio.com/wiki/findCover):
visibilityPosition: Array - format Position (Optional) used to select cover that unit can see in that direction from
ignoreObject: Object (Optional) Ignore this object in visibility check
This description leads to the assumption that if visibilityPosition is the same position as the threat (the wolf in the example above) it will select a cover where the threat can still be seen. If this is true then another use of it would be so set visibilityPosition to the position of the own group leader (so his hand signals could be seen - if there where any in ArmA).
-
I had a tinker but I'm getting error messages.
Could one of you guys have a go at getting a guy to hide and post the code you used?
-
I've tried and failed miserably... :D
The basic usage is probably:
_enemy = _unit findNearestEnemy (position _unit);
_posThreat = _unit getHideFrom _enemy;
_cover = _unit findCover [(position _unit), _posThreat, 20];
_unit setHideBehind [_cover, _posThreat];
So the findCover command does not make a unit actually do anything. All it does is to find a suitable location to hide from a given threat.
If you're serious about this topic and want to dig deeper then take a look at the formation.fsm in your characters.pbo (that's where I got the above "knowledge" from).
-
taken from Rommels script help to me. he used findcover to find the position to hide at (in this case 43m away from the units current position) and then simply used commandmove to move the AI there. worked like a charm.
bool = _unit findCover [getPos _unit, getPos _unit, 43];
_unit commandMove getPos _bool;
I usually use a 2nd number after the 43 to ensure the AI choose cover not to close to where they are now.
bool = _unit findCover [getPos _unit, getPos _unit, 43,20]; now the AI will look for cover that's less than 43m away but more than 20m away.
absolutley no idea what the other options do but they sound interesting. Object = object findCover [position, hidePosition, maxDist, minDist, visibilityPosition, ignoreObject] http://community.bistudio.com/wiki/findCover (http://community.bistudio.com/wiki/findCover)