Home   Help Search Login Register  

Author Topic: Tank or Vehicle in Hull Down  (Read 1922 times)

0 Members and 1 Guest are viewing this topic.

Offline Sparticus76

  • Members
  • *
Tank or Vehicle in Hull Down
« on: 12 Mar 2009, 04:38:56 »
Is it possible to move a vehicle forward until the gunner can see a target or pos, but the driver of the vehicle can not, therefore putting it into a hull down position?

Edit: Am I unclear or is it just not possible without using pre-placed markers to "domove" units to?
« Last Edit: 15 Mar 2009, 10:45:57 by Sparticus76 »

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Tank or Vehicle in Hull Down
« Reply #1 on: 16 Mar 2009, 11:31:51 »
This is not a trivial issue I'm afraid and can be broken down:
* Detect when gunner has line-of-sight to a position.
* Detect when in a hull-down position with respect to that position (as you say, a reasonable way to do this would be to detect when the driver does not have line-of-sight).

The problem with this approach is that there is no easy way to determine if someone can see something. There is also no way to work out arbitrary LOS in ArmA (is the path A->B clear of obstacles?)! You also can't work out exactly where someone's "eye" is, but you can make a good enough approximation, especially for this purpose.

* Using an addon, fire an invisible, infinitely fast, no-damage bullet and see where it hits something. Still has issues, but will detect all objects in ArmA.
* Using scripts, check ground height at each position along the path from A->B. You can do this by creating a game-logic at position A and pointing its vectorDir directly at B. Take heights at positions along that path with modelToWorld, then when _logic modelToWorld [0, _i, 0] < 0 (i.e. height above ground level) is negative, then you have hit the ground, so LOS is blocked. This will ignore buildings, folliage, people, etc, only taking into account the terrain.
    - Alternatively, you could move the logic at a constant 10000m ASL, but along this path (path x,y component, but constant z), and check the height AGL (getPos) from that position in comparison to the ASL height of the calculated path. If the height AGL of the logic was greater than the difference in ASL heights, then you have "hit" ground. This technique would then take into account buildings as well as terrain, even if the other objects were still ignored.

Searching for line of sight might find you some solutions.
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Wolfrug

  • Addons Depot
  • Former Staff
  • ****
  • Official OFPEC Old Timer
Re: Tank or Vehicle in Hull Down
« Reply #2 on: 16 Mar 2009, 12:18:22 »
Spooner is too modest to advertise his own SPON LOS, which does what he's talking about above (LOS, with consideration to buildings and units).  ;)

That alone however does not solve the problem, especially as different tank models would have different driver positions and different hull sizes (and different movement axises for their guns - e.g. the damned T-72 can't aim down far enough for a hull down position to be really viable unless expertly executed). But if you could make this work, even provisionally, then that'd be pretty awesome.

Wolfrug out.
"When 900 years YOU reach, look as good you will not!"

Offline Sparticus76

  • Members
  • *
Re: Tank or Vehicle in Hull Down
« Reply #3 on: 17 Mar 2009, 08:16:22 »
Thankyou gents

Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Tank or Vehicle in Hull Down
« Reply #4 on: 17 Mar 2009, 20:26:11 »
SPON_LOS is one possibility, but it really should be called "LookingAt" since what it does is tells you what the player is looking at, so it would need to be rewritten to work for arbitrary LOS calculations. I have also largely rewritten it for SPON Recognise, so it is a bit out of date (as a separate release).
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)

Offline Sparticus76

  • Members
  • *
Re: Tank or Vehicle in Hull Down
« Reply #5 on: 23 Mar 2009, 09:15:02 »
Code: [Select]
I cant get my head around that script of yours...

[codefor [{ _i = 0 }, { _i < _maxRange }, { _i = _i + _bigStep }] do
{
if ((positionCameraToWorld [0, 0, _i]) select 2 <= 0) exitWith
{
for [{ _j = _i - _bigStep }, { _j <= _i }, { _j = _j + _smallStep }] do
{
if ((positionCameraToWorld [0, 0, _j]) select 2 <= 0) exitWith
{
_viewableRange = _j;
};
};
};
};

What does that do?

Code: [Select]
if ((positionCameraToWorld [0, 0, _j]) select 2
Isn't that a Z co-ordinate, as in up or down?



Offline Spooner

  • Members
  • *
  • Mostly useless
    • Community Base Addons
Re: Tank or Vehicle in Hull Down
« Reply #6 on: 23 Mar 2009, 12:43:47 »
Here, I am detecting the ground. I am checking positions along the line the player's camera is looking using positionCameraToWorld. When the Z position of a point on that line is < 0, then I've detected terrain. Since this distance could be long, I first go through checking points that are spaced out (_bigStep) and then, once I've found the terrain, I recheck points between the last and current position that are close together (_smallStep). This gives fine granularity of range without having to check every few cm on the path.

You, however, don't want to use the player's view. You want something very similar, but first place a gamelogic in the position of the "eye" and point it (setVectorDir) in the direction you want to look. You would then want to check its line of "sight" using:
Code: [Select]
_logic modelToWorld [0, 0, _i];
rather than
Code: [Select]
positionCameraToWorld [0, 0, _i];
[Arma 2] CBA: Community Base Addons
[Arma 1] SPON Core (including links to my other scripts)