Images
Visible Wonders

Visible Wonders

This is just an implementation of The Immortal Wombat’s Visible Wonders script: "On the completion of certain wonders, a representation of them appears on the map next to the city in which they were built. This adds a bit of atmosphere to the game ..."

The Script

//--------------------------------------------------------------------------
// MoT Mod for CTP2 by BureauBert
// 1.0 BETA
// http://ctp2.free.fr/
//--------------------------------------------------------------------------
////////////////////////////////////////////////////////////////////////////
// Map-visual wonders
// mod brought to you by The Immortal Wombat, aka. Ben Weaver
////////////////////////////////////////////////////////////////////////////

///////////////////////////////////
// Globals
///////////////////////////////////

// declared in main.slc

///////////////////////////////////
// Begin game initialisations
///////////////////////////////////

// InitVisibleWonders() in main.slc
// called from setup.slc

///////////////////////////////////
// Functions
///////////////////////////////////

// Common functions in main.slc

///////////////////////////////////
// The wonders
///////////////////////////////////

void_f IWW_DoGreatWall(city_t walledcity) {
	location_t iwwCityLoc;
	location_t iwwLoc;
	int_t iwwPlayer;
	int_t iwwTheWall;
	int_t iwwRand;
	int_t iwwCountA;
	int_t iwwCountB;
	int_t iwwCheck;

	iwwPlayer = walledcity.owner;
	iwwCityLoc = walledcity.location;
	iwwCheck = 1;

	for(iwwCountB = 4; iwwCountB < 7; iwwCountB = iwwCountB + 1){		// Make sure there are no wonders in the Wall gaps.
		if(iwwCountB != 5){
			if(GetNeighbor(iwwCityLoc, iwwCountB, iwwLoc)) {
				for(iwwCountA = 0; iwwCountA < IWW_WONDERTIMP.#; iwwCountA = iwwCountA + 1){
					if(TileHasImprovement(iwwLoc, IWW_WONDERTIMP[iwwCountA])){
						iwwCheck = 0;
					}
				}
			}
		}
	}
	if(iwwCheck > 0) {
		iwwTheWall = TerrainImprovementDB(TILEIMP_WONDER_GREAT_WALL_A);
		if(GetNeighbor(iwwCityLoc, 6, iwwLoc)) {
			if(TerrainType(iwwLoc) == TerrainDB(TERRAIN_PLAINS)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_GRASSLAND)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_DESERT)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_MOUNTAIN)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_HILL)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_TUNDRA)
			) {
				VIS_VisiStuffPlacement = 1;
				GrantAdvance(iwwPlayer, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
				Event:CreateImprovement(iwwPlayer, iwwLoc, iwwTheWall, 0);
				FinishImprovements(iwwLoc);
			}
			elseif(!IsSeaTerrain(iwwLoc) && !TileHasWonder(iwwLoc) && !TileHasCapital(iwwLoc) && !TileHasMonument(iwwLoc)) {
				iwwRand = random(2);
				if(iwwRand == 0){
					VIS_VisiStuffPlacement = 1;
					Terraform(iwwLoc, TerrainDB(TERRAIN_PLAINS));
					GrantAdvance(iwwPlayer, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
					Event:CreateImprovement(iwwPlayer, iwwLoc, iwwTheWall, 0);	
					FinishImprovements(iwwLoc);
				}
				else {
					VIS_VisiStuffPlacement = 1;
					Terraform(iwwLoc, TerrainDB(TERRAIN_GRASSLAND));
					GrantAdvance(iwwPlayer, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
					Event:CreateImprovement(iwwPlayer, iwwLoc, iwwTheWall, 0);	
					FinishImprovements(iwwLoc);
				}
			}
		}

		iwwTheWall = TerrainImprovementDB(TILEIMP_WONDER_GREAT_WALL_B);
		if(GetNeighbor(iwwCityLoc, 4, iwwLoc)) {
			if(TerrainType(iwwLoc) == TerrainDB(TERRAIN_PLAINS)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_GRASSLAND)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_DESERT)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_MOUNTAIN)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_HILL)
			|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_TUNDRA)
			) {
				VIS_VisiStuffPlacement = 1;
				GrantAdvance(iwwPlayer, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
				Event:CreateImprovement(iwwPlayer, iwwLoc, iwwTheWall, 0);	
				FinishImprovements(iwwLoc);
			}
			elseif(!IsSeaTerrain(iwwLoc) && !TileHasWonder(iwwLoc) && !TileHasCapital(iwwLoc) && !TileHasMonument(iwwLoc)) {
				iwwRand = random(2);
				if(iwwRand == 0){
					VIS_VisiStuffPlacement = 1;
					Terraform(iwwLoc, TerrainDB(TERRAIN_PLAINS));
					GrantAdvance(iwwPlayer, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
					Event:CreateImprovement(iwwPlayer, iwwLoc, iwwTheWall, 0);
					FinishImprovements(iwwLoc);
				}
				else {
					VIS_VisiStuffPlacement = 1;
					Terraform(iwwLoc, TerrainDB(TERRAIN_GRASSLAND));
					GrantAdvance(iwwPlayer, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
					Event:CreateImprovement(iwwPlayer, iwwLoc, iwwTheWall, 0);	
					FinishImprovements(iwwLoc);
				}
			}
		}
	}
}

HandleEvent(CreateWonder) 'IWW_major_redevelopment_in_progress' post {
	int_t iwwStructure;
	int_t iwwPlayer;
	city_t iwwCity;
	location_t iwwCityLoc;
	int_t iwwCountA;
	int_t iwwCountB;
	int_t iwwVisible;
	int_t iwwWonder;
	location_t iwwLoc;
	location_t iwwWonderLoc;

	iwwCity = city[0];
	iwwPlayer = city[0].owner;
	iwwStructure = value[0].value;
	iwwCityLoc = city[0].location;
	iwwVisible = 0;

	// GWW if you are not using the great wall, delete from here:
	if(iwwStructure == WonderDB(WONDER_GREAT_WALL)) {
		IWW_DoGreatWall(city[0]);
	} 
	//to here

	for(iwwCountA = 0; iwwCountA < IWW_VISIWONDER.#; iwwCountA = iwwCountA + 1) {
		if(iwwStructure == IWW_VISIWONDER[iwwCountA]) {
			iwwWonder = IWW_WONDERTIMP[iwwCountA];
			iwwVisible = 1;
		}
	}
	if(iwwVisible == 1) {
		int_t iwwCheck;
		int_t iwwTimp;
		int_t iwwRand;
		iwwWonderLoc = iwwCityLoc;		// null starting point
							// Basic routine: find a 'flat' tile with no iwwTimps.
		for(iwwCountA = 7; iwwCountA > -1; iwwCountA = iwwCountA - 1) {
			if(GetNeighbor(iwwCityLoc, iwwCountA, iwwLoc)) {
				iwwTimp = 0;
				if(TerrainType(iwwLoc) == TerrainDB(TERRAIN_PLAINS)
				|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_GRASSLAND)
				|| TerrainType(iwwLoc) == TerrainDB(TERRAIN_DESERT)) {
					for(iwwCountB = 0; iwwCountB < MOD_NUMOFTILEIMPS; iwwCountB = iwwCountB + 1) {
						if(TileHasImprovement(iwwLoc, iwwCountB)){
							iwwTimp = iwwTimp + 1;
						}
						if(TileHasWonder(iwwLoc) || TileHasCapital(iwwLoc)) {
							iwwTimp = iwwTimp + 10;
						}
						if(HasGood(iwwLoc) > -1) {
							iwwTimp = iwwTimp + 10;
						}
					}
					if(iwwTimp < 1) {
						iwwWonderLoc = iwwLoc;
						iwwCountA = -1;
					}
				}
			}
		}
		if(iwwWonderLoc == iwwCityLoc) {	// still...
			iwwCheck = 0;
			GetRandomNeighbor(iwwCityLoc, iwwLoc);
			while(iwwCheck < 8) {
				iwwTimp = 0;
				if(IsMountainTerrain(iwwLoc) || IsSeaTerrain(iwwLoc) || TileHasWonder(iwwLoc) || TileHasCapital(iwwLoc) || TileHasMonument(iwwLoc) || HasGood(iwwLoc) > -1) {
					iwwTimp = iwwTimp + 1;
				}
				if(iwwTimp == 0){
					for(iwwCountA = 0; iwwCountA < MOD_NUMOFTILEIMPS; iwwCountA = iwwCountA + 1) {	// find a random location with
						if(TileHasImprovement(iwwLoc, iwwCountA)){				// tile imps, cut them.
							Event:CutImprovements(iwwLoc);
						}
					}
					iwwWonderLoc = iwwLoc;
					iwwCheck = 8;
				}
				else {
					GetRandomNeighbor(iwwCityLoc, iwwLoc);
					iwwCheck = iwwCheck + 1;
				}
			}
			if(iwwWonderLoc != iwwCityLoc && !TileHasWonder(iwwWonderLoc) && !TileHasCapital(iwwWonderLoc) && !TileHasMonument(iwwLoc)) {
				iwwRand = random(2);
				if(iwwRand == 1) {
					Terraform(iwwWonderLoc, TerrainDB(TERRAIN_PLAINS));
				} elseif(iwwRand==0){
					Terraform(iwwWonderLoc, TerrainDB(TERRAIN_GRASSLAND));
				}
			}
		}

		// By now, the only reason you would not have found a 
		// place is if you are surrounded by mountains, water or wonders

		if(iwwWonderLoc != iwwCityLoc && !TileHasWonder(iwwWonderLoc) && !TileHasCapital(iwwWonderLoc)) {
			VIS_VisiStuffPlacement = 1;
			GrantAdvance(iwwPlayer, AdvanceDB(ADVANCE_SUBNEURAL_ADS));
			Event:CreateImprovement(iwwPlayer, iwwWonderLoc, iwwWonder, 0);
			FinishImprovements(iwwWonderLoc);
			location[0] = iwwWonderLoc;
		}
	}
}				

///////////////////////////////////
// Pillage Protection
///////////////////////////////////

HandleEvent(PillageOrder) 'WondersPillageProtectA' pre {
	location_t iwwLoc;

	iwwLoc = army[0].location;

	if(TileHasWonder(iwwLoc)) {
		return STOP;
	}
	else {
		return CONTINUE;
	}
}

HandleEvent(PillageUnit) 'WondersPillageProtectB' pre {
	location_t iwwLoc;
	
	iwwLoc = unit[0].location;

	if(TileHasWonder(iwwLoc)) {
		return STOP;
	}
	else {
		return CONTINUE;
	}
}

HandleEvent(CutImprovements)'WondersPillageProtectC' pre {
	location_t iwwLoc;
	
	iwwLoc = location[0];

	if(TileHasWonder(iwwLoc)) {
		return STOP;
	}
	else {
		return CONTINUE;
	}
}

// prevent overbuilding of visible wonders
		
HandleEvent(CreateImprovement) 'WondersOverbuildProtection' pre {	
	if(TileHasWonder(location[0])) {
		return STOP;
	}
	return CONTINUE;
}