//////////////////////////////////////////////////////////////////////////// // Religion Code //////////////////////////////////////////////////////////////////////////// city_t ConvertedCity[]; int_t ConvertorCiv[]; int_t ReligiousCount; int_t PlayerReligion[]; // What is inside the brackets is the player who has been converted // and the value of the variable equal the player who converted HandleEvent(BeginTurn) 'SaveReligionsArrays' post { // At the Begginning of the game int_t tmpPlayer; for(tmpPlayer = 0; tmpPlayer <= 32; tmpPlayer = tmpPlayer + 1) { // For all if(IsPlayerAlive(tmpPlayer)) { // alive player PlayerReligion[tmpPlayer] = tmpPlayer; // Given them a religion } } DisableTrigger('SaveReligionsArrays'); } HandleEvent(CreateCity) 'StoreCityReligionAccordingToTheCiv' post { if(CityIsValid(city[0])) { player[0] = city[0].owner; ConvertorCiv[ReligiousCount] = city[0]; // Store the converted city ConvertedCity[ReligiousCount] = player[0]; // and the player who converted ReligiousCount = ReligiousCount + 1; } } int_f GetCityConvertor(city_t tmpCity) { // Get wich player converted the city int_t tmpPlayer; int_t i; if(CityIsValid(tmpCity)) { for(i = 0; i <= ReligiousCount; i = i + 1) { if(tmpCity == ConvertedCity[i]) { tmpPlayer = ConvertorCiv[i]; } } } return tmpPlayer; // if GetCityConvertor = 0, means city is not converted } int_f GetCityReligion(city_t tmpCity) { // Get for what religion the city was converted int_t tmpPlayer; int_t i; int_t Religion; if(CityIsValid(tmpCity)) { for(i = 0; i <= ReligiousCount; i = i + 1) { if(tmpCity == ConvertedCity[i]) { tmpPlayer = ConvertorCiv[i]; Religion = PlayerReligion[tmpPlayer]; } } } return Religion; } HandleEvent(ConvertCity) 'ConvertCityAccordingToReligion' post { // When a city was converted int_t i; int_t tmpplayer; if(CityIsValid(city[0]) && IsPlayerAlive(player[0])) { // See who is converting tmpplayer = player[0]; Event: ConvertCity(city[0], PlayerReligion[tmpplayer], 0); // And convert the city to his religion (maybe another civ reigion) ConvertorCiv[ReligiousCount] = city[0]; // Store the converted city ConvertedCity[ReligiousCount] = player[0]; // and the player who converted ReligiousCount = ReligiousCount + 1; } } int_t PlayerConverting; int_t PlayerWhoIsConverted; city_t FaithfulCity; HandleEvent(ConvertCity) 'DoYouWantToConvert' pre { // Also when a city is being converted int_t i; int_t CityCount; int_t TotalCityCount; int_t ConvertedCitiesChance; int_t theReligion; city_t tmpCity; int_t k; int_t j; int_t CityReligion; city_t tmpCity2; if(CityIsValid(city[0]) && IsPlayerAlive(player[0])) { // See who is converting FaithfulCity = city[0]; // For the message: Store the converted city, PlayerWhoIsConverted = city[0].owner; // the player who owns the city, PlayerConverting = player[0]; // and the player who is converting player[1] = PlayerWhoIsConverted; if(IsHumanPlayer(player[1])) { // If he is a human player message(player[1], 'DoYouWantToConvertCiv'); // Send him a message } else{ // if the player who is converting isnt human TotalCityCount = PlayerCityCount(player[1]); // Get its total number of cities for(i=0; i <= player[1].cities; i = i + 1) { GetCityByIndex(player[1], i, tmpCity); // Check all of its cities theReligion = GetCityReligion(tmpCity); // their conversion religion (if is converted) if(theReligion == PlayerReligion[player[1]]) { CityCount = CityCount + 1; // and get how many cities the convertor civ has converted in this cities } } ConvertedCitiesChance = 11 - (CityCount*10)/TotalCityCount; // Get how likely the civ accepts being conveted if(Random(ConvertedCitiesChance) == 0 && player[1].cities > 5) { // if half of its cities has been converted by the convertor civ for(k=0; k <= player[1].cities; k = k + 1) { // And all of his cities get convertedF GetCityByIndex(player[1], k, tmpCity); CityReligion = GetCityReligion(tmpCity); if(CityReligion != PlayerReligion[player[0]]) { Event: ConvertCity(tmpCity, PlayerReligion[player[0]], 0); Event:AddHappyTimer(tmpCity, 1, -4, 14); ConvertedCity[ReligiousCount] = tmpCity; ConvertorCiv[ReligiousCount] = PlayerReligion[player[0]]; ReligiousCount = ReligiousCount + 1; } else{ Event:AddHappyTimer(tmpCity, 1, 4, 14); } for(j = 0; j <= ReligiousCount; j = j + 1) { // Also the cities that he converted are converted by the convertor if(ConvertorCiv[j] == player[1]) { tmpCity2 = ConvertedCity[j]; Event: ConvertCity(tmpCity2, PlayerReligion[player[0]], 0); ConvertedCity[j] = 0; ConvertorCiv[j] = 0; ConvertedCity[ReligiousCount] = tmpCity2; ConvertorCiv[ReligiousCount] = PlayerReligion[player[0]]; ReligiousCount = ReligiousCount + 1; } } } // } } } } // This has to be added in the info_str.txt // DONT_CONVERT "Dont Convert" // CONVERT "Convert" // WILL_WE_CONVERT_TITLE " Citizens of {city[0].name} claims civ conversion! // WILL_WE_CONVERT_TEXT "{player[0].leader_name}, the {player[0].civ_name_singular} religion is spresding in // our empire. The conversion of {city[0].name} has lead to protests to have all of our cities // to this religion, wich they claim to be the true faith. Shall we convert all of our cities? AlertBox 'DoYouWantToConvertCiv' { // If the converted player is human he gets this message int_t k; int_t j; int_t CityReligion; city_t tmpCity; city_t tmpCity2; Title(ID_WILL_WE_CONVERT_TITLE); Text(ID_WILL_WE_CONVERT_TEXT); Show(); city[0] = FaithfulCity ; player[0] = PlayerConverting; player[1] = PlayerWhoIsConverted; Button(ID_DONT_CONVERT) { // If the player doesnt accept Event:AddHappyTimer(city[0], 1, -2, 14); // The city wich has been recently converted gets -2 happiness for 1 turn Kill(); } Button(ID_CONVERT) { // if the player do accept PlayerReligion[player[1]] = PlayerReligion[player[0]]; // His religion changes for(k=0; k <= player[1].cities; k = k + 1) { // And all of his cities get convertedF GetCityByIndex(player[1], k, tmpCity); CityReligion = GetCityReligion(tmpCity); if(CityReligion != PlayerReligion[player[0]]) { Event: ConvertCity(tmpCity, PlayerReligion[player[0]], 0); Event:AddHappyTimer(tmpCity, 1, -4, 14); ConvertedCity[ReligiousCount] = tmpCity; ConvertorCiv[ReligiousCount] = PlayerReligion[player[0]]; ReligiousCount = ReligiousCount + 1; } else{ Event:AddHappyTimer(tmpCity, 1, 4, 14); } for(j = 0; j <= ReligiousCount; j = j + 1) { // Also the cities that he converted are converted by the convertor if(ConvertorCiv[j] == player[1]) { tmpCity2 = ConvertedCity[j]; Event: ConvertCity(tmpCity2, PlayerReligion[player[0]], 0); ConvertedCity[j] = 0; ConvertorCiv[j] = 0; ConvertedCity[ReligiousCount] = tmpCity2; ConvertorCiv[ReligiousCount] = PlayerReligion[player[0]]; ReligiousCount = ReligiousCount + 1; } } } Kill(); } } city_t UnconvertedCity; int_t PlayerUnconverting; HandleEvent(UnconvertCity) 'NewUncovertCity' pre { //reformation by city owner int_t Religion; city_t tmpCity; int_t tmpPlayer; tmpPlayer = city[0].owner; PlayerUnconverting = tmpPlayer; UnconvertedCity = city[0]; Religion = GetCityReligion(city[0]); // Check wich religion converted the player if(PlayerReligion[tmpPlayer] != tmpPlayer) { // If he had a conversion before if(Religion == PlayerReligion[tmpPlayer] // and If the religion is the same as yours && PlayerReligion[tmpPlayer] != tmpPlayer) { message(tmpPlayer, 'NewUncovertCityMessage1'); // Send this message } } elseif(Religion != PlayerReligion[tmpPlayer]) { // if is another ones religion // Otherwise if it is another civ religion message(tmpPlayer, 'NewUncovertCityMessage2'); } } // This has to be added in the info_str.txt // //CONVERT_OR_NOT "You sent our troops to unconvert this city. But you can either convert the city to our religion or rescue the old religion created by our // people hundreds of years ago an be free of the {player[1].civ_name_singular} religious influence. But if we rescue the old religion we may // lost strategic conditions, our civiliztion may have diplomatic problems with {player[1].civ_name_singular} and the people of {city[0].name} will became unhappy with the change. So What should we do?" //CREATE_RELIGION "Rescue Old Religion" //CANCEL_UNCONVERSION "Cancel Order" //CONVERT_TO_RELIGION "Convert to our Religion" // AlertBox 'NewUncovertCityMessage1' { int_t j; text(ID_CONVERT_OR_NOT); show(); city[0] = UnconvertedCity; player[0] = PlayerUnconverting; player[1] = PlayerReligion[PlayerUnconverting]; Button(ID_CANCEL_UNCONVERSION) { Event: ConvertCity(UnconvertedCity, PlayerReligion[PlayerUnconverting], 0); Kill(); } Button(ID_CREATE_RELIGION) { PlayerReligion[PlayerUnconverting] = PlayerUnconverting; Event: ConvertCity(UnconvertedCity, PlayerUnconverting, 0); for(j = 0; j <= ReligiousCount; j = j + 1) { // Also the cities that he converted are converted by the convertor if(ConvertedCity[j] == UnconvertedCity) { ConvertedCity[j] = 0; ConvertorCiv[j] = 0; ConvertedCity[ReligiousCount] = UnconvertedCity; ConvertorCiv[ReligiousCount] = PlayerReligion[PlayerUnconverting]; ReligiousCount = ReligiousCount + 1; } } Kill(); } } AlertBox 'NewUncovertCityMessage2' { int_t j; text(ID_CONVERT_OR_NOT); show(); Button(ID_CONVERT_TO_RELIGION) { Event: ConvertCity(UnconvertedCity, PlayerReligion[PlayerUnconverting], 0); for(j = 0; j <= ReligiousCount; j = j + 1) { // Also the cities that he converted are converted by the convertor if(ConvertedCity[j] == UnconvertedCity) { ConvertedCity[j] = 0; ConvertorCiv[j] = 0; ConvertedCity[ReligiousCount] = UnconvertedCity; ConvertorCiv[ReligiousCount] = PlayerReligion[PlayerUnconverting]; ReligiousCount = ReligiousCount + 1; } } Kill(); } Button(ID_CREATE_RELIGION) { PlayerReligion[PlayerUnconverting] = PlayerUnconverting; Event: ConvertCity(UnconvertedCity, PlayerUnconverting, 0); for(j = 0; j <= ReligiousCount; j = j + 1) { // Also the cities that he converted are converted by the convertor if(ConvertedCity[j] == UnconvertedCity) { ConvertedCity[j] = 0; ConvertorCiv[j] = 0; ConvertedCity[ReligiousCount] = UnconvertedCity; ConvertorCiv[ReligiousCount] = PlayerReligion[PlayerUnconverting]; ReligiousCount = ReligiousCount + 1; } } Kill(); } } HandleEvent(BeginTurn) 'ConvertorTakesTheMoneyPerTurn' post { // Every Turn int_t SinfulCiv; int_t theReligion; int_t theTenth; int_t i; SinfulCiv = player[0]; message(player[0], 'ReligionInfo'); for(i=0; i <= player[0].cities; i = i + 1) { // If it is converted by GetCityByIndex(SinfulCiv, i, city[0]); theReligion = GetCityReligion(city[0]); // Check all the cities of player if(theReligion == PlayerReligion[SinfulCiv] // If it has the same religion of the player who converted && PlayerReligion[SinfulCiv] != SinfulCiv) { // and the city who converted isnt himself theTenth = 1 + city[0].population/2; // it only take 1 gold per pop population. yet he take at least one. AddGold(SinfulCiv, - theTenth); AddGold(theReligion, theTenth); } elseif(theReligion != PlayerReligion[SinfulCiv]){ // Else if it is another player religion who converte the civ theTenth = city[0].population*3; // 3 golds per pop is taken to the religion owner AddGold(SinfulCiv, - theTenth); AddGold(theReligion, theTenth); } } } messagebox 'ReligionInfo' { int_t tmpPlayer; tmpPlayer = g.player; tmpPlayer = player[0]; PlayerReligion[tmpPlayer] = player[1]; text(ID_RELIGIOUS_INFO); } HandleEvent(IndulgenceSaleMade) 'ConvertorTakesTheMoneyFromIndulgences' pre { // Sell indulgence order int_t SinfulCiv; int_t PriestCiv; int_t ConvertorCiv; int_t theTenth; unit_t GodsUnit; PriestCiv = GodsUnit.owner; // ConvertorCiv = GetCityReligion(city[0]); SinfulCiv = City[0].owner; if(PlayerReligion[SinfulCiv] == PlayerReligion[PriestCiv]) { // If city has been converted by a civ with his own religion theTenth = 1 + city[0].population/2; // He gets 1 gold per 2 city pop (yet it gets at least one) AddGold(SinfulCiv, - theTenth); AddGold(PriestCiv, theTenth); } else{ // if city has been coverted by a civ with another religion theTenth = city[0].population*3; // he take 3 gold per pop AddGold(SinfulCiv, - theTenth); AddGold(PriestCiv, theTenth); } }