Jump to content

Covering all tiles with an object based on class in a random map


Recommended Posts

This is for https://github.com/0ad-matters/community-maps-2/issues/134

This works but I think there must be a better way. It seems crude, and the object (a placement obstruction) covers most, but not all, the tiles. Any suggestions?

The usage of createArea() was already in the map script. The new code is the call to createDecoration()
 

    g_Map.log("Freezing water");
    createArea(
        new MapBoundsPlacer(),
        [
            new TerrainPainter("alpine_ice_01"),
            new TileClassPainter(clIce),
            new SmoothElevationPainter(ELEVATION_SET, heightSeaGround - 0.1, 0),
        ],
        stayClasses(clWater, 0));

    createDecoration(
        [
            [new SimpleObject("obstructors/placement", 1, 1, 0, 0)],
        ],
        [
            scaleByMapSize(600, 1800),
        ],
        stayClasses(
            clIce, 0,
        )
    );

 

screenshot0044.png

  • Like 2
Link to comment
Share on other sites

So this works, got some help from @Jammyjamjamman and @trompetin17

 

    g_Map.log("Freezing water");
    const IceArea = new createArea(
        new MapBoundsPlacer(),
        [
            new TerrainPainter("alpine_ice_01"),
            new TileClassPainter(clIce),
            new SmoothElevationPainter(ELEVATION_SET, heightSeaGround - 0.1, 0),
        ],
        stayClasses(clWater, 0));

    for (const position of IceArea.getPoints())
        g_Map.placeEntityPassable("obstructors/placement", 0, position);

 

  • Like 1
Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...