////////////////////////////////////////////////////////////////////////////////// // Religion Code by Pedrunn and Mapfi v0.99, 20th October 2002, diplo enabled // ////////////////////////////////////////////////////////////////////////////////// city_t allCities[]; //array of all cities int_t CityReligion[]; //corresponding array with the religion of those cities int_t PlayerReligion[31]; //array of the players chosen state religion int_t PlayerNum; //number of players alive and kicking int_t CityRel; //for storing then intended religion of the city in the loop process int_t Convertor; //player who converts a city int_t Sinner; //player who's city is being converted int_t ReformerPlayer; //used for code in messages of ReformingCity int_t NewReformCost; //dito int_t ReligionLevel; //percentage of pop with a certain religion unit_t ReligiousSettler[]; //array of all settlers int_t SettlerReligion[]; //corresponding array with the religion of those settlers location_t ReligiousLocation; //location where a settler is ordered to settle int_t LocationReligion; //religion of the settler that settles at this location int_t PlayerTenthPay[31]; //gold that a player will pay as tenth int_t PlayerTenthGet[31]; //gold that a player will get as tenth int_t Receiver; //player receiving message int_t HappyModInfo[13]; //gives the player an info of the effect of the religion on his cities int_t ReligionChange[16]; //carries any changes to message the human player int_t ReligionAssim[4]; //caaries any assimilations to message human player int_t SentChanges[2]; //keeping track of how many messages are sent int_t infocycle[3]; //after how many turns the religion info pops up //setting the religion as player number (default) for all players alive at start HandleEvent(BeginTurn) 'settingreligion' pre { int_t i; infocycle[0] = 0; infocycle[1] = 5; infocycle[2] = 0; PlayerNum = 0; for (i = 1; i <= 30; i = i + 1) { //without the barbarians if(IsPlayerAlive(i)) { PlayerReligion[i] = i ; // setting the religion of all players to theirs as default PlayerNum = PlayerNum + 1; } } DisableTrigger('settingreligion'); // just doing this the very first turn } /////////////////// // New Functions // /////////////////// int_f GetCityReligion(city_t theCity) { //returns religion of a city int_t i; int_t tmpReligion; city_t tmpCity; tmpcity = theCity; tmpReligion = tmpCity.owner; // default value for (i = 0; i < allCities.#; i = i + 1) { if (CityIsValid(allCities[i])) { if (tmpCity == allCities[i]) { tmpReligion = CityReligion[i]; } } } return tmpReligion; } int_f CheckforCity(city_t theCity) { //returns place of city in array, or next free place int_t i; city_t tmpCity; tmpCity = theCity; for (i = 0; i < allCities.#; i = i + 1) { if (CityIsValid(allCities[i])) { if (tmpCity == allCities[i]) { return i; } } else{ return i; } } return allCities.#; } void_f StoreCity(city_t theCity, int_t theReligion) { //stores city in allCities array int_t i; city_t tmpCity; int_t tmpReligion; tmpCity = theCity; tmpReligion = theReligion; i = CheckforCity(tmpCity); allCities[i] = tmpCity; CityReligion[i] = tmpReligion; } int_f GetPlayerCityReligionLevel(int_t thePlayer, int_t theReligion) { //returns percentage*100 of this player's cities with this religion int_t i; int_t count; int_t Level; int_t tmpReligion; int_t tmpPlayer; city_t tmpCity; tmpPlayer = thePlayer; tmpReligion = theReligion; count = 0; for (i = 0; i < allCities.#; i = i + 1) { if (CityIsValid(allCities[i])) { tmpCity = allCities[i]; if (tmpCity.owner == tmpPlayer) { if (CityReligion[i] == tmpReligion) { count = count + 1; } } } } Level = (count*10000)/PlayerCityCount(tmpPlayer); return Level; } int_f GetReligionLevel(int_t theReligion) { //returns percentage*100 pop with this religion of the whole pop int_t i; city_t tmpCity; int_t tmpReligion; int_t ConvertedPop; int_t WorldPop; int_t Level; WorldPop = 0; ConvertedPop = 0; tmpReligion = theReligion; for(i = 0; i < allCities.#; i = i + 1) { if(CityIsValid(allCities[i])) { tmpCity = allCities[i]; WorldPop = WorldPop + tmpCity.population; if(CityReligion[i] == tmpReligion) { ConvertedPop = ConvertedPop + tmpCity.population; } } } Level = (ConvertedPop*10000)/WorldPop; //percentage return Level; } void_f StoreSettlerReligion(unit_t theUnit, int_t theReligion) { //stores settler and the religion of the city it was created in int_t i; int_t tmpReligion; int_t success; unit_t tmpUnit; army_t tmpArmy; tmpUnit = theUnit; tmpReligion = theReligion; success = 0; while(i < ReligiousSettler.# && success == 0) { if(ReligiousSettler[i].valid == 0) { ReligiousSettler[i] = tmpUnit; SettlerReligion[i] = tmpReligion; success = 1; } if(tmpUnit == ReligiousSettler[i]) { // prevents a settler from being assigned a new religion by just passing a turn in a city in which another unit is created success = 1; } i = i + 1; } if(success == 0) { i = ReligiousSettler.#; ReligiousSettler[i] = tmpUnit; SettlerReligion[i] = tmpReligion; } } int_f HowManyPlayersHaveReligion(int_t theReligion) { int_t i; int_t count; int_t tmpReligion; tmpReligion = theReligion; count = 0; for(i = 1; i < PlayerReligion.#; i = i + 1){ if (PlayerReligion[i] == tmpReligion) { count = count + 1; } } return count; } void_f AddPlayerTenth(int_t thePlayer, int_t theTenth) { int_t tmpPlayer; int_t tmpTenth; tmpPlayer = thePlayer; tmpTenth = theTenth; if (tmpTenth > 0) { PlayerTenthGet[tmpPlayer] = PlayerTenthGet[tmpPlayer] + tmpTenth; } else{ PlayerTenthPay[tmpPlayer] = PlayerTenthPay[tmpPlayer] + tmpTenth; } } void_f AddReligionTenth(int_t theReligion, int_t theTenth) { int_t i; int_t tmpReligion; int_t tmpTenth; tmpReligion = theReligion; tmpTenth = theTenth; for (i = 0; i <= 30; i = i + 1){ if (PlayerReligion[i] == tmpReligion) { AddPlayerTenth(i, tmpTenth); } } } void_f AddToHappyModInfo(int_t theMod) { int_t tmpMod; tmpMod = themod; HappyModInfo[tmpMod] = HappyModInfo[tmpMod] + 1; } void_f MessageReligion(int_t thePlayer, int_t theReligion, int_t theType) { int_t tmpPlayer; int_t tmpReligion; int_t tmpType; int_t i; tmpPlayer = thePlayer; tmpReligion = theReligion; tmpType = theType; i = 0; if (tmpType == 1) { while (ReligionChange[i] != 0) { i = i + 1; } ReligionChange[i] = tmpPlayer; ReligionChange[i + 1] = tmpReligion; } elseif (tmpType == 2) { while (ReligionAssim[i] != 0) { i = i + 1; } ReligionAssim[i] = tmpPlayer; ReligionAssim[i + 1] = tmpReligion; } } void_f SendReligionMessage(int_t theType) { int_t tmpType; int_t i; tmpType = theType; if (tmpType == 1) { if (ReligionChange[(SentChanges[0]*2)] == 0) { for (i = 0; i < SentChanges[0]*2; i = i + 1){ ReligionChange[i] = 0; } SentChanges[0] = 0; } else{ player[0] = ReligionChange[(SentChanges[0]*2)]; player[3] = ReligionChange[(SentChanges[0]*2+1)]; SentChanges[0] = SentChanges[0] + 1; message(g.player, 'StateReligionChange'); } } elseif (tmpType == 2) { if (ReligionAssim[(SentChanges[1]*2)] == 0) { for (i = 0; i < SentChanges[1]*2; i = i + 1){ ReligionAssim[i] = 0; } SentChanges[1] = 0; } else{ player[0] = ReligionAssim[(SentChanges[1]*2)]; player[3] = ReligionAssim[(SentChanges[1]*2+1)]; SentChanges[1] = SentChanges[1] + 1; message(g.player, 'ReligionAssimilated'); } } } //ConvertCity(city_t, int_t, int_t) //ConvertCityOrder(army_t, location_t) //ConvertCityUnit(unit_t, city_t) /////////////////////// //New EventHandlers // /////////////////////// HandleEvent(CreateUnit) 'SetNewSettlerReligion' post { int_t unitNum; int_t i; int_t tmpReligion; unit_t tmpUnit; city_t tmpcity; location_t tmpLoc; if(CityIsValid(city[0])) { tmpcity = city[0]; tmpLoc = tmpcity.location; unitNum = GetUnitsAtLocation(tmpLoc); for(i = 0; i < unitNum; i = i + 1) { GetUnitFromCell(tmpLoc, i, tmpUnit); if(tmpUnit.type == UnitDB(UNIT_SETTLER) || tmpUnit.type == UnitDB(UNIT_URBAN_PLANNER) || tmpUnit.type == UnitDB(UNIT_SEA_ENGINEER)){ tmpReligion = GetCityReligion(tmpcity); StoreSettlerReligion(tmpUnit, tmpReligion); } } } } HandleEvent(Settle) 'ReligiousCityLocation' post { int_t i; unit_t tmpUnit; army_t tmpArmy; for(i = 0; i < ReligiousSettler.#; i = i + 1) { if(ReligiousSettler[i].valid == 1) { tmpUnit = ReligiousSettler[i]; GetArmyFromUnit(tmpUnit, tmpArmy); if(tmpArmy == army[0]) { ReligiousLocation = army[0].location; LocationReligion = SettlerReligion[i]; } } } } HandleEvent(CreateCity) 'NewCreateCity' post { int_t i; city_t tmpCity; int_t tmpReligion; if(CityIsValid(city[0])) { tmpCity = city[0]; tmpReligion = PlayerReligion[tmpCity.owner]; if (ReligiousLocation == tmpcity.location) { tmpReligion = LocationReligion; } StoreCity(tmpCity, tmpReligion); } } HandleEvent(ConvertCityUnit) 'ControlConversion' pre { int_t Convertor; int_t SinCity; Convertor = unit[0].owner; SinCity = GetCityReligion(city[0]); if(!IsHumanPlayer(Convertor)) { if(PlayerReligion[Convertor] == SinCity) { //AI Event: IndulgenceSaleMade(unit[0], city[0]); AddEffect(city[0].location, "SPECEFFECT_INDULGENCE_SALES", "SOUND_ID_INDULGENCE_SALES"); return STOP; } } elseif(PlayerReligion[Convertor] == SinCity) { //human message(Convertor, 'NothingToReformHere'); return STOP; } } HandleEvent(ConvertCityUnit) 'newConvertCity' post { int_t i; city_t tmpCity; tmpCity = city[0]; CityRel = PlayerReligion[unit[0].owner]; Event:ConvertCity(tmpCity, CityRel, 0); //actual conversion with the civ's state religion StoreCity(tmpCity, CityRel); } HandleEvent(ConvertCityUnit) 'DoYouWantToConvert' post { city_t tmpCity; int_t tmpReligion; if (CityIsValid(city[0])) { tmpCity = city[0]; Convertor = unit[0].owner; Sinner = tmpCity.owner; tmpReligion = PlayerReligion[Convertor]; if (IsHumanPlayer(Sinner) && tmpReligion != PlayerReligion[Sinner] && GetPlayerCityReligionLevel(Sinner, tmpReligion) > 1000) { //human player[3] = tmpReligion; message(Sinner, 'DoYouWantToConvertCiv'); // let him choose if he wants to convert his empire } elseif (!IsHumanPlayer(Sinner) && PlayerReligion[Sinner] != tmpReligion && GetReligionLevel(tmpReligion) > 2*GetReligionLevel(PlayerReligion[Sinner]) && GetPlayerCityReligionLevel(Sinner, tmpReligion) > 2500) { //AI MessageReligion(Sinner, tmpReligion, 1); PlayerReligion[Sinner] = tmpReligion; } elseif (!IsHumanPlayer(Sinner) && PlayerReligion[Sinner] != tmpReligion && GetPlayerCityReligionLevel(Sinner, tmpReligion) > 7500) { //also AI MessageReligion(Sinner, tmpReligion, 1); PlayerReligion[Sinner] = tmpReligion; } else{ Event:AddHappyTimer(city[0], 1, -2, 14); //AI denying city's request } } } // ReformCityUnit(unit_t, city_t) // ReformCityOrder(army_t) // UnconvertCity(city_t) HandleEvent(ReformCityUnit) 'NewUncovertCity' pre { //reformation by city owner int_t tmpReligion; int_t CityReligion; int_t CityReligionLevel; int_t cityPop; int_t unitNum; int_t u; unit_t tmpUnit; city_t tmpCity; if(CityIsValid(city[0])) { tmpCity = city[0]; cityPop = tmpCity.population; ReformerPlayer = g.player; tmpReligion = PlayerReligion[ReformerPlayer]; CityReligion = GetCityReligion(city[0]); // Check which religion converted the player CityReligionLevel = GetReligionLevel(CityReligion); unitNum = GetUnitsAtLocation(tmpCity.location); for(u = 0; u < unitNum; u = u + 1) { GetUnitFromCell(tmpCity.location, u, tmpUnit); if(IsCivilian(tmpUnit)) { unitNum = unitNum -1; } } NewReformCost = (CityReligionLevel*PlayerNum*cityPop*5)/(unitNum*100); if(PlayerGold(ReformerPlayer) > NewReformCost) { if(IsHumanPlayer(ReformerPlayer)){ //human if(CityReligion != tmpReligion && CityReligion != ReformerPlayer && ReformerPlayer != tmpReligion) { player[3] = tmpReligion; message(ReformerPlayer, 'NewUncovertCityMessage1'); AddMovement(unit[0], -100); } elseif(CityReligion == tmpReligion && ReformerPlayer != tmpReligion) { player[3] = tmpReligion; message(ReformerPlayer, 'NewUncovertCityMessage2'); AddMovement(unit[0], -100); } elseif(CityReligion == ReformerPlayer && ReformerPlayer != tmpReligion) { message(ReformerPlayer, 'NewUncovertCityMessage3'); AddMovement(unit[0], -100); } elseif(CityReligion != tmpReligion && ReformerPlayer == tmpReligion) { message(ReformerPlayer, 'NewUncovertCityMessage4'); AddMovement(unit[0], -100); } else{ //if all equal but I think in that case the game doesn't let you order a reformation message(ReformerPlayer, 'NothingToReformHere'); AddMovement(unit[0], -100); } } elseif(PlayerGold(ReformerPlayer) > 3*NewReformCost && CityReligion != tmpReligion && GetReligionLevel(tmpReligion) > CityReligionLevel/2) { //AI StoreCity(tmpCity, tmpReligion); AddGold(g.player, - NewReformCost); CityRel = tmpReligion; Event:ConvertCity(tmpCity, CityRel, 0); AddEffect(tmpCity.location, "SPECEFFECT_REFORMCITY", "SOUND_ID_REFORM_CITY"); AddMovement(unit[0], -100); Event:AddHappyTimer(tmpCity, 1, -2, 14); } elseif(PlayerGold(ReformerPlayer) > 3*NewReformCost && CityReligion == tmpReligion && random(3) == 0 && GetPlayerCityReligionLevel(ReformerPlayer, tmpReligion) < 8000 && ReformerPlayer != tmpReligion) { //AI returning to old religion MessageReligion(ReformerPlayer, ReformerPlayer, 1); PlayerReligion[ReformerPlayer] = ReformerPlayer; StoreCity(tmpCity, ReformerPlayer); AddGold(g.player, - NewReformCost); CityRel = ReformerPlayer; Event:ConvertCity(tmpCity, CityRel, 0); AddEffect(tmpCity.location, "SPECEFFECT_REFORMCITY", "SOUND_ID_REFORM_CITY"); AddMovement(unit[0], -100); Event:AddHappyTimer(tmpCity, 1, -2, 14); } else{ //AI not doing anything } } else{ message(ReformerPlayer, 'DontHaveEnoughMoneyToReform'); AddMovement(unit[0], -100); } } return STOP; } HandleEvent(IndulgenceSaleMade) 'newSellIndulgences' pre { int_t SinfulCiv; int_t SinfulReligion; int_t PriestCiv; int_t PriestReligion; int_t tmpReligion; int_t Tenth; int_t TenthFactor; city_t tmpCity; tmpCity = city[0]; PriestCiv = unit[0].owner; PriestReligion = PlayerReligion[PriestCiv]; tmpReligion = GetCityReligion(city[0]); SinfulCiv = tmpCity.owner; if(!IsHumanPlayer(PriestCiv) && PlayerGold(PriestCiv) > 800 ) { //AI will try to convert first if(PriestReligion != tmpReligion) { StoreCity(tmpCity, PriestReligion); CityRel = PriestReligion; Event:ConvertCity(tmpCity, CityRel, 0); AddEffect(tmpCity.location, "SPECEFFECT_CONVERT_CITIES", "SOUND_ID_CONVERT_CITIES"); AddMovement(unit[0], -100); AddGold(PriestCiv, -400); return STOP; } } TenthFactor = 2; if(HasAdvance(tmpCity.owner, ID_ADVANCE_THEOLOGY)) { TenthFactor = 4; } if(HasAdvance(tmpCity.owner, ID_ADVANCE_AGE_OF_REASON)) { TenthFactor = 2; } if(HasAdvance(tmpCity.owner, ID_ADVANCE_MASS_MEDIA)) { TenthFactor = 1; } if (PriestReligion == tmpReligion) { // If city has same religion as cleric owner Tenth = tmpCity.population*TenthFactor; // he gets 5 gold per pop AddGold(SinfulCiv, - Tenth); AddGold(PriestCiv, Tenth); } elseif (PriestReligion != tmpReligion) { // if city has other religion Tenth = (tmpCity.population*TenthFactor)/2; // he gets 1 gold per pop AddGold(SinfulCiv, - Tenth); AddGold(PriestCiv, Tenth); } } HandleEvent(BeginTurn) 'ConvertorTakesTheMoneyPerTurn' post { // Every Turn int_t i; int_t u; int_t nr; int_t CurrentRound; int_t tmpPlayer; int_t tmpReligion; int_t theTenth; int_t TenthFactor; int_t PopNumPay; int_t HappyMod; int_t HappyBonus; int_t Level; int_t CityCount; int_t CityReligionLevel; int_t unitNum; city_t tmpCity; city_t FirstCity; unit_t tmpUnit; CurrentRound = GetCurrentRound(); tmpPlayer = g.player; tmpReligion = PlayerReligion[tmpPlayer]; //reset HapyModInfo for (i = 0; i <= 12; i = i + 1){ HappyModInfo[i] = 0; } // Reconvert all cities, Happiness Modifier and AI reform its cities CityCount = PlayerCityCount(tmpPlayer); for (i = 0; i < CityCount; i = i + 1) { GetCityByIndex(tmpPlayer, i, tmpCity); if(CityIsValid(tmpCity)) { CityRel = GetCityReligion(tmpCity); Event:ConvertCity(tmpCity, CityRel, 0); CityReligionLevel = GetReligionLevel(CityRel); if (CityReligionLevel*PlayerNum >= 10000) { HappyMod = (CityReligionLevel*PlayerNum - 10000)/(PlayerNum -1); HappyBonus = 1; } else{ HappyMod = 10000 - CityReligionLevel*PlayerNum; HappyBonus = -1; } //HappyMod is now on a scale of 0 to 10000, this means that: //loosing all your empire to another religion while not having converted the state religion //is equal to converting the whole world if(HappyMod < 1250) { HappyBonus = 0; AddToHappyModInfo(6); } elseif(HappyMod >= 1250 && HappyMod < 2750) { AddToHappyModInfo(6+HappyBonus); HappyBonus = HappyBonus * 1; } elseif(HappyMod >= 2750 && HappyMod < 4250) { AddToHappyModInfo(6+(2*HappyBonus)); HappyBonus = HappyBonus * 2; } elseif(HappyMod >= 4250 && HappyMod < 5750) { AddToHappyModInfo(6+(3*HappyBonus)); HappyBonus = HappyBonus * 3; } elseif(HappyMod >= 5750 && HappyMod < 7250) { AddToHappyModInfo(6+(4*HappyBonus)); HappyBonus = HappyBonus * 4; } elseif(HappyMod >= 7250 && HappyMod < 8750) { AddToHappyModInfo(6+(5*HappyBonus)); HappyBonus = HappyBonus * 5; } elseif(HappyMod >= 8750) { AddToHappyModInfo(6+(6*HappyBonus)); HappyBonus = HappyBonus * 6; } Event:AddHappyTimer(tmpCity, 1, HappyBonus, 14); if(!IsHumanPlayer(tmpPlayer) && CityRel != tmpReligion){ //AI reforming his cities (goal set to 0 in goals.txt) unitNum = GetUnitsAtLocation(tmpCity.location); for(u = 0; u < unitNum; u = u + 1) { GetUnitFromCell(tmpCity.location, u, tmpUnit); if(!IsCivilian(tmpUnit)) { Event:ReformCityUnit(tmpUnit, tmpCity); } } } } } //diplomacy and search new players for(i = 1; i <= 30; i = i + 1) { //without the barbarians if (tmpPlayer != i && IsPlayerAlive(i) && i > 0) { if(PlayerReligion[i] == 0) { if (PlayerCityCount(i) > 0) { GetCityByIndex(i, 0, FirstCity); PlayerReligion[i] = GetCityReligion(FirstCity); //if city has no religion -> default is owner number PlayerNum = PlayerNum + 1; } } //VOID LogRegardEvent(int, int, regardDelta, regardEventType, ID_string, Delta_what) //regardDelta is the amount to increase the first player's regard towards the second by. //The Regard Event Types are ScenarioEvent, MilitaryPowerEvent, MilitarySafetyEvent, DiplomacyEvent, GoldEvent, KnowledgeEvent, & ProductionEvent. So "0" is probably the null event type. //ID_string is a string used in the Diplomacy intelligence screen. //Delta_what has, I think, something to do with turns. For example, // Make the Allies like each other //LogRegardEvent(2, 3, 1000, 0, ID_WW_BLANK, turnMax); //where turnMax is the number of turns in the WW2 scenario. It doesn't seem to make the change recur though. elseif(tmpReligion != PlayerReligion[i]) { player[3] = i; LogRegardEvent(player[3], player[0], -2, 0, ID_NONE, 0); } else { player[3] = i; LogRegardEvent(player[3], player[0], 5, 0, ID_NONE, 0); } } } // the tenth: player gets/pays for each city if (tmpPlayer == 0) { //only doing this on the barbarians' turn for everybody -> saves comp time for (i = 0; i <= 30; i = i + 1 ){ PlayerTenthPay[i] = 0; PlayerTenthGet[i] = 0; } for (i = 0; i < allCities.#; i = i + 1) { if(CityIsValid(allCities[i])) { tmpCity = allCities[i]; Sinner = tmpCity.owner; Convertor = CityReligion[i]; tmpReligion = PlayerReligion[Sinner]; TenthFactor = 3; if(HasAdvance(tmpCity.owner, ID_ADVANCE_THEOLOGY)) { TenthFactor = 5; } if(HasAdvance(tmpCity.owner, ID_ADVANCE_AGE_OF_REASON)) { TenthFactor = 3; } if(HasAdvance(tmpCity.owner, ID_ADVANCE_MASS_MEDIA)) { TenthFactor = 1; } PopNumPay = tmpCity.Population*TenthFactor; if (tmpReligion != Convertor) { nr = HowManyPlayersHaveReligion(Convertor); if (nr != 0) { // if somebody has this religon as state religion AddPlayerTenth(Sinner,-PopNumPay*(1+(nr-1)/2)); AddReligionTenth(Convertor, (PopNumPay*(1+(nr-1)/2))/nr); } //else city doesn't pay to anyone } // if tmpReligion == Convertor don't pay } } } theTenth = PlayerTenthGet[tmpPlayer] + PlayerTenthPay[tmpPlayer]; AddGold(tmpPlayer, theTenth); //Religious Info if (tmpPlayer != 0) { for(i = 1; i < 200; i = i + 1) { if(CurrentRound == infocycle[0] + infocycle[1]*i){ Receiver = tmpPlayer; ReligionLevel = GetReligionLevel(tmpPlayer)/100; player[3] = tmpReligion; message(tmpPlayer, 'ReligionInfo'); } } } if (IsHumanPlayer(tmpPlayer)) { SendReligionMessage(1); SendReligionMessage(2); } } //when a city is captured the converted sign dissappears if the //city's religion is the same as capturer's player number, but that turns out ok at he beginning of the next turn //BUT //when a player dies his religion would dissappear, //this code merges the dead religion with that the victorious player's HandleEvent(CaptureCity) 'PlayerDiedReligionIsAssimilated' pre { // Dead players int_t i; int_t KillerPlayer; int_t DeadPlayer; int_t CityReligion; int_t NewReligion; city_t tmpCity; KillerPlayer = g.player; DeadPlayer = city[0].owner; if (PlayerCityCount(DeadPlayer) == 1) { NewReligion = PlayerReligion[KillerPlayer]; PlayerReligion[DeadPlayer] = 0; if (NewReligion == DeadPlayer) { //if conquerer had the deceased's religion he gets his old one back PlayerReligion[KillerPlayer] = KillerPlayer; NewReligion = KillerPlayer; } if (IsHumanPlayer(KillerPlayer)) { player[0] = DeadPlayer; player[3] = NewReligion; message(KillerPlayer, 'ReligionAssimilated'); } else{ MessageReligion(DeadPlayer, NewReligion, 2); } //I have seen the follwoing code not change the last just taken city - it'll have no religion but i saw it only happen once... for (i=0; i < allCities.#; i = i + 1) { if(CityIsValid(allCities[i])) { tmpCity = allCities[i]; CityReligion = GetCityReligion(tmpCity); if (CityReligion == DeadPlayer) { StoreCity(tmpCity, NewReligion); } } } } } ///////////////// //NewMessages // ///////////////// messagebox 'ReligionInfo' { text(ID_RELIGIOUS_INFO); if (infocycle[2] == 0) { show(); } Button(ID_CYCLE) { Kill(); message(g.player, 'InfoCycleMessage'); } Button(ID_OK) { Kill(); } } messagebox 'InfoCycleMessage' { text(ID_INFO_CYCLE); show(); infocycle[0] = GetCurrentRound(); Button(ID_ET5) { infocycle[1] = 5; Kill(); } Button(ID_ET10) { infocycle[1] = 10; Kill(); } Button(ID_ET20) { infocycle[1] = 20; Kill(); } if (infocycle[2] == 0) { Button(ID_OIMSGT) { infocycle[2] = 1; Kill(); message(g.player, 'InfoCycleMessage'); } } if (infocycle[2] == 1) { Button(ID_DMOS) { infocycle[2] = 0; Kill(); message(g.player, 'InfoCycleMessage'); } } } Alertbox 'StateReligionChange' { text(ID_STATE_RELIGION_CHANGE); show(); Button(ID_OK) { Kill(); SendReligionMessage(1); } } Alertbox 'ReligionAssimilated' { text(ID_RELIGION_ASSIMILATED); show(); Button(ID_OK) { Kill(); SendReligionMessage(2); } } AlertBox 'DoYouWantToConvertCiv' { Title(ID_WILL_WE_CONVERT_TITLE); Text(ID_WILL_WE_CONVERT_TEXT); show(); Button(ID_DONT_CONVERT) { // If the player doesn't accept Event:AddHappyTimer(city[0], 1, -2, 14); // The city which has recently been converted gets -2 happiness for 1 turn Kill(); } Button(ID_CONVERT) { // if the player does accept MessageReligion(Sinner, PlayerReligion[Convertor], 1); PlayerReligion[Sinner] = PlayerReligion[Convertor]; // His religion changes Kill(); } } messagebox 'NothingToReformHere' { text(ID_NOTHING_TO_REFORM_HERE); // "The city of {city[0].name} is already converted to our empire official religion." show(); Button(ID_OK) { Kill(); } } messagebox 'DontHaveEnoughMoneyToReform' { text(ID_NOT_ENOUGH_MONEY_TO_REFORM); // "Sir, the reformation of this city will cost you {NewReformCost} gold. Unfortunetly our funds dont have enough money." show(); Button(ID_OK) { Kill(); } } Alertbox 'NewUncovertCityMessage1' { text(ID_CONVERT_OR_NOT1); show(); Button(ID_CANCEL_UNCONVERSION) { // "Cancel Order" Kill(); } Button(ID_CONVERT_TO_RELIGION) { // "Convert to our Religion" CityRel = PlayerReligion[ReformerPlayer]; StoreCity(city[0], CityRel); AddGold(g.player, - NewReformCost); Event:ConvertCity(city[0], CityRel, 0); AddEffect(city[0].location, "SPECEFFECT_REFORMCITY", "SOUND_ID_REFORM_CITY"); Event:AddHappyTimer(city[0], 1, -2, 14); Kill(); } Button(ID_CREATE_RELIGION) { // "Rescue Old Religion" MessageReligion(ReformerPlayer, ReformerPlayer, 1); PlayerReligion[ReformerPlayer] = ReformerPlayer; CityRel = ReformerPlayer; StoreCity(city[0], CityRel); AddGold(g.player, - NewReformCost); Event:ConvertCity(city[0], CityRel, 0); AddEffect(city[0].location, "SPECEFFECT_REFORMCITY", "SOUND_ID_REFORM_CITY"); Event:AddHappyTimer(city[0], 1, -2, 14); Kill(); } } Alertbox 'NewUncovertCityMessage2' { text(ID_CONVERT_OR_NOT2); show(); Button(ID_CANCEL_UNCONVERSION) { // "Cancel Order" Kill(); } Button(ID_CREATE_RELIGION) { // "Rescue Old Religion" MessageReligion(ReformerPlayer, ReformerPlayer, 1); PlayerReligion[ReformerPlayer] = ReformerPlayer; CityRel = ReformerPlayer; StoreCity(city[0], CityRel); AddGold(g.player, - NewReformCost); Event:ConvertCity(city[0], CityRel, 0); AddEffect(city[0].location, "SPECEFFECT_REFORMCITY", "SOUND_ID_REFORM_CITY"); Event:AddHappyTimer(city[0], 1, -2, 14); Kill(); } } Alertbox 'NewUncovertCityMessage3' { text(ID_CONVERT_OR_NOT3); show(); Button(ID_CANCEL_UNCONVERSION) { // "Cancel Order" Kill(); } Button(ID_CONVERT_TO_RELIGION) { // "Convert to our Religion" CityRel = PlayerReligion[ReformerPlayer]; StoreCity(city[0], CityRel); AddGold(g.player, - NewReformCost); Event:ConvertCity(city[0], CityRel, 0); AddEffect(city[0].location, "SPECEFFECT_REFORMCITY", "SOUND_ID_REFORM_CITY"); Event:AddHappyTimer(city[0], 1, -2, 14); Kill(); } } Alertbox 'NewUncovertCityMessage4' { text(ID_CONVERT_OR_NOT4); show(); Button(ID_CANCEL_UNCONVERSION) { // "Cancel Order" Kill(); } Button(ID_CONVERT_TO_RELIGION) { // "Convert to our Religion" CityRel = PlayerReligion[ReformerPlayer]; StoreCity(city[0], CityRel); AddGold(g.player, - NewReformCost); Event:ConvertCity(city[0], CityRel, 0); AddEffect(city[0].location, "SPECEFFECT_REFORMCITY", "SOUND_ID_REFORM_CITY"); Event:AddHappyTimer(city[0], 1, -2, 14); Kill(); } }