Home   Help Search Login Register  

Author Topic: Proper landingzone  (Read 4911 times)

0 Members and 1 Guest are viewing this topic.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Proper landingzone
« on: 30 May 2006, 15:26:29 »
Is there some way to actually get a chopper to choose a proper landingzone without defining it yourself in the editor? What I want is having a unit placed anywhere on a island, then create a chopper to pick the unit up and then drop him off somewhere else on the island. I've got everything sorted out except the landingzones. I don't want to place different LZs on the map in the editor so the chopper only lands at one of them. I want the chopper to land as close as possible to the unit, but not at a crappy LZ where it ends up crashing.

I've tried placing empty helipads at the position of the unit, but of course it didn't turn out well. The chopper didn't land in forest if the helipad was placed there, but it did land on trees if the helipad was placed close enough to a area where it could land or if it was placed in a area far from a forest but with shitloads of trees. I tried using only the land "get in" command, but that made the chopper sometimes land a few km from the unit, even though there were several places where it could pick him up, and the chopper still crashed in trees. Another problem is that the chopper got problems when trying to pick up a unit in a hill. The chopper won't find a flat area, and keeps bumping into the ground or hovering too high.

Anyway, I remeber the BAS MH47 having some sort of script that worked quite well. So I tried to find it, and I think I did. Problem is, it doesn't seem to actually be a solution, and it didn't work well when I tried it on a chopper in the editor, so I don't know why it keep working perfect when I use the MH47.

So, anybody got any ideas on how to make a chopper find a flat area to land and manage to keep away from trees? Of course, it also have to be able to land at a hilly area, just as long as the hill isn't too steep.

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: Proper landingzone
« Reply #1 on: 30 May 2006, 17:53:35 »
Yabbididuu, hmm. Once upon a time I had a thought about this very same issue. I never got into making a solution (didn't need it actually) but I will tell you what I had in mind. I was thinking of writing a script which places invisible objects at ground level on an area big enough for the chopper to land, and then check the height of the objects relative to sea level. That way we could get a elevation "matrice" from the area and figure out from it if it is suitable for the chopper to land on.

Have you checked that silola's Dynamic AI Creator doesn't include a function/script to do such checking? I recall it has some sort of checking routines for checking where to place waypoints but I don't remember right now if there is one suitable for this situation.

Also the script should check for objects to not be in the landing area or too close to it. I think this can get CPU heavy  :P (like DAC)

I think that controlling the chopper precisely into the suitable landing area would require a setPos loop to force the chopper go into the correct spot. That should be avoided though, if possible.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Proper landingzone
« Reply #2 on: 30 May 2006, 20:31:47 »
May be this helps:

Code: [Select]
;helidescend.sqs by Mandoble
;Quick landing of helicopters
;Emergency climb if something is hit during descend
;then choose alternative descending point
;
;Arguments:
;helicopter
;Below this altitude the helicopter cannot do emergency climbs (landed or almost)
;Altitude to reach in emergency climb before moving to another landing point
;script to be executed when landed. This script receives the helipcopter as argument.
;
;Example:
;Heli1 will descend quickly to 0m
;If climb rate in descension is positive above 2m, heli1 will climb quickly to 50m and move to
;a different nearby location before trying to land again.
;[heli1,2,50,""]exec"helidescend.sqs"

_heli         = _this select 0
_safetyminalt = _this select 1
_safetymaxalt = _this select 2
_script       = _this select 3
#descender
_dmg = damage _heli
~1
@(unitReady driver _heli)|| (damage _heli > 0.9)
?damage _heli > 0.9:exit
;Lo bajamos a nivel de suelo sobre su posición actual
driver _heli sideChat "Descending";
_heli flyInHeight 0
driver _heli doMove getPos _heli
~1
#verificarrebote
_vel = velocity _heli
_pos = getPos _heli
;Comprobación de choque contra algo (rebote)
;No desciende por un momento, pero está a más de 1m del suelo, luego choca
? ((_vel select 2 >= 0) && (_pos select 2 > _safetyminalt))||(damage _heli > _dmg): goto "elevarseymoverse"
?damage _heli > 0.9:exit
? getPos _heli select 2 < _safetyminalt: goto "landed"
~0.01
goto "verificarrebote"

#elevarseymoverse
;Por seguridad, le paramos donde está
driver _heli sideChat "We hit something, trying again";
doStop driver _heli
_heli flyInHeight _safetymaxalt
driver _heli doMove getPos _heli
~1
@(unitReady driver _heli) || (damage _heli > 0.9)
?damage _heli > 0.9:exit
_ang = random 360
_pos = [(_pos select 0)+101*sin(_ang),(_pos select 1)+101*cos(_ang),_pos select 2]
driver _heli doMove _pos
~1
@unitReady driver _heli
goto "descender"

#landed
driver _heli sideChat "landed";
_heli action ["engine off"]
? _script != "":[_heli]exec _script
exit

I use it for quick descends over forests or cities without helipads.
The choper will descend quickly, ensuring that its climb rate (descending) is always negative, at least, above indicated alt. If the climb rate goes 0 or positive before, something has been hit (a tree or whatever), then the choper stops, climbs to safety alt, moves 100m away and retries the descend. You may provide also a script to be executed when choper is correctly landed.

What this script does not check is how flat is the terrain below the choper.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Proper landingzone
« Reply #3 on: 30 May 2006, 21:43:25 »
Hmm, well, I've been thinking about the same way to detect if there is a too steep hill. I started working on a script now to check if there is a forest or not where the LZ is. Found a way to place a object in the center of a square (the square is as big as a square of forest) so I can place a game logic at the position where the forest would be if it's there. Only problem is, I didn't think of the fact that forests ain't defined in a config.cpp, so they got no classnames, and therefor I can't use nearestObject command to check for forest parts :-\

Anyone got a idea how I can check for forest in any other way? Or do anyone know how to get the nearestObject command to work without classname? :P

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: Proper landingzone
« Reply #4 on: 30 May 2006, 22:02:00 »
Check silola's DAC. It's not the most easiest code to read (not much comments IIRC) but there should be such a system somewhere in DAC to detect forests because that's what he was claiming in some introductory pdf IIRC that waypoints are not placed into forest for vehicles.

Offline Planck

  • Honoured
  • Former Staff
  • ****
  • I'm never wrong ....I'm just not always right !
Re: Proper landingzone
« Reply #5 on: 30 May 2006, 23:22:47 »
hmmmmmmmmmm...........forest models do indeed have classnames defined in the config.bin.


Quote

Model name                                      ClassName            Description
---------------                                       --------------           --------------

les ctverec pruchozi_T1                    "Forest001T1"        Forest Square
les ctverec pruchozi_T2                    "Forest001T2"        Forest Square
les trojuhelnik pruchozi                    "Forest002"            Forest Triangle
O\Tree\les_nw_ctver_pruhozi          "ForestRes01"        Forest Square
O\Tree\les_nw_ctver_pruhozi_T1    "ForestRes01T1"     Forest Square
O\Tree\les_nw_ctver_pruhozi_T2    "ForestRes01T2"     Forest Square
O\Tree\les_nw_jehl_T1                    "ForestRes02T1"     Forest Triangle
O\Tree\les_nw_jehl_T2                    "ForestRes02T2"     Forest Triangle
O\Tree\les_nw_jehl_trojuhelnik       "ForestRes03"         Forest Triangle
O\Tree\les_nw_trojuhelnik               "ForestRes02"         Forest Triangle
les_su_ctver_pruhozi                       "Forest003"             Forest Square
les_su_ctver_pruhozi_T1                 "Forest003T1"          Forest Square
les_su_ctver_pruhozi_T2                 "Forest003T2"          Forest Square
les_su_trojuhelnik                            "Forest004"             Forest Triangle


Planck
I know a little about a lot, and a lot about a little.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Proper landingzone
« Reply #6 on: 31 May 2006, 07:59:54 »
hmm, problem is I'm not gonna use this script in a mission on a official island, and the guy who made the unofficial island I'm using said the forests he is using doesn't have classnames :-\ Though now I can test if the script will work at all, so thanks ;)

And I've looked into DAC, and I think it will take me ages to figure out something from that script :P

Offline Baddo

  • Former Staff
  • ****
  • Reservist Jaeger
Re: Proper landingzone
« Reply #7 on: 31 May 2006, 17:59:19 »
And I've looked into DAC, and I think it will take me ages to figure out something from that script :P

Yes DAC files are obscure. A couple of comments here and there could do wonders... maybe the developer decided to remove comments from the release version. For example a header comment for every file to explain what exact functionalities the file has would be good for these kinds of massive script packs  ;)

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Proper landingzone
« Reply #8 on: 02 Jun 2006, 18:21:17 »
bah...I've had a look at the DAC scripts that's placing the waypoints, and I think I found the coding that's supposed to detect a forest, though it doesn't work :P TBH I have no idea wtf the guy has been scripting...way to advanced...

anyway, I've been messing around, and I just noticed something. If I use the nearestobject command to check a position (_obj = nearestobject [x,y,z]), and set the z-value to a bit over ground (like 5 or something, since it seems the z-value of a forest is more than 0), I do get the classname...but I also get the damn ID number... :P

So, if anybody got an idea how to use this information, then please post your suggestions ;)

If I could just get only the classname, then it would have been perfect, cause then I could run it against the classnames of the forests and then it should have worked...

gonna go have a look in the comref to see if there's something I may use from there :P

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Proper landingzone
« Reply #9 on: 02 Jun 2006, 22:01:22 »
To check how flat is a terrain you may use the following concept:
a grid of moving particles is created, a group moving W->E and a second group moving N->S, covering the selected area.
At fixed intervals, the particles triggers a script with their positions, so it is quite easy to calculate maximum and minimum height over terrain for horizontally moving and vertically moving particles. Note that particles, once moving, will not change their altitude over sea level.

The good point is that particles may be transparent, so you check flatness of terrain without any visible object/effect.

Code: [Select]
;checkflat by Mandoble
;Arguments:
; Center of the landing area
; Lengh to the square to check
; How may checks per square side
; Marks transparent true/false
;
;Example:
; 100m^2 area-check in squares of 10 by 10
; [getPos logic1, 100, 10, false]exec"checkflat.sqs"
;
_center = _this select 0
_lengh  = _this select 1
_cells  = _this select 2
_transp = _this select 3

_tr = 1
?_transp:_tr = 0
;Adjust max time to increase accuracy
_maxtime = 5.0
_d = _lengh / (_cells - 1)
_delay = 1.0 / (_cells * 2)

_time = _maxtime / _cells
zinith = true
zinitv = true
maxzhelilandh = 0.0
minzhelilandh = 0.0
maxzhelilandv = 0.0
minzhelilandv = 0.0

_i = 0
_xh = (_center select 0) - _lengh / 2.0
_yh = (_center select 1) + _lengh / 2.0
_xv = (_center select 0) - _lengh / 2.0
_yv = (_center select 1) + _lengh / 2.0
_velh = [_lengh /_maxtime, 0, 0]
_velv = [0, -_lengh /_maxtime,0]
#detectors
_pos = [_xh,_yh,0]
drop["cl_basic","","Billboard",_time,_maxtime,_pos,_velh,0,25.50,20,0,[1],[[1,1,1,_tr]],[1],0,0,"dropposh.sqs","dropposh.sqs",""]
_pos = [_xv,_yv,0]
drop["cl_basic","","Billboard",_time,_maxtime,_pos,_velv,0,25.50,20,0,[1],[[1,1,1,_tr]],[1],0,0,"dropposv.sqs","dropposv.sqs",""]
~_delay
_yh = _yh - _d
_xv = _xv + _d
_i = _i + 1
?_i < _cells:goto "detectors"
~_maxtime
~1
hint format["Max vertical dev W/E:%1, Max vertical dev N/S:%2", abs(maxzhelilandh - minzhelilandh), abs(maxzhelilandv - minzhelilandv)]
exit

Code: [Select]
;dropposv.sqs
_z = _this select 2
?zinitv:maxzhelilandv=_z;minzhelilandv=_z;zinitv=false;exit
?maxzhelilandv < _z:maxzhelilandv=_z
?minzhelilandv > _z:minzhelilandv=_z
exit

Code: [Select]
;dropposh.sqs
_z = _this select 2
?zinith:maxzhelilandh=_z;minzhelilandh=_z;zinith=false;exit
?maxzhelilandh < _z:maxzhelilandh=_z
?minzhelilandh > _z:minzhelilandh=_z
exit

EDIT:
added position check script also at end of life of particles.
« Last Edit: 03 Jun 2006, 01:56:40 by Mandoble »

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Proper landingzone
« Reply #10 on: 03 Jun 2006, 00:47:41 »
Thanks mate, works like a charm. Now I just gotta figure out a way to detect that damn forest :-\

Think I'm gonna send a mail to the DAC guy. Anyway, since the damn editors depot is gone, anyone got that array to string or string to array (or both if there is both :P) function? I could have some use of it.

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Proper landingzone
« Reply #11 on: 03 Jun 2006, 02:56:00 »
Well, probably you should be concerned about any solid obstable group higher than 2 or 3 meters, not only forests. Groups of large rocks, buildings, etc would be as dangerous as forests.

Just an idea. If you set a small object moving diagonally through a square NW->SE and keeping its velocity vector updated every second while checking its speed, existance and damage you may easily detect forests (large area obstacles). More than probably, the moving object will hit an obstacle and decelerate or get damaged.
Code: [Select]
_ulcorner = _this select 0
_speed = _this select 1
_flighttime = 3
_strnull == format["%1",objNull]
_vel = [_speed*sin(135),_speed*cos(135), 9]
_object = "BulletSingleW" camCreate [_ulcorner select 0,_ulcorner select 1, 3]
_object setDir 135
;_object switchCamera "EXTERNAL"
_timeini = time
_timeold = time
_object setVelocity _vel
~1
#check
?(_time - _timeold) > 1.0:_timeold = time;_object setVelocity _vel
?(time-_timeini)>_flighttime:goto "endcheckok"
?(speed _object) < ((_speed*3.6)/2.0):goto "endchecknook"
?(damage _object > 0.0)||(format["%1",_object] == _strnull):goto "endchecknook"
~0.1
goto "check"

#endcheckok
hint "SAFE AREA"
exit

#endchecknook
hint "LOOK FOR A BETTER AREA"
exit

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Proper landingzone
« Reply #12 on: 03 Jun 2006, 14:13:32 »
Thanks mate, it works quite well. Only problem may be that the bullet hits the ground if it checks a sloped area, but I figure if you run the check twice with the second bullet starting from the other corner and going the other way (so if one bullet hits something, but not the other, then it got to be a hill, since the second should have hit the same object.)

Offline Mandoble

  • Former Staff
  • ****
    • Grunt ONE and MandoMissile suite
Re: Proper landingzone
« Reply #13 on: 03 Jun 2006, 14:56:31 »
Hitting sloped area is an advantage, the bullet object will be null after the hit and before end of flighttime which means you hit something bad for the landing zone (a tree, a rock, a hause, a sloped terrain with a terrain elevation higher than 3 meters, etc). I used a bullet for the script example, which has a limitation: bullet object is automatically erased by OFP engine 3 seconds more of less after the object is created. This is the flighttime maximum limit.

Offline Garcia

  • Members
  • *
  • Leeds United is the best football team...EVER!
Re: Proper landingzone
« Reply #14 on: 03 Jun 2006, 16:06:19 »
Well, 3 seconds is more than enough, cause if I'm to give it a velocity that's low enough to not check a too large area in the 3 seconds, it falls to the ground it seems (at least it didn't work), so I had to turn the flighttime down to less than 1 second :P Gonna mess around a bit with the script to get it as close to perfection as possible.