 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:15
|
|
Cube,
If it's just forests and jungles you're worried about, that's no problem. I've got a couple of handlers that'll cut down the trees. It's getting late here now, but I'll pull them out of my scenario.slc and post them tomorrow.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:15
|
|
The promised code is attached. It's been so long since I actually played the game (as opposed to trying to reprogramme it) that I almost forgot I had them. I hope that I've put everything in that you need and that it's working properly.
But I think a few words of explanation might be called for. There's two handlers: NewCityTileImprovement, which triggers whenever a city is created, and ExpandingCityTileImprovement, which triggers whenever a city's population reaches six, the default min population for citysize1.
NewCityTileImprovement basically just terraforms any forest or jungle tiles (that don't have trade goods on them) in a new city's radius into plains. It actually does a bit more because I had to overcome an AI design fault. Any human player who is about to build a city and discovers there's a Goody Hut next door will automatically look in the Goody Hut. The AI doesn't do this: because the GOAL_SETTLE priorities have to be so much higher than all the other goals, settlers will ignore Goody Huts. So the situation can arise where the AI builds a city adjacent to a Goody Hut and then later discovers that the Goody Hut is one of those city generating ones. But you can't build a city inside another city's radius, so this situation has to be excluded, otherwise the handler causes the game to crash. While doing this I thought I'd exclude another irksome AI feature where the city generating Goody Hut is not actually in another city's radius but close to it so that the AI ends up with two cities that are *very* close together. The bit of code
code:
if (Distance(location[0], THE_NEAREST_CITY.location)<7
&& !IsHumanPlayer(player[0])) {//but it's in a lousy location, so
event: DisbandCity(tmpCity);
}
will disband any AI city that comes from a Goody Hut and is within a radius of 7 of an existing city. You might want to adjust the "7"; I play on big maps and like my AI cities far apart.
There's also a couple of lines further down:
code:
if (TerrainType(theLoc)==18) { //brown (desert) hills
Terraform(theLoc, 9);//change to hills
}
Sometimes the AI builds cities next to those 'Sand Dune'-like hills. I think this is a waste of time so this just changes them to ordinary hills. Actually, I guess you could add code like this, here and in the corresponding slots in the ExpandingCityTileImprovement handler, to terraform anything you want. Here's the numbers you need:
CTP2 Terrain Indices:
0 TERRAIN_FOREST
1 TERRAIN_PLAINS
2 TERRAIN_TUNDRA
3 TERRAIN_GLACIER
4 TERRAIN_GRASSLAND
5 TERRAIN_DESERT
6 TERRAIN_SWAMP
7 TERRAIN_JUNGLE
8 TERRAIN_MOUNTAIN
9 TERRAIN_HILL
10 TERRAIN_WATER_SHALLOW
11 TERRAIN_WATER_DEEP
12 TERRAIN_WATER_VOLCANO
13 TERRAIN_WATER_BEACH
14 TERRAIN_WATER_SHELF
15 TERRAIN_WATER_TRENCH
16 TERRAIN_WATER_RIFT
17 TERRAIN_DEAD
18 TERRAIN_BROWN_HILL
19 TERRAIN_TYPE_BROWN_MOUNTAIN
20 TERRAIN_WHITE_HILL
21 TERRAIN_WHITE_MOUNTAIN
22 TERRAIN_WATER_KELP
23 TERRAIN_WATER_REEF
24 TERRAIN_SPECIAL1
25 TERRAIN_SPECIAL1
ExpandingCityTileImprovement is a bit different. The SLIC terraform function works instantaneously and doesn't have any prerequisites. The event CreateImprovement, on the other hand, requires both that the cell owner has any Advances that are needed for the type of improvement you want to carry out and also that he has enough PW stored up to pay for them. It also doesn't work instantaneously but more realistically takes a few turns just like when you do it manually.
So you'll need to adjust the RemoveAdvance lines for forest and jungle in terrain.txt from agricultural revolution to something really basic like agriculture. Also, to make sure that the AI has enough PW to pay for these improvements you might have to lower their cost. If there's a problem here, tell me about it because another possibility is to use SLIC to give the AI whatever PW it needs. (In the mod I was working on, the AI is a bit different and always has lots of reserve PW; so I never had to worry about this.)
What happens here is that when the city grows to 6, you get a message saying
quote:
"Sire, The city of {city[0].name} is bursting at the seams. We have
sent squads of workers to scour the surrounding countryside and collect building
materials for it's expansion."
|
and most, but not all, of the forests/jungles in the cells that the city is about to expand out into will start to be transformed into plains.
While we're on the topic of terraforming, the reason, IMHO, why you need to terraform so much is because the map generator is so lousy. Here's the settings from Const.txt that I use for my map generator:
quote:
# all numbers are integers ranging from 0 to 100
PERCENT_LAND 40 # how much of the world is land
PERCENT_CONTINENT 50 # how much of the world tends toward big continents verses small islands
PERCENT_HOMOGENOUS 5 ## how "clumpy" the land terrain is
# the meridians are normalized on the map at 0 to 100 - 0 is all the way north
# and 100 is all the way south - 50 is the middle - this works on a map of
# any size
MERIDIANA 1 # north of this is north pole
MERIDIANB 44 # north of this is north mild
MERIDIANC 48 # north of this is north desert
MERIDIAND 52 # north of this is the equatorial region
MERIDIANE 56 # north of this is south desert
MERIDIANF 99 # north of this is the south mild, south is the south pole
# the humidity controls the distribution of forest, jungle, swamp, grass, plains, desert
# tundra and glacier
# A bump map is randomly generated. The bumps range from 0 to 100. High bumps are
# wet terrain, low vallies are dry terrain.
# What terrain is used depends on what meridian you are in
# The height values have a gaussian distribution, with middle values being the most
# common. The HLEVEL values should be adjusted to take into account the integral
# of the gaussian.
# HLEVELA must be greater than HLEVELB, HLEVELB must be greater than HLEVELC etc
HLEVELA 99 # above this is the wet terrain
HLEVELB 95 # above this is sort of wet terrain
# here's the middle
HLEVELC 5 # below this is sort of dry terrain
HLEVELD 1 # below this is dry terrain
# The wet/dry slider on the custommap screen uses these values.
# The sum of all the wet values together with the swamp wet value will add to 100.
# Similarly for the dry values. Actually, swamp = 100 - (forest + grass + plains + desert).
FORESTWET 20
GRASSWET 70
PLAINSWET 10
DESERTWET 0
# This leaves 0 for swamp.
FORESTDRY 20
GRASSDRY 70
PLAINSDRY 10
DESERTDRY 0
# This leaves 0 for swamp.
# The warm/cold slider on the custommap screen uses these values.
WHITEWARM 1#5
BROWNWARM 5#30
TEMPERATURERANGEADJUSTWARM 1#75
WHITECOLD 1#30
BROWNCOLD 5
TEMPERATURERANGEADJUSTCOLD 1#120
# The goodcount slider on the custommap screen uses these values.
RICHNESSFEWGOODS 25
RIVERCELLWIDTHFEWGOODS 25
RIVERCELLHEIGHTFEWGOODS 25
RICHNESSMANYGOODS 75
RIVERCELLWIDTHMANYGOODS 5
RIVERCELLHEIGHTMANYGOODS 5
PERCENT_MOUNTAIN 5 # percentage of land with mountains on it - this is a target only
MOUNTAIN_CELL 10#5 # length of a side of a cell - one cell contains at most 1 mountain chain.
PERCENT_HILLS 15 # percent of land with hills on it
MOUNTAIN_SPREAD 25 # chance that the mountain chain spreads out
MOUNTAIN_LENGTH 3 #25 # average length of a mountain chain
GLACIER_EXTENT 1#3 # number of tiles the glacier extends - should be normalized
PERCENT_VOLCANO 1 # percent of deep sea floor with volcanos
PERCENT_TRENCH 4 # percent chance that a trench is seeded - then it spreads automatically
# Swamps are placed at humidity levels above what forest works out to.
PERCENT_FOREST 20
PERCENT_GRASS 40
PERCENT_PLAINS 25
PERCENT_DESERT 1#10
PERCENT_WHITE 2#20
PERCENT_BROWN 2#20
TEMPERATURE_RANGE_ADJUST 10#60
# Adjust the temperature height map by negative this amount at the
# poles, positive at the equator, linear scale in between
NICE_RADIUS 10 # radius of effect when calculating niceness of player placement
# the mininum start distance between players is 2 * NICE_RADIUS
PERCENT_RIVER 5 # percent of land with a river on it
RIVER_LENGTH 15 # average river length
RIVER_CELL_WIDTH 5 # Size of cells to be searched for river starts
RIVER_CELL_HEIGHT 5 # (highest point in each cell)
|
These give (dare I say it in the context of the current civ3 vs CTP2 controversy) more civ2 like maps. They're by no means perfect: I can't get rid of the big clumps of hills and mountains. As I recall Scorpion59 had an excellent map generator but he'd never tell us the secret of it. Whenever the topic came up he'd just say something like 'It's an ongoing process. It just takes patience and fiddling around with the settings a bit.' Maybe if anyone reading this can get really good results, they could post them or start a discussion or something.
Finally, it looks like we can safely conclude that the terraforming/tileimprovement apparatus as given in Strategies.txt is broken. When you first posted I thought 'Good luck to him. Maybe he'll find something I overlooked.' But now Wombat says he never could get it to work, and that makes three of us. It's clear that it's only half exposed: there's no mention of nets in ImprovementLists.txt yet the AI builds them quite happily. It looks like using SLIC is the only way you can get the terraforming/tileimprovements you want.
Attachment: treecutters.slc
This has been downloaded 12 time(s).
|
|
|  |
 |
|
Cube
|
 |
El Paso, Tx
Nov 2000 time: 22:15
|
|
Hi Peter,
I'm using medmod 2 and city sizes change at size 8. I was wondering if there's a way to make it so that this triggers when a city reaches a low growth rate, or if not size 3. I would also like it to look within it's radius and terraform( in the real way using create improvement) forest jungles and other terrain to grassland or plains(whichever the AI has enough PW to build).
I would also like the AI to build hills or mountains in its low production cities or remove them in order to reduce pollution. I was also wondering if it's possible to make the AI build commerce Improvements when it's science gets low, because as it stands it only builds them on swamps tundras and other bad terrains.
this is how I edited the file, to try to make it terraform at size 3 and in the current raduis.
HandleEvent(MakePop)'ExpandingCityTileImprovement'
post {
location_t theLoc;
location_t firstLoc;
// this triggers when the city's population grows to
// 3
int_t i;
int_t j;
if (city[0].population==3) {
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)==0 || TerrainType(theLoc)==7 ) {
// 0=forest, 7=jungle
Event:CreateImprovement(city[0].owner,theLoc, 32,0);
//change to plains
}
}
}
}
will it work?
Last edited by Cube on 23-08-2001 at 05:01
|
|
|  |
 |
|
Cube
|
 |
El Paso, Tx
Nov 2000 time: 22:15
|
|
I don't like the other handler because it uses terraform instead of createimprovement, so I'll just change that. Will the make pop trigger(the second one) stop when the City gets bigger than 6( or in my case 8)? Would I have to make more trigger for size 20( when it reaches maxsize again for the second radius in medmod), size 36(max for 3rd radius), size 44(max for 4th radius), and size 56( max for 5th raduis)?
I added the code to my mm2_scenario.slc and it says that there's a syntax error in the code on line 189, which is somewhere in the beginning of the code.
Last edited by Cube on 23-08-2001 at 08:40
|
|
|  |
 |
|
Cube
|
 |
El Paso, Tx
Nov 2000 time: 22:15
|
|
I guess that makes sense, I think I'll leave it like that, but change it to grassland. Is there a way to make it so that it does it if a city is larger than or equal to 8, by using >= instead of ==. How would I make it so that it does this at citysizes 3, 4, etc... how would it look at the tiles?
I was wondering does this work for the human player or just the AI? I think the create one should work for the human and the AI, but the second one should only work for the AI, seeing as how the human knows how to terraform.
Last edited by Cube on 24-08-2001 at 04:37
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:15
|
|
Hmm, I never thought of that. If you were to use 3<=city[0].population then, I think that what should happen is that every time the city's population increases beyond 2 it'll do a search of the tiles (within the citysize1 radius) and try to do the terraforming. If it's got enough PW, it'll do it and after that nothing happens. If it doesn't have enough PW, it'll do whatever it can and then try again when the city's pop increases again. Sounds like a good idea. See if it works.
Edit: This is assuming you're not using the NewCity handler. Otherwise, make it 8<=city[0].population. This would be my choice because it should ensure that the AI gets off to a better start.
Last edited by Peter Triggs on 24-08-2001 at 05:25
|
|
|  |
 |
|
Immortal Wombat
|
 |
in perpetuity
Dec 2000 time: 05:15
|
|
Yep, that should work, if you want it to...
I should point out, as it was pointed out to me, that tmpPW, and tmpPW2 are not both needed, it could just as easily read:
code:
// declaration here
int_t tmpPw;
if (TerrainType(theLoc)==0 || TerrainType(theLoc)==7 ) {
// 0=forest, 7=jungle
tmpPw = player[0].publicworkslevel;
tmpPw = tmpPw + 400;
setPW(city[0].owner, tmpPw);
Event:CreateImprovement(city[0].owner,theLoc, 32,0);
//change to plains
}
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:15
|
|
Delete the line " tertype= TerrainType(theLoc);"; it was a temporary variable I was using to tell me what the terrain type of the location was. Sorry, I should have checked this more thoroughly.
How about if you attach the SLIC file you've got this in? It should make it easier to see what's happening.
|
|
|  |
 |
|
Peter Triggs
|
|
Gone Fishin, Canada
Jan 2000 time: 05:15
|
|
OK, try this file. When you changed the CreateImprovement event from plains to grassland you left out the closing curly brackets "}" in a couple of places. I stuck this file into a scenario and didn't get any syntax errors. Moreover, it seems to work. I didn't test it thoroughly but give it a try and see what happens.
Attachment: mm2_scenario.slc
This has been downloaded 12 time(s).
|
|
|  |
All times are GMT. The time now is 05:15. Apolyton Time is 00:15. |
top of page
|
| archivepost |
|
Forum Rules:
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
|
HTML code is ON
vB code is ON
Smilies are ON
[IMG] code is ON
|
|
|
|
|
|