Page 1 of 1

Way to vary max LOS?

Posted: Sat Dec 11, 2021 1:59 pm
by Karvon
I was wondering if there was a way of capping LOS distance to reflect night actions or battles in fog/dust, etc?

Re: Way to vary max LOS?

Posted: Sat Dec 11, 2021 6:59 pm
by Paul59
Karvon wrote: Sat Dec 11, 2021 1:59 pm I was wondering if there was a way of capping LOS distance to reflect night actions or battles in fog/dust, etc?
It's easily possible for a Editor created scenario.

Just put this script in the FUNCTION StartTurnPost(side) of the scenarios .bsf file.

Code: Select all

	// CUSTOM - Set variable visibility for fog etc.
	visibility = SkewedRandom(2, 6, 1) * 10; 

//  visibility = 300; // For demo only.

	for (j = 0; j < 2; j++)
	{
		for (i = 0; i < GetUnitCount(j); i++)
		{
			id = GetUnitID(j,i);
			if (id != -1)
				{
					v = visibility;
					// Increase visibility for units on windmill hill
					if (GetTileHeight(GetUnitX(id), GetUnitY(id)) >= 50)
						{
							v += 60;
						}
					SetAttrib(id, "LOS", v);
				}
		}
	}
It will need a few variables defined, at least these:

Code: Select all

	int j;
	int visibility;
	int v;
and maybe a few others, they just go at the start of the FUNCTION StartTurnPost(side)

I used this in my Castulo scenario, which is available for download. Download it, open the .bsf file and you can see how it's done. I originally got the script from the Pike and Shot scenario Lutzen. If I remember correctly, the actual range of LOS varies from turn to turn, simulating the effect of the smoke clearing or getting worse. The bit about the windmill hill just gives an extended LOS for units on hills equal to or over 50 high. I have never tried changing the values, but I am guessing that you would have to change the values in

Code: Select all

visibility = SkewedRandom(2, 6, 1) * 10;
If you want it for a mod, I am afraid I don't know how it would be done, but I am sure RBS would know.


cheers

Paul