Add vegetation to the stream boxes

Moderator: rbodleyscott

Post Reply
toska
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 483
Joined: Mon Jan 25, 2016 12:07 pm

Add vegetation to the stream boxes

Post 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?
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28378
Joined: Sun Dec 04, 2005 6:25 pm

Re: Add vegetation to the stream boxes

Post 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.
Richard Bodley Scott

Image
toska
Master Sergeant - Bf 109E
Master Sergeant - Bf 109E
Posts: 483
Joined: Mon Jan 25, 2016 12:07 pm

Re: Add vegetation to the stream boxes

Post 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?
Attachments
Stream1.jpg
Stream1.jpg (443.03 KiB) Viewed 1493 times
Stream2.jpg
Stream2.jpg (704.74 KiB) Viewed 1493 times
Adebar
Sergeant First Class - Elite Panzer IIIL
Sergeant First Class - Elite Panzer IIIL
Posts: 400
Joined: Tue Oct 14, 2014 10:39 pm
Location: HRR

Re: Add vegetation to the stream boxes

Post by Adebar »

Looks fine. :o

Great idea, Toska!
Image
rbodleyscott
Field of Glory 2
Field of Glory 2
Posts: 28378
Joined: Sun Dec 04, 2005 6:25 pm

Re: Add vegetation to the stream boxes

Post 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.
Richard Bodley Scott

Image
Post Reply

Return to “Field of Glory II: Medieval - Modding”