Zlin Posted June 3, 2013 Posted June 3, 2013 (edited) Ok you script writing guru's, I have a question please. I have seen that it is possible to get the position of a moving unit, as in the Medevac lua script so nicely written by Ragnarda and also as seen in Decks' HueyDrop scripts. So, my question is... Is it possible to: When a AI ground unit is killed (unit alive = false) Get ground units current position build waypoint table for AI CAS heli (Huey Gunship or Cobra, etc) that includes: Waypoint 1 - takeoff from ramp/runway Waypoint 2 - location of unit that was just killed Waypoint 3 - landing back at home base And, at waypoint 2, have the CAS unit orbit until Medevac rescue pickup is completed. Once the rescued unit is picked up by Medevac, then have the CAS heli RTB I have the logic worked out in my head, just am not sure how to convert it into a lua script. It seems like it should be possible to do this. Any thoughts? **Update 06-4-13 Ok. So, I figured out how to get a ground unit's current position by using the unit:getPoint() which gives me the x,y,z coordinates I can also get the coordinates of the AI helicopter sitting on the ramp (parking hot) using the same technique as above. So, is there a way to build a route for the AI Heli using the coordinates I obtained using my unit:getPoint() commands for both the ground unit and the AI heli? local unitName = 'HMMWV' -- HMMWV is my ground unit local unit = Unit.getByName(unitName) local unitpos = unit:getPoint() -- current coords for HMMWV local heloName = 'HELO' -- HELO is my AH-64A that is sitting at an airport (parking hot) local helo = Unit.getByName(heloName) local helopos = helo:getPoint() -- coords for my HELO Edited June 4, 2013 by Zlin
Zlin Posted June 9, 2013 Author Posted June 9, 2013 Well, I think I have found my own solution. After looking at some scripts by Grimes, Deck, RagnarDa, and probably others that I can't remember. The attached mission has a huey on a heliport, with no waypoints, and one HMMWV on a road nearby. I created a script that obtains the current position of the huey, the current position of the HMMWV, then uses those positions to create waypoints for the huey to follow. The huey will fly to the HMMWV then fly back to wherever it took off from. Either unit can be moved anywhere on the map without having to change the script itself. My intended purpose is for when I'm flying medevac hueys only, but would like an AI gunship of some sort to also fly to a unit and provided CAS. If anyone has any (constructive) comments on the script, or if you know a better way of doing it, please let me know.route_to_unit_example.mizset_route_to_unit.lua
Recommended Posts