Skip to content

6 Terrain

dreamness edited this page Mar 26, 2025 · 1 revision

passability

from ra3map import Ra3Map

m_2 = Ra3Map.load_map('m_2')

# set a rect area's passability as passable
for x in range(90, 150):
    for y in range(100, 200):
        m_2.set_terrain_passability(x, y, PassabilityEnum.Passable)

# set a rect area's passability as impassable
for x in range(90, 150):
    for y in range(100, 200):
        m_2.set_terrain_passability(x, y, PassabilityEnum.Impassable)

#  if a location is passable
print(m_2.get_terrain_passability(x, y))

m_2.save()

terrain height

from ra3map import Ra3Map

m_2 = Ra3Map.load_map('m_2')

# set a rect area's height to 300
for x in range(100, 150):
    for y in range(100, 120):
        m_2.set_terrain_height(x, y, 300)

# get a position's height
print(m_2.get_terrain_height(120, 150)

# update terrain's passability automatically
# It is recommended to call this function; 
# otherwise, there might be a situation where the vehicle climbs over the cliff.
m_2.update_terrain_passability()

m_2.save()

Clone this wiki locally