Home   Help Search Login Register  

Author Topic: Find Cover  (Read 1561 times)

0 Members and 1 Guest are viewing this topic.

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Find Cover
« on: 25 Feb 2009, 03:05:26 »
How do I use this?

Code: [Select]
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.
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Find Cover
« Reply #1 on: 25 Feb 2009, 04:03:42 »
Here is an example of the basic usage:

Code: [Select]
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 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].
try { return true; } finally { return false; }

Offline Sparticus76

  • Members
  • *
Re: Find Cover
« Reply #2 on: 25 Feb 2009, 07:20:32 »
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?

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Find Cover
« Reply #3 on: 25 Feb 2009, 12:42:31 »
Well, the last two parameters are said to be connected. To quote the corresponding BIKI article:

Quote
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).
« Last Edit: 25 Feb 2009, 15:19:47 by Worldeater »
try { return true; } finally { return false; }

Offline The-Architect

  • Former Staff
  • ****
  • Bite my shiny metal...
    • Bob's Un-official Flashpoint Page
Re: Find Cover
« Reply #4 on: 25 Feb 2009, 21:37:47 »
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?
James Andrew Wilkinson 1977 - 2005 R.I.P.
"If it ain't the friggin' incoming it's the friggin' outgoing. Only difference is who gets the friggin' grease, and that ain't no friggin' difference at all."

Offline Worldeater

  • Former Staff
  • ****
  • Suum cuique
Re: Find Cover
« Reply #5 on: 26 Feb 2009, 07:24:40 »
I've tried and failed miserably... :D

The basic usage is probably:
Code: [Select]
    _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).
« Last Edit: 26 Feb 2009, 07:27:40 by Worldeater »
try { return true; } finally { return false; }

Offline twisted

  • Members
  • *
  • I'm a llama!
Re: Find Cover
« Reply #6 on: 26 Feb 2009, 16:09:42 »
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.

Code: [Select]
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