I actually never liked the way global warming is presented in civilization, so I planned to add this to my mod. But my question is how hard would it be to add a new terrain to this terrain warming cycle?
Are we talking about base terrain like grasslands and plains, or features like forests and jungles?
SetGlobalDefine("MARSH_TERRAIN", szVal);
idx = FindInInfoClass(szVal);
GC.getDefinesVarSystem()->SetValue("MARSH_TERRAIN", idx);
else if (pPlot->getTerrainType() == eMarshTerrain)
{
pPlot->setTerrainType(eTemperateTerrain);
bChanged = true;
}
TerrainTypes eWarmingTerrain = ((TerrainTypes)(GC.getDefineINT("GLOBAL_WARMING_TERRAIN")));
TerrainTypes eFrozenTerrain = ((TerrainTypes)(GC.getDefineINT("FROZEN_TERRAIN")));
TerrainTypes eColdTerrain = ((TerrainTypes)(GC.getDefineINT("COLD_TERRAIN")));
[COLOR="Red"]TerrainTypes eMarshTerrain = ((TerrainTypes)(GC.getDefineINT("MARSH_TERRAIN")));[/COLOR]
TerrainTypes eTemperateTerrain = ((TerrainTypes)(GC.getDefineINT("TEMPERATE_TERRAIN")));
TerrainTypes eDryTerrain = ((TerrainTypes)(GC.getDefineINT("DRY_TERRAIN")));
TerrainTypes eBarrenTerrain = ((TerrainTypes)(GC.getDefineINT("BARREN_TERRAIN")));
TerrainTypes eShallowsTerrain = ((TerrainTypes)(GC.getDefineINT("SHALLOW_WATER_TERRAIN")));
FeatureTypes eColdFeature = ((FeatureTypes)(GC.getDefineINT("COLD_FEATURE")));
FeatureTypes eTemperateFeature = ((FeatureTypes)(GC.getDefineINT("TEMPERATE_FEATURE")));
FeatureTypes eWarmFeature = ((FeatureTypes)(GC.getDefineINT("WARM_FEATURE")));
FeatureTypes eFalloutFeature = ((FeatureTypes)(GC.getDefineINT("NUKE_FEATURE")));
void CvGame::doGlobalWarming()
{//GWMod Start M.A.
int iGlobalWarmingDefense = 0;
int iTreeHuggerDefenseBonus = GC.getDefineINT("TREEHUGGER_DEFENSE_BONUS");
bool abTreeHugger[MAX_PLAYERS];
for (int iI = 0; iI < MAX_PLAYERS; iI++)//GWMod Loop to look for environmentalism witten by EmperorFool
{
abTreeHugger[iI] = false;
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
for (int iJ = 0; iJ < GC.getNumCivicOptionInfos(); iJ++)
{
CivicTypes eCivic = GET_PLAYER((PlayerTypes)iI).getCivics((CivicOptionTypes)iJ);
if (GC.getCivicInfo(eCivic).getExtraHealth() != 0)
{
abTreeHugger[iI] = true;
break;
}
}
}
}
for (int i = 0; i < GC.getMapINLINE().numPlotsINLINE(); ++i)
{
CvPlot* pPlot = GC.getMapINLINE().plotByIndexINLINE(i);
if (pPlot->getFeatureType() != NO_FEATURE)
{
int iFeatureWarmingDefense = GC.getFeatureInfo(pPlot->getFeatureType()).getWarmingDefense();
if (iFeatureWarmingDefense > 0)
{
PlayerTypes eCulturalOwner = pPlot->getOwner();
if (eCulturalOwner != NO_PLAYER)
{
if (abTreeHugger[eCulturalOwner])
{
iGlobalWarmingDefense += (iFeatureWarmingDefense) * (iTreeHuggerDefenseBonus);
}
else
{
iGlobalWarmingDefense += iFeatureWarmingDefense;
}
}
else
{
iGlobalWarmingDefense += iFeatureWarmingDefense;
}
}
}
}
iGlobalWarmingDefense = iGlobalWarmingDefense * GC.getDefineINT("GLOBAL_WARMING_FOREST") / std::max(1, GC.getMapINLINE().getLandPlots());
int iUnhealthWeight = GC.getDefineINT("GLOBAL_WARMING_UNHEALTH_WEIGHT");
int iBonusWeight = GC.getDefineINT("GLOBAL_WARMING_BONUS_WEIGHT");
int iPowerWeight = GC.getDefineINT("GLOBAL_WARMING_POWER_WEIGHT");
int iGlobalWarmingValue = 0;
for (int iPlayer = 0; iPlayer < MAX_PLAYERS; ++iPlayer)
{
CvPlayer& kPlayer = GET_PLAYER((PlayerTypes) iPlayer);
if (kPlayer.isAlive())
{
int iLoop;
for (CvCity* pCity = kPlayer.firstCity(&iLoop); pCity != NULL; pCity = kPlayer.nextCity(&iLoop))
{
iGlobalWarmingValue -= (pCity->totalBadBuildingHealth() * iUnhealthWeight) + (pCity->getBonusBadHealth() * iBonusWeight) + (pCity->getPowerBadHealth() * iPowerWeight); //GWMod Changed to be total building bad health and to include power and bonuses M.A.
}
}
}
iGlobalWarmingValue /= GC.getMapINLINE().numPlotsINLINE();
TerrainTypes eWarmingTerrain = ((TerrainTypes)(GC.getDefineINT("GLOBAL_WARMING_TERRAIN")));
TerrainTypes eFrozenTerrain = ((TerrainTypes)(GC.getDefineINT("FROZEN_TERRAIN")));
TerrainTypes eColdTerrain = ((TerrainTypes)(GC.getDefineINT("COLD_TERRAIN")));
[COLOR="Red"]TerrainTypes eMarshTerrain = ((TerrainTypes)(GC.getDefineINT("MARSH_TERRAIN")));[/COLOR][COLOR="Green"]//added by NotSoGood[/COLOR]
TerrainTypes eTemperateTerrain = ((TerrainTypes)(GC.getDefineINT("TEMPERATE_TERRAIN")));
TerrainTypes eDryTerrain = ((TerrainTypes)(GC.getDefineINT("DRY_TERRAIN")));
TerrainTypes eBarrenTerrain = ((TerrainTypes)(GC.getDefineINT("BARREN_TERRAIN")));
TerrainTypes eShallowsTerrain = ((TerrainTypes)(GC.getDefineINT("SHALLOW_WATER_TERRAIN")));
FeatureTypes eColdFeature = ((FeatureTypes)(GC.getDefineINT("COLD_FEATURE")));
FeatureTypes eTemperateFeature = ((FeatureTypes)(GC.getDefineINT("TEMPERATE_FEATURE")));
FeatureTypes eWarmFeature = ((FeatureTypes)(GC.getDefineINT("WARM_FEATURE")));
FeatureTypes eFalloutFeature = ((FeatureTypes)(GC.getDefineINT("NUKE_FEATURE")));
//Global Warming
for (int iI = 0; iI < iGlobalWarmingValue; iI++)
{
if (getSorenRandNum(100, "Global Warming") + iGlobalWarmingDefense < GC.getDefineINT("GLOBAL_WARMING_PROB"))
{
CvPlot* pPlot = GC.getMapINLINE().syncRandPlot(RANDPLOT_NOT_CITY); // GWMod removed check for water tile M.A.
if (pPlot != NULL)
{
FeatureTypes eFeature = pPlot->getFeatureType();
bool bChanged = false;
if (pPlot->getFeatureType() != NO_FEATURE)
{
if (pPlot->getFeatureType() != GC.getDefineINT("NUKE_FEATURE"))
{// GWMod won't remove features if underlaying terrain can melt
if (pPlot->getFeatureType() != eColdFeature)
{
if ((pPlot->calculateBestNatureYield(YIELD_FOOD, NO_TEAM) > 1) && (pPlot->getFeatureType() == eTemperateFeature))
{
pPlot->setFeatureType(eWarmFeature);
bChanged = true;
}
else if (pPlot->getTerrainType() == eColdTerrain)
{
pPlot->setTerrainType(eTemperateTerrain);
bChanged = true;
}
[COLOR="Green"]//added by NotSoGood[/COLOR]
[COLOR="red"]else if (pPlot->getTerrainType() == eMarshTerrain)
{
pPlot->setTerrainType(eTemperateTerrain);
bChanged = true;
}[/COLOR]
else if (pPlot->getTerrainType() == eFrozenTerrain)
{
pPlot->setTerrainType(eColdTerrain);
bChanged = true;
}
else
{
pPlot->setFeatureType(NO_FEATURE);
bChanged = true;
}
}
else
{
pPlot->setFeatureType(NO_FEATURE);
bChanged = true;
}
}
}
else if (!pPlot->isWater()) // GWMod added check for water tile M.A.
{// GWMod stepped terrain changes M.A.
if (pPlot->getTerrainType() == eBarrenTerrain)
{
if (isOption(GAMEOPTION_RISING_SEAS))
{
if (pPlot->isCoastalLand())
{
if (!pPlot->isHills() && !pPlot->isPeak())
{
pPlot->setTerrainType(eShallowsTerrain);
bChanged = true;
}
}
}
}
else if (pPlot->getTerrainType() == eDryTerrain)
{
pPlot->setTerrainType(eBarrenTerrain);
bChanged = true;
}
else if (pPlot->getTerrainType() == eTemperateTerrain)
{
pPlot->setTerrainType(eDryTerrain);
bChanged = true;
}
else if (pPlot->getTerrainType() == eColdTerrain)
{
pPlot->setTerrainType(eTemperateTerrain);
bChanged = true;
}
[COLOR="green"]//added by NotSoGood[/COLOR][COLOR="red"]
else if (pPlot->getTerrainType() == eMarshTerrain)
{
pPlot->setTerrainType(eTemperateTerrain);
bChanged = true;
}[/COLOR]
else if (pPlot->getTerrainType() == eFrozenTerrain)
{
pPlot->setTerrainType(eColdTerrain);
bChanged = true;
}
}
if (bChanged)
{
pPlot->setImprovementType(NO_IMPROVEMENT);
CvCity* pCity = GC.getMapINLINE().findCity(pPlot->getX_INLINE(), pPlot->getY_INLINE());
if (pCity != NULL)
{
if (pPlot->isVisible(pCity->getTeam(), false))
{
CvWString 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);
}
}
}
}
}
}
//Nuclear Winter
int iNuclearWinterValue = 0;
iNuclearWinterValue += getNukesExploded() * GC.getDefineINT("GLOBAL_WARMING_NUKE_WEIGHT") / 100;
for (int iI = 0; iI < iNuclearWinterValue; iI++)
{
if (getSorenRandNum(100, "Nuclear Fallout") + iGlobalWarmingDefense < GC.getDefineINT("NUCLEAR_WINTER_PROB"))
{
CvPlot* pPlot = GC.getMapINLINE().syncRandPlot(RANDPLOT_LAND | RANDPLOT_NOT_CITY);
FeatureTypes eFeature = pPlot->getFeatureType();
if (pPlot != NULL)
{
bool bChanged = false;
if (pPlot->getFeatureType() != NO_FEATURE)
{
if (pPlot->getFeatureType() != GC.getDefineINT("NUKE_FEATURE"))
{
if (pPlot->getFeatureType() != eColdFeature)
{
pPlot->setFeatureType(NO_FEATURE);
bChanged = true;
}
}
}
else
{
pPlot->setFeatureType(eFalloutFeature);
bChanged = true;
}
if (getSorenRandNum(100, "Nuclear Winter") + iGlobalWarmingDefense < GC.getDefineINT("NUCLEAR_WINTER_PROB"))
{
if (pPlot->getTerrainType() == eColdTerrain)
{
pPlot->setTerrainType(eFrozenTerrain);
bChanged = true;
}
if (pPlot->calculateTotalBestNatureYield(NO_TEAM) > 1)
{
pPlot->setTerrainType(eColdTerrain);
bChanged = true;
}
}
if (bChanged)
{
pPlot->setImprovementType(NO_IMPROVEMENT);
CvCity* pCity = GC.getMapINLINE().findCity(pPlot->getX_INLINE(), pPlot->getY_INLINE());
if (pCity != NULL)
{
if (pPlot->isVisible(pCity->getTeam(), false))
{
CvWString szBuffer = gDLL->getText("TXT_KEY_MISC_NUCLEAR_WINTER_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);
}
}
}
}
}
}
}//GWMod end M.A.
Hi minor annoyance
I really like the idea behind your mod, but i've tested the mod (included in pig and unofficial expansion) and in my games anything happens, i've compared screen from 1700 to 2070 (much after the last tech was researched) and any singe tile, nothing changed...
well, maybe it's cause i play in small maps?
Sorry to ask the obvious question, but you did turn it on in the custom game option menu, right? (For PIG)
If you did, to see if it works you should be able to fiddle with one of the XML settings to make GW much more likely, so you can check whether the mod is at least working.
If you mean the "rising seas" option, yes, i've enabled it, or maybe i've missed an option??



No that's right. You didn't miss anything. I'll look into it. It's quite possible that when I produced the GWmod for 3.19 (in the thread for the mod) I missed something that is making the mod not work. If other people used the 3.19 code I released, it may be the reason it's not working in other mods.
I suppose at worst, there is no global warming at all in the game. That probably doesn't bother some players.
Thanks for the report anyway!![]()


Nooo i like the global warming concept, in civ4 it's messed up, but with the minor annoyance changes would be interesting!
I like that the world changes in accoring to the players emissions![]()

To be honest, I have never tried to see if it works in BULL either.![]()
When I merged it into BULL I noticed that there was a change (in CvEnum.h?) that wasn't marked with a MA comment, but IIRC it caused a compiler error so you must have found it too. To be honest, I have never tried to see if it works in BULL either.![]()
to extreme levels to check the code. My computer is so slow I just can't play the game. My last game (which did have my GW changes) too 100 hours to finish and it was on normal speed and medium sized map. I've heard people finish marathon games on huge maps in 15 hours. Right now this computer is struggling to keep up with my typing and I don't type very fast. So I'll be reformatting soon.
bonus)
, or the global warming "attack".
from buildings
from bonuses (coal, oil etc.)
from a city having power
are too low then there isn't enough
per city so there's no enough room on the map to have enough cities to have enough
to trigger GW.
) and all
resource bonuses (totalling 6
).
) + (GLOBAL_WARMING_POWER_WEIGHT x city's bonus
) = number of developed cities needed to cause 1 check for GW a turn.
weight of 20 and the city building's total
was 7 (does not include drydock or ironworks) it was 1 x 400 / 20 x 7 = 28.5 developed cities needed to cause global warming. That's much more likely.
values are the problem. Those need to be higher.Ok I can't get this to run as a stand alone mod even.
Attached is my attempt at making it compatible with 3.19. Can anyone figure out why it's not working?
I can't get civ4 to work at all recently. Some problem with barbarian in the force controls xml. I don't know what that is so I should reinstall. After reformatting.