|
Author
|
|
Topic: creating natural disasters via SLIC???? |  |
|
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 07, 2001 06:26
  |
 |
 |  |
And everyone (drumroll) here is some cool code  Alpha I thought about that too(tracking improvements) and here is what i came up with: have a variable say isDrought - and default it to -1. When we have a drought set it to three and then decrement it bu 1 each turn. when it gets to zero remove the improvment and set it to -1. Too easy. Anyway the code that can be added to mine is: 1+2. Drought/Good Weather Building I can't work out how to add a building to a city. anyone? 3. Add a earthquake code. I also took the liberty to add floods as a natural disaster as there is already a flood function. Enough rambling lets post some crappy code 
code:
#include "msg.slc" HandleEvent(BeginTurn) 'FirstTurn' pre { Message (g.player, 'StartMessage'); //Message when you start a game DisableTrigger('FirstTurn') }HandleEvent(BeginTurn) 'EveryTurn' pre { int_t DisasterType; int_t FloodStrength; int_t isDrought; //Used to determing whether we are is drought, or something else. isDrought = -1; //The next will do two checks. If it is greater than zero, decrement. //If it is 0 then destroy all the 'Drought' buildings and set it to -1 if (isDrought > 0) { isDrought = isDrought - 1; } elseif (isDrought == 0) { isDrought = -1; Message (g.player, 'DroughtEnd'); //Message when drought ends } int_t isWeather; //Used to determing whether we are is drought, or something else. isWeather = -1; //The next will do two checks. If it is greater than zero, decrement. //If it is 0 then destroy all the 'Drought' buildings and set it to -1 if (isWeather > 0) { isWeather = isWeather - 1; } elseif (isWeather == 0) { isWeather = -1; Message (g.player, 'WeatherEnd'); //Message when good wheather ends } //Start the disaster code here DisasterType = random (10); if (DisasterType == 1) { Message (g.player, 'DroughtBegin'); //Create the building 'Drought' for(m = 0; m <= player.cities; m = m + 1){ //Insert Building Code here } isDrought = 3; //Three turns of drought } if (DisasterType == 2) { Message (g.player, 'WeatherBegin'); //Create the building 'GoodWeather' for(m = 0; m <= player.cities; m = m + 1){ //Insert Building Code here } isWeather = 3; //Three turns of weather } if (DisasterType == 3 | | DisasterType == 4 | | DisasterType == 5 | | DisasterType == 6) { Message (g.player, 'Earthquake'); //Do the Earthquake Stuff } if (DisasterType == 7 | | DisasterType == 8) { Message (g.player, 'Flood'); FloodStrength = Random(3) + 1 Flood(FloodStrength); } }
I havent yet tested this(its not ready) so there may be careless spelling errors, missing ';'s, etc. Alsoo I think this (part of it, anyway) should just be for large random disasters. I was thinking that up the top I could just at a if(random(10)==1) then and then there is only a 1/10 chance of anything occuring at all. What do you think? Radical_Manuvr got any code for me?  |
Radical_Manuvr Chieftain Maryland, USA Dec 2000
|
 |
posted January 07, 2001 08:54
|
 |
 |  |
I just started on the earthquake stuff. Determined how to indicate the random location based on map size so it will work with any map, but I've only spent an hour on it so far so. Haven't tested yet either and I'm not sure how long it will take me.Question about using building for the +/- food. If this is a human player, what's to stop them from selling the building? I don't have another method for the +/- food at this point but just thought I would throw that out. To add a building I didn't find a nice easy way, maybe someone else knows of one. Here are the functions I think you need to do it. VOID ClearBuildQueue(city) Remove all items from the build queue of the given city. Example: city_t tmpCity; int_t i; for(i = 0; i < player[0].cities; i = i + 1) { GetCityByIndex(player[0], i, tmpCity); if(CityisValid(tmpCity)) { ClearBuildQueue(tmpCity) } } //clears the build queues of all of player[0]’s cities VOID AddBuildingToBuildList(city, buildingType) Add the building type to the end of the city’s queue. Example: if(!city[0].buildqueuelength) { AddBuildingToBuildList(city[0], BuildingDB(IMPROVE_CITY_WALLS)); } //if the city is not building anything, it will put the improvement City Walls into its build queue. 2 events that may help
BuildFront(city_t) Try to build the first thing in a city's queue OR BuyFront(city_t) Rush buy an item in a city BuildFront is probably better. It may not require gold since it looks like BuyFront does. The above set of functions and events may require you to determine the gold a player has, how much the rush buy costs and add enough gold using AddGold(city). I haven't tried the event below but it may work nice and clean. Since int_t is integer I suppose you have to know the index number of the building you want to add. Hopefully this will work. CreateBuilding(city_t, int_t) Create a building For getting rid of the building VOID DestroyBuilding(city, building) Remove the specified building from the city.
Example: DestroyBuilding(city[0], BuildingDB(IMPROVE_SILO)); Back to work on the quakes. Later
|
Radical_Manuvr Chieftain Maryland, USA Dec 2000
|
 |
posted January 07, 2001 08:58
|
 |
 |  |
Forgot to add that the flood function or event (forgot which it is) is like the global warming disaster. As far as I know that would affect all coasts and possibly swamps (if it works like CTP1) anywhere on the map not just those near a random epicenter. |
Locutus Prince Apolyton Borg Hengelo/Enschede, The Netherlands Nov 1999
|
 |
posted January 07, 2001 09:02
  |
 |
 |  |
heardie: Here's how to add a building: CreateBuilding(tmpCity, BuildingDB(IMPROVE_DROUGHT));Radical: Here's how to prevent sales:
code:
EventHandler(SellBuilding) 'SellBuilding' pre { int_t type; type = value[0]; if (type = BuildingDB(IMPROVE_DROUGHT)) { return STOP; } }
|
Alpha Wolf Settler Chicago Illinois Feb 2001
|
 |
posted January 07, 2001 13:03
 |
 |
 |  |
quote:
 Originally posted by Radical_Manuvr on 01-07-2001 08:58 AM Forgot to add that the flood function or event (forgot which it is) is like the global warming disaster. As far as I know that would affect all coasts and possibly swamps (if it works like CTP1) anywhere on the map not just those near a random epicenter.
 |
Thats one of the reasons I avoided the existing flooding criteria. Assuming that it would flood ALL areas and i was also worried about the rerouting of rivers that happened on the first global warming (i assume its similiar in ctp2 also). IF i get my work project done today, i want to slap some of these great ideas from you and Locutus in my game and try them out. ------------------ History is written by the victor. |
Locutus Prince Apolyton Borg Hengelo/Enschede, The Netherlands Nov 1999
|
 |
posted January 07, 2001 14:26
  |
 |
 |  |
Important correction: to add a building one should use the code: Event:CreateBuilding(tmpCity, BuildingDB(IMPROVE_DROUGHT)); So with 'Event:' in front of the eventname. I don't know how that could fallen away. To destroy it the function DestroyBuilding will work, as Radical mentioned earlier.To get non-global floods, you could use the Terraform function. My suggestion would be: check all squares in a 3 tile radius (or something similar) and if a tile is swamp, plain or grassland either adjacent to sea or with a river running through it, terraform it to beach/shallow water (whatever turns out to work best), do the same for all squares adjacent to it. (To get an adjacent tile, use a for loop and GetNeighbor). If a tile is of any other terraintype or doesn't have a river or sea near it, check the next tile. A good way to cycle through tiles could be to use a double for-loop with MakeLocation that has variables x and y(which range from location.x - 3 to location.x + 3, similar for y) as arguments, which come from the for-loops. |
Radical_Manuvr Chieftain Maryland, USA Dec 2000
|
 |
posted January 07, 2001 14:32
|
 |
 |  |
I've got part of the earthquake stuff working.So far if it's centered on a city it may destroy a building depending on the size quake. Also depends on if the building is there or not. It may try to destroy a building that isn't built yet in which case nothing happens. If it's level 8 (highest) you'll lose city walls. That can be easily changed by anyone to something else or deleted. Random tiles surrounding the epicenter may lose tile improvements. Random units in or around the epicenter will lose hitpoints. At this point I don't have them getting killed. I have it tied to the scale of the quake but if their hit points are less than 8 I'm not taking hitpoints because they ended up with negative hitpoints in some cases and weird stuff started happening. All this works with me specifying a location I know is a city. I'm working on the random location part but it's been crashing so far. I haven't tried with specifying a location say one tile from a city to see what happens. Probably gonna break for a while and watch some football. I'll post what works later today even if I don't get the random location part working. Maybe someone else can get that. I was trying to make it so this would work with any size map automatically. It may turn out that you just have to edit scenario.txt and plug in your map size. I'm trying to use GetMapHeight () and GetMapWidth () I'm not sure if a variable goes between the () or not. I'm crashing with nothing between the (). Hopefully Locutus or someone else can answer before I get back to it later. |
Alpha Wolf Settler Chicago Illinois Feb 2001
|
 |
posted January 07, 2001 14:38
 |
 |
 |  |
quote:
 Originally posted by Locutus on 01-07-2001 02:26 PM To get non-global floods, you could use the Terraform function. My suggestion would be: check all squares in a 3 tile radius (or something similar) and if a tile is swamp, plain or grassland either adjacent to sea or with a river running through it, terraform it to beach/shallow water (whatever turns out to work best), do the same for all squares adjacent to it. (To get an adjacent tile, use a for loop and GetNeighbor). If a tile is of any other terraintype or doesn't have a river or sea near it, check the next tile. A good way to cycle through tiles could be to use a double for-loop with MakeLocation that has variables x and y(which range from location.x - 3 to location.x + 3, similar for y) as arguments, which come from the for-loops.
 |
This this the same concept i'd use to see if a tile has a river so i can build a dam on it as a tile improvement? ------------------ History is written by the victor. |
Locutus Prince Apolyton Borg Hengelo/Enschede, The Netherlands Nov 1999
|
 |
posted January 07, 2001 16:05
  |
 |
 |  |
Radical, post what you have, even if it doesn't work (the random part). I'll have a look at it. I got mapsize-independent location-generators working for CtPI and if needed I'll do it again for CtPII.Alpha, Yeah, I suppose that's possible. What effect should a dam have anyway? [This message has been edited by Locutus (edited January 07, 2001).] |
Alpha Wolf Settler Chicago Illinois Feb 2001
|
 |
posted January 07, 2001 18:58
 |
 |
 |  |
quote:
 Originally posted by Locutus on 01-07-2001 04:05 PM Radical, post what you have, even if it doesn't work (the random part). I'll have a look at it. I got mapsize-independent location-generators working for CtPI and if needed I'll do it again for CtPII.Alpha, Yeah, I suppose that's possible. What effect should a dam have anyway? [This message has been edited by Locutus (edited January 07, 2001).]
 |
I figured dams were early power generators, so they'd production. Figured it would give me another option for some forst tiles since this is were I like to build and i cant put farms or mines there. Then a wonder like TVA or Hoover would double that effect. ------------------ History is written by the victor. |
Radical_Manuvr Chieftain Maryland, USA Dec 2000
|
 |
posted January 07, 2001 19:03
|
 |
 |  |
AW, please type your email address so I can send you the files. I'll post here but figured it would be eaiser for you if I sent them. I'll also send to Locutus and Herdie if his addy is here. Your addy came up strange when I clicked on the email icon. |
Radical_Manuvr Chieftain Maryland, USA Dec 2000
|
 |
posted January 07, 2001 19:18
|
 |
 |  |
Still didn't get random location to work. It just crashes with no msg when I include the lines for that. It may be that it's putting the location off the map. Perhaps limiting to between 3 and max x-4 would fix it. Same with y. Anyway, this works for a certain location, whatever is in tmpXloc, tmpYloc. I commented out the last random part I tried to get to work.I was using huge map size for testing it so it may not work with other sizes. Put a city in the location, add some bldgs, and units all around and in the city and see what happens. Pretty cool, IMHO. It works at locations other than cities as well. I probably have some unnecessary stuff in this but it works (except the random part) anyway. Never claimed to be a programmer. I planned to add a msg and maybe have a city lose a pop if the epicenter was a city, but this is what's done for now. scenario.slc ///////////////////////////////////////////////////////////////////////////////////// // Script for the earthquake disaster mod 1.0 // // last update 01-07-2001 by Charles Rothermel Apolyton name Radical_Manuvr // ///////////////////////////////////////////////////////////////////////////////////// ////////////////////// // Global variables // //////////////////////
int_t humanPlayer; // The human player number int_t tmpYloc; int_t tmpXloc; int_t turnCount; // Number of turns elapsed int_t turnMax; // Turns until scenario ends location_t disasterLoc; location_t disasterLoc2; #include "EQ_func.slc" // Functions ////////////// // Handlers // ////////////// //--------------------------------- // Stuff to do when the game starts //----------------------------------- HandleEvent(BeginTurn) 'EQStart_F' pre { int_t tmpPlayer; if(IsHumanPlayer(player[0])) { humanPlayer = player[0]; turnMax = 600; // if turnCount reaches turnMax, the game ends turnCount = 0; // number of turns elapsed // tmpXloc = 64; // max x for huge map, if using different size enter max x here // tmpYloc = 128; // max y for huge map, if using different size enter max y here // tmpXloc = GetMapWidth(); // tmpYloc = GetMapheight(); DisableTrigger('EQStart_F'); } } //----------------------- // Stuff to do every turn //------------------------- HandleEvent(BeginTurn) 'EQEachTurn_F' post { city_t tmpCity; int_t i; int_t tmpPlayer; int_t tmpRichter; // Richter scale simulator int_t tmpDestroy; // used to determine which building to destroy int_t tmpnumberUnits; tmpPlayer = player[0]; // tmpXloc = Random(63); // -1 from map size since random starts at 0 // tmpYloc = Random(127); // -1 same tmpXloc = 29; tmpYloc = 75; if (tmpPlayer == 1) { turnCount = turnCount + 1; // increment turn counter if (turnCount > turnMax) { if (humanPlayer == 1) { Event:GiveMap(2,1); // this is temporary just need something here } } // temp for testing take out later MakeLocation(disasterLoc, tmpXloc, tmpYloc); tmpRichter = Random(8); // random number from 0-8 tmpDestroy = Random(52); // random number from 0-52 GetCityByLocation(disasterLoc, tmpCity); if (CityIsValid(tmpCity)) { // if a city exists at the epicenter tmpnumberUnits = UnitsInCell(disasterLoc); // number of units in cell if (tmpnumberUnits > 0) { QuakeDamage (disasterLoc, tmpnumberUnits, tmpRichter); } for (i = 0; i < tmpRichter; i = i + 1) { GetRandomNeighbor(disasterLoc, disasterLoc2); // find a random tile one tile from epicenter Event:CutImprovements(disasterLoc2); // destroy tile improvements if found tmpnumberUnits = UnitsInCell(disasterLoc2); // number of units in cell if (tmpnumberUnits > 0) { QuakeDamage (disasterLoc2, tmpnumberUnits, tmpRichter); } } if (tmpRichter > 5) { // if quake is 6, 7, or 8 a building will be destroyed if it exists // if the building doesn't exist nothing happens to buildings if (tmpDestroy == 0 | | tmpDestroy == 1) { // 2 in 52 chance DestroyBuilding(tmpCity, BuildingDB(IMPROVE_VR_AMUSEMENT_PARK)); } elseif (tmpDestroy == 2) { // 1 in 52 chance DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ACADEMY)); } elseif (tmpDestroy == 3) { // 1 in 52 chance from here down DestroyBuilding(tmpCity, BuildingDB(IMPROVE_AIRPORT)); } elseif (tmpDestroy == 4) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ANTI_BALLISTIC_MISSILES)); } elseif (tmpDestroy == 5) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_AQUA_FILTER)); } elseif (tmpDestroy == 6) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_AQUEDUCT)); } elseif (tmpDestroy == 7) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ARCOLOGIES)); } elseif (tmpDestroy == 8) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ARENA)); } elseif (tmpDestroy == 9) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BALLISTA_TOWERS)); } elseif (tmpDestroy == 10) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BANK)); } elseif (tmpDestroy == 11) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BASCILICA)); } elseif (tmpDestroy == 12) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BATTLEMENTS)); } elseif (tmpDestroy == 13) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BAZAAR)); } elseif (tmpDestroy == 14) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BEHAVIORAL_MOD_CENTER)); } elseif (tmpDestroy == 15) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BODY_EXCHANGE)); } elseif (tmpDestroy == 16) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_BROKERAGE)); } elseif (tmpDestroy == 17) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CAPITOL)); } elseif (tmpDestroy == 18) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CITY_WALLS)); } elseif (tmpDestroy == 19) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_COMPUTER_CENTER)); } elseif (tmpDestroy == 20) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CORNUCOPIC_VAT)); } elseif (tmpDestroy == 21) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CORRECTIONAL_FACILITY)); } elseif (tmpDestroy == 22) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_COURTHOUSE)); } elseif (tmpDestroy == 23) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_DRUG_STORE)); } elseif (tmpDestroy == 24) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_E_BANK)); } elseif (tmpDestroy == 25) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ECO_TRANSIT)); } elseif (tmpDestroy == 26) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FACTORY)); } elseif (tmpDestroy == 27) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FLAK_TOWERS)); } elseif (tmpDestroy == 28) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FOOD_SILO)); } elseif (tmpDestroy == 29) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FORCEFIELD)); } elseif (tmpDestroy == 30) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_FUSION_PLANT)); } elseif (tmpDestroy == 31) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_GAIA_COMPUTER)); } elseif (tmpDestroy == 32) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_GRANARY)); } elseif (tmpDestroy == 33) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_HOSPITAL)); } elseif (tmpDestroy == 34) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_INCUBATION_CENTER)); } elseif (tmpDestroy == 35) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_MATTER_DECOMPILER)); } elseif (tmpDestroy == 36) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_MICRO_DEFENSE)); } elseif (tmpDestroy == 37) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_MILL)); } elseif (tmpDestroy == 38) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_MOVIE_PALACE)); } elseif (tmpDestroy == 39) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_NANITE_FACTORY)); } elseif (tmpDestroy == 40) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_NUCLEAR_PLANT)); } elseif (tmpDestroy == 41) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_OIL_REFINERY)); } elseif (tmpDestroy == 42) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ORBITAL_LABORATORY)); } elseif (tmpDestroy == 43) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_POWER_SATELLITE)); } elseif (tmpDestroy == 44) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_PUBLIC_TRANSPORTATION)); } elseif (tmpDestroy == 45) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_PUBLISHING_HOUSE)); } elseif (tmpDestroy == 46) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_RECYCLING_PLANT)); } elseif (tmpDestroy == 47) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_ROBOTIC_PLANT)); } elseif (tmpDestroy == 48) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_SECURITY_MONITOR)); } elseif (tmpDestroy == 49) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_SHRINE)); } elseif (tmpDestroy == 50) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_TELEVISION)); } elseif (tmpDestroy == 51) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_THEATER)); } elseif (tmpDestroy == 52) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_UNIVERSITY)); } if (tmpRichter == 8) { // if quake is 8, city walls will be destroyed if they exist // at this magnitude something should go DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CITY_WALLS)); } } } else { // no city at epicenter Event:CutImprovements(disasterLoc); // destroy tile improvements if found at epicenter tmpnumberUnits = UnitsInCell(disasterLoc); // number of units in cell if (tmpnumberUnits > 0) { QuakeDamage (disasterLoc, tmpnumberUnits, tmpRichter); } for (i = 0; i < tmpRichter; i = i + 1) { // the higher the Richter number the more likely a tile improvement will be destroyed // can be up to 8 tile improvements destroyed surrounding epicenter GetRandomNeighbor(disasterLoc, disasterLoc2); // find a random tile one tile from epicenter Event:CutImprovements(disasterLoc2); // destroy tile improvements if found tmpnumberUnits = UnitsInCell(disasterLoc2); // number of units in cell if (tmpnumberUnits > 0) { QuakeDamage (disasterLoc2, tmpnumberUnits, tmpRichter); } // possible that it will use the same tile 8 times or other combos, ex. 1 twice, another once, another 3 times // losing all tile impr. around epicenter should be rare } } } } EQ_func.slc /////////////// // Functions // ///////////////
// Damages all units in location void_f QuakeDamage (location_t tmpLoc, int_t tmpNum, int_t tmpNum2) { int_t i; unit_t tmpUnit; for (i = 0; i < tmpNum; i = i + 1) { GetUnitFromCell(tmpLoc, i, tmpUnit); if (tmpUnit.hp > 8) { DamageUnit(tmpunit, tmpNum2); // Subtract tmpNum2 hit points from the specified unit } } } |
Alpha Wolf Settler Chicago Illinois Feb 2001
|
 |
posted January 07, 2001 22:32
 |
 |
 |  |
quote:
 Originally posted by Radical_Manuvr on 01-07-2001 07:03 PM AW, please type your email address so I can send you the files. I'll post here but figured it would be eaiser for you if I sent them. I'll also send to Locutus and Herdie if his addy is here. Your addy came up strange when I clicked on the email icon.
 |
CTPAlphaWolf@aol.com When I setup that account on aol i set it up as CTP Alpha Wolf forgetting that the email address would freak out on the spaces. Took me a few days of harrassing poor Dan and Mark in order to figure out that my actual email address didnt have the spaces. Now I'm afraid to touch it in my profile....LOL I think i remember seeing that buildings are assigned a number as its read into the database. If so, you can just do a loop thru the number of buildings and would save a ton of code. Something like: if (tmpRichter > 4) { // if quake is 5, 6, 7, or 8 buildings have a chance to be destroyed // if the building doesn't exist nothing happens to buildings for(b = 0; Building.Type[b] <> ""; b = b + 1) { //assuming this is how to identify the end of the array if random(tmpRichter * 3) > 12 { //chance any building will be destroyed DestroyBuilding(tmpCity, Building.Type[b]) } } Also, depending on how SLIC does there rounding, tmpRichter = Random(8); will most likely give you a range of 0 to 7. Most of the randomizers i've seen over the years simply drop fractional values so getting the 8 would be so rare that in essence it would never happen. However, if SLIC's randomizer rounds then you can get 8 more often. ------------------ History is written by the victor. [This message has been edited by Alpha Wolf (edited January 07, 2001).] [This message has been edited by Alpha Wolf (edited January 07, 2001).]
|
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 07, 2001 22:38
  |
 |
 |  |
Great work! I'll force that together with my code and see what happens. This should be good |
Alpha Wolf Settler Chicago Illinois Feb 2001
|
 |
posted January 07, 2001 23:26
 |
 |
 |  |
What is #include "EQ_func.slc" // Functions ???? I put the code into scenario.slc but the game crashes on that line.
------------------ History is written by the victor. |
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 08, 2001 00:14
  |
 |
 |  |
EW_FUNC
code:
/////////////// // Functions // ///////////////// Damages all units in location void_f QuakeDamage (location_t tmpLoc, int_t tmpNum, int_t tmpNum2) { int_t i; unit_t tmpUnit; for (i = 0; i < tmpNum; i = i + 1) { GetUnitFromCell(tmpLoc, i, tmpUnit); if (tmpUnit.hp > 8) { DamageUnit(tmpunit, tmpNum2); // Subtract tmpNum2 hit points from the specified unit } } }
|
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 08, 2001 00:17
  |
 |
 |  |
So close to getting this work.. Okay now I added this############################################################ IMPROVE_DROUGHT { DefaultIcon ICON_IMPROVE_GRANARY Description DESCRIPTION_IMPROVE_GRANARY EnableAdvance ADVANCE_AGRICULTURE ProductionCost 0 Upkeep 0 FoodPercent -0.25 } ############################################################ IMPROVE_GREATWEATHER { DefaultIcon ICON_IMPROVE_GRANARY Description DESCRIPTION_IMPROVE_GRANARY EnableAdvance ADVANCE_AGRICULTURE ProductionCost 0 Upkeep 0 FoodPercent 0.25 } ############################################################ ANd it crashed saying 'buildings.txt:727: Record does not start with name' not how can I fix this? |
Alpha Wolf Settler Chicago Illinois Feb 2001
|
 |
posted January 08, 2001 00:42
 |
 |
 |  |
quote:
 Originally posted by heardie on 01-08-2001 12:17 AM'buildings.txt:727: Record does not start with name' not how can I fix this?
 |
i got that error when i tried to add some wonders to the end of the wonders file. I moved them all to the top and the error went away. Made no other changes. ------------------ History is written by the victor. |
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 08, 2001 01:59
  |
 |
 |  |
Thanks Alpha. More errors here though and i havent even tried adding radical's eq code.i dont know how or why but the line for(m = 0; m <= player.cities; m = m + 1){ is being flagged as an wrror, because 'player is not a structure'. This must work,, shouldnt it? NOTE: I will be gone most likly till friday from the forums, but when i return I hope to have it all done bar floods  |
Alpha Wolf Settler Chicago Illinois Feb 2001
|
 |
posted January 08, 2001 03:56
 |
 |
 |  |
On a scale of 1 to 10 (expert), my SLIC is about a 2, but that sure looks right to me. I assume that you declared "int_t m"? As I've been trying to implement Rad's code (so far unsuccessfully) I've noticed some of the error messages are misleading. So now when I get an error on a line, I mostly ignore the message itself and concentrate on the entire line. But according to the SLIC doc player.cities is valid.Oh crud....while i was looking at valid flags I realized that we could code for labor strikes if a city riots and remove a percentage of PW. Someone turn my brain off before I have any more ideas....LOL We probably want to use the "AddCenter(loc)" to center on the quake also. OMG, the examples show how to make a city immune to riots and revolts. I was so tired when I read thru this stuff the first time that I didnt realize how many things we can do. And i wonder if we could use SLIC to have the AI build an effective army. Interesting that there is an unit.name but not an army.name. We could have had units join specific armies and when those armies = 12 units, off they go to war, like a blitzkrieg. I wonder how to tell which units are grouped. whew, i finally switched the brain off for the night or I'll be up all night coming up with new ideas.  ------------------ History is written by the victor. |
Radical_Manuvr Chieftain Maryland, USA Dec 2000
|
 |
posted January 08, 2001 09:41
|
 |
 |  |
Heardie and AW, if you try to run my code remember that it only works on a specific tile at the moment. Locutus said he'd take a look at it to add random locations.AW when you get the error about EQ_func.slc...did you create the EQ_func.slc file and enter the code? It was near the bottom of the code posting. Counting up from the bottom }, go up 19 lines including blanks. Everything below that line (EQ_func.slc) goes in EQ_func.slc. I probably should have made it more clear that you need 2 files. I would have liked to use a for loop for the buildings but didn't see numbers for them anywhere. I didn't look real hard though. That wasn't the part that took long to do and I don't know whether it would make the game run slower. Maybe if the random number was for the bldg near the end of the list??? Random - I was assuming that Random(8) would give me a chance at 0,1,2,3,4,5,6,7,8. From this site: · INT Random(range) Return a random number from 0 to range. I didn't think I'd get something like 2.37 and have it rounded. I'm pretty sure I got an 8 on my 18th turn in one test. I can't say for sure since I felt pressured and didn't get to make the message I had intended "reports of a magnitude 8 earthquake have come in from sector 3, 47". Anyway, I think random(any number) gives you "any number" + 1 (for zero). On the last Heardie msg about structures - I found that sometimes you have to use your own variable instead of the built-in variables. In this case tmpPlayer.cities or something. I have no idea when or whatever, I just experiment when I get errors. I'm stepping away from this for a few days. I'm helping playtest the Alex scenario and I need to play. I also wanted to look more closely to see if any of the other stuff in scenario.slc can be put into functions. When I get the msg or any other changes to the EQ mod I'll post them. Probably before Friday, shouldn't take long for the msg. |
Alpha Wolf Settler Chicago Illinois Feb 2001
|
 |
posted January 08, 2001 12:24
 |
 |
 |  |
Thanks for all the help. I hadnt realized at first that it was 2 files. I tried leave it all as one and took out the reference to eq_func, but it didnt like that so I'll try 2 files tonight. I think we have enough of a start to be able to work it all out including the randomized location. I was reading the SLIC doc last night so now I'm an expert And tomorrow I will win the lottery....LOLI'm going to try to swipe the "general" code from the shipped scenarios and see if i can get that too work too.  ------------------ History is written by the victor. |
Locutus Prince Apolyton Borg Hengelo/Enschede, The Netherlands Nov 1999
|
 |
posted January 08, 2001 16:11
  |
 |
 |  |
Heardie, Use player[0] instead of player. Don't use tmpPlayer or whatever, that won't work, SLIC will think it's a number instead of a player.AW, An Eyepointer is better than AddCenter, 'cause another AddCenter event might occur and you loose the center on the earthquake. An eyepointer is that button with an eye on it you sometimes see. Clicking on it centers on a location (or unit or city). Using SLIC to improve AI will prove extremely difficult in practive (though a little 'push in the back' here and there will be possible). Checking if a units are in the same army is simple: cycle through all units in an army (using a for loop and army.size and GetUnitFromArmy) and compare. Radical, Random(x) should work from 0 to x-1. I tried Random(3) a couple of dozen times and never got anything but 0, 1, 2. Are you sure you got an 8 once? We should both try again if you are to double check our findings. Here's fixed code from Radical. The weird thing is, it basicly works but a call to a random function seems to crash the game without an error message. I'm fairly sure it's the Random fuction causing the problem, but I have no idea what the problem is. This is very weird 'cause I've used it often enough in the past without problems. Maybe it can't handle values larger then 60 or something? I tested it on a 48x96 maps and I think Random(52) isn't causing any problems, so if there is a problem with large numbers, the critical number is between 52 and 96. AW, you're an expert now, could you figure this out? I'm gonna be very busy for the next two days at least, so I won't have time to figure it out, but I will ASAP, this affects everyone working with SLIC and the Random code including yours truly. Note that there are no comments with this code, it crews up the thread so I just left them out. Shouldn't be too hard to understand anyway (all code can go in 1 file). code:
int_t humanPlayer; int_t turnCount; int_t turnMax; location_t disasterLoc; location_t disasterLoc2; int_t maxX; int_t maxY;void_f QuakeDamage (location_t tmpLoc, int_t theNum, int_t theNum2) { int_t i; int_t tmpNum; int_t tmpNum2; unit_t tmpUnit; tmpNum = theNum; tmpNum2 = theNum2; for (i = 0; i < tmpNum; i = i + 1) { GetUnitFromCell(tmpLoc, i, tmpUnit); if (tmpUnit.hp > 8) { DamageUnit(tmpunit, tmpNum2); } } } HandleEvent(BeginTurn) 'EQStart_F' pre { if(IsHumanPlayer(player[0])) { humanPlayer = player[0]; } turnMax = 600; turnCount = 0; DisableTrigger('EQStart_F'); maxX = GetMapWidth(); maxY = GetMapheight(); } HandleEvent(BeginTurn) 'EQEachTurn2_F' post { city_t tmpCity; int_t i; int_t tmpPlayer; int_t tmpRichter; int_t tmpDestroy; int_t tmpnumberUnits; int_t tmpXloc; int_t tmpYloc; tmpPlayer = player[0]; if (tmpPlayer == 0) { // && Random(2) == 1 tmpXloc = Random(maxX); tmpYloc = Random(maxY); // value[0] = tmpXloc; // value[1] = tmpYloc; // Message(1, 'EQTest'); turnCount = turnCount + 1; if (turnCount > turnMax) { if (humanPlayer == 1) { Event:GiveMap(2,1); } } MakeLocation(disasterLoc, tmpXloc, tmpYloc); tmpRichter = Random(8); tmpDestroy = Random(52); GetCityByLocation(disasterLoc, tmpCity); if (CityIsValid(tmpCity)) { tmpnumberUnits = UnitsInCell(disasterLoc); if (tmpnumberUnits > 0) { QuakeDamage (disasterLoc, tmpnumberUnits, tmpRichter); } for (i = 0; i < tmpRichter; i = i + 1) { GetRandomNeighbor(disasterLoc, disasterLoc2); Event:CutImprovements(disasterLoc2); tmpnumberUnits = UnitsInCell(disasterLoc2); if (tmpnumberUnits > 0) { QuakeDamage (disasterLoc2, tmpnumberUnits, tmpRichter); } } if (tmpRichter > 5) { if (tmpDestroy <= 50) { DestroyBuilding(tmpCity, tmpDestroy); } if (tmpRichter == 8) { DestroyBuilding(tmpCity, BuildingDB(IMPROVE_CITY_WALLS)); } } if (tmpCity.owner == 1) { value[0] = tmpRichter; city[0] = tmpCity; location[0] = disasterLoc; Message(1, 'EQCityHit'); } } else { Event:CutImprovements(disasterLoc); tmpnumberUnits = UnitsInCell(disasterLoc); if (tmpnumberUnits > 0) { QuakeDamage (disasterLoc, tmpnumberUnits, tmpRichter); } for (i = 0; i < tmpRichter; i = i + 1) { GetRandomNeighbor(disasterLoc, disasterLoc2); Event:CutImprovements(disasterLoc2); tmpnumberUnits = UnitsInCell(disasterLoc2); if (tmpnumberUnits > 0) { QuakeDamage (disasterLoc2, tmpnumberUnits, tmpRichter); } } if (CellOwner(disasterLoc) == 1) { value[0] = tmpRichter; location[0] = disasterLoc; Message(1, 'EQNoCityHit'); } } } } Messagebox 'EQCityHit' { Show(); Text(ID_EQ_CITY_HIT); EyePoint(location[0]); } // in textfiles: EQ_CITY_HIT "Sire, a horrible thing has happened! An earthquake of size {value[0]} on the scale // of Richter struck in the center of the city of {city[0].name}. People are hiding or fleeing in panic // and the damage is enormous!" Messagebox 'EQNoCityHit' { Show(); Text(ID_EQ_NO_CITY_HIT); EyePoint(location[0]); } Messagebox 'EQTest' { Show(); Text(ID_TEST_EQ); } // in textfiles: EQ_NO_CITY_HIT "Sire, a report just came in. An earthquake of size {value[0]} on the scale // of Richter struck our empire. Luckily no large cities were at the epicenter, so damage is limited."
[This message has been edited by Locutus (edited January 08, 2001).] [This message has been edited by Locutus (edited January 08, 2001).] |
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 08, 2001 17:53
  |
 |
 |  |
Thats right player[0]! I did figure that out after looking inn the ND Slic!Now I have yet another problem. It doesn't seem to read any of the code in thee 'If's' after the message, because no buildings get created. This is what should work
code:
if (DisasterType == 1) { Message (g.player, 'DroughtBegin'); //doesn't read after here for(m = 0; m <= player[0].cities; m = m + 1) { Event:CreateBuilding(city[0], BuildingDB(IMPROVE_DROUGHT)); } isDrought = 3; //Three turns of drought }
I'm sure it doesnt read after the message because isDrought never gets set to 3, because it never goes back to zero witht the code up the top Uggh! [This message has been edited by heardie (edited January 08, 2001).]
|
Harlan ctpmaps.apolyton/harlan Berkeley, CA, USA b.02-15-99
|
 |
posted January 10, 2001 18:58
 |
 |
 |  |
Here's a break from posting code to posting an article on disasters. Science is only beginning to realize that, in recorded history, the earth has been hit by some natural disasters that make an ordinary earthquake or volcano small potatoes in comparison. Below is an article about one such disaster. I've looked into this alot, and the prime culprit generally seems to be comets, which in turn can trigger large earthquakes or volcanoes. The article below doesn't mention it, but odds are good based on other evidence that the volcanic explosion mentioned below was triggered by a comet.So I think having the occasional mega disaster that effects the whole world some and one part of it alot would be a good thing to have in the game. I'll try to dig up more info on mega-disasters, if people are interested. I highly recommend reading the book Catastophe mentioned below, btw. Lots of eyewitness accounts and records from just about every culture on major natural upheaval in the 500s AD, yet history books have completely overlooked this and other such episodes so far. Only in the past few years with greater advancement in the study of tree rings and ice core samples, plus the hitting of Jupiter by a large comet, has science found these ideas acceptable and really gotten into researching them. Before Shoemaker-Levy hitting Jupiter, the common wisdom was that it was impossible for a comet to hit a planet, even though there can be no other explanation for the large impact in Siberia in 1908. Its literally just in the last year or two that a flood of books and reseach has been finished on this, with Catastophe being one example, so we're all still learning a lot about history. The Dark Ages May Have Really Been Dimmer
LOS ALAMOS, N.M., Dec. 17, 2000 -- The beginning of the Dark Ages may have been literal, as well as figurative, as the result of a massive volcanic eruption in the 6th century, according to a volcanologist at the Department of Energy's Los Alamos National Laboratory. Ken Wohletz said an eruption in the Indonesian archipelago could have produced a 150-meter-thick cloud layer over the entire Earth, triggering a chain of climatic, agricultural, political and social changes that ushered in the Dark Ages. Evidence supporting the catastrophe includes tree-ring and ice-core measurements, indications of a huge underwater caldera, and ash and pumice in the same area, said Wohletz, who discusses his work modeling such an eruption today (Dec. 17) at the fall meeting of the American Geophysical Union. The 6th century was a turbulent, unsettling period in human history. The Roman Empire began to fall; nomads of central Asia migrated to Europe and the Near East; civilizations in Persia, Indonesia and South America collapsed; major religions experienced considerable change as natural events were viewed as omens. Many of these social transformations resulted from widespread crop failures and the explosion of plague around the globe, which in turn were caused by major climatic changes, Wohletz said. Beginning in about the year 535, according to historical and archeological records, the weather was colder and drier, sunlight diminished, snow fell in summer and regions of persistent drought suffered floods. Wohletz was a resource for a book postulating that the climate changes resulted from a huge volcanic eruption. The book, "Catastrophe: A Quest for the Origins of the Modern World" by David Keys, was published earlier this year. Wohletz said he worked with Keys to try to identify a volcano that could produce such dramatic climate change. "We came up with an eruption that would certainly be the largest in recorded history, some four or five times bigger than the (1815) eruption of Tambora, which is usually considered the biggest eruption in the past few millennia," he said. Such an explosion, he said, would eject some 200 cubic kilometers of material, and one-third to one-half of it would be lofted into the stratosphere, where it would remain suspended for months to years while being carried around the globe. "It would have produced enough dust and water vapor (in the form of ice crystals) to form a cloud layer 150 meters thick over the entire globe, and that's a conservative estimate," he said, adding that a cloud of particles that thick may have diminished the transmission of sunlight by as much as 50 percent. Wohletz said tree-ring data collected around the world and ice-core measurements in Greenland and Antarctica support the possibility of a huge eruption in the 6th century. Ocean depth measurements between Sumatra and Java where Krakatoa exploded in a well known 1883 eruption indicate the presence of a caldera up to 50 kilometers in diameter, and a recent survey uncovered evidence of ash and pumice layers formed in the area during the appropriate time frame. Under a likely scenario, a large volcano, which Wohletz calls proto-Krakatoa, connected the islands of Sumatra and Java. When it erupted and then subsided, it created the Sundra Strait and left a ring of smaller volcanoes, including the present day Krakatoa. The ash, dust and water vapor blown into the stratosphere would disperse across both the Northern and Southern Hemispheres. "This volcano would have had the potential to be a major player in destabilizing the climate around the world," he said. "An eruption that could produce a caldera 50 kilometers across would have been big enough." Although definitive evidence for such a catastrophic eruption has not been discovered, the possibility deserves a full-scale field study, Wohletz said, in part because of the potential impact on the world if another such catastrophe happens. "(Key's book) is the first detailed account of how closely humanity is linked to the natural world," he said. "If the natural world goes through some large upheaval, we'll all be affected."
|
wheathin Prince Charming Apr 99
|
 |
posted January 11, 2001 12:11
 |
 |
 |  |
Similarly, there is a lot of interesting research over the last three years or so about the "Great Flood." The flood of Noah is repeated in hundreds of other cultural myths from southern europe and the middle east, but only recently have scientists identified it: the massive expansion of the Black Sea about 7,000-9,000 years ago.The Black Sea had been a small lake in a large depression, but the Bosporous was closed off by a large natural dam - part of the mountains in the area. Eventually, the dam broke and flooded the basin. The lake, now a sea, rose hundreds of feet, covering what had been hills, marshes, and plains that supported small early human communities. Those communities fled into Southern Europe, the Causasus, and Anatolia, taking with them an oral history of the flood, which was steadily incorporated into their origin myths and creation stories. Linguists and Anthropologists first identified the possibility based on the prevalence of flood myths. Recent examinations of the floor of the black sea have revealed the outlines of structures and tools on the sea bed - encampments or villages. |
Locutus Prince Apolyton Borg Hengelo/Enschede, The Netherlands Nov 1999
|
 |
posted January 11, 2001 13:22
  |
 |
 |  |
Heardie, Well, that's because you have a variable m, you make it zero, you create a building in city[0] (let's say city[0] happens to be Rome at that point), then you make m one, then you create another building in Rome, then you make m two, make another building in Rome, etc. You create all the buildings in the same city. city[0] is not much different from a regular variable, it stores a values and stays the same until you manually change it. The only catch is that these built-in variables might change if a certain event happens (or another eventhandler executed at the same time changes it), but you can't control those events. The events you invoke from within an EventHandler or function are put in a queue and executed one at a time at CtP2's leasure, outside your control. So unless an event happens to occur just as you cycle through your cities, city[0] will remain the same throughout the eventhandler or function your code is in (unless you manually change it of course).You must insert the line "GetCityByIndex(player[0], m, tmpCity);" between the for line and the CreateBuilding line and declare tmpCity higher up in the code and use it instead of city[0] in CreateBuilding (so that tmpCity actually cycles through all cities). Maybe you can use city[0] directly as well but whenever possible it's safer to use a user-defined variable like tmpCity so if another event happens that changes the value of city[0], you're screwed - I'm not sure if it's possible for this to happen in CtPII but it was in CtPI and I for one think it's better to be safe than sorry. Harlan/wheatin, Yeah, I'm aware of such stories, it would indeed be cool to implement, though I'll leave the details on how to do that to others, unless my help is needed for the 'technical' part of course. |
Jerk Chieftain Green Bay, WI USA Nov 2000
|
 |
posted January 11, 2001 15:20
|
 |
 |  |
Locutus,I cut and pasted your last code in and got a delightful crash that required a reboot in order to load the game again. I broke it down to test if it was the Random() causing a crash by making my own slic file with just parts of the code posted. I was able to Random() any number I chose and display it in a message box without any crashes or errors. I included further pieces of your code and encountered a slic error (I have debugslic=yes in my profile.txt) in "object testingthis function_GetCityByLocation. Wrong type of arguement." I could close the little warning window and go back to playing though. It didn't crash the game. Anyways, from what I have seen Random() isn't causing problems. *Edit* Ignore the wrong type of arguement thing, I used int_t instead of city_t. Stupid me. *Edit again* Through trial and error (and a number of reboots) I found the troublesome part that was causing it to crash: Event:CutImprovements(disasterLoc); Commenting them out kept the game from crashing. Maybe we have to check if there are improvments there to pilliage first. If that doesn't work I guess we can terraform it to the same terrain type. (I think that would kill the improvements) [This message has been edited by Jerk (edited January 11, 2001).] [This message has been edited by Jerk (edited January 11, 2001).] |
Harlan ctpmaps.apolyton/harlan Berkeley, CA, USA b.02-15-99
|
 |
posted January 11, 2001 15:40
 |
 |
 |  |
Yeah, The Black Sea flood is another stunning example that's just been discovered. Pretty astounding, the few things they've come across so far as they start to explore. The Black Sea is a complete biological dead zone once you get below about 100 meters, so they've already found a ship from BC times looking basically like it did when it went down, even with the mast still standing! So far they've only come across one house from pre-flood times, but if they do find whole towns, it could be some of the most astounding discoveries of all time. The theory is the flood came slowly, about a mile a day. Fast enough so that everyone had to flee, but slow enough so that the buildings would all still be standing.Still, that was such a wierd disaster its hard to see how it could be implemented in the game. Its a good example though of how the catastophists are getting the upper hand over the gradualists (those who think that large natural disasters almost never happen) through new revelations. A reason why the gradualists have had the upper hand is because apparently the last 1500+ years have been unusually quiet. But that's just luck: an analysis of the ice cores shows there's a big comet hit about once every 1000 years. If the comet (or pieces of it, sometimes it breaks up entering the atmosphere) hits water, the effects are very different than if it hits land. Meteor hits are apparently much less common, but that did take care of the dinosaurs. One implementation issue I don't know if you've all addressed. In the game the years per turn is always different from one age to the next. But natural disaster occurances shoudn't speed up like technological advancement does. So the odds of a disaster occurring if there's 1 turn per 10 years should be ten times as great as if there's 1 turn per 1 year. |
wheathin Prince Charming Apr 99
|
 |
posted January 11, 2001 17:18
 |
 |
 |  |
Good point about the time frame. But the difference in turn length (from one to 20?) means that a disaster that might occur three or four times before 1500 (5500 years) might never occur in the rest of the game (800 years). Note that minor disasters have been *very* regular, if only because of El Nino. Two years ago there was a book about all the El Ninos, and their effects on history, including some of the worst famines and floods in history, as well as other "unexplained" events, such as the destruction of the first colony in Virginia at Roanoke (a spectacularly severe winter they were unprepared for).
|
Harlan ctpmaps.apolyton/harlan Berkeley, CA, USA b.02-15-99
|
 |
posted January 11, 2001 23:51
 |
 |
 |  |
You're right Wheathin, but that's okay. Once turns start coming 1 year per turn, things get pretty hot and heavy in other areas so I doubt people would mind not getting whacked by disasters as often. Anyways, if you do have an average of 1 major disaster per 1000 years, the odds are good it will happen in the last 800 years of play, and it would be a real doozie if it hit a fully populated and developed planet.I think El Nino is too minor of an effect to include in the game though. Cities get 3 year starvation protection as default, and El Ninos rarely last that long. But a prolonged drought would be really interesting to play through. I wonder if SLIC can handle it well though, since Wouter says its weak in the food dept. |
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 12, 2001 19:06
  |
 |
 |  |
Thanks again Locutus, but I am still having prollems*heardie sighs and bangs head against table again!* I did wait you said and go tthis error In object EveryTurn, function _GetCityByIndex: Value out of bounds What does it mean? |
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 13, 2001 04:07
  |
 |
 |  |
Okay figureed that out, just remove the '=' from the for loops. Now i problem that i cant work out because it is not flagged as an error. When the drought building is built isdrought is set to three. then each turn it is decremented by 1 and then when it gets to zero the drought building is removed yet this doesnt work!Have a look at the code. Can you tell me why not? |
Locutus Prince Apolyton Borg Hengelo/Enschede, The Netherlands Nov 1999
|
 |
posted January 13, 2001 08:04
  |
 |
 |  |
Guess I should have looked at the code more closely earlier, I could have picked out most of the bugs fairly quickly if I wanted to. This is the perfect example of why some people are against using a lot of comments in code, it make you loose the overview of the actual logic. I don't agree with these people, but this *is* a classic. Here's part of the code with the comments removed:code:
isDrought = -1; if (isDrought > 0) { isDrought = isDrought - 1; }
You see? isDrought is always -1! You should make it a global variable instead of local (move the declaration out of the eventhandler and place it at the very top of the file, right above '#include msg.slc') and initialize it to -1 (or 0, doesn't really matter here) in a seperate eventhandler that only gets executed once (FirstTurn will do the trick). Now the code *should* work, or at least I can't spot any other obvious bugs in the drought part of the code (the isWeather part has similar bugs but I guess you can figure those out yourself now). [This message has been edited by Locutus (edited January 13, 2001).] |
heardie GGS Co-Webmaster
Aug 1999
|
 |
posted January 13, 2001 19:20
  |
 |
 |  |
hmmm, I am a fool. It's always the simpilest errors that get you. It's the same with c++, they're a ***** to track down and when you see them, it is so obviouos.Thanks a ton Locutus What would have been really cool was a debug window in the game where you cacn track variable values  [This message has been edited by heardie (edited January 14, 2001).] |
Locutus Prince Apolyton Borg Hengelo/Enschede, The Netherlands Nov 1999
|
 |
posted January 14, 2001 06:33
  |
 |
 |  |
quote:
 Originally posted by heardie on 01-13-2001 07:20 PM hmmm, I am a fool. It's always the simpilest errors that get you. It's the same with c++, they're a ***** to track down and when you see them, it is so obviouos.
 |
Yep, it's always those little things that do it. Fortunately, as you become more experienced, you get a nose for them and tracking them down becomes a lot easier (or at least that's what's happening with me). quote:

Thanks a ton Loctus.
 |
Can't anyone write my name correctly anymore these days?  quote:

What would have been really cool was a debug window in the game where you cacn track variable values 
 |
Tip: always make a few messageboxes pop up on command (pressing a key, ending a turn, moving a unit, whatever) that contain important information about variables and stuff. Almost as good as a debug window  |
Locutus Prince Apolyton Borg Hengelo/Enschede, The Netherlands Nov 1999
|
 |
posted January 14, 2001 08:18
  |
 |
 |  |
Jerk,Sorry, I seem to have overlooked your post for some reason. Thanks for all the hard work, it's much appreciated. But your findings are very strange and contradict my findings. I originally had it so that the Random function was performed everytime a player's turn began. This usually crashed the game after 2 or 3 players had had their turn. Then I made it so that the only time when the Random function was performed, was during the barbarian's turn. This caused the game to crash as soon as the Barbarians had their first turn, every single time. So my conclusion was that the Random function was broken. Now you're telling me it's the CutImprovements event that's broken and the Random function works fine. This sounds like a much better explanation but it doesn't explain my crashes. I will look into this in more detail when I have the chance (who's stupid idea was it to give a day only 24 hours? ) and prey that you're right and I made a mistake or whatever... |
Jerk Chieftain Green Bay, WI USA Nov 2000
|
 |
posted January 14, 2001 12:41
|
 |
 |  |
Locutus,It worked last time I tested it. It no longer works. I guess it wasn't the cuttileimprovements that is causing the damage. However, removing the random parts for picking the random x and y position and the richter and damage variables still produces a crash for me when the barbarians take their first turn (after my very first turn). I can also comment out everything under the "if (CityIsValid(tmpCity)) {" and it does not crash. This is why I don't think it's Random() causing the problem.
|
skorpion59 CTP Maps Webmaster Tulsa, Oklahoma, USA, (GMT -6) May 99
|
 |
posted January 14, 2001 13:27
  |
 |
 |  |
Locutus,I played with this a little and from what I can tell, the Random IS broken. CtP2 just abends when using it.
|
Jerk Chieftain Green Bay, WI USA Nov 2000
|
 |
posted January 14, 2001 23:08
|
 |
 |  |
Well, after testing I still maintain that it's still an issue with the Effect:cuttileimprovements(disasterloc) portion of the script. I believe that the effect has a problem working in spots where nobody is at or is yet to be uncovered. I have gone through and tested this several times. If I remove the effect and replace it with Terraform(disasterloc,17) I get no crash and it replaces the random tiles with a dead tile. If I go ahead and start a game, jot down the x and y for a tile near my city, replace the randoms with those set x and y coordinates it works with cuttileimprovement. If I rig the random number so x and y will fall around my city (Random(3) + mycityY,Random(3) + mycityY) it also works without a crash. I think that is the problem. The game doesn't work when you randomly pick a spot on the map early in the game when the overwhelming odds are that the spot will be an undiscovered portion of land. Try doing what I did to test this. Replace the cuttileimprovement with terraform(disasterloc,17). Then put that back, and try rigging the random choice to fall in your original city radius. I can reproduce the error by adding this little chunk of script into script.slc:
code:
HandleEvent(BeginTurn) 'IWillCrash' post { location_t tmpLoc; location_t disasterLoc; if(g.year > 3) { MakeLocation(disasterLoc, 1, 1); Event:CutImprovements(disasterLoc); } }
| |