View Full Version : Editing GLOBAL_WARMING_TERRAIN to TERRAIN_COAST?
Munch May 31, 2007, 11:48 AM When global warming strikes, terrain is turned to desert, because of the tag:
<Define>
<DefineName>GLOBAL_WARMING_TERRAIN</DefineName>
<DefineTextVal>TERRAIN_DESERT</DefineTextVal>
</Define>
Has anyone experimented with the effect of changing this to TERRAIN_COAST (and is that even the correct name)? In theory instead of tiles becoming desert they would become coast tiles, but I can see that this might be a problem for city tiles becoming coast, and the game not knowing how to respond. So, are city tiles considered when the RNG picks tiles to transform?
Vrenir May 31, 2007, 01:42 PM I don't know the answer, but Global Warming seems to be something to hold off modding for the next month in the hope that there might be some new feature (in the events category) of BtS that could be perfect.
Sto May 31, 2007, 03:50 PM Global warming does not affect cities but does not change the tile type . Howewer , when you set a water terrain type to a land plot , it should change the plot type to water . to see what can happend , you need to test that i think . I 'm not sure to how global warming begin , i think that depend on the number nuke exploded .
Tcho !
Munch May 31, 2007, 07:03 PM Well, I've now changed:
<DefineTextVal>TERRAIN_DESERT</DefineTextVal>
To:
<DefineTextVal>TERRAIN_COAST</DefineTextVal>
... and the result is really interesting. To test I launched 44 ICBMs on a Duel size map using worldbuilder and it works fine, tiles were turning into coast squares every turn, eventually tearing my land mass to pieces! Brilliant! :nuke: :goodjob:
Of course it wasn't a serious game, but I played a few turns more and tried to invade the other Civ, Germany, whose land was also rapidly disappearing. I had to transport my Mechanised Infantry using Galleons!
Vrenir May 31, 2007, 07:10 PM Did the cities delete themselves when their tiles turned to coast? Did the cities stay as little islands surrounded by water? Please do tell.
Idea: Would it be possible to tell the computer to change coastal tiles to sea tiles (and thus adjacent tiles to coast) at random for global warming, effectively causing the ocean to rise each turn and eat away at the coasts?
Munch Jun 01, 2007, 04:36 AM Did the cities delete themselves when their tiles turned to coast? Did the cities stay as little islands surrounded by water? Please do tell.
It seems that city squares themselves are not considered by the RNG for global warming modification, none of my cities were deleted, and no units on city tiles drowned. Yes, if you play the game for long enough then you will end up only with little islands where your cities are! I did this last night but forgot to take any screenshots.
I've got some new screenshots though to give examples; game is Duel size Ice Age, Quick speed Future start.
This is the initial land set up, after placing my city I gave myself 44 ICBMs in WorldBuilder:
http://i198.photobucket.com/albums/aa78/Condi_Rice/Civ4ScreenShot0112.jpg
Only 3 turns after launching my nukes, this is the land set up. Thebes has lost its bananas to the tide, and a few other tiles are submerged:
http://i198.photobucket.com/albums/aa78/Condi_Rice/Civ4ScreenShot0114.jpg
About 10 turns later, the wheat is lost and so Memphis has been separated from my capital. Also a nice lake has appeared 1N of the sugar:
http://i198.photobucket.com/albums/aa78/Condi_Rice/Civ4ScreenShot0115.jpg
Just like if you had manually added the coast tiles in WorldBuilder, the graphics look very slightly off - the tiles which have fallen prey to the tide are a darker blue than regular coast - not expected, but I think it makes it more dramatic.
Idea: Would it be possible to tell the computer to change coastal tiles to sea tiles (and thus adjacent tiles to coast) at random for global warming, effectively causing the ocean to rise each turn and eat away at the coasts?
I don't believe this is possible by only changing XML files. There is only one "TERRAIN_(terrain type here)" variable to change in GlobalDefines.xml to do with global warming. Also the tiles are picked indiscriminately I think, regardless of there proximity to coast, latitude etc, as long as they aren't city tiles (either that or I just happened not to see any cities get washed away).
It's all very apocalyptic. Unless your cities have sea resources - which aren't affected by global warming - they will only just be able to sustain themselves working the masses of coast tiles. Also unless you've built your cities on top of a crucial military resource, you eventually will lose all the resources, and will be sending around your Mechanised Infantry and Marines on Galleons.
Another interesting thing which I hadn't forseen, was the game adapting to circumstances. The only victory condition I had on was Domination, and as land outside of my borders disappeared, my percentage of land control increased! So, if the right tiles disappear, it is possible to get a domination victory this way.
Vrenir Jun 01, 2007, 10:23 AM Fascinating. Even as it is, I really do think that this is better than turning them to desert. I mean, now there are definite reasons not to end the world with global warming, or if you are a crazy dominion-set gambler, reasons to bring about a nuclear holocaust. Great idea.
Munch Jun 01, 2007, 02:11 PM Fascinating. Even as it is, I really do think that this is better than turning them to desert.
I agree, it's not perfect but I'm definitely going to keep this instead of desert! :goodjob:
I'm pleased at how well it worked out. The land was disappearing quite rapidly, perhaps because 44 ICBMs is a lot! Still, I think I might reduce the speed that global warming devours tiles before trying this out in a proper game.
Sto Jun 01, 2007, 02:50 PM THe only way to reduce global warming is to reduce warming_prob . The function take a random number for any nuke exploded and then if it's less than warming_prob , affect a tile . ie : if 50 nukes have exploded the function test 50 times a random number between 0 and 99 and each time it's less then warming_prob there is the effect .
Tcho !
Gaius Octavius Jun 03, 2007, 07:25 PM Very interesting. I could envision a situation where you change this to Ice, and instead you'd get nuclear winter. :D
Munch Jun 04, 2007, 05:51 AM Very interesting. I could envision a situation where you change this to Ice, and instead you'd get nuclear winter. :D
That's also easily done. Do you mean snow tiles (which you can walk across) or ice (which is impassable)?
Either would be interesting, but the latter will destroy all troops on a tile chosen for global warming, by encasing them in ice. Kinda similar to the coast effect, which claimed the life of one of my scouts. Could severely alter the balance of power during a war if someone's stack gets annihilated by nature.
mark777 Jun 04, 2007, 10:31 PM thankyou very interesting
thadian Jun 14, 2007, 09:33 PM Does GW affect ONLY the player?
thadian Jun 14, 2007, 09:34 PM That's also easily done. Do you mean snow tiles (which you can walk across) or ice (which is impassable)?
Either would be interesting, but the latter will destroy all troops on a tile chosen for global warming, by encasing them in ice. Kinda similar to the coast effect, which claimed the life of one of my scouts. Could severely alter the balance of power during a war if someone's stack gets annihilated by nature.
or if your a coastal-dependant civ and your main cities go under!!
(Alexandros) Nov 15, 2007, 05:17 AM Interesting variation! Munch, do you think it could be possible to use both desert and coast as side-effects? I think this would be the most realistic option, since both cases seem to happen in the real world: Desertification and submersion
Munch Nov 15, 2007, 05:48 AM or if your a coastal-dependant civ and your main cities go under!!
Cities are never affected by global warming, and so can not be changed to desert, or coast, or ice etc.
Interesting variation! Munch, do you think it could be possible to use both desert and coast as side-effects? I think this would be the most realistic option, since both cases seem to happen in the real world: Desertification and submersion
:)
At the minute, through simple xml file editing, no. But, for someone with python expertise I see no reason why the function which chooses a tile to change should not include a random number element; this would specify that if the number selected is above a certain threshold the tile turns to one thing (e.g. GLOBAL_WARMING_TERRAIN_1), otherwise to the other (GLOBAL_WARMING_TERRAIN_2). It's beyond me though, at the minute!
Thorn Nov 16, 2007, 12:04 PM Just stumbled across this. That looks great! I've always hated the 'turn tile to desert' thing. This reminds me of Alpha Centauri when I would cause so much global warming that all I had left at the end of the game was small island-cities. Of course, if the city wasn't dome protected it disappeared. :D
jpinard Nov 16, 2007, 01:03 PM I could see this not working well if you have a map with large contiguous continents. Or does it still work well?
stljeffbb Nov 17, 2007, 05:04 PM It seems that ice is not a terrian but a feature as I tried to modify to TERRAIN_ICE and got an error message...I think I'm going to try tundra as perhaps this is a good representation (without the extra commerce gold) of global warming....not complete oblieration, but greatly reduced.....
Munch Nov 18, 2007, 05:59 AM I could see this not working well if you have a map with large contiguous continents. Or does it still work well?
Well, tiles are turned to coast at random, regardless of whether they are near natural coast, rivers, or just in the middle of a fat continent. So it might not be the effect you want, but it is interesting. You'd get holes appearing in your continent which, given long enough, would form lakes and tear the continent to pieces.
It seems that ice is not a terrian but a feature as I tried to modify to TERRAIN_ICE and got an error message...I think I'm going to try tundra as perhaps this is a good representation (without the extra commerce gold) of global warming....not complete oblieration, but greatly reduced.....
Have a look in the file CIV4TerrainInfos.xml and you will see that there is no TERRAIN_ICE (you are right, it is a feature and not a terrain type), but there is TERRAIN_SNOW, which is the kind of snow tile you can walk on. So at least this is possible.. after all, encasing the whole world in ice would just be daft, cos you wouldn't be able to get anywhere.
But yes, turning the tiles to tundra does sound interesting, I'll try it in my next game - let me know how it works out! :) Does it remove tile improvements too? Can you only improve tiles turned to tundra if they are by a river?
stljeffbb Nov 19, 2007, 10:31 AM Hi Munch.....I haven't reached the nuke age yet in my current game...I'm using Carter's Earth mod with "Planetary" size (one larger than huge) and the possibility of 32 nations...my rig is fairly fast, but it still takes about 30-40 seconds per turn especially in the later stages...
I'm thinking we need a "global warming mod" ....I'm wondering if we can use the random events engine to have the old "ice melting, water rises" from an older version of Civ. I could easily see it being triggered by the invention of industrialism....I don't yet know how the events engine works, but I'm going to check it out...perhaps the hard part will be telling the computer which tiles to coastal-ize.
Jeff
EDIT: I believe you are correct about tundra tiles....can only be improved if by a river or hold a resource...I'm not sure about cottages (I've never tried it)
GeoModder Nov 24, 2007, 03:16 PM EDIT: I believe you are correct about tundra tiles....can only be improved if by a river or hold a resource...I'm not sure about cottages (I've never tried it)
Cottages can't be constructed on tundra tiles not adjacent to a river, so I reckon those would be destroyed too if a tile with a cottage changes to tundra.
Actually this makes the National Park wonder quite valuable, as it is the only game mechanism that can give some use to tundra tiles again after a climate change.
digitCruncher Nov 26, 2007, 06:33 PM This was my first XML change EVER!! And it balanced a whole lot of things IMO...
I got the tundra working, and it makes river-side tiles much more important in a post-apopolytic wasteland. The +1 :food: and +1 :commerce: doesn't kill a city in its tracks, however it still is an annoyance. With biology, by killing your towns, you can now survive mass global warming in every city with no losses, except your GP farm.
Ice IMO is as bad as desert, as you cannot EVER improve on desert, or ice. You can, however, improve on river-side tundra tiles, which is useful.
Now to fix my other two pet peeves by XML :D
oldsaxon Dec 04, 2007, 08:15 AM Just as a neat twist (for a game or two), you could set up a very cold map, and have global warming turn the squares to grassland.
Still, I reckon Coast is the best option so far proposed.
stljeffbb Dec 16, 2007, 10:40 AM OK, I've been modding a fair amount with events over the past few weeks, successfully adding plagues for individual civs but not quite yet able to figure things out on a global scale (one would think bGlobal would do it, but I have not been able to figure it out yet as I have not been able to get bGlobal to work for me).....
I'm wondering does anyone know where the global warming mechanics are...they do NOT appear to be in events...I was thinking of adding an asteroid event, but there is no way to do this just usind the XML :(
I must admit that I find modding this game to be much more of an obtuse affair compared to my modding with games like Medieval Total War II, the Hearts of Iron series, and even going back to Birth of the Federation....yes I'm whining, but I shouldn't have to learn entirely new program languages (Python) to be able to mod right away how I want, whereas the other mentioned games pretty much allow a person to mod almost anything right away (at least as far as game mechanics are concerned).
Jeff
Seven05 Dec 16, 2007, 03:41 PM Global warming is handled by the DLL in CvGame.cpp, there is a method 'doGlobalWarming()' that is not exposed to python. The default implimentation is to loop 'x' times, pick a random land plot that isn't a city and use the global warming probability as a percentage chance to destroy any feature and/or improvement on the plot and change the terrain to the global warming terrain defined in your globals xml file. The doGlobalWarming() method isn't exposed to python but it wouldn't be to hard to add a check for a python override in there.
I've modified global warming myself since the original method is a cheap hack. The 'x' number of times it loops to try and change the terrain is simply the number of nuclear explosions that have occurred in the current game including both nuclear weapons and reactor meltdowns.
As obtuse of an affair as it is, you can do far more with Civ 4 modding than other games allow. The small price to pay is that you need to learn one or two programming languages, both of which are in widespread use so any knowledge gained will be useable elsewhere. Yes, I'm lecturing, but I prefer the flexibility of Civ 4 over the over-simplified and restricted tools included to mod other games. ;)
Munch Dec 16, 2007, 04:10 PM Global warming is handled by the DLL in CvGame.cpp, there is a method 'doGlobalWarming()' that is not exposed to python.
Where is this file found? Is it in \Sid Meier's Civilization 4\Beyond the Sword\CvGameCoreDLL (or is that a folder I made up when messing with the files) ...?
Also, am I right in thinking you don't have to compile these .cpp files, and that just editing and saving is enough?
stljeffbb Dec 16, 2007, 06:52 PM Global warming is handled by the DLL in CvGame.cpp, there is a method 'doGlobalWarming()' that is not exposed to python. The default implimentation is to loop 'x' times, pick a random land plot that isn't a city and use the global warming probability as a percentage chance to destroy any feature and/or improvement on the plot and change the terrain to the global warming terrain defined in your globals xml file. The doGlobalWarming() method isn't exposed to python but it wouldn't be to hard to add a check for a python override in there.
I've modified global warming myself since the original method is a cheap hack. The 'x' number of times it loops to try and change the terrain is simply the number of nuclear explosions that have occurred in the current game including both nuclear weapons and reactor meltdowns.
As obtuse of an affair as it is, you can do far more with Civ 4 modding than other games allow. The small price to pay is that you need to learn one or two programming languages, both of which are in widespread use so any knowledge gained will be useable elsewhere. Yes, I'm lecturing, but I prefer the flexibility of Civ 4 over the over-simplified and restricted tools included to mod other games. ;)
Well put, although sometimes simple is better ;)
Thanks for the global warming info as well! :)
PS...hmmmm, I looked through my "CVgame" files (represented as text files in my CvGameCoreDLL folder) and had no luck finding "doGlobalWarming()".....but it may be only some of the files from the master DLL file....I probably need a decompiler or something to that effect.....
Seven05 Dec 16, 2007, 11:47 PM Yes, unfortunately you will need to compile the DLL to see your changes in the game. It is burried in CvGame.cpp, here's the entire doGlobalWarming() method:
void CvGame::doGlobalWarming()
{
CvCity* pCity;
CvPlot* pPlot;
CvWString szBuffer;
TerrainTypes eWarmingTerrain;
bool bChanged;
int iI;
eWarmingTerrain = ((TerrainTypes)(GC.getDefineINT("GLOBAL_WARMING_TERRAIN")));
for (iI = 0; iI < getNukesExploded(); iI++)
{
if (getSorenRandNum(100, "Global Warming") < GC.getDefineINT("GLOBAL_WARMING_PROB"))
{
pPlot = GC.getMapINLINE().syncRandPlot(RANDPLOT_LAND | RANDPLOT_NOT_CITY);
if (pPlot != NULL)
{
bChanged = false;
if (pPlot->getTerrainType() != eWarmingTerrain)
{
if (pPlot->calculateTotalBestNatureYield(NO_TEAM) > 1)
{
pPlot->setTerrainType(eWarmingTerrain);
bChanged = true;
}
}
if (pPlot->getFeatureType() != NO_FEATURE)
{
if (pPlot->getFeatureType() != GC.getDefineINT("NUKE_FEATURE"))
{
pPlot->setFeatureType(NO_FEATURE);
bChanged = true;
}
}
if (bChanged)
{
pPlot->setImprovementType(NO_IMPROVEMENT);
pCity = GC.getMapINLINE().findCity(pPlot->getX_INLINE(), pPlot->getY_INLINE());
if (pCity != NULL)
{
if (pPlot->isVisible(pCity->getTeam(), false))
{
szBuffer = gDLL->getText("TXT_KEY_MISC_GLOBAL_WARMING_NEAR_CITY", pCity->getNameKey());
gDLL->getInterfaceIFace()->addMessage(pCity->getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_GLOBALWARMING", MESSAGE_TYPE_INFO, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pPlot->getX_INLINE(), pPlot->getY_INLINE(), true, true);
}
}
}
}
}
}
}
Now, if all you want to do is add an event that increases the chances of global warming all you need to do is increase the recorded number of nuclear explosions. You have two functions for this, both are exposed to python. They are also in CvGame.cpp if you want to see them but all they do is get & set a member variable on the game object. The two methods are:
int getNukesExploded() const;
This simply returns the current count of nuclear explosions. For global warming this is how many tiles can potentially be affected each turn.
void changeNukesExploded(int iChange);
This is normally called when a nuke explodes with the arg (iChange) as 1, like; changeNukesExploded(1); It's not an unsigned int so negative numbers should work if you ever want to decrease the global warming effect just be sure to use getNukesExploded() to make sure you don't change the counter below zero as they might not have error handling for that in there I haven't look that closely.
In python these can both be called using the game object, this is from memory so double check it before you try it but it should be as simple as something like:
game = GC.getGame()
game.changeNukesExploded(10)
Or to reduce the count by three for example:
change = 0 - min(game.getNukesExploded(),3)
game.changeNukesExploded(change)
I don't remember if you get the game object with getGame() or something else. FYI, min() returns the lowest of the two args so it's a good way of establishing a max value and max() returns the highest so it works to establish a minimum value. Yes, they're backwards but thats how us programming types think :)
|
|