charliereddog 9 Posted May 15, 2007 I'm trying to get a dynamic chopper script to pick up if the requested landing zone is on a building or not, and thereby set the scripted landing altitude to the correct level. However I don't know how to get anywhere with this. Any suggestions? Share this post Link to post Share on other sites
Spinor 0 Posted May 15, 2007 There is a command 'nearestBuilding object', but this would require the generation of a dummy object at the map click position. As an alternative you could try <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_obj=nearestObject[_xclick,_yclick,0,"Building"] If a building is found (check for !isNull _obj), a naive test whether the click is close, try for example <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[_x_click,_y_click] distance _obj<5 If you really want to get serious to exactly test whether the click is on the building, play around with the intersect command, something like <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">[_obj,"VIEW"] intersect [[_xclick,_yclick,200], [_xclick,_yclick,0]] but I have no idea whether "VIEW" is a proper LOD name to use. Share this post Link to post Share on other sites
charliereddog 9 Posted May 15, 2007 Spinor, thanks for that. When you say dummy obj, what do you mean? My code is already moving a marker to the position on the map, and a Invis H to the point on the ground. Would I be able to trigger the nearestobject from the H? Guess I'll need to readup on nearestobject. Share this post Link to post Share on other sites
charliereddog 9 Posted May 16, 2007 I've settled on using MyLandingH distance (Nearestobject "building")<3 to determine whether they've clicked on a building, so cheers for that help. Now all I need to do is work out the height of the building. Ideas? I note that the z pos of getpos doesn't seem to work on stacked objects from the wiki. I'm guessing that stacked objects in this context means a person on a building??? Anyone know whether invisible H's are subject to gravity in the same way as if you setpos a man at 10 he'll fall? I could thereby determine a safe alt that no building would be, and then drop an H onto it? (I know an invisible H isn't necessary the way I'm working, but it is already in the code and mission, and it's not exactly demanding on resources! Share this post Link to post Share on other sites
Spinor 0 Posted May 16, 2007 To determine the building height you might wanna try the new ArmA 'boundingBox' and 'modelToWorld' commands. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">boundingBox _building --> [_min,_max] returns two 3D vectors _min, _max defining the dimension of an object, relative to that object. <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_min = _building modelToWorld _min; _max = _building modelToWorld _max will transform these vectors to proper world coordinates. In general, this procedure should exactly determine the position and dimensions of an object. I am not abolutely sure about the mathematics, but the height of the building above ground level should be given by Quote[/b] ]_height=_max select 2 Share this post Link to post Share on other sites
Taurus 20 Posted May 16, 2007 Sweet Spinor I so wish this board had a "save this reply for later reference" function. Share this post Link to post Share on other sites
charliereddog 9 Posted May 16, 2007 If that works, and I'll try it in a second, you're a fecking genius Spinor. If it doesn't well, you probably are anyway! Share this post Link to post Share on other sites
charliereddog 9 Posted May 16, 2007 Yep, you are good. It works like a charm now. Only now I have a problem, in that domove or commandmove isn't positioning the chopper at the right position. It comes up short everytime?? Share this post Link to post Share on other sites
Spinor 0 Posted May 16, 2007 Short in height or short in x,y? I have not tried my suggestion yet, so please verify that it provides the correct position(s), e.g. by placing an object or dropping a particle effect. Share this post Link to post Share on other sites
charliereddog 9 Posted May 16, 2007 OK, I've got the following code. (Relevant snippet) <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">?(derh distance _building)>3:_landAlt=0;goto "notroof" ?(derh distance _building)<=3:goto "rooftop" hint format["%1",derh distance _building] #rooftop _box=boundingbox _building _max=_box select 1 _bdheight=_max select 2 _LandAlt= ceil(_bdheight/0.3048) I've hinted the _bdheight as well, and it comes out correctly. Thats how I knew I had to round up the figure. Short as in short [x,y] The hint in the code above is usually around 113, which with my really poor maths makes the ground distance to be around 110m short, and yet when you aim at the chopper, it says about 74m. Share this post Link to post Share on other sites
Spinor 0 Posted May 16, 2007 Quote[/b] ]The hint in the code above is usually around 113 I.e. you click on the building, and the reported distance is 113? Are you positive the correct building is recognized? Share this post Link to post Share on other sites
Taurus 20 Posted May 16, 2007 Charliereddog Please remember that the AI pilot is happy if he's "near" the spot you set out if you are letting him hover. Its only for some obscure reason that AI pilots must climb to 50(feet as we know it to be now ) and then very carefully place the heli on the waypoint position and then to fly to next wp i.e WP0 ,move, on Act: heli fly in 30 WP1, move, on Act: heli fly in 30 What will happen with heli altitude 30 35 40 45 50 <- waypoint 1 reached. 45 <- flying off to next 40 35 30 Share this post Link to post Share on other sites
charliereddog 9 Posted May 17, 2007 Spinor, I'm absolutely positive the correct building is being recognised, I've tested that bit extensively. I've also tested that the inv H I'm using as a dummy pos (remnant from the old script which will probably come out) is also being placed on the correct position. As I script, I always test out each bit in turn, and then go back and tidy up and consolidate each bit. Taurus, You're bang on. That's why I've shied away from using Waypoints at all, because of the strange up down behaviour at them, and the poor transition between directions of WP's. What I don't understand is if you order via the command menu a soldier to move to a particular position, does he stop short? IF so, then there's obviously something wrong with the engine. However, in OFP, I never experienced problems. I wonder if I change the chopper for a soldier, and order the move to derh, whether or not it will show a problem? At the moment, this is proving to be a real showstopper for my code, as it means that it won't land on a building, and isn't as accurate as the original Chopscript I'm modifying, although it will land much better, and IMO much more realistic. Share this post Link to post Share on other sites
mr.peanut 1 Posted June 7, 2007 <table border="0" align="center" width="95%" cellpadding="0" cellspacing="0"><tr><td>Code Sample </td></tr><tr><td id="CODE">_max = _box select 1 _max = _building modelToWorld _max _bdheight = _max select 2 Share this post Link to post Share on other sites
KeyCat 131 Posted June 7, 2007 Short as in short [x,y] The hint in the code above is usually around 113, which with my really poor maths makes the ground distance to be around 110m short, and yet when you aim at the chopper, it says about 74m. I bumbed into this issue a couple months ago and can confirm that AI helis stops short of given WP/cordinate. If anyone have any ideas for a "precision moveto script" please share. Haven't had much time to look into it lately... AI helicopters always short on moveto's/WP's /KC Share this post Link to post Share on other sites
mr.peanut 1 Posted June 8, 2007 MandoAir at www.ofpec.com Share this post Link to post Share on other sites
KeyCat 131 Posted June 8, 2007 Thanks for the pointer Peanut, will check it out! Also just remember that BAS Blackhawk for OFP had some precision movement for ladder extraction etc. Maybe that source can give some ideas to... /KC Share this post Link to post Share on other sites