Jump to content

MIST teleport on flat area


horus0129
 Share

Recommended Posts

Hi, MIST teleport function question here.

 

I want to teleport ground unit groups on flat points in specific zone.

 

I've found some terrain related mist functions like mist.isTerrainValid and mist.terrainHeightDiff but no working examples yet.

 

Could someone show me how to use these scripts properly?

 

Here is simple preset

group name : test

zone name : test zone

 

 

Thanks in advance.

Link to comment
Share on other sites

Both of those functions are used to check if a generated point would be suitable for your needs. For instance isTerrainvalid simply checks to see if the point on the ground matches the type of point needed for a unit. The scripting engine actually allows you to place AI ground units on the black sea if you give it such a coordinate. The function terrainHeightDiff operates under the same principle, but it just tries to find a relatively flat piece of land. If the area you are checking is mountainous terrain it might not find a "flat" area.

 

 

The function mist.teleportInZone() does use the isTerrainValid check as part of its code. So if you are using a trigger zone, and know its in a relatively flat area, you can just use that function and the script will figure out the type of terrain that needs to be checked depending on the group type.

 

mist.teleportInZone('test', 'test zone') might be all you need. :)

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

Both of those functions are used to check if a generated point would be suitable for your needs. For instance isTerrainvalid simply checks to see if the point on the ground matches the type of point needed for a unit. The scripting engine actually allows you to place AI ground units on the black sea if you give it such a coordinate. The function terrainHeightDiff operates under the same principle, but it just tries to find a relatively flat piece of land. If the area you are checking is mountainous terrain it might not find a "flat" area.

 

 

The function mist.teleportInZone() does use the isTerrainValid check as part of its code. So if you are using a trigger zone, and know its in a relatively flat area, you can just use that function and the script will figure out the type of terrain that needs to be checked depending on the group type.

 

mist.teleportInZone('test', 'test zone') might be all you need. :)

 

Thanks Grimes, as always!

 

Sometimes the units are spawned on a steep area when teleportInZone is activated because I can't check every single point if it's how much flat. So I'm thinking It would be good to combine terrainHeightDiff and teleportInZone(loop checking until the area is flat, if it's flat then teleport the group), but how? The problem is that I have no idea what does the usage example codes in hoggit doc mean...:cry: I'm not a programmer. Could you tell me simple working example?

Link to comment
Share on other sites

Sometimes the units are spawned on a steep area when teleportInZone is activated because I can't check every single point if it's how much flat. So I'm thinking It would be good to combine terrainHeightDiff and teleportInZone(loop checking until the area is flat, if it's flat then teleport the group), but how? The problem is that I have no idea what does the usage example codes in hoggit doc mean...:cry: I'm not a programmer. Could you tell me simple working example?

 

I'll look into adding the terrainHeightDiff check to the function.

 

Those are working examples, they are just very simplified and might not apply specifically to what you are wanting to do. Basically both will generate up to 10 random points inside a zone, if a given point passes the test, either terrainHeightDiff or isTerrainValid, then the point could be used for whatever it is you want to use it for.

 

Breaking it down you have to get into the syntax of lua. This page should help in that regard http://lua-users.org/wiki/ControlStructureTutorial

 

A for loop starts at a value, in this case 1, and will run the code within the loop until it reaches the end value, (10). In this example I use it to run the code a certain number of times. So it generates a new point within 1 km of a given zone and then calls mist.isTerrainValid each time. If the point is on land or a road the mist function returns a true value.

 

   for i = 1, 10 do
     local newPoint = mist.getRandomPointInZone(point1, 1000)      
       if mist.isTerrainValid(newPoint, {'LAND', 'ROAD'}) == true then
         -- use newPoint for something
         break
     end
   end

The right man in the wrong place makes all the difference in the world.

Current Projects: Scripting Wiki, Something...

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread), SLMOD, IADScript, Mission Editing Wiki!, Mission Building Forum

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...