Page 1 of 1

Add vegetation to the stream boxes

Posted: Sat Mar 06, 2021 9:38 pm
by toska
Greetings, I would like to add vegetation to the stream boxes.

Which files decide which types of terrain contain vegetation and which does not?

Re: Add vegetation to the stream boxes

Posted: Sun Mar 07, 2021 8:10 am
by rbodleyscott
toska wrote: Sat Mar 06, 2021 9:38 pm Greetings, I would like to add vegetation to the stream boxes.

Which files decide which types of terrain contain vegetation and which does not?
Do you mean in the random map generator?

If so streams are actually placed by the following loop in BM_PopulateFromTileData() in /Data/Battle/Scripts/MapGenerateBattle.bsf

Code: Select all

	// Streams, rivers and roads - also need to be done outside main loop (if streams trump roads where incompatible)
	for (x = 0; x < width; x++)
	{
		for (y = 0; y < height; y++)
		{
			data = BM_GetTileDataX(x, y, 1);

			border = 0;
			if (IsValidTile(x,y) != 1)
				{
					border = 1;
				}

			if ((data == 11) || (data == 12)) // Stream data not generated outside border
				{
					PlaceTileByType(x, y, style, "WATER", 1);

					if (GetUniversalVar("StreamSize") == 1)
						{
							PlaceTileByType(x, y, style, "MEDIUMSTREAMS", 0);
						}

					if (GetUniversalVar("StreamSize") == 2)
						{
							PlaceTileByType(x, y, style, "DEEPSTREAMS", 0);
						}
				}
				
			if ((data == 16) || (data == 17))
				{
					PlaceTileByType(x, y, style, "WATER", 0);
				}

			if (((data == 6) || (data == 12) || (data == 17)) && (border == 0)) // Road
				{
					PlaceTileByType(x, y, style, "TRACK", 1);
//          PlaceTileByType(x, y, style, "ROAD", 1);
				}
			
		}
	}
You would need to place the vegetation objects after the

Code: Select all

PlaceTileByType(x, y, style, "WATER", 1);
line.

The hard part would be avoiding placing vegetation in the middle of the stream. That is why I didn't do it myself.

The actual stream overlays are placed automatically by the engine, so you have no control over which ones are used where - at least not without a lot of extra code, as used for rivers.

Re: Add vegetation to the stream boxes

Posted: Sun Mar 07, 2021 4:32 pm
by toska

Code: Select all

{
					PlaceTileByType(x, y, style, "WATER", 1);

                          object = PlaceObject((x * 100) + Rand(10,100), (y * 100) + Rand(10,100), gAdjustableObjectStyle, "BushesTile");
							if (object != -1)
								{
									SetObjectRotation(object, 157 * Rand(0, 3));
								}
Thank you very much Richard. I have done this and I think it looks great!

This is going to give problems with the multiplayer?

Re: Add vegetation to the stream boxes

Posted: Sun Mar 07, 2021 9:29 pm
by Adebar
Looks fine. :o

Great idea, Toska!

Re: Add vegetation to the stream boxes

Posted: Mon Mar 08, 2021 9:14 am
by rbodleyscott
toska wrote: Sun Mar 07, 2021 4:32 pm

Code: Select all

{
					PlaceTileByType(x, y, style, "WATER", 1);

                          object = PlaceObject((x * 100) + Rand(10,100), (y * 100) + Rand(10,100), gAdjustableObjectStyle, "BushesTile");
							if (object != -1)
								{
									SetObjectRotation(object, 157 * Rand(0, 3));
								}
Thank you very much Richard. I have done this and I think it looks great!

This is going to give problems with the multiplayer?
It is hard to say, but as a general rule you should not play MP with a modded main build.