//------------------------------------- //-------------------------------------- // // Natural disaster coding for CTP2 // by the Immortal Wombat // and Peter Triggs // //-------------------------------------------- //--------------------------------------------- //---------- // Variables //------------ // Co-ordinates int_t maxX; int_t maxY; int_t vX; int_t vY; // Game stuff, players and units int_t ND_NumPlayers; // How many players ? int_t ND_human; // The human player // Global variables for use in messages int_t PlaguedCityCounter; location_t QuakeLoc; int_t tmpRichter; city_t theNearestCity; //------------------------- #include "ND_msg.slc" // messages //------------------------- //////////////////////////////////////////////////// // // Disaster Functions // /////////////////////////////////////////////////////// //---------------------------- // // Assorted Shortcut Functions // //-------------------------------- //--------------------------------------- // Unit Damage code by Radical_Manouver //----------------------------------------- void_f QuakeDamage (location_t tmpLoc, int_t tmpDamage) { int_t i; unit_t tmpUnit; for (i = 0; i < GetUnitsAtLocation(tmpLoc); i = i + 1) { GetUnitFromCell(tmpLoc, i, tmpUnit); if (tmpUnit.hp > 8) { DamageUnit(tmpunit, tmpDamage); } } } //find thePlayer's theNearestCity to theLocation, outside or equal to theDistance boundary // return the distance from theLocation to theNearestCity // return -1 if no such city exists // // PETER TRIGGS VERSION ;-) // int_f FindTheNearestCity( int_t thePlayer, location_t theLocation, int_t theDistance){ int_t smlDist; int_t tmpDist; int_t i; city_t tmpCity; smlDist=1000; //initialize to some absurdly large number if (IsPlayerAlive(thePlayer)) { if (PlayerCityCount(thePlayer)> 0) { for(i = 0; i < PlayerCityCount(thePlayer); i = i + 1) { if(GetCityByIndex(thePlayer, i, tmpCity)) { tmpDist = Distance(theLocation, tmpCity.location); if (theDistance <= tmpDist && tmpDist < smlDist) { smlDist = tmpDist; theNearestCity = tmpCity; } } } if (smlDist<1000) { return smlDist; } else{ return -1;// no such city exists } } } else{ return -1; // no cities at all or not a valid player } } //-------------------------------------------------------------------------------------------- // // MAIN DISASTER FUNCTIONS BELOW HERE // //--------------------------------------------------------------------------------------------- ///////////////////////////////// // // Plague / Epidemic Function // /////////////////////////////////// void_f Plague (int_t thePlayer){ int_t tmpPlayer; tmpPlayer = thePlayer; if(IsHumanPlayer(tmpPlayer)){ //message(1, 'startdata'); int_t CityCount; player[0] = tmpPlayer; CityCount = player[0].cities; PlaguedCityCounter = 0; int_t i; for(i = 0; i < CityCount; i = i + 1){ //message(1, 'testdata'); int_t PPChance; PPChance = random(100); city_t PlaguedCity; GetCityByIndex(tmpPlayer, i, PlaguedCity); if(PlaguedCity.population >= 3){ // // Building that reduce plague chance are: // aqueduct, drug store, aqua-filter, hospital // // Start = 50/50 chance of plague in PlaguedCity // + aqueduct --> 40/60 chance // + drug store --> 30/70 chance // + hospital --> 20/80 chance // + aqua filter --> 10/90 chance // if(CityHasBuilding(PlaguedCity, "IMPROVE_AQUEDUCT")){ PPChance = PPChance - 10; } if(CityHasBuilding(PlaguedCity, "IMPROVE_DRUG_STORE")){ PPChance = PPChance - 10; } if(CityHasBuilding(PlaguedCity, "IMPROVE_HOSPITAL")){ PPChance = PPChance - 10; } if(CityHasBuilding(PlaguedCity, "IMPROVE_AQUA_FILTER")){ PPChance = PPChance - 10; } if(PPChance >= 50){ // replace to 50 again for a base 50/50 chance of strike city[0] = PlaguedCity; int_t tmpDead; tmpDead = city[0].population/5; int_t j; for(j = 0; j < tmpDead; j = j + 1){ Event:KillPop(PlaguedCity); } Event:AddHappyTimer(PlaguedCity, 3, -2, 14); // 3 turns of -2 happiness PlaguedCityCounter = PlaguedCityCounter + 1; } } } player[0] = tmpPlayer; if(PlaguedCityCounter >= 1){ if(HasAdvance(tmpPlayer, ID_ADVANCE_MEDICINE)){ message(tmpPlayer, 'EpidemicYou'); if(tmpPlayer != ND_human){ message(ND_human, 'EpidemicOther'); } } else{ message(tmpPlayer, 'PlagueHitYou'); if(tmpPlayer != ND_human){ message(ND_human, 'PlagueHitOther'); } } } else{ message(tmpPlayer, 'PlagueDidntHitYou'); if(tmpPlayer != ND_human){ message(ND_human, 'PlagueDidntHitOther'); } } } // closing the IsHuman brackets } ///////////////////////////////// // // Earthquakes // /////////////////////////////////// //-------------------- // Earthquake function //---------------------- void_f Quake_Event () { int_t tmpPlayer; city_t tmpCity; int_t DistanceFromCity; int_t tmpX; int_t tmpY; int_t i; int_t j; int_t citypop; int_t tmpPops; int_t tmptmpRichter; int_t TType; int_t T2Type; location_t nLoc; location_t mLoc; location_t QuakeLoc; location_t tmpLoc; tmpX = Random(maxX); tmpY = Random(maxY); MakeLocation(QuakeLoc, tmpX, tmpY); //for test, set the quake location // GetCityByIndex(player[0],0,tmpCity); // GetNeighbor(tmpCity.location,0,tmpLoc); // QuakeLoc=tmpLoc; // tmpX=QuakeLoc.x; // tmpY=QuakeLoc.y; tmptmpRichter = random(100); if(tmptmpRichter >= 97){ tmpRichter = 8; } elseif(tmptmpRichter >= 92){ tmpRichter = 7; } elseif(tmptmpRichter >= 82){ tmpRichter = 6; } elseif(tmptmpRichter >= 72){ tmpRichter = 5; } elseif(tmptmpRichter >= 60){ tmpRichter = 4; } elseif(tmptmpRichter >= 45){ tmpRichter = 3; } elseif(tmptmpRichter >= 30){ tmpRichter = 2; } else{ tmpRichter = 1; } TType = TerrainType(QuakeLoc); if(TType == TerrainDB(TERRAIN_MOUNTAIN) // || TType == TerrainDB(TERRAIN_BROWN_MOUNTAIN) // If the quake is on a mountain square || TType == TerrainDB(TERRAIN_WHITE_MOUNTAIN)){ // int_t Beaches; Beaches = 0; for(i = 0; i < 8; i = i + 1){ // look for nearby beaches GetNeighbor(QuakeLoc, i, tmpLoc); T2Type = TerrainType(tmpLoc); if(T2Type == TerrainDB(TERRAIN_WATER_BEACH)){ // if there is one, Beaches = Beaches + 1; // the quake must be caused by a destructive plate boundary } // so will be more powerful if(Beaches >= 2){ tmpRichter = tmpRichter*3/2; // up to force 8 } } GetCityByLocation(QuakeLoc, tmpCity); if(CityIsValid(tmpCity)){ // there's a city at the epicenter citypop = tmpCity.population; if(tmpRichter >= 7){ tmpPops = citypop/2; for(i = 0; i < tmpPops; i = i + 1){ AddPops(tmpCity,-1); } if(GetUnitsAtLocation(QuakeLoc) > 0){ QuakeDamage(QuakeLoc, 8); } Event:AddHappyTimer(tmpCity, 3, -3, 14); // -3 happiness for 3 turns due to "Conquest" } elseif(tmpRichter >= 5){ tmpPops = citypop/3; for(i = 0; i < tmpPops; i = i + 1){ AddPops(tmpCity,-1); } if(GetUnitsAtLocation(QuakeLoc) > 0){ QuakeDamage(QuakeLoc, 5); } Event:AddHappyTimer(tmpCity, 2, -2, 14); // -2 happiness for 2 turns due to "Conquest" } elseif(tmpRichter >= 2){ tmpPops = citypop/4; for(i = 0; i < tmpPops; i = i + 1){ AddPops(tmpCity,-1); } if(GetUnitsAtLocation(QuakeLoc) > 0){ QuakeDamage(QuakeLoc, 3); } Event:AddHappyTimer(tmpCity, 2, -1, 14); // -1 happiness for 2 turns due to "Conquest" } else{ if(GetUnitsAtLocation(QuakeLoc) > 0){ QuakeDamage(QuakeLoc, 1); } Event:AddHappyTimer(tmpCity, 1, -1, 14); // -1 happiness for 1 turn due to "Conquest" } city[0] = tmpCity; player[0] = tmpPlayer; message(tmpCity.owner, 'HitYourCity'); if(tmpCity.owner != ND_human){ message(ND_human, 'HitOtherCity'); } for(i = 0; i < 55; i = i + 1) { // destroy buildings int_t randnum; randnum = random(100); if(CityHasBuilding(tmpCity, "IMPROVE_ARCOLOGIES")){ // if city has arcologies randnum = randnum - 40; // make the chance counter less } // so that there is much less chance of... if(randnum < 50 && tmpRichter >= 7 // this. it should give || randnum < 40 && tmpRichter >= 5 // more powerful quakes || randnum < 30 && tmpRichter >= 3 // a greater likelihood || randnum < 20 && tmpRichter >= 1) { // of destroying buildings if(i != BuildingDB(IMPROVE_ARCOLOGIES)){ // then... arcologies excluded DestroyBuilding(tmpcity, i); // destroy buildings. } } } } else { //when there's no city at QuakeLoc, just kill the tile improvements for(i=0; i<24; i=i+1){ if (TileHasImprovement(QuakeLoc, i)) { Event:CutImprovements(QuakeLoc); } } } // now do the effects of the quake: 24 tiles to consider if(tmpRichter >= 3){ for(i = 0; i < 8; i = i + 1){ GetNeighbor(QuakeLoc, i, nLoc); for(j=0; j<24; j=j+1){ // Cycle through first 24 tile improvements !!! if (i == 0) { if (TileHasImprovement(nLoc, j)) { Event:CutImprovements(nLoc); } if( tmpRichter >=5){ GetNeighbor(nLoc, 0, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } } if(i == 1){ if( tmpRichter >=4){ if (TileHasImprovement(nLoc, j)) { Event:CutImprovements(nLoc); } } if( tmpRichter ==8){ GetNeighbor(nLoc, 1, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } if( tmpRichter >=7){ GetNeighbor(nLoc, 0, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } if( tmpRichter >=6){ GetNeighbor(nLoc, 2, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } } if(i == 2){ if (TileHasImprovement(nLoc, j)) { Event:CutImprovements(nLoc); } if( tmpRichter >=5){ GetNeighbor(nLoc, 2, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } } if(i == 3){ if( tmpRichter >=4){ if (TileHasImprovement(nLoc, j)) { Event:CutImprovements(nLoc); } } if( tmpRichter ==8){ GetNeighbor(nLoc, 3, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } if( tmpRichter >=6){ GetNeighbor(nLoc, 5, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } if( tmpRichter >=7){ GetNeighbor(nLoc, 4, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } } if(i == 4){ if( tmpRichter >=4){ if (TileHasImprovement(nLoc, j)) { Event:CutImprovements(nLoc); } } if( tmpRichter ==8){ GetNeighbor(nLoc, 4, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } if( tmpRichter >=6){ GetNeighbor(nLoc, 2, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } if( tmpRichter >=7){ GetNeighbor(nLoc, 7, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } } if(i == 5 ){ if (TileHasImprovement(nLoc, j)) { Event:CutImprovements(nLoc); } if(tmpRichter == 8){ GetNeighbor(nLoc, 5, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } } if(i == 6){ if(tmpRichter >= 6){ if(TileHasImprovement(nLoc, j)) { Event:CutImprovements(nLoc); } } if( tmpRichter ==8){ GetNeighbor(nLoc, 6, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } if( tmpRichter >=6){ GetNeighbor(nLoc, 5, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } if( tmpRichter >=7){ GetNeighbor(nLoc, 7, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } } if(i == 7){ if (TileHasImprovement(nLoc, j)) { Event:CutImprovements(nLoc); } if( tmpRichter >=6){ GetNeighbor(nLoc, 7, mLoc); if (TileHasImprovement(mLoc, j)) { Event:CutImprovements(mLoc); } } } } } } if (CellOwner(QuakeLoc)>-1) { DistanceFromCity=FindTheNearestCity(CellOwner(QuakeLoc), QuakeLoc, 0); message(1,'theQuakeEvent'); if (0= 2){ force = random(8); // up to force 8 } else{ force = random(4); // otherwise, its not very powerful } } elseif(TType == TerrainDB(TERRAIN_WATER_RIFT) // if its on a rift or volcano, then it's a || TType == TerrainDB(TERRAIN_WATER_VOLCANO)){ // constructive plate boundary, where plates // are separating, causing an uprising of lava force = random(6); // so can be in betweeny powerful. } else { // if its not on those terrains. } // do nothing if(force > 0){ // (if there is a volcano) // Do this regardless of city or not if(GetUnitsAtLocation(VolcLoc) > 0){ // If there are units here QuakeDamage(VolcLoc, force); // damage them by 'force' } for(i=0; i<24; i=i+1){ // for all locations, cycle 24 T.I. if (TileHasImprovement(LavaLoc, i)) { // if the tile has any of the 24 tileimps Event:CutImprovements(LavaLoc); // remove them } } GetCityByLocation(VolcLoc, VolcCity); // find a city if(CityIsValid(tmpCity)){ // if it is there city[0] = tmpCity; citypop = city[0].population; for(i = 0; i < force; i = i + 1){ Event:KillPop(VolcCity); // kill one pop for each force point } for(i = 0; i < 55; i = i + 1) { // destroy buildings randnum = random(100); if(CityHasBuilding(tmpCity, "IMPROVE_ARCOLOGIES")){ // if city has arcologies randnum = randnum - 20; // make the chance counter less } // so that there is less chance of... if(randnum < 50 && force >= 7 // this. it should give || randnum < 40 && force >= 5 // more powerful volcanos || randnum < 30 && force >= 3 // a greater likelihood || randnum < 20 && force >= 1) { // of destroying buildings if(i != BuildingDB(IMPROVE_ARCOLOGIES)){ // then... arcologies excluded DestroyBuilding(tmpcity, i); // destroy buildings. } } } message(VolcCity.owner, 'VolcanoHitYou'); // It hit your city if(VolcCity.owner != ND_human){ // if you are a computer player message(ND_human, 'VolcanoHitOther'); // tell the human } } // THEN... for(i = 0; i < force; i = i + 1){ // depending on its strength GetRandomNeighbor(VolcLoc, LavaLoc); // find a number of its neighbors for(i=0; i<24; i=i+1){ if (TileHasImprovement(LavaLoc, i)) { // if the tile has any of the 24 tileimps Event:CutImprovements(LavaLoc); // remove them } } tmpPlayer = CellOwner(LavaLoc); if(!HasAdvance(tmpPlayer, ID_ADVANCE_CONSERVATION)){ // if the player hasn't got conservation EnableTrigger('regenerateterrain'); // let the tile recover slowly makelocation(deadLoc, Lavaloc.x, LavaLoc.y); } terraform(LavaLoc, TerrainDB(TERRAIN_DEAD)); // But kill it for now. GetCityByLocation(LavaLoc, LavaCity); if(CityIsValid(LavaCity)){ // If there is a city there... city[0] = LavaCity; tmpPops = city[0].population; tmpDead = tmpPops / 3; for(j = 0; j < tmpDead; j = j + 1){ // for 1/3 of the population Event:KillPop(LavaCity); // Kill them } } // This prevents the human from getting } // multiple messages when the volcano is // near many cities if (CellOwner(VolcLoc) > -1) { GetCityByLocation(VolcLoc, VolcCity); // find a city if(!CityIsValid(tmpCity)){ // if it is NOT there ('cos thats already dealt with) city_t theNearestCity; int_t DistanceFromCity; DistanceFromCity = FindTheNearestCity(CellOwner(VolcLoc), VolcLoc, 0); // How close is the if (0 < DistanceFromCity && DistanceFromCity <= 4){ // nearest city owned by city[0] = theNearestCity; // the person who owns the volcano player[0] = city[0].owner; // if between 0 and 4 tiles away... message(theNearestCity.owner, 'VolcanoNearYou'); // message its close to them if(theNearestCity.owner != ND_human){ // if that wasnt the human message(ND_human, 'VolcanoNearOther'); // message the human too } } } } } } void_f Regenerate(location_t theOtherLocation){ int_t TType; int_t DeadCounter; TType = TerrainType(theOtherLocation); if(TType == TerrainDB(TERRAIN_DEAD)){ // if someone else hasn't terraformed it back, if(DeadCounter >= 10){ // then when 10 turns have passed terraform(theOtherLocation, TerrainDB(TERRAIN_GRASSLAND)); // the land has recovered DeadCounter = 0; DisableTrigger('RegenerateTerrain'); // and no longer needs regenerating } else{ // if < 10 turns have passed DeadCounter = DeadCounter + 1; // record the passing of time. } } } HandleEvent(BeginTurn) 'RegenerateTerrain' pre { // enabled by pre-Conservation volcano location_t DeadLoc; if(IsHumanPlayer(player[0])){ Regenerate(DeadLoc); // once each turn, run the regeneration } } ////////////////////////// // // // Tsunamis // // // ////////////////////////// void_f KillingPeopleFunction (city_t theCity) { city_t tmpCity; int_t i; tmpCity = theCity; if(CityIsValid(tmpCity)){ city[0] = tmpCity; int_t citypop; citypop = city[0].population; Event:KillPop(tmpCity); // kill 1 pop for(i = 0; i < 55; i = i + 1) { int_t randnum; randnum = random(100); // if(randnum < 20) { // 20% chance of killing buildings DestroyBuilding(tmpCity, i); // } } } } void_f Tsunami () { int_t tmpX; int_t tmpY; location_t TsuLoc; location_t tmpLoc; city_t TsuCity; int_t tmpPlayer; int_t MessageCount; tmpX = Random(maxX); tmpY = Random(maxY); MakeLocation(TsuLoc, tmpX, tmpY); int_t TType; int_t T2Type; int_t i; city_t tmpCity; MessageCount = 0; TType = TerrainType(Tsuloc); if(TType == TerrainDB(TERRAIN_WATER_BEACH)){ GetCityByLocation(tmpLoc, tmpCity); // if there is a sea-city there if(CityIsValid(tmpCity)){ KillingPeopleFunction(tmpCity); tmpPlayer = tmpCity.owner; if(IsPlayerAlive(tmpPlayer) && tmpPlayer > 0){ message(tmpPlayer, 'THU'); if(tmpPlayer != ND_human){ message(ND_human, 'THO'); } MessageCount = MessageCount + 1; } } for(i = 0; i < 8; i = i + 1){ GetNeighbor(TsuLoc, i, tmpLoc); GetCityByLocation(tmpLoc, tmpCity); // if there is a city if(CityIsValid(tmpCity)){ KillingPeopleFunction(tmpCity); tmpPlayer = tmpCity.owner; if(IsPlayerAlive(tmpPlayer) && tmpPlayer > 0){ message(tmpPlayer, 'THU'); if(tmpPlayer != ND_human){ message(ND_human, 'THO'); } MessageCount = MessageCount + 1; } } else { T2Type = TerrainType(tmpLoc); // if there is no city if(T2Type == TerrainDB(TERRAIN_GRASSLAND) || T2Type == TerrainDB(TERRAIN_PLAINS) || T2Type == TerrainDB(TERRAIN_DESERT) || T2Type == TerrainDB(TERRAIN_SWAMP) || T2Type == TerrainDB(TERRAIN_TUNDRA)) { terraform(tmpLoc, TerrainDB(TERRAIN_WATER_BEACH)); // ruthlessly drown it all } } } } elseif(TType == TerrainDB(TERRAIN_WATER_SHALLOW)){ GetCityByLocation(tmpLoc, tmpCity); // if there is a sea-city there if(CityIsValid(tmpCity)){ KillingPeopleFunction(tmpCity); // do this (see above) tmpPlayer = tmpCity.owner; if(IsPlayerAlive(tmpPlayer) && tmpPlayer > 0){ message(tmpPlayer, 'THU'); if(tmpPlayer != ND_human){ message(ND_human, 'THO'); } MessageCount = MessageCount + 1; } } for(i = 0; i < 8; i = i + 1){ GetNeighbor(TsuLoc, i, tmpLoc); GetCityByLocation(tmpLoc, tmpCity); // if there is a city if(CityIsValid(tmpCity)){ KillingPeopleFunction(tmpCity); tmpPlayer = tmpCity.owner; if(IsPlayerAlive(tmpPlayer) && tmpPlayer > 0){ message(tmpPlayer, 'THU'); if(tmpPlayer != ND_human){ message(ND_human, 'THO'); } MessageCount = MessageCount + 1; } } int_t j; for(j = 0; j < 8; j = j + 1){ location_t OtherLoc; GetNeighbor(tmpLoc, j, OtherLoc); GetCityByLocation(OtherLoc, tmpCity); // if there is a city if(CityIsValid(tmpCity) && tmpCity.location != TsuLoc){ KillingPeopleFunction(tmpCity); tmpPlayer = tmpCity.owner; GetCityByLocation(TsuLoc, TsuCity); if(!CityIsValid(TsuCity) && MessageCount < 1){ // could be a city at tsuloc, and 2 if(IsPlayerAlive(tmpPlayer) && tmpPlayer > 0){ message(tmpPlayer, 'THU'); // squares away, so only message if(tmpPlayer != ND_human){ // here if there isnt a city message(ND_human, 'THO'); //at TsuLoc } MessageCount = MessageCount + 1; } } } else{ if(T2Type == TerrainDB(TERRAIN_GRASSLAND) || T2Type == TerrainDB(TERRAIN_PLAINS) || T2Type == TerrainDB(TERRAIN_DESERT) || T2Type == TerrainDB(TERRAIN_SWAMP) || T2Type == TerrainDB(TERRAIN_TUNDRA)) { terraform(tmpLoc, TerrainDB(TERRAIN_WATER_BEACH)); // ruthlessly drown it all } } } } } if (CellOwner(TsuLoc) > -1) { if(MessageCount < 1){ // if we've not messaged before city_t theNearestCity; int_t DistanceFromCity; DistanceFromCity = FindTheNearestCity(CellOwner(TsuLoc), TsuLoc, 0); // How close is the if (2 < DistanceFromCity && DistanceFromCity <= 6 && MessageCount < 1){ // nearest city owned by city[0] = theNearestCity; // the person who owns the volcano player[0] = city[0].owner; // if between 0 and 4 tiles away... tmpPlayer = player[0]; if(IsPlayerAlive(tmpPlayer)){ message(tmpPlayer, 'THNU'); // message: its close to them if(tmpPlayer != ND_human){ // if that wasnt the human message(ND_human, 'THNO'); // message the human too } } } } } } //-------------------------------------------------- // all disaster code must come above the handlers //---------------------------------------------------- //------------------------ // Handlers: // Init Scenario // Disaster Handler //---------------------------- //---------- // Begin Game //------------ HandleEvent(BeginTurn) 'NDStart' pre { int_t i; maxX = GetMapWidth(); maxY = GetMapHeight(); ND_NumPlayers = preference("NumPlayers"); DisableTrigger('NDStart'); DisableTrigger('RegenerateTerrain'); for(i = 1; i < ND_NumPlayers; i = i + 1){ if(IsHumanPlayer(i)){ ND_human = i; } } } // //HandleEvent(BeginTurn)'ReportData' post { // // if (player[0]==1) { // message(2, 'StartData'); // DisableTrigger('ReportData'); // } //} // //============================= // DISASTER // HANDLER //================================ //----------------------------- // Disasters included are: // Plague, Earthquake, Volcano, Tsunami, //-------------------------------- HandleEvent(BeginTurn) 'ND_RunEachTurn' post { int_t i; int_t j; int_t QuakeChance; int_t PlagueChance; int_t VolcanoChance; int_t TsunamiChance; city_t tmpCity; location_t nLoc; location_t mLoc; int_t tmpPlayer; tmpPlayer = player[0]; if(g.year >= 3){ QuakeChance = random(199); // This selects a random number between (and including) PlagueChance = random(99); // 0 and the number in brackets VolcanoChance = random(999); // For each disaster. TsunamiChance = random(11); // if(PlagueChance >= 98){ // To make each disaster more or less likely, Plague(tmpPlayer); // figure out how many turns (roughly) you want each to occur } // then plug in numbers in the random line, and in the if(QuakeChance >= 169){ // lines like this one. Quake_Event(); // eg. For a quake every ten turns } // make QuakeChance = random(9) // 0 -> 9 = 10 if(VolcanoChance >= 995){ // then make the quake_event happen VolcanoEvent(); // if(QuakeChance >= 9){ } // so it only works (on average) once in ten turns if(TsunamiChance >= 11){ // bear in mind for 8 players, this is nearly once every Tsunami(); // human turn, though depending on how far through the game you are } // it may happen far away from any cities } }