Page 1 of 1

Question on smoke?

Posted: Wed Jan 07, 2015 9:45 am
by GottaLove88s
How long does smoke float around for?

Does it stay for the same number of turns whether it came from a mortar bombardment, an engineer, or the smoke artillery barrage?

Does smoke always disappear at the beginning of the turn of the player that fired it? (it would be deeply unpleasant if smoke evaporated just before an enemy took his turn lol)

Where can I control (increase/decrease) the number of turns that smoke stays for...?

Thanks! :D

Re: Question on smoke?

Posted: Wed Jan 07, 2015 4:25 pm
by pipfromslitherine
The smoke logic is controlled by OBJECTS.BSF script in DATA/OBJECTS/SYSTEM

Cheers

Pip

Re: Question on smoke?

Posted: Thu Jan 08, 2015 11:03 am
by GottaLove88s
Thanks again Pip.

Got it. So if I understand the code correctly, BA2 uses age as a counter (which it stores in ObjectData for each smoke cloud). It then checks a binary AND so that every other turn it will run the test to randomly remove smoke.

So there's a 25% chance of the smoke disappearing after 2 turns, 50% after 4, 75% after 6, and after 8 turns it's definitely gone...

I assume it runs this test independently for each 'unit' of smoke, so that an artillery barrage of smoke will gradually dissipate at different times, not all en masse?... Elegant guys! Nice

Code: Select all

FUNCTION Smoke_StartTurn(objectid, user)
{
	int age ;
	int odd ;
	
	age = GetObjectData(objectid, 0) ;
	age += 1 ;
	SetObjectData(objectid, 0, age) ;
	
	odd = age & 1;
	
	if (odd == 0)
	{
		// every pair of turns, chance of smoke removal increases by 25%
		age /= 2 ;
		age *= 25 ;
		
		if (Rand(0, 99) < age)
		{
			AddVizFunctionCall("DeleteObject", objectid) ;
		}
	}
}