////////////////////////////////////////////////////////////////////////////
//
// Destroy buildings script to allow for destruction of buildings due to conquest.
//
// By Dale
//
// Version 1.1 5-May-2001
//
////////////////////////////////////////////////////////////////////////////

///////////////////////////////////
// Mod notes!
//
// Variables:
// None.
//
// This script will check every city when conquored for buildings, and if that building
// exists, it will randomly destroy the building (by default 50% chance).  It will also check
// nuked cities for buildings and destroy them randomly (by default 75% chance).
//
// In both events (CaptureCity & NukeCity) the only thing a modder needs to watch out for
// is the amount of buildings that are checked (see line: for(i = 0; i < 80; i = i + 1) {).
// If you have more than 80 buildings in your mod/scenario, you need to change this number to
// reflect that.
//
///////////////////////////////////

///////////////////////////////////
// Capture City event
///////////////////////////////////

HandleEvent(CaptureCity) 'MM2_DestroyBuildsOnCapture' pre {
	city_t tmpcity;
	int_t tmpbuilding;
	int_t i;
	int_t randnum;

	tmpcity = city[0];
	if(CityIsValid(tmpcity)) {
		for(i = 0; i < 80; i = i + 1) {
			randnum = random(100);
			if(randnum < 50) {
				DestroyBuilding(tmpcity, i);
			}
		}
	}
}

///////////////////////////////////
// Nuke City event
///////////////////////////////////

HandleEvent(NukeCity) 'MM2_DestroyBuildsOnNuke' pre {
	city_t tmpcity;
	int_t tmpbuilding;
	int_t i;
	int_t randnum;

	tmpcity = city[0];
	if(CityIsValid(tmpcity)) {
		for(i = 0; i < 80; i = i + 1) {
			randnum = random(100);
			if(randnum < 75) {
				DestroyBuilding(tmpcity, i);
			}
		}
	}
}




