// This SLIC file will find out what Government you are in, and store it in GOVT_WhatGovtAmI. // To further use this, GOVT_WhatGovtAmI equals the government index from govern.txt (not in discovery order). // // What Govt Am I? script for CTP2 - Version 0.3 // // By Dale Kent - 9 November 2002 // // Use freely where so you may see fit. :) // // See me at Apolyton CTP2 forums - http://www.apolyton.net/forums // modified and adapted for Cradle by PT int_t GOVT_GovtUnits[];//identifies govDB indices from govern.txt with the gov specific settlers in units.txt int_t GOVT_WhatGovtAmI[];//maps player index to their current govDB index HandleEvent(BeginTurn) 'GOVT_SetupArrays' pre {//at start int_t PlayerCount; int_t count; GOVT_GovtUnits[0] = UnitDB(UNIT_SETTLER_ANARCHY); //0 is the governmentDB index of ANARCHY GOVT_GovtUnits[1] = UnitDB(UNIT_SETTLER_CALIPHATE); //1 is the governmentDB index of CALIPHATE GOVT_GovtUnits[2] = UnitDB(UNIT_SETTLER_CITY_STATE);//and so on GOVT_GovtUnits[3] = UnitDB(UNIT_SETTLER_COMMUNISM); GOVT_GovtUnits[4] = UnitDB(UNIT_SETTLER_CORP_REPUB); GOVT_GovtUnits[5] = UnitDB(UNIT_SETTLER_DEMOCRACY); GOVT_GovtUnits[6] = UnitDB(UNIT_SETTLER_DICTATORSHIP); GOVT_GovtUnits[7] = UnitDB(UNIT_SETTLER_DYNASTY); GOVT_GovtUnits[8] = UnitDB(UNIT_SETTLER_ECOTOPIA); GOVT_GovtUnits[9] = UnitDB(UNIT_SETTLER_FASCISM); GOVT_GovtUnits[10] = UnitDB(UNIT_SETTLER_MONARCHY); GOVT_GovtUnits[11] = UnitDB(UNIT_SETTLER_OLIGARCHY); GOVT_GovtUnits[12] = UnitDB(UNIT_SETTLER_REPUBLIC); GOVT_GovtUnits[13] = UnitDB(UNIT_SETTLER_TECHNOCRACY); GOVT_GovtUnits[14] = UnitDB(UNIT_SETTLER_THEOCRACY); GOVT_GovtUnits[15] = UnitDB(UNIT_SETTLER_TRIBUNAL_EMPIRE); GOVT_GovtUnits[16] = UnitDB(UNIT_SETTLER_TYRANNY); GOVT_GovtUnits[17] = UnitDB(UNIT_SETTLER_VDEMOCRACY); if( preference("MaxPlayers") < preference("NumPlayers") + 3) { PlayerCount = preference("NumPlayers") + 3; // Add 3 players to handle revolts } else{ PlayerCount =preference("MaxPlayers"); } for(count = 0; count <= PlayerCount; count = count + 1) { GOVT_WhatGovtAmI[count] = 0; // Default everyone to anarchy! } DisableTrigger('GOVT_SetupArrays'); DisableTrigger('ReInitializeGovData'); } HandleEvent(EndTurn) 'ReInitializeGovData' pre {//in case someone reloads SLIC int_t PlayerCount; int_t count; if (IsHumanPlayer(player[0])){ GOVT_GovtUnits[0] = UnitDB(UNIT_SETTLER_ANARCHY); //0 is the governmentDB index of ANARCHY GOVT_GovtUnits[1] = UnitDB(UNIT_SETTLER_CALIPHATE); //1 is the governmentDB index of CALIPHATE GOVT_GovtUnits[2] = UnitDB(UNIT_SETTLER_CITY_STATE);//and so on GOVT_GovtUnits[3] = UnitDB(UNIT_SETTLER_COMMUNISM); GOVT_GovtUnits[4] = UnitDB(UNIT_SETTLER_CORP_REPUB); GOVT_GovtUnits[5] = UnitDB(UNIT_SETTLER_DEMOCRACY); GOVT_GovtUnits[6] = UnitDB(UNIT_SETTLER_DICTATORSHIP); GOVT_GovtUnits[7] = UnitDB(UNIT_SETTLER_DYNASTY); GOVT_GovtUnits[8] = UnitDB(UNIT_SETTLER_ECOTOPIA); GOVT_GovtUnits[9] = UnitDB(UNIT_SETTLER_FASCISM); GOVT_GovtUnits[10] = UnitDB(UNIT_SETTLER_MONARCHY); GOVT_GovtUnits[11] = UnitDB(UNIT_SETTLER_OLIGARCHY); GOVT_GovtUnits[12] = UnitDB(UNIT_SETTLER_REPUBLIC); GOVT_GovtUnits[13] = UnitDB(UNIT_SETTLER_TECHNOCRACY); GOVT_GovtUnits[14] = UnitDB(UNIT_SETTLER_THEOCRACY); GOVT_GovtUnits[15] = UnitDB(UNIT_SETTLER_TRIBUNAL_EMPIRE); GOVT_GovtUnits[16] = UnitDB(UNIT_SETTLER_TYRANNY); GOVT_GovtUnits[17] = UnitDB(UNIT_SETTLER_VDEMOCRACY); if( preference("MaxPlayers") < preference("NumPlayers") + 3) { PlayerCount = preference("NumPlayers") + 3; // Add 3 players to handle revolts } else{ PlayerCount =preference("MaxPlayers"); } for(count = 0; count <= PlayerCount; count = count + 1) { GOVT_WhatGovtAmI[count] = 0; // Default everyone to anarchy! } } DisableTrigger('ReInitializeGovData'); DisableTrigger('GOVT_SetupArrays'); } HandleEvent(EndTurn) 'CheckMyGovernment' post { int_t tmpPlayer; int_t tmpUnitType; int_t govDBindex; city_t tmpCity; tmpPlayer = player[0]; if(PlayerCityCount(tmpPlayer)) { GetCityByIndex(tmpPlayer, 0, tmpCity); for(govDBindex = 0; govDBindex < GOVT_GovtUnits.#; govDBindex = govDBindex + 1) { tmpUnitType = GOVT_GovtUnits[govDBindex];//the Gov specific unit paired with govDBindex event:BuildUnit(tmpCity,tmpUnitType);//try to add one to buildlist, will only succeed if //the player's gov has index govDBindex } } } HandleEvent(BeginTurn) 'DeleteCheckUnits1' post { //match the player with his govt type and remove the dummy unit int_t govDBindex; int_t tmpUnitType; city_t tmpCity; if(PlayerCityCount(player[0])) {// because you can still be alive without having cities GetCityByIndex(player[0], 0, tmpCity); for(govDBindex = 0; govDBindex < GOVT_GovtUnits.#; govDBindex = govDBindex + 1) { tmpUnitType = GOVT_GovtUnits[govDBindex]; if(IsUnitInBuildList(tmpCity, tmpUnitType)) {//if this type of unit is in BuildList GOVT_WhatGovtAmI[player[0].owner] = govDBindex; //the player's govt is the govDBindex corresponding to it KillUnitFromBuildList(tmpCity, tmpUnitType); } } } } HandleEvent(FinishBeginTurn) 'Make_AI_Happy' pre { int_t numCities; int_t maxCities; int_t hapAmt; int_t i; city_t tmpCity; if (!IsHumanPlayer(player[0].owner) ){ numCities=PlayerCityCount(player[0].owner); if (numCities){ government[0]=GOVT_WhatGovtAmI[player[0].owner]; maxCities=GovernmentDB(government[0].type).TooManyCitiesThreshold; if (numCities > maxCities){ hapAmt=numCities-maxCities; for (i=0;i