Jump to content

Land SufaceType Check


Motion_Blurz

Recommended Posts

Firstly, any assistance is much appreciated. 

 

I am not much for coding and have to beg borrow steal what I can find when it comes to scripting to make missions feel more alive and dynamic.  I have a script that generates random OPFOR spawns.  It's nice but there isn't a conditional check to discriminate what type of surface it is spawning onto and thus you get guys with AKs and APCs out floating in the water shooting at you.  So much for that surprise sea infiltration....

 

I would like to change that but uncertain how to properly do so with the Land.SurfaceType.  I am at wits end with how to properly insert this check.

 


            local _aheadPointInf = AmbushZone.getPointAheadOfUnit(PlayerUnit:GetName(), math.random(3200,3700),"Infantry")
            local aheadPoint = POINT_VEC3:NewFromVec3( _aheadPointInf )
            local aheadZone = ZONE_RADIUS:New( "AmbushZone_"..Function.RandomVariable(3), aheadPoint:GetVec2(), math.random(600,800) )
            local group = AmbushZone.SpawnInfantry:SpawnInZone(aheadZone,true)
            SCHEDULER:New( nil,
            
            function()
              Function.DestroyGroup(group)
            end, {},AmbushZone.EnemyUnitsLifeTime)  


Edited by Motion_Blurz
substance
Link to comment
Share on other sites

  • Motion_Blurz changed the title to Land SufaceType Check

Well, you would first have to decide what to do depending on the terrain type that is returned. 

 

Once you have the point where you want to spawn, you would then invoke land.getSurfaceTye(), which returns a code 1..5, for each of which you will have to decide what to do, e.g. a small boat for shallow water, a ship for deep water (water), maybe a tank for roads.

 

Also: when invoking getSurfaceType(), remember that it takes a two-value vector that contains x in the first, and a 3-vector's z in the second (y) attribute...

 

 


Edited by cfrag
Link to comment
Share on other sites

Perhaps I have been performing the wrong step or putting it in the incorrect place when I have made attempts at getSurfaceType and to then take an action.  

 

Simply put, what I would like to accomplish with the above is to have a SurfaceType check that occurs and then only spawn if the return is 1  or perhaps rather ~= 3 

Link to comment
Share on other sites

1 hour ago, Motion_Blurz said:

Perhaps I have been performing the wrong step or putting it in the incorrect place when I have made attempts at getSurfaceType and to then take an action.  

 

Simply put, what I would like to accomplish with the above is to have a SurfaceType check that occurs and then only spawn if the return is 1  or perhaps rather ~= 3 

 

After first line, put :

if land.getSurfaceType(_aheadPointInf) ~= 3 and land.getSurfaceType(_aheadPointInf) ~= 2 then

then put all the rest, and add an "end" at the end to close the added "if".


Edited by toutenglisse
Link to comment
Share on other sites

You can try to use 'not' instead of  '~='

 

if not land.getSurfaceType(_aheadPointInf) == 3 and not land.getSurfaceType(_aheadPointInf) == 2 then

--do your LUA here

end

 

or better, check if is land, road or runway

 

if land.getSurfaceType(_aheadPointInf) == 1 or land.getSurfaceType(_aheadPointInf) == 4 or land.getSurfaceType(_aheadPointInf) == 5 then

--do your LUA here

end


Edited by dark_wood
Link to comment
Share on other sites

  • Recently Browsing   0 members

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