// Call to Conquest Script ////////////////// INITIALISATION HandleEvent(BeginTurn)'CTC_NumofPlayers' pre { int_t i; int_t j; int_t livePlayers; city_t tmpCity; if (g.year==0){ //else done at endturn when SLIC reloaded SetPreference("AlienEndGame",0);// turn bloodlust on ? if (preference("MaxPlayers") < preference("NumPlayers")){ CTC_PLAYER_COUNT= preference("NumPlayers"); } else{ CTC_PLAYER_COUNT= preference("MaxPlayers"); } for (i=0;i 0){ message(player[0],'CTC_ReStartOptions');//just for DESTROY_BUILDINGS_PERCENT, etc DisableTrigger('CTC_ReloadSlic'); } } } HandleEvent(BeginTurn) 'CTC_InitGeogThreatSystem' pre { // on turn 0: DisableTrigger('CTC_ReinitializeAfterReloadingSLIC'); DisableTrigger('CTC_ReInstateCheckGeogArraysOnCapture'); DisableTrigger('CTC_AI_GeogThreatStates'); DisableTrigger('CTC_MakeContact'); DisableTrigger('CTC_MakeContactWithHuman'); DisableTrigger('CTC_LoadDipStateCycles'); DisableTrigger('CTC_CheckGeogArraysOnCapture'); DisableTrigger('CTC_CheckGeogArraysOnCreate'); DisableTrigger('CTC_CheckGeogArraysOnKill'); DisableTrigger('CTC_CheckGeogArraysAfterSurrender'); DisableTrigger('CTC_Pre_Trigger_AI_Tactics');// hence: DisableTrigger('CTC_Trigger_AI_Land_Tactics'); DisableTrigger('CTC_TacticsPrep');//make field army arrays DisableTrigger('CTC_AI_Land_Tactics'); DisableTrigger('CTC_InitGeogThreatSystem'); } // if someone reloads SLIC: HandleEvent(EndTurn) 'CTC_ReinitializeAfterReloadingSLIC' pre { int_t i; int_t j; city_t tmpCity; int_t CitiesDoneFlg; int_t HasSteelFlg; int_t HasFlightFlg; int_t livePlayers; SetPreference("AlienEndGame",0);// turn bloodlust on DisableTrigger('CTC_CheckForCities'); DisableTrigger('CTC_InitGeogThreatSystem'); DisableTrigger('CTC_AI_GeogThreatStates'); DisableTrigger('CTC_MakeContact'); DisableTrigger('CTC_MakeContactWithHuman'); DisableTrigger('CTC_LoadDipStateCycles'); DisableTrigger('CTC_CheckGeogArraysOnCapture'); DisableTrigger('CTC_CheckGeogArraysOnCreate'); DisableTrigger('CTC_CheckGeogArraysOnKill'); DisableTrigger('CTC_CheckGeogArraysAfterSurrender'); DisableTrigger('CTC_Pre_Trigger_AI_Tactics');// hence: DisableTrigger('CTC_Trigger_AI_Land_Tactics'); DisableTrigger('CTC_TacticsPrep');//make field army arrays DisableTrigger('CTC_AI_Land_Tactics'); DisableTrigger('CTC_Bombard_PillboxSpec'); DisableTrigger('StartBuildingAirBases'); DisableTrigger('BuildNearbyAirBase'); DisableTrigger('LookForAirBase'); DisableTrigger('BuildNearbyAirBaseAfterSwap'); DisableTrigger('SaveTheAirBases'); DisableTrigger('TrackAirBases'); DisableTrigger('DeleteAirBase'); DisableTrigger('GroupAirUnits'); DisableTrigger('SaveThePlanes'); DisableTrigger('BackToLandingPlaceAfterBombarding'); // unit building system: if (preference("MaxPlayers") < preference("NumPlayers")){ CTC_PLAYER_COUNT= preference("NumPlayers"); } else{ CTC_PLAYER_COUNT= preference("MaxPlayers"); } livePlayers=0; for (i=0;i 0){//for reloadslic HAM_ON=1; EnableTrigger('CTC_Start_Hammurabi'); EnableTrigger('CTC_Start_Ramses'); EnableTrigger('CTC_Start_Cyrus'); EnableTrigger('CTC_Start_Alexander'); EnableTrigger('CTC_Start_Caesar'); // EnableTrigger('Restart_Muhammad'); <= TBD, doesn't exist EnableTrigger('CTC_Start_Charlemagne'); // EnableTrigger('Restart_HernanCortes'); <= TBD, doesn't exist EnableTrigger('CTC_Start_StonewallJackson'); EnableTrigger('CTC_Start_DwightEisenhower'); EnableTrigger('CTC_Start_NormanSchwarzkopf'); EnableTrigger('CTC_Start_Zhukov'); EnableTrigger('CTC_Start_Rommel'); } Kill(); message(player[0],'CTC_SixthOption'); } Button(ID_NO) { Kill(); message(player[0],'CTC_SixthOption'); } } messagebox 'CTC_SixthOption' { show(); Title(ID_CollateralDamage); Text(ID_SixthOptionM); Button(ID_HIGHF) { PILLAGE_PERCENT=9; Kill(); message(player[0],'CTC_SeventhOption'); } Button(ID_MEDIUMF) { PILLAGE_PERCENT=6; Kill(); message(player[0],'CTC_SeventhOption'); } Button(ID_LOWF) { PILLAGE_PERCENT=3; Kill(); message(player[0],'CTC_SeventhOption'); } Button(ID_DontInclude) { PILLAGE_PERCENT=0; Kill(); message(player[0],'CTC_SeventhOption'); } } messagebox 'CTC_SeventhOption' { show(); Title(ID_AutoPilot); Text(ID_SeventhOptionM); Button(ID_YES) { CTC_AUTOPILOT=1; Kill(); message(player[0],'CTC_EndOptions'); } Button(ID_NO) { Kill(); message(player[0],'CTC_EndOptions'); } } messagebox 'CTC_EndOptions' { show(); Text(ID_EndOptionsM); // That's all for now. Have fun! Button(ID_STARTGAME){ Kill(); } } //////////////////////////////// // // ENABLED/DISABLED HANDLERS // //////////////////////////////// HandleEvent(MoveUnits)'CTC_QuickStartMove' pre { //Run Quickstart Once at Game Start int_t i; int_t j; int_t numSettlers; unit_t tmpUnit; if (g.year==0) { for(j=1; j < CTC_PLAYER_COUNT; j=j+1){ if (IsPlayerAlive(j)){ GetUnitByIndex(j,0,tmpUnit); if (GetUnitsAtLocation(tmpUnit.location)==1){ numSettlers=4; } else{ numSettlers=3; } for(i=0; i3 int_t i; int_t tmpDead; int_t PPChance; int_t j; int_t hospitalCount; int_t drugstoreCount; int_t foodsiloCount; int_t aqueductCount; city_t PlaguedCity; city_t tmpCity; tmpPlayer = thePlayer; CityCount = PlayerCityCount(tmpPlayer); PLAGUED_CITY_COUNTER = 0; DEATH_COUNT=0; aqueductCount=0; properCityCount=0; // what about AI?: if (IsHumanPlayer(tmpPlayer)){//ancient plagues for(i = 0; i < CityCount; i = i + 1){ GetCityByIndex(tmpPlayer, i, PlaguedCity); if (PlaguedCity.population>3){ properCityCount=properCityCount+1; if(CityHasBuilding(PlaguedCity, "IMPROVE_AQUEDUCT")){ aqueductCount=aqueductCount+1; } } } if(properCityCount){ if ((aqueductCount*100)/properCityCount< 85){//must have 85% aqueducts in proper Cities to prevent plagues for(i = 0; i < CityCount; i = i + 1){ GetCityByIndex(tmpPlayer, i, PlaguedCity); if(PlaguedCity.population > 3){ // // Buildings that reduce plague chance are: // aqueduct // // Start = 100% chance of plague in PlaguedCity PPChance = 100; // + aqueduct --> 40/60 chance // if(CityHasBuilding(PlaguedCity, "IMPROVE_AQUEDUCT")){ PPChance = PPChance - 60; } if(random(100) <= PPChance){ Event:AddHappyTimer(PlaguedCity, 3, -2, 14); // 3 turns of -2 happiness PLAGUED_CITY_COUNTER = PLAGUED_CITY_COUNTER + 1; if (random(100) <= PPChance/2){//serious plague, people die city[0] = PlaguedCity; tmpDead = city[0].population/8; //from 5 DEATH_COUNT=DEATH_COUNT+tmpDead; for(j = 0; j < tmpDead; j = j + 1){ Event:KillPop(PlaguedCity); } } } } } } // cities and deaths done, now messages else{// no more plagues message(tmpPlayer,'CTC_ForesightPreventedPlague'); for (j=0;j20 ? int_t i; int_t tmpDead; int_t PPChance; int_t j; int_t hospitalCount; int_t drugstoreCount; int_t foodsiloCount; int_t successFlg; city_t PlaguedCity; city_t tmpCity; tmpPlayer = thePlayer; CityCount = PlayerCityCount(tmpPlayer); PLAGUED_CITY_COUNTER = 0; DEATH_COUNT=0; hospitalCount=0; drugstoreCount=0; foodsiloCount=0; properCityCount=0; successFlg=0; // what about AI?: if (IsHumanPlayer(tmpPlayer)){ if (HasAdvance(tmpPlayer, ID_ADVANCE_RAILROAD) ){//modern epidemics for(i = 0; i < CityCount; i = i + 1){ GetCityByIndex(tmpPlayer, i, PlaguedCity); if(PlaguedCity.population >= 20){// only proper cities suffer // // Building that reduce epidemic chance are: // food silo, drug store, hospital // // Start = 100% chance of epidemic in PlaguedCity PPChance = 100; // + food silo --> 50/50 chance // + hospital --> 25/75 chance // + drug store --> 0/100 chance // if(CityHasBuilding(PlaguedCity, "IMPROVE_FOOD_SILO")){ foodsiloCount=foodsiloCount+1; PPChance = PPChance - 50; } if(CityHasBuilding(PlaguedCity, "IMPROVE_HOSPITAL")){ hospitalCount=hospitalCount+1; PPChance = PPChance - 25; } if(CityHasBuilding(PlaguedCity, "IMPROVE_DRUG_STORE")){ drugstoreCount=drugstoreCount+1; PPChance = PPChance - 25; } if(random(99)<=PPChance-1){ city[0] = PlaguedCity; tmpDead = city[0].population/20;//from 5 DEATH_COUNT=DEATH_COUNT+tmpDead; for(j = 0; j < tmpDead; j = j + 1){ Event:KillPop(PlaguedCity); } Event:AddHappyTimer(PlaguedCity, 3, -3, 14); // 3 turns of -3 happiness PLAGUED_CITY_COUNTER = PLAGUED_CITY_COUNTER + 1; } } } // cities and deaths done, now messages if(HasAdvance(tmpPlayer, ID_ADVANCE_PHARMACEUTICALS)){ if (drugstoreCount==CityCount){ // total success message(tmpPlayer,'CTC_NoMoreEpidemics'); for (j=0;j= 3 && IsHumanPlayer(player[0].owner)){ PlagueChance = random(100); if(PlagueChance 8 ) { if (TerrainType(location[0])<10 || (TerrainType(location[0])>17 && TerrainType(location[0])<22) ){//not at sea CyrusLoc=location[0].location; event:AccomplishFeat(featDB(FEAT_GOT_CYRUS), army[0].owner); DisableTrigger('CTC_Cyrus'); } } } HandleEvent(BeginTurnUnit) 'CTC_Start_Cyrus' pre { if(Unit[0].type == UnitDB(UNIT_CYRUS)) { CyrusCount=50; EnableTrigger('CTC_CyrusLives'); EnableTrigger('CTC_CyrusDies'); DisableTrigger('CTC_Start_Cyrus'); } } HandleEvent(BeginTurnUnit) 'CTC_CyrusLives' post { int_t j; int_t numCities; int_t tmpPlayer; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_CYRUS)) { CTC_VeteranEffect(Unit[0].location); CyrusCount=CyrusCount-1; if (CyrusCount<=0){//dies of old age tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_CYRUS); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } event:DisbandUnit(unit[0]); DisableTrigger('CTC_CyrusLives'); DisableTrigger('CTC_CyrusDies'); } } } HandleEvent(KillUnit) 'CTC_CyrusDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_CYRUS)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_CYRUS); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_CyrusLives'); DisableTrigger('CTC_CyrusDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } // Alexander the Great HandleEvent(CreateWonder) 'CTC_AlexandertheGreat' post { if(value[0] == WonderDB(WONDER_ARISTOTLES_LYCEUM)) { if (GetUnitsAtLocation(city[0].location)<12){ CreateUnit(city[0].owner, UnitDB(UNIT_ALEXANDER_THE_GREAT), city[0].location, 0); } else{ CreateUnit(city[0].owner, UnitDB(UNIT_ALEXANDER_THE_GREAT), city[0].location, 1); } EnableTrigger('CTC_Start_Alexander'); DisableTrigger('CTC_AlexandertheGreat'); } } HandleEvent(BeginTurnUnit) 'CTC_Start_Alexander' pre { if(Unit[0].type == UnitDB(UNIT_ALEXANDER_THE_GREAT)) { AlexanderCount=50; EnableTrigger('CTC_AlexanderLives'); EnableTrigger('CTC_AlexanderDies'); DisableTrigger('CTC_Start_Alexander'); } } HandleEvent(BeginTurnUnit) 'CTC_AlexanderLives' post { int_t j; int_t tmpPlayer; int_t numCities; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_ALEXANDER_THE_GREAT)) { CTC_VeteranEffect(Unit[0].location); AlexanderCount=AlexanderCount-1; if (AlexanderCount<=0){//dies of old age tmpPlayer=Unit[0].owner; numCities=PlayerCityCount(tmpPlayer); for(j = 0; j < numCities; j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } SetString(0,ID_UNIT_ALEXANDER_THE_GREAT); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); event:DisbandUnit(unit[0]); DisableTrigger('CTC_AlexanderLives'); DisableTrigger('CTC_AlexanderDies'); } } } HandleEvent(KillUnit) 'CTC_AlexanderDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_ALEXANDER_THE_GREAT)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_ALEXANDER_THE_GREAT); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_AlexanderLives'); DisableTrigger('CTC_AlexanderDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } // Caesar HandleEvent(CreateWonder) 'CTC_Caesar' post { if(value[0] == WonderDB(WONDER_THE_APPIAN_WAY)) { if (GetUnitsAtLocation(city[0].location)<12){ CreateUnit(city[0].owner, UnitDB(UNIT_CAESAR), city[0].location, 0); } else{ CreateUnit(city[0].owner, UnitDB(UNIT_CAESAR), city[0].location, 1); } DisableTrigger('CTC_Caesar'); EnableTrigger('CTC_Start_Caesar'); } } HandleEvent(BeginTurnUnit) 'CTC_Start_Caesar' pre {// if SLIC is reloaded if(Unit[0].type == UnitDB(UNIT_CAESAR)) { CaesarCount=50; EnableTrigger('CTC_CaesarLives'); EnableTrigger('CTC_CaesarDies'); DisableTrigger('CTC_Start_Caesar'); } } HandleEvent(BeginTurnUnit) 'CTC_CaesarLives' post { int_t j; int_t tmpPlayer; int_t numCities; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_CAESAR)) { CTC_VeteranEffect(Unit[0].location); CaesarCount=CaesarCount-1; if (CaesarCount==0){//dies of old age tmpPlayer=Unit[0].owner; numCities=PlayerCityCount(tmpPlayer); SetString(0,ID_UNIT_CAESAR); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); for(j = 0; j < numCities; j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } event:DisbandUnit(unit[0]); DisableTrigger('CTC_CaesarLives'); DisableTrigger('CTC_CaesarDies'); } } } HandleEvent(KillUnit) 'CTC_CaesarDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_CAESAR)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_CAESAR); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_CaesarLives'); DisableTrigger('CTC_CaesarDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } // Muhammad //HandleEvent(CreateWonder) 'Muhammad' post { // if(value[0] == WonderDB(WONDER_CHICHEN_ITZA)) { // CreateUnit(city[0].owner, UnitDB(UNIT_MUHAMMAD), city[0].location, 0); // DisableTrigger('Muhammad'); // } //} // Charlemagne HandleEvent(VictoryMoveOrder) 'CTC_Charlemagne' post { if(HasAdvance(Army[0].owner,ID_ADVANCE_CHIVALRY) && army[0].size>9) { if (TerrainType(location[0])<10 || (TerrainType(location[0])>17 && TerrainType(location[0])<22)){//not at sea CharlemagneLoc=location[0].location; player[0]=army[0].owner; event:AccomplishFeat(featDB(FEAT_GOT_CHARLEMANGE), player[0]); DisableTrigger('CTC_Charlemagne'); } } } HandleEvent(BeginTurnUnit) 'CTC_Start_Charlemagne' pre { if(Unit[0].type == UnitDB(UNIT_CHARLEMANGE)) { CharlemagneCount=50; EnableTrigger('CTC_CharlemagneLives'); EnableTrigger('CTC_CharlemagneDies'); DisableTrigger('CTC_Start_Charlemagne'); } } HandleEvent(BeginTurnUnit) 'CTC_CharlemagneLives' post { int_t j; int_t numCities; int_t tmpPlayer; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_CHARLEMANGE)) { CTC_VeteranEffect(Unit[0].location); CharlemagneCount=CharlemagneCount-1; if (CharlemagneCount==0){//dies of old age tmpPlayer=Unit[0].owner; numCities=PlayerCityCount(tmpPlayer); SetString(0,ID_UNIT_CHARLEMANGE); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); for(j = 0; j < numCities; j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } event:DisbandUnit(unit[0]); DisableTrigger('CTC_CharlemagneLives'); DisableTrigger('CTC_CharlemagneDies'); } } } HandleEvent(KillUnit) 'CTC_CharlemagneDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_CHARLEMANGE)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_CHARLEMANGE); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_CharlemagneLives'); DisableTrigger('CTC_CharlemagneDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } // Hernan Cortes //HandleEvent(CreateWonder) 'HernanCortes' post { // if(value[0] == WonderDB(WONDER_EAST_INDIA_COMPANY)) { // CreateUnit(city[0].owner, UnitDB(UNIT_HERNAN_CORTES), city[0].location, 0); // DisableTrigger('HernanCortes'); // } //} // StonewallJackson HandleEvent(VictoryMoveOrder) 'CTC_StonewallJackson' post { if(HasAdvance(Army[0].owner,ID_ADVANCE_CAVALRY_TACTICS) && army[0].size>10) { if (TerrainType(location[0])<10 || (TerrainType(location[0])>17 && TerrainType(location[0])<22)){//not at sea StonewallJacksonLoc=location[0].location; player[0]=army[0].owner; event:AccomplishFeat(featDB(FEAT_GOT_STONEWALL_JACKSON), player[0]); DisableTrigger('CTC_StonewallJackson'); } } } HandleEvent(BeginTurnUnit) 'CTC_Start_StonewallJackson' pre { if(Unit[0].type == UnitDB(UNIT_STONEWALL_JACKSON)) { StonewallJacksonCount=50; EnableTrigger('CTC_StonewallJacksonLives'); EnableTrigger('CTC_StonewallJacksonDies'); DisableTrigger('CTC_Start_StonewallJackson'); } } HandleEvent(BeginTurnUnit) 'CTC_StonewallJacksonLives' post { int_t j; int_t tmpPlayer; int_t numCities; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_STONEWALL_JACKSON)) { CTC_VeteranEffect(Unit[0].location); StonewallJacksonCount=StonewallJacksonCount-1; if (StonewallJacksonCount==0){//dies of old age tmpPlayer=Unit[0].owner; numCities=PlayerCityCount(tmpPlayer); SetString(0,ID_UNIT_STONEWALL_JACKSON); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); for(j = 0; j < numCities; j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } event:DisbandUnit(unit[0]); DisableTrigger('CTC_StonewallJacksonLives'); DisableTrigger('CTC_StonewallJacksonDies'); } } } HandleEvent(KillUnit) 'CTC_StonewallJacksonDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_STONEWALL_JACKSON)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_STONEWALL_JACKSON); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_StonewallJacksonLives'); DisableTrigger('CTC_StonewallJacksonDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } HandleEvent(VictoryMoveOrder) 'CTC_Rommel' post { if(HasAdvance(Army[0].owner,ID_ADVANCE_INTERNAL_COMBUSTION) && army[0].size>9 ) { if (TerrainType(location[0])<10 || (TerrainType(location[0])>17 && TerrainType(location[0])<22) ){//not at sea RommelLoc=location[0].location; event:AccomplishFeat(featDB(FEAT_GOT_ROMMEL), army[0].owner); DisableTrigger('CTC_Rommel'); } } } HandleEvent(BeginTurnUnit) 'CTC_Start_Rommel' pre { if(Unit[0].type == UnitDB(UNIT_ERWIN_ROMMEL)) { RommelCount=50; EnableTrigger('CTC_RommelLives'); EnableTrigger('CTC_RommelDies'); DisableTrigger('CTC_Start_Rommel'); } } HandleEvent(BeginTurnUnit) 'CTC_RommelLives' post { int_t j; int_t numCities; int_t tmpPlayer; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_ERWIN_ROMMEL)) { CTC_VeteranEffect(Unit[0].location); CyrusCount=RommelCount-1; if (RommelCount<=0){//dies of old age tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_ERWIN_ROMMEL); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } event:DisbandUnit(unit[0]); DisableTrigger('CTC_RommelLives'); DisableTrigger('CTC_RommelDies'); } } } HandleEvent(KillUnit) 'CTC_RommelDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_ERWIN_ROMMEL)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_ERWIN_ROMMEL); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_RommelLives'); DisableTrigger('CTC_RommelDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } HandleEvent(VictoryMoveOrder) 'CTC_Zhukov' post { if(HasAdvance(Army[0].owner,ID_ADVANCE_ROCKETRY) && army[0].size>10 ) { if (TerrainType(location[0])<10 || (TerrainType(location[0])>17 && TerrainType(location[0])<22) ){//not at sea ZhukovLoc=location[0].location; event:AccomplishFeat(featDB(FEAT_GOT_ZHUKOV), army[0].owner); DisableTrigger('CTC_Zhukov'); } } } HandleEvent(BeginTurnUnit) 'CTC_Start_Zhukov' pre { if(Unit[0].type == UnitDB(UNIT_GEORGI_ZHUKOV)) { ZhukovCount=50; EnableTrigger('CTC_ZhukovLives'); EnableTrigger('CTC_ZhukovDies'); DisableTrigger('CTC_Start_Zhukov'); } } HandleEvent(BeginTurnUnit) 'CTC_ZhukovLives' post { int_t j; int_t numCities; int_t tmpPlayer; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_GEORGI_ZHUKOV)) { CTC_VeteranEffect(Unit[0].location); CyrusCount=ZhukovCount-1; if (ZhukovCount<=0){//dies of old age tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_GEORGI_ZHUKOV); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } event:DisbandUnit(unit[0]); DisableTrigger('CTC_ZhukovLives'); DisableTrigger('CTC_ZhukovDies'); } } } HandleEvent(KillUnit) 'CTC_ZhukovDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_GEORGI_ZHUKOV)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_GEORGI_ZHUKOV); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_ZhukovLives'); DisableTrigger('CTC_ZhukovDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } // Dwight Eisenhower HandleEvent(VictoryMoveOrder) 'CTC_DwightEisenhower' post { if(HasAdvance(Army[0].owner,ID_ADVANCE_TANK_WARFARE) && army[0].size>10) { if (TerrainType(location[0])<10 || (TerrainType(location[0])>17 && TerrainType(location[0])<22)){//not at sea DwightEisenhowerLoc=location[0].location; player[0]=army[0].owner; event:AccomplishFeat(featDB(FEAT_GOT_DWIGHT_EISENHOWER), player[0]); DisableTrigger('CTC_DwightEisenhower'); } } } HandleEvent(BeginTurnUnit) 'CTC_Start_DwightEisenhower' pre { if(Unit[0].type == UnitDB(UNIT_DWIGHT_EISENHOWER)) { DwightEisenhowerCount=50; EnableTrigger('CTC_DwightEisenhowerLives'); EnableTrigger('CTC_DwightEisenhowerDies'); DisableTrigger('CTC_Start_DwightEisenhower'); } } HandleEvent(BeginTurnUnit) 'CTC_DwightEisenhowerLives' post { int_t j; int_t tmpPlayer; int_t numCities; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_DWIGHT_EISENHOWER)) { CTC_VeteranEffect(Unit[0].location); DwightEisenhowerCount=DwightEisenhowerCount-1; if (DwightEisenhowerCount==0){//dies of old age tmpPlayer=Unit[0].owner; numCities=PlayerCityCount(tmpPlayer); SetString(0,ID_UNIT_DWIGHT_EISENHOWER); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); for(j = 0; j < numCities; j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } event:DisbandUnit(unit[0]); DisableTrigger('CTC_DwightEisenhowerLives'); DisableTrigger('CTC_DwightEisenhowerDies'); } } } HandleEvent(KillUnit) 'CTC_DwightEisenhowerDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_DWIGHT_EISENHOWER)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_DWIGHT_EISENHOWER); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_DwightEisenhowerLives'); DisableTrigger('CTC_DwightEisenhowerDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } // Norman Schwarzkopf HandleEvent(VictoryMoveOrder) 'CTC_NormanSchwarzkopf' post { if(HasAdvance(Army[0].owner,ID_ADVANCE_SUPERSONIC_FLIGHT) && army[0].size>10) { // army[0] should have interceptors NormanSchwarzkopfLoc=location[0].location; player[0]=army[0].owner; event:AccomplishFeat(featDB(FEAT_GOT_NORMAN_SCHWARZKOPF), player[0]); DisableTrigger('CTC_NormanSchwarzkopf'); } } HandleEvent(BeginTurnUnit) 'CTC_Start_NormanSchwarzkopf' pre {// if SLIC is reloaded if(Unit[0].type == UnitDB(UNIT_NORMAN_SCHWARZKOPF)) { NormanSchwarzkopfCount=50; EnableTrigger('CTC_NormanSchwarzkopfLives'); EnableTrigger('CTC_NormanSchwarzkopfDies'); DisableTrigger('CTC_Start_NormanSchwarzkopf'); } } HandleEvent(BeginTurnUnit) 'CTC_NormanSchwarzkopfLives' post { int_t j; int_t tmpPlayer; int_t numCities; city_t tmpCity; if(Unit[0].type == UnitDB(UNIT_NORMAN_SCHWARZKOPF)) { CTC_VeteranEffect(Unit[0].location); NormanSchwarzkopfCount=NormanSchwarzkopfCount-1; if (NormanSchwarzkopfCount==0){//dies of old age tmpPlayer=Unit[0].owner; numCities=PlayerCityCount(tmpPlayer); SetString(0,ID_UNIT_NORMAN_SCHWARZKOPF); message(tmpPlayer,'CTC_LeaderDeadOfOldAge'); for(j = 0; j < numCities; j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -1, 12); } event:DisbandUnit(unit[0]); DisableTrigger('CTC_NormanSchwarzkopfLives'); DisableTrigger('CTC_NormanSchwarzkopfDies'); } } } HandleEvent(KillUnit) 'CTC_NormanSchwarzkopfDies' pre { int_t j; int_t tmpPlayer; city_t tmpCity; if (Unit[0].type == UnitDB(UNIT_NORMAN_SCHWARZKOPF)){ tmpPlayer=Unit[0].owner; SetString(0,ID_UNIT_NORMAN_SCHWARZKOPF); message(tmpPlayer,'CTC_LeaderKilled'); DisableTrigger('CTC_NormanSchwarzkopfLives'); DisableTrigger('CTC_NormanSchwarzkopfDies'); for(j = 0; j < PlayerCityCount(tmpPlayer); j = j + 1) { GetCityByIndex(tmpPlayer, j, tmpCity); Event:AddHappyTimer(tmpCity, 3, -2, 12); } } } messagebox 'CTC_LeaderDeadOfOldAge' { show(); Text (ID_LeaderHasDiedM) ; Button(ID_BUTTON_CLOSE){ Kill(); } } messagebox 'CTC_LeaderKilled' { show(); Text (ID_LeaderKilledM) ; Button(ID_BUTTON_CLOSE){ Kill(); } } //////////////////////// // Surrender Handlers //////////////////////// int_t CTC_THE_LOSER; int_t CTC_THE_WINNER; HandleEvent(CaptureCity) 'CTC_PreSurrender' pre { CTC_THE_LOSER=city[0].owner; } HandleEvent(CaptureCity) 'CTC_SurrenderTrigger' post { int_t i; int_t AI_surrender_coefficient; int_t numCities; city_t tmpCity; city_t tmpCityArray[]; int_t numUnits; unit_t tmpUnit; unit_t tmpUnitArray[]; if (CITY_SURRENDER_RATIO && UNIT_SURRENDER_RATIO){ if ( !IsHumanPlayer(CTC_THE_LOSER) && CTC_THE_LOSER>0 && GetCurrentRound()>80 ){//Humans and Barbs don't surrender player[1]=CTC_THE_LOSER; CTC_THE_WINNER=player[0]; if (IsHumanPlayer(CTC_THE_WINNER) && PlayerCityCount(CTC_THE_LOSER)){ if (CITY_SURRENDER_RATIO*player[1].cities <= player[0].cities && UNIT_SURRENDER_RATIO*player[1].militaryunits <= player[0].militaryunits){ //the surrender condition Message(CTC_THE_WINNER, 'CTC_SurrenderMessage');// fix message } elseif (PlayerCityCount(CTC_THE_LOSER) && IsHumanPlayer(player[0])) {//only send messages when he has something left to surrender if (CITY_SURRENDER_RATIO*PlayerCityCount(CTC_THE_LOSER)<=PlayerCityCount(player[0])){//city criterion satisfied if (80*UNIT_SURRENDER_RATIO*player[1].militaryunits <= 100*player[0].militaryunits){ Message(player[0].owner, 'CTC_OverwhelmingSuperiority'); } elseif (60*UNIT_SURRENDER_RATIO*player[1].militaryunits <= 100*player[0].militaryunits) { Message(player[0].owner, 'CTC_MajorSuperiority'); } } elseif (UNIT_SURRENDER_RATIO*player[1].militaryunits <= player[0].militaryunits){//unit criterion satisfied if (80*CITY_SURRENDER_RATIO*PlayerCityCount(CTC_THE_LOSER)<= 100*PlayerCityCount(player[0])){ Message(player[0].owner, 'CTC_OverwhelmingSuperiority1'); } elseif (60*CITY_SURRENDER_RATIO*PlayerCityCount(CTC_THE_LOSER)<= 100*PlayerCityCount(player[0])) { Message(player[0].owner, 'CTC_MajorSuperiority1'); } } elseif (75*CITY_SURRENDER_RATIO*PlayerCityCount(CTC_THE_LOSER) <= 100*PlayerCityCount(player[0]) && (75*UNIT_SURRENDER_RATIO*player[1].militaryunits) <= 100*player[0].militaryunits){ Message(player[0].owner, 'CTC_MilitarySuperiority'); } } } else{//for AI simulate mergeciv if (CTC_AI_FEAR_RADIUS<4){ AI_surrender_coefficient=100-15*CTC_AI_FEAR_RADIUS; } else{ AI_surrender_coefficient=50; } if (AI_surrender_coefficient*CITY_SURRENDER_RATIO*player[1].cities <= 100*player[0].cities && AI_surrender_coefficient*UNIT_SURRENDER_RATIO*player[1].militaryunits <= 100*player[0].militaryunits){ DisableTrigger('CTC_CheckGeogArraysOnCapture'); GodMode(1); numUnits=player[1].units; if (numUnits){ for (i=0; i 0){ if(Random(9)<1) {//include random chance of quicker merge DoMerge=1; } } if (DoMerge){ if (player[0].owner == MERGE_SOURCE){ //so MERGE_SOURCE must still be alive if (IsPlayerAlive(MERGE_TARGET)){ DisableMessageClass(180103);//disable conquered by message player[1]=MERGE_TARGET; message(CTC_THE_CONQUERER,'CTC_ImportantNewsComingIn'); EnableTrigger('CTC_MergecivExec'); } } } if (player[0].owner == CTC_THE_CONQUERER){//decrease count every time CTC_THE_CONQUERER has a turn MERGE_COUNTDOWN=MERGE_COUNTDOWN-1; } if (MERGE_COUNTDOWN <0){ //shut down CTC_THE_CONQUERER=0; MERGE_SOURCE=0; MERGE_TARGET=0; EnableMessageClass(180103); DisableTrigger('CTC_MergecivCheck'); // here's the place to check to see if we want to do another one } } alertbox 'CTC_ImportantNewsComingIn' { Title(ID_BREAKING_NEWS); Text (ID_ImportantNewsComingInTxt ); Button(ID_BUTTON_CLOSE){ Kill(); } } HandleEvent(EndTurn) 'CTC_MergecivExec' pre { int_t CivOneUnitCount; int_t PWtotal; int_t numAI; int_t i; if (!IsHumanPlayer(player[0].owner) ){//aborted if SLIC reloaded player[1]=MERGE_TARGET; PWtotal = player[1].publicworkslevel; PWtotal = PWtotal + player[0].publicworkslevel; CivOneUnitCount=player[0].units; numAI=0; for (i=1;i 60) { for (i = 0; i < GetUnitsAtLocation(city[0].location); i = i + 1) { GetUnitFromCell(city[0].location, i, tmpUnit); // cycle through all units at current location if (UnitDB(tmpUnit.type).powerpoints == 82) { // if unit is Militia KillUnit(tmpUnit); // kill this unit } } } } // if city is disbanded, kill it's immobile units HandleEvent(DisbandCity) 'CTC_MilitiaCityDisbanded' pre { // triggers if city is disbanded unit_t tmpUnit; int_t tmpNum; int_t i; if (CityIsValid(city[0])){ tmpNum=GetUnitsAtLocation(city[0].location); for (i = 0; i < tmpNum; i = i + 1) { GetUnitFromCell(city[0].location, i, tmpUnit); // cycle through all units at current location if (UnitDB(tmpUnit.type).powerpoints == 82 || UnitDB(tmpUnit.type).powerpoints == 80) { // if unit is immobile KillUnit(tmpUnit); // kill this unit } } } } // MOVE HANDLERS // prevent immobile units from moving through numpad commands HandleEvent(MoveToOrder) 'CTC_MilitiaMoveNumpad' pre { if (ArmyIsValid(army[0])){ if (CTC_ArmyHasImmobileUnit(army[0])) { // don't let other units get trapped with immobile units event:UngroupOrder(army[0]); return STOP; // don't allow army to move } } } // prevent immobile units from moving HandleEvent(MoveOrder) 'CTC_MilitiaMove' pre { city_t tmpCity; if (ArmyIsValid(army[0])){ if (CTC_ArmyHasImmobileUnit(army[0])) { // don't let other units get trapped with immobile units event:UngroupOrder(army[0]); return STOP; // don't allow army to move } } } // prevent Militia units from boarding a transport HandleEvent(MoveIntoTransport) 'CTC_MilitiaBoard' pre {// triggers right before an army boards a transport if (ArmyIsValid(army[0])){ if (CTC_ArmyHasImmobileUnit(army[0])) { return STOP; } } } HandleEvent(BoardTransportOrder) 'CTC_MilitiaBoardTransportOrder' pre { if (ArmyIsValid(army[0])){ if (CTC_ArmyHasImmobileUnit(army[0])) { return STOP; } } } // MISC HANDLERS HandleEvent( DetrenchOrder) 'CTC_MilitiaDetrenchOrder' pre {// don't let them detrench if (ArmyIsValid(army[0])){ if (CTC_ArmyHasImmobileUnit(army[0])) { return STOP; } } } /////////////////// // // Bombard Special Effects // /////////////////// location_t BOMB_LOC; Void_f Do_Bombard_Effect(army_t theArmy, location_t theLocation, int_t pillageFlg){ army_t tmpArmy; location_t tmpLoc; city_t tmpCity; unit_t tmpUnit; int_t i; int_t cityFlg; int_t landFlg; int_t impFlg; int_t EffectResult; int_t doArmyFlg; int_t enemyFlg; tmpArmy=theArmy; tmpLoc=theLocation; EffectResult=0; cityFlg=0; impFlg=0; landFlg=0; doArmyFlg=1; enemyFlg=0; if (GetUnitsAtLocation(tmpLoc)){ enemyFlg=1; } if (GetCityByLocation(tmpLoc,tmpCity)){ cityFlg=1; } for (i=0;i<24;i=i+1){// standard tileimp.txt if (TileHasImprovement(tmpLoc, i) ){ impFlg=1; i=24; } } if (pillageFlg && impFlg){ event:CutImprovements(tmpLoc); } if (TerrainType(tmpLoc)<10 || (TerrainType(tmpLoc)>17 && TerrainType(tmpLoc)<22) ){//land target landFlg=1; } for (i=0;i2) { SelectUnit(unit[0]); city[0]=tmpcity; player[0]=unit[0].owner; Message(player[0], 'CTC_AddPopToCityQ'); //ask if we want him to settle there } } } } } messagebox 'CTC_AddPopToCityQ'{ Show(); Text(ID_CTC_AddPopToCityM); //M_AddPopToCity "{player[0].leader_name#SIR_CAP}, shall I settle in this city?" Button(ID_NO){ Kill(); } Button(ID_YES){ Event:DisbandUnit(unit[0]); AddPops(city[0],1); Kill(); } } /////////// // Disband Cities and Create Refugees int_t THE_CITY_OWNER; HandleEvent(CaptureCity) 'CTC_DisbandCities' pre { THE_CITY_OWNER=city[0].owner; } //these will be part of the mergeciv system: HandleEvent(CaptureCity) 'CTC_EnableMergeAfterCaptureCity' pre { if (g.year>300){ EnableTrigger('CTC_MergeAfterCaptureCity'); DisableTrigger('CTC_EnableMergeAfterCaptureCity'); } } HandleEvent(CaptureCity) 'CTC_MergeAfterCaptureCity' post { // TBD } HandleEvent(CaptureCity) 'CTC_DisbandCities' post { // This is in large part Martin Guehmann's KillCityOption. I had a handler that did something quite similar but // Martin's was much better. So I've incorporated quite a lot of his code into mine. int_t refugees; //pop to send to the winner's cities int_t escapees; //pop to send to the loser's cities int_t casualties; //pop that died in the attack int_t Pw; int_t i; int_t j; city_t tmpCity; int_t tmpDist; int_t theDist; location_t tmpLoc; //the disbanded city's location if (CityIsValid(city[0])){ if (IsHumanPlayer(player[0]) && 211)){ // the AI always disbands small cities that are too close or too far away FinishBuilding(city[0]);// Winnie did this (why?) refugees=(50*city[0].population)/100;// send them randomly around the winner's empire casualties=(30*city[0].population)/100; escapees= city[0].population-(refugees+casualties); tmpDist=999999; if (IsPlayerAlive(THE_CITY_OWNER)){// what about if not? if (PlayerCityCount(THE_CITY_OWNER)){ For (i=0; i0){ if (PlayerCityCount(THE_CITY_OWNER)){ For (i=0; i0){ message(THE_CITY_OWNER,'CTC_OurEscapeeMessage'); } else{ message(THE_CITY_OWNER,'CTC_DemandRetaliationMessage'); } } else{ for (i=0; i5 && !IsHumanPlayer(city[0].owner) ) { player[0]=city[0].owner; GetNeighbor(city[0].location, 0, firstLoc);//go north of the City for (j=0; j<=7 ; j=j+1) { //directions GetNeighbor(firstLoc, j, theLoc);//look around if ( CellOwner(theLoc)==city[0].owner && HasGood(theLoc)==-1) { if (TerrainType(theLoc)==TerrainDB(TERRAIN_FOREST) || TerrainType(theLoc)==TerrainDB(TERRAIN_JUNGLE) ) { // 0=forest, 7=jungle Event:CreateImprovement(city[0].owner,theLoc, TerrainImprovementDB(TILEIMP_TERRAFORM_PLAINS),0); //change to plains } if (TerrainType(theLoc)==TerrainDB(TERRAIN_GRASSLAND) || TerrainType(theLoc)==TerrainDB(TERRAIN_PLAINS) ) { if (HasRiver(theLoc)){ if (TileHasImprovement(theLoc,TerrainImprovementDB(TILEIMP_ADVANCED_FARMS))){ Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_HYDROPONIC_FARMS),0); } elseif (TileHasImprovement(theLoc,TerrainImprovementDB(TILEIMP_FARMS))) { Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_ADVANCED_FARMS),0); } else{ Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_FARMS),0); } } } } } GetNeighbor(city[0].location, 2, firstLoc);//go east of the City for (j=0; j<=7 ; j=j+1) { //directions GetNeighbor(firstLoc, j, theLoc);//look around if ( CellOwner(theLoc)==city[0].owner && HasGood(theLoc)==-1) { if (TerrainType(theLoc)==TerrainDB(TERRAIN_FOREST) || TerrainType(theLoc)==TerrainDB(TERRAIN_JUNGLE) ) { // 0=forest, 7=jungle Event:CreateImprovement(city[0].owner,theLoc, TerrainImprovementDB(TILEIMP_TERRAFORM_PLAINS),0); //change to plains } if (TerrainType(theLoc)==TerrainDB(TERRAIN_GRASSLAND) || TerrainType(theLoc)==TerrainDB(TERRAIN_PLAINS) ) { if (HasRiver(theLoc)){ if (TileHasImprovement(theLoc,TerrainImprovementDB(TILEIMP_ADVANCED_FARMS))){ Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_HYDROPONIC_FARMS),0); } elseif (TileHasImprovement(theLoc,TerrainImprovementDB(TILEIMP_FARMS))) { Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_ADVANCED_FARMS),0); } else{ Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_FARMS),0); } } } } } GetNeighbor(city[0].location, 5, firstLoc);//go west of the City for (j=0; j<=7 ; j=j+1) { //directions GetNeighbor(firstLoc, j, theLoc);//look around if ( CellOwner(theLoc)==city[0].owner && HasGood(theLoc)==-1) { if (TerrainType(theLoc)==TerrainDB(TERRAIN_FOREST) || TerrainType(theLoc)==TerrainDB(TERRAIN_JUNGLE) ) { // 0=forest, 7=jungle Event:CreateImprovement(city[0].owner,theLoc, TerrainImprovementDB(TILEIMP_TERRAFORM_PLAINS),0); //change to plains } if (TerrainType(theLoc)==TerrainDB(TERRAIN_GRASSLAND) || TerrainType(theLoc)==TerrainDB(TERRAIN_PLAINS) ) { if (HasRiver(theLoc)){ if (TileHasImprovement(theLoc,TerrainImprovementDB(TILEIMP_ADVANCED_FARMS))){ Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_HYDROPONIC_FARMS),0); } elseif (TileHasImprovement(theLoc,TerrainImprovementDB(TILEIMP_FARMS))) { Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_ADVANCED_FARMS),0); } else{ Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_FARMS),0); } } } } } GetNeighbor(city[0].location, 7, firstLoc);//go south of the City for (j=0; j<=7 ; j=j+1) { //directions GetNeighbor(firstLoc, j, theLoc);//look around if ( CellOwner(theLoc)==city[0].owner && HasGood(theLoc)==-1) { if (TerrainType(theLoc)==TerrainDB(TERRAIN_FOREST) || TerrainType(theLoc)==TerrainDB(TERRAIN_JUNGLE) ) { // 0=forest, 7=jungle Event:CreateImprovement(city[0].owner,theLoc, TerrainImprovementDB(TILEIMP_TERRAFORM_PLAINS),0); //change to plains } if (TerrainType(theLoc)==TerrainDB(TERRAIN_GRASSLAND) || TerrainType(theLoc)==TerrainDB(TERRAIN_PLAINS) ) { if (HasRiver(theLoc)){ if (TileHasImprovement(theLoc,TerrainImprovementDB(TILEIMP_ADVANCED_FARMS))){ Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_HYDROPONIC_FARMS),0); } elseif (TileHasImprovement(theLoc,TerrainImprovementDB(TILEIMP_FARMS))) { Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_ADVANCED_FARMS),0); } else{ Event:CreateImprovement(city[0].owner,theLoc,TerrainImprovementDB(TILEIMP_FARMS),0); } } } } } } } HandleEvent(CreateCity)'CTC_New_City_Location_Fix' post { //for when the AI founds a city, possibly in a lousy location // rem june 2003: this is old and not really necessary for CTC location_t theLoc; city_t tmpCity; int_t i; int_t CityOK; //this preliminary stuff is for where the AI discovers a city in a goody hut that's //too close to one of its existing cities. if (!IsHumanPlayer(player[0])) { CityOK=0; if (value[1]==-1) {// if it came from a goody hut if (PlayerCityCount(player[0])==1) {// it was the first city CityOK=1; } elseif (PlayerCityCount(player[0])>0) { for(i=0; i0){ CitiesDoneFlg=1; for (i=1; i< CTC_PLAYER_COUNT ; i=i+1){ //make sure everyone in the game has cities if (IsPlayerAlive(i)){ if (PlayerCityCount(i)==0) { CitiesDoneFlg=0; // someone doesn't have any citys, i=CTC_PLAYER_COUNT; } } } if(CitiesDoneFlg==1){ for (i=1;i1){//if in trouble, no more specials and really prioritize units ConsiderStrategicState(player[0],2650,StrategyDB(STRATEGY_WAR_BUILDLISTS_HIGH),-1,-1,-1); } } } } // note: remember that the unit building strats have priority 3500 HandleEvent(NextStrategicState) 'CTC_AI_GeogThreatStates' pre { int_t i; int_t j; int_t triggerAttack; int_t HumanTarget; int_t GeogThreat; int_t numArmies; int_t minCity; city_t tmpCity; if ( !IsHumanPlayer(player[0]) && player[0].owner>0){ if (player[0].publicworkslevel >20000){ ConsiderStrategicState(player[0],2500,StrategyDB(STRATEGY_LOTS_MORE_TILE_IMPROVEMENTS),-1,-1,-1); } elseif (player[0].publicworkslevel >10000) { ConsiderStrategicState(player[0],2500,StrategyDB(STRATEGY_MORE_TILE_IMPROVEMENTS),-1,-1,-1); } // default BuildSettlerProductionLevel 0.50 if (80 6){ // here BuildSettlerProductionLevel 0.20 ConsiderStrategicState(player[0],2600,StrategyDB(STRATEGY_KEEP_SETTLING),-1,-1,-1); } } // WAR GOALS & BUILDLISTS: if (AtWarCount(player[0]) ){// when at war with anybody always default to military plus more OFFENSE and DEFENSE // only prioritizing SEIGE goals, what about the others? ConsiderStrategicState(player[0],2600,StrategyDB(STRATEGY_SEIGE),-1,-1,-1); ConsiderStrategicState(player[0],2550,StrategyDB(STRATEGY_WAR_BUILDLISTS_MED),-1,-1,-1); // should only need to do this once: so it could be a handler, not a function ? ClearSpecialsFromBuildLists(player[0]); if (AtWarCount(player[0])>1){ //if in trouble, no more specials or settlers, and really prioritize units ConsiderStrategicState(player[0],2650,StrategyDB(STRATEGY_WAR_BUILDLISTS_HIGH),-1,-1,-1); } else{//when at war with one opponant //maybe sooner: start with catapults and increase frequency with bombard effectiveness? if (HasAdvance(player[0],ID_ADVANCE_AERODYNAMICS)){ if (random(2)<1){ ConsiderStrategicState(player[0],2650,StrategyDB(STRATEGY_BOMBARD),-1,-1,-1); } } for (i=1;i 2*player[0].cities){ // if he's strong, build more units ConsiderStrategicState(player[0],2700,StrategyDB(STRATEGY_MORE_UNITS),-1,-1,-1); } } } // GET THE FIRST THREATENING HUMAN: HumanTarget=CTC_IsThreatenedByAHuman(player[0].owner,0,CTC_AI_FEAR_RADIUS+1); //is there a Human who poses 1<= Geog Threat level <=CTC_AI_FEAR_RADIUS? (=initially 1) if (HumanTarget){ if (!AtWarWith(player[0],HumanTarget)){ GeogThreat=CTC_GetGeogThreat(player[0].owner, HumanTarget); // high threat stuff if (GeogThreat <= CTC_AI_FEAR_RADIUS){ //use BUILD_LIST_SEQUENCE_DEFAULT_MIL plus more OFFENSE and DEFENSE ConsiderStrategicState(player[0],2500,StrategyDB(STRATEGY_PREPARE_FOR_WAR),-1,-1,-1); } //=> this will eventually put all AI civs who don't like their Human neighbour //on BUILD_LIST_SEQUENCE_DEFAULT_MIL plus more OFFENSE and DEFENSE // diplomatically, they're open to negotiations elseif ( GeogThreat == CTC_AI_FEAR_RADIUS+1 && GetEffectiveRegard(player[0],HumanTarget)<275){ ConsiderStrategicState(player[0],2500,StrategyDB(STRATEGY_PREPARE_FOR_WAR),-1,-1,-1); } // else default personality strategy if (GeogThreat < CTC_AI_FEAR_RADIUS+2){ if (g.year<150){// exploration stuff (find the enemy) if (AtWarCount(player[0])==0){ ConsiderStrategicState(player[0],2500,StrategyDB(STRATEGY_EXPLORE_WIDE),-1,-1,-1); } else{// at war but not with human target ConsiderStrategicState(player[0],2500,StrategyDB(STRATEGY_EXPLORE_FAR),-1,-1,-1); } } // preemptive attack stuff // on higher difficulty levels give the human a bit more time to get established int_t startYearforPreAtt; if (preference("Difficulty")>2){ startYearforPreAtt=80 + (preference("Difficulty")*preference("Difficulty")); } else{ startYearforPreAtt=80; } if (g.year>startYearforPreAtt){ triggerAttack=0; if (AtWarCount(HumanTarget)==0){ triggerAttack=1; } elseif (AtWarCount(HumanTarget)<=CTC_AI_FEAR_RADIUS) { if (MilitaryRank(HumanTarget)==100 || CitiesRank(HumanTarget)==100 || PopulationRank(HumanTarget)==100){ triggerAttack=1; } // science rank ? if (AtWarCount(HumanTarget)==1){//in case of stagnation for (i=1;i15 || GetLastHotWarAttack(HumanTarget,player[1])>15){ LogRegardEvent(player[0],HumanTarget,-25,2,ID_RICH_PICKINGS,0); triggerAttack=1; } } } if (triggerAttack){ //if he's not at war or he's strong or there's no fighting if (g.year>150){ player[1]=HumanTarget; if (player[0].militaryunits CTC_AI_FEAR_RADIUS-1){ //do nothing more, give him a break } else{// so GeogThreat < CTC_AI_FEAR_RADIUS LogRegardEvent(player[0],HumanTarget,-15,2,ID_SOFT_TARGET,0); ConsiderStrategicState(player[0],2700,StrategyDB(STRATEGY_PREEMPTIVE_ATTACK),-1,-1,-1); for (j=1;j160 && AtWarCount(player[0])==0 ){ //in any case ConsiderStrategicState(player[0],2500,StrategyDB(STRATEGY_PRIORITIZE_WONDERS),-1,-1,-1); } } } HandleEvent(NextDiplomaticState) 'CTC_LoadDipStateCycles' pre { int_t GeogThreatVal_01; int_t GeogThreatVal_10; if ( !IsHumanPlayer(player[0]) ){ GeogThreatVal_01=CTC_GetGeogThreat(player[0].owner,player[1].owner); GeogThreatVal_10=CTC_GetGeogThreat(player[1].owner,player[0].owner); if (IsHumanPlayer(player[1])) { //AI to Human stuff if ( AtWarWith(player[0],player[1])) {//if at war with a human if (GeogThreatVal_01 <= CTC_AI_FEAR_RADIUS){ if (GeogThreatVal_01 == CTC_AI_FEAR_RADIUS){ if (AtWarCount(player[1]) > CTC_AI_FEAR_RADIUS+1) {//give him a break ConsiderDiplomaticState(player[0],player[1],3000,diplomacyDB(DIPLOMACY_DEFAULT),-1,-1,-1); // maybe adjust regard and trust here } else{ ConsiderDiplomaticState(player[0],player[1],3000,diplomacyDB(DIPLOMACY_STAY_AT_WAR),-1,-1,-1); } } else{//otherwise it's a vendetta ConsiderDiplomaticState(player[0],player[1],3000,diplomacyDB(DIPLOMACY_STAY_AT_WAR),-1,-1,-1); } } else{//usually out of range: try to counter the game system if (( GeogThreatVal_01 > CTC_AI_FEAR_RADIUS+1 && GetLastHotWarAttack(player[0],player[1])>10) || (GetLastHotWarAttack(player[0],player[1])>20 && GetLastHotWarAttack(player[1],player[0])>20)){ LogRegardEvent(player[0],player[1], 200, 0, ID_TOO_FAR_WAY, 0); SetTrust(player[0],player[1], 500); ConsiderDiplomaticState(player[0],player[1],9999,diplomacyDB(DIPLOMACY_DEFAULT),-1,-1,-1); } } } if (GeogThreatVal_01 <= CTC_AI_FEAR_RADIUS) {// high threat // give more time here ? if (g.year<50){ ConsiderDiplomaticState(player[0],player[1],2000,diplomacyDB(DIPLOMACY_DEFAULT),-1,-1,-1); } elseif(AtWarCount(player[1]) CTC_AI_FEAR_RADIUS){ if (GetEffectiveRegard(player[0],player[1])<275){ LogRegardEvent(player[0],player[1],20,4,ID_BRIBERY,0); // 4=diplomacy event? } elseif (GetEffectiveRegard(player[0],player[1])>375){ LogRegardEvent(player[0],player[1],-20,4,ID_BRIBERY,0); // 4=diplomacy event? } ConsiderDiplomaticState(player[0],player[1],2100,diplomacyDB(DIPLOMACY_OPEN_TO_NEGOTIATION),-1,-1,-1); } else{ ConsiderDiplomaticState(player[0],player[1],2000,diplomacyDB(DIPLOMACY_DEFAULT),-1,-1,-1); } } elseif (GeogThreatVal_01 == CTC_AI_FEAR_RADIUS+1) {// medium threat if (g.year<100){ ConsiderDiplomaticState(player[0],player[1],2000,diplomacyDB(DIPLOMACY_DEFAULT),-1,-1,-1); } else{// get ready for pre-emptive attack if ( AtWarCount(player[1]) base states if (GeogThreatVal_01==1 && GeogThreatVal_10<=2) { ConsiderDiplomaticState(player[0],player[1],2000,diplomacyDB(DIPLOMACY_PROVOKE_WAR),-1,-1,-1); } elseif (GeogThreatVal_01<=4) { ConsiderDiplomaticState(player[0],player[1],2000,diplomacyDB(DIPLOMACY_DEFAULT),-1,-1,-1); } else{ ConsiderDiplomaticState(player[0],player[1],2000,diplomacyDB(DIPLOMACY_MAKE_FRIEND),-1,-1,-1); } //=> special states if (player[1].cities>3){ // if either player is at war with or threatened by a human, make friends if (CTC_IsThreatenedByAHuman(player[1],0,3) || CTC_IsAtWarWithHuman(player[1]) ){ if (AtWarWith(player[0],player[1])){ EnableTrigger('CTC_StopAttackingThreatenedPlayer'); } ConsiderDiplomaticState(player[0],player[1],3000,diplomacyDB(DIPLOMACY_MAKE_FRIEND),-1,-1,-1); LogRegardEvent(player[0],player[1],60,0,ID_NONE,0); } elseif (CTC_IsThreatenedByAHuman(player[0],0,3) || CTC_IsAtWarWithHuman(player[0]) ){ if (AtWarWith(player[0],player[1])){ EnableTrigger('CTC_StopThreatenedPlayerFromAttacking'); } ConsiderDiplomaticState(player[0],player[1],3000,diplomacyDB(DIPLOMACY_MAKE_FRIEND),-1,-1,-1); LogRegardEvent(player[0],player[1],60,0,ID_NONE,0); } } else{//crush the weaklings: induce war if (g.year > 120){ LogRegardEvent(player[0],player[1],-60,0,ID_NONE,0); } } } } } HandleEvent(NextDiplomaticState) 'CTC_AtWarWithHumanIntell' post {// regard hits too excessive? int_t perType; if ( !IsHumanPlayer(player[0]) && IsHumanPlayer(player[1]) && AtWarWith(player[0],player[1])){ perType=GetPersonalityType(player[0]); if (random(99)<2){ LogRegardEvent(player[0],player[1],-55,1,ID_AT_WAR_BANANAS,0); } elseif (perType==PersonalityDB(PERSONALITY_GHANDI)){ LogRegardEvent(player[0],player[1],-50,1,ID_AT_WAR_DIPLOMAT,0); } elseif (perType==PersonalityDB(PERSONALITY_STALIN) || perType==PersonalityDB(PERSONALITY_CEASAR) || perType==PersonalityDB(PERSONALITY_DEGAULLE)){ LogRegardEvent(player[0],player[1],-50,1,ID_AT_WAR_MILITARIST,0); } elseif (perType==PersonalityDB(PERSONALITY_MEDICI) ){ LogRegardEvent(player[0],player[1],-50,1,ID_AT_WAR_ECONOMIST,0); } elseif (perType==PersonalityDB(PERSONALITY_TELLER) || perType==PersonalityDB(PERSONALITY_STRANGELOVE)){ LogRegardEvent(player[0],player[1],-50,1,ID_AT_WAR_ECOTOPIAN,0); } elseif (perType==PersonalityDB(PERSONALITY_CALLENBACH) || perType==PersonalityDB(PERSONALITY_NADER) ){ LogRegardEvent(player[0],player[1],-50,1,ID_AT_WAR_SCIENTIST,0); } } } HandleEvent(NextDiplomaticState)'CTC_AI_to_AI_Proposal_Generator' pre { int_t GeogThreatVal_01; int_t GeogThreatVal_10; int_t regardBoost; GeogThreatVal_01=CTC_GetGeogThreat(player[0].owner,player[1].owner); GeogThreatVal_10=CTC_GetGeogThreat(player[1].owner,player[0].owner); if (!IsHumanPlayer(player[0]) && 02 || GeogThreatVal_10 >2 || AtWarCount(player[0])>1 || CTC_IsThreatenedByAHuman(player[0],0,3) //special case: focus AI aggression || CTC_IsAtWarWithHuman(player[0]) //special case: focus AI aggression ) { regardBoost=60; if (GetEffectiveRegard(player[1],player[0]) < 600){ regardBoost=600-GetEffectiveRegard(player[1],player[0]); } LogRegardEvent(player[1],player[0], regardBoost, 0, ID_NONE, 0); SetTrust(player[1],player[0], 500); ConsiderNewProposal(player[0],player[1], 2500,32,0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0],player[1]); } } //exchange maps if (!AtWarWith(player[0],player[1]) && g.year >80 && (GetAgreementDuration(player[0],player[1],23)>20 || GetAgreementDuration(player[0],player[1],23)==-1) ){ ConsiderNewProposal(player[0],player[1], 2550,23,0,ID_NONE,ID_NONE,ID_NONE); Event:NewProposal(player[0],player[1]); } } } HandleEvent(NextDiplomaticState) 'CTC_AI_to_AI_Establish_Embassy' pre { //start this when there's only two AI players left int_t AI_playercount; int_t i; AI_playercount=0; if (!IsHumanPlayer(player[0]) && 0CTC_AI_FEAR_RADIUS+1 || (GetLastHotWarAttack(player[0],player[1])>20 && GetLastHotWarAttack(player[1],player[0])>20)){ ConsiderResponse(player[0], player[1], 3500, 2);//2=accept } } } } HandleEvent(KillPlayer) 'CTC_IncrementFearRadius' pre { if (IsHumanPlayer(player[1])){ CTC_AI_FEAR_RADIUS=CTC_AI_FEAR_RADIUS+1; EnableTrigger('CTC_AI_to_AI_Establish_Embassy');//not the best place for this } } HandleEvent(GrantAdvance)'CTC_ShowAdvance'post{ if(IsHumanPlayer(player[0])){ if (value[0]==AdvanceDB(ADVANCE_FEUDALISM) || value[0]==AdvanceDB(ADVANCE_INDUSTRIAL_REVOLUTION) ){ LibraryAdvance(value[0]); } } } HandleEvent(GrantAdvance) 'CTC_PlayerGetsGovtAdvance' pre { if (IsHumanPlayer(player[0])){ if (value[0]==AdvanceDB(ADVANCE_PHILOSOPHY)){ DisableMessageClass(90203); message(player[0],'PlayerGotPhilosophy'); } elseif(value[0]==AdvanceDB(ADVANCE_BUREAUCRACY)) { EnableMessageClass(90203); } elseif (value[0]==AdvanceDB(ADVANCE_THEOLOGY)) { DisableMessageClass(90203); message(player[0],'PlayerGotTheology'); } elseif(value[0]==AdvanceDB(ADVANCE_NATIONALISM) || value[0]==AdvanceDB(ADVANCE_INDUSTRIAL_REVOLUTION)) { EnableMessageClass(90203); } elseif (value[0]==AdvanceDB(ADVANCE_GLOBAL_COMMUNICATIONS)) { DisableMessageClass(90203); message(player[0],'PlayerGotGlobComm'); } } } messagebox 'PlayerGotPhilosophy' { Show(); Text(ID_PLAYER_DISCOVERS_PHILOSOPHY); MessageType("CIVILIZATION"); Button(ID_BUTTON_NOT_NOW) { Kill(); } Button(ID_BUTTON_C_DEM) { SetGovernment(GovernmentDB(GOVERNMENT_CLASSICAL_DEMOCRACY)); Kill(); } Button(ID_BUTTON_OLIGARCHY) { SetGovernment(GovernmentDB(GOVERNMENT_OLIGARCHY)); Kill(); } Button(ID_BUTTON_MONARCHY) { SetGovernment(GovernmentDB(GOVERNMENT_MONARCHY)); Kill(); } // out of button space } messagebox 'PlayerGotTheology' { Show(); Text(ID_PLAYER_DISCOVERS_THEOLOGY); MessageType("CIVILIZATION"); Button(ID_BUTTON_NOT_NOW) { Kill(); } Button(ID_BUTTON_THEOCRACY) { SetGovernment(GovernmentDB(GOVERNMENT_THEOCRACY)); Kill(); } Button(ID_BUTTON_THEO_EMP) { SetGovernment(GovernmentDB(GOVERNMENT_THEOCRATIC_EMPIRE)); Kill(); } Button(ID_BUTTON_DONT_SHOW_AGAIN){ DisableMessageClass(90203); Kill(); } } messagebox 'PlayerGotGlobComm' { Show(); Text(ID_PLAYER_DISCOVERS_GLOBAL_COMMUNICATIONS); MessageType("CIVILIZATION"); Button(ID_BUTTON_NOT_NOW) { Kill(); } Button(ID_BUTTON_ECO_FUNDAMENTALISM) { SetGovernment(GovernmentDB(GOVERNMENT_ECO_FUNDAMENTALISM)); Kill(); } Button(ID_BUTTON_GLOBAL_CORPORATISM) { SetGovernment(GovernmentDB(GOVERNMENT_GLOBAL_CORPORATISM)); Kill(); } Button(ID_BUTTON_TECHNOCRACY) { SetGovernment(GovernmentDB(GOVERNMENT_TECHNOCRACY)); Kill(); } } // try to prevent the AI from settling on owned land (no contact) at start // and for rest of game HandleEvent(SettleOrder) 'CTC_PreventCrowding' pre { int_t locOwner; int_t locBad; if (!IsHumanPlayer(army[0].owner)){ locOwner=CellOwner(army[0].location); locBad=1; if (locOwner == -1 || locOwner == army[0].owner){ locBad=0; } if (locBad){ return Stop; } } } ////////////////////////////////////////////////// // MAKE CONTACT WITH THE FIRST THREATENING HUMAN: ////////////////////////////////////////////////// HandleEvent(BeginTurn) 'CTC_MakeContact' pre { int_t HumanTarget; int_t GeogThreat; int_t i; int_t numArmies; army_t tmpArmy; city_t tmpCity; if (g.year<250){//should be sufficient HumanTarget=CTC_IsThreatenedByAHuman(player[0].owner,0,CTC_AI_FEAR_RADIUS+1); //is there a Human who poses 1<= Geog Threat level <=CTC_AI_FEAR_RADIUS? (=initially 1) if (HumanTarget){ GeogThreat=CTC_GetGeogThreat(player[0].owner, HumanTarget); if (GeogThreat < CTC_AI_FEAR_RADIUS+2){ if (GetEffectiveRegard(HumanTarget,player[0]) == 300 || GetEffectiveRegard(HumanTarget,player[0]) == 500){ // no contact CTC_THE_TARGET_PLAYER=HumanTarget; EnableTrigger('CTC_MakeContactWithHuman'); numArmies=player[0].armies; for (i=0;i