Jump to content

is there a way to detect a FORREST or CITY as validated spawn terrain type?


Recommended Posts

Posted

having issues with placing spawned units that spawn inside cities(inside/on top of buildings) or in forests inside a spawn zone, so if there would be some kind of expanded terrain type detection, besides existing getSurfaceType() or land.SurfaceType {LAND=1,SHALLOW_WATER=2,WATER=3,ROAD=4,RUNWAY=5}, to avoid such terrains in purpose of spawning ground units or off road ground unit route.points?

map layers of this kind do exist so if anyone knows of ways to detect them would be very helpful. tnx.

Posted

There are some long existing feature requests for scripting info on cities and forests. For each the best you can do is to setup some area definition as a disallowed zone. Get a random point, see if its in a city/forest zone, then allow or deny spawning there. 

With cities you can be a little more creative with code and depending on your needs can be relatively simple or add some extra processing. For example you can use world.searchObjects to return scenery objects near a given point. If its really simple you can just check how many objects are in the area, more than 10 it is probably a city. If you want more details you can use getDesc and getPosition on the returned objects then do some math on the box parameters with orientation and point from getPosition to figure out the rough area the object takes up. Now you can do a pointInPolygon to verify a random point you want to place the unit isn't occupied by a building. 

  • Like 1

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

Current Projects:  Grayflag ServerScripting Wiki

Useful Links: Mission Scripting Tools MIST-(GitHub) MIST-(Thread)

 SLMOD, Wiki wishlist, Mission Editing Wiki!, Mission Building Forum

Posted
9 hours ago, Grimes said:

world.searchObjects

this sounds ok like if number of units is greater then threshold limit, disregard and continue with next point but does it return trees as objects also?

 

9 hours ago, Grimes said:

There are some long existing feature requests for scripting info on cities and forests. For each the best you can do is to setup some area definition as a disallowed zone. Get a random point, see if its in a city/forest zone, then allow or deny spawning there.

i dont get this one. getrandompointinzone is fine, then how to setup area definition? does dcs distinguish city/forest layers without manually defining zones if not using objects count?

Posted
Quote

 local foundUnits = {}
 local sphere = trigger.misc.getZone('Test.Zone.Forrest')
 local volS = {
   id = world.VolumeType.SPHERE,
   params = {
     point = sphere.point,
     radius = sphere.radius
   }
 }
 
 local ifFound = function(foundItem, val)
    foundUnits[#foundUnits + 1] = foundItem:getName()
    return true
 end
 return world.searchObjects(Object.Category.SCENERY, volS, ifFound)

This returns 0 objects even zone in forest. So its fine for cities for now.

 

  • 1 year later...
Posted

I've recently started making scripted missions in my free time and I was bummed out that there is no way to detect trees in an area. I would really love if there were more land surface types - urban, forrest, mountain, etc! 🙂

  • Like 1
  • Recently Browsing   0 members

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