Rod
King
Plant Forest - Forest Mod
Actually this is my first trial on Modding CivIV and I decided to convert a part of an old vanilla mod (Green Mod) for Warlords.
Aim of this mod :
1)Gives your workers the ability to plant forest after you researched Paper.
2)You can plant leafy tree forest on plains or grassland, even when they have other improvements, these get destroyed (except roads/ railroads).
It takes 30 turns.
3)You can plant needle tree forests on tundra, even when it has another improvement, this one get destroyed (except roads/ railroads).
It takes 45 turns.
4)You can not plant forest on existing forests or jungles.
My ModComponent comes with a really enhanced Documentation, so if you want to merge the function into your mods, you simply need the ChangeLog and follow it step by step (copy and paste) .
Credits to : Master Lexx (who created the original code), Sevo (who provided a bugfix)
Kudos to TheLopez whom inspired me to principles of good Documentation thanks to his excellent Documentation.
ChangeLog
1) Added lines in
\Warlords\Mods\ForestMod\Assets\XML\Terrain\CIV4ImprovementInfos.xml
2) add following lines in :
\Warlords\Mods\ForestMod\Assets\XML\Units\CIV4BuildInfos.xml
3) Added Lines in
Warlords\Mods\ForestMod\Assets\XML\ArtCIV4ArtDefines_Improvement.xml
4) Added Lines in
Warlords\Mods\ForestMod\Assets\XML\Units\CIV4UnitInfos.xml
in
<Type>UNIT_WORKER</Type>
and
<Type>UNIT_INDIAN_FAST_WORKER</Type>
search 2 times for
Afterwards fill in:
5) Added new file
\Warlords\Mods\ForestMod\Assets\XML\Text\ForestMod_GameTextInfos.xml
contains
6) Added new file
\Warlords\Mods\ForestMod\Assets\XML\Text\ForestMod_GameTextInfos_Objects.xml
contains
7) Added following lines in
\Warlords\Mods\ForestMod\Assets\Python\CvEventManager.py
7.1) added
in the header of file
after
add
after
7.2) in the mainbody
after
add
7.3) in the mainbody
after
add
8) Added lines in
Warlords\Mods\ForestMod\Assets\XML\Technologies\CIV4TechInfos.xml
and here comes the file itself. As usual you can unpack it in your mod folder :
ForestMod 1.01 for Warlords 2.08
(fixed two bugs and one virus problem)
Actually this is my first trial on Modding CivIV and I decided to convert a part of an old vanilla mod (Green Mod) for Warlords.
Aim of this mod :
1)Gives your workers the ability to plant forest after you researched Paper.
2)You can plant leafy tree forest on plains or grassland, even when they have other improvements, these get destroyed (except roads/ railroads).
It takes 30 turns.
3)You can plant needle tree forests on tundra, even when it has another improvement, this one get destroyed (except roads/ railroads).
It takes 45 turns.
4)You can not plant forest on existing forests or jungles.
My ModComponent comes with a really enhanced Documentation, so if you want to merge the function into your mods, you simply need the ChangeLog and follow it step by step (copy and paste) .
Credits to : Master Lexx (who created the original code), Sevo (who provided a bugfix)
Kudos to TheLopez whom inspired me to principles of good Documentation thanks to his excellent Documentation.
ChangeLog
Spoiler :
1) Added lines in
\Warlords\Mods\ForestMod\Assets\XML\Terrain\CIV4ImprovementInfos.xml
Code:
[INDENT][INDENT][INDENT]<ImprovementInfo>[/INDENT][/INDENT][/INDENT]
<Type>IMPROVEMENT_NEW_FOREST</Type>
<Description>TXT_KEY_IMPROVEMENT_NEW_FOREST</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_NEW_FOREST_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_NEW_FOREST</ArtDefineTag>
<PrereqNatureYields/>
<YieldChanges/>
<bActsAsCity>0</bActsAsCity>
<bHillsMakesValid>0</bHillsMakesValid>
<bFreshWaterMakesValid>0</bFreshWaterMakesValid>
<bRiverSideMakesValid>0</bRiverSideMakesValid>
<bNoFreshWater>0</bNoFreshWater>
<bRequiresFlatlands>0</bRequiresFlatlands>
<bRequiresRiverSide>0</bRequiresRiverSide>
<bRequiresIrrigation>0</bRequiresIrrigation>
<bCarriesIrrigation>0</bCarriesIrrigation>
<bRequiresFeature>0</bRequiresFeature>
<bWater>0</bWater>
<bGoody>0</bGoody>
<bPermanent>0</bPermanent>
<iTilesPerGoody>0</iTilesPerGoody>
<iGoodyRange>0</iGoodyRange>
<iUpgradeTime>0</iUpgradeTime>
<iAirBombDefense>0</iAirBombDefense>
<iDefenseModifier>0</iDefenseModifier>
<iPillageGold>0</iPillageGold>
<TerrainMakesValids>
<TerrainMakesValid>
<TerrainType>TERRAIN_GRASS</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_PLAINS</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
</TerrainMakesValids>
<FeatureMakesValids>
<FeatureMakesValid>
<FeatureType>FEATURE_JUNGLE</FeatureType>
<bMakesValid>0</bMakesValid>
</FeatureMakesValid>
<FeatureMakesValid>
<FeatureType>FEATURE_FOREST</FeatureType>
<bMakesValid>0</bMakesValid>
</FeatureMakesValid>
</FeatureMakesValids>
<ImprovementPillage/>
<ImprovementUpgrade/>
<TechYieldChanges/>
<RouteYieldChanges/>
<WorldSoundscapeAudioScript>ASSS_FOREST_SELECT_AMB</WorldSoundscapeAudioScript>
<bGraphicalOnly>0</bGraphicalOnly>
</ImprovementInfo>
<ImprovementInfo>
<Type>IMPROVEMENT_NEW_FORESTW</Type>
<Description>TXT_KEY_IMPROVEMENT_NEW_FOREST</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_NEW_FOREST_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_NEW_FOREST</ArtDefineTag>
<PrereqNatureYields/>
<YieldChanges/>
<bActsAsCity>0</bActsAsCity>
<bHillsMakesValid>0</bHillsMakesValid>
<bFreshWaterMakesValid>0</bFreshWaterMakesValid>
<bRiverSideMakesValid>0</bRiverSideMakesValid>
<bNoFreshWater>0</bNoFreshWater>
<bRequiresFlatlands>0</bRequiresFlatlands>
<bRequiresRiverSide>0</bRequiresRiverSide>
<bRequiresIrrigation>0</bRequiresIrrigation>
<bCarriesIrrigation>0</bCarriesIrrigation>
<bRequiresFeature>0</bRequiresFeature>
<bWater>0</bWater>
<bGoody>0</bGoody>
<bPermanent>0</bPermanent>
<iTilesPerGoody>0</iTilesPerGoody>
<iGoodyRange>0</iGoodyRange>
<iUpgradeTime>0</iUpgradeTime>
<iAirBombDefense>0</iAirBombDefense>
<iDefenseModifier>0</iDefenseModifier>
<iPillageGold>0</iPillageGold>
<TerrainMakesValids>
<TerrainMakesValid>
<TerrainType>TERRAIN_TUNDRA</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
</TerrainMakesValids>
<FeatureMakesValids>
<FeatureMakesValid>
<FeatureType>FEATURE_JUNGLE</FeatureType>
<bMakesValid>0</bMakesValid>
</FeatureMakesValid>
<FeatureMakesValid>
<FeatureType>FEATURE_FOREST</FeatureType>
<bMakesValid>0</bMakesValid>
</FeatureMakesValid>
</FeatureMakesValids>
<ImprovementPillage/>
<ImprovementUpgrade/>
<TechYieldChanges/>
<RouteYieldChanges/>
<WorldSoundscapeAudioScript>ASSS_FOREST_SELECT_AMB</WorldSoundscapeAudioScript>
<bGraphicalOnly>0</bGraphicalOnly>
</ImprovementInfo>
\Warlords\Mods\ForestMod\Assets\XML\Units\CIV4BuildInfos.xml
Code:
[INDENT][INDENT][INDENT]<BuildInfo>[/INDENT][/INDENT][/INDENT]
<Type>BUILD_NEW_FOREST</Type>
<Description>TXT_KEY_BUILD_NEW_FOREST</Description>
<Help/>
<PrereqTech>TECH_PAPER</PrereqTech>
<iTime>3000</iTime>
<bKill>0</bKill>
<ImprovementType>IMPROVEMENT_NEW_FOREST</ImprovementType>
<RouteType>NONE</RouteType>
<EntityEvent>ENTITY_EVENT_SHOVEL</EntityEvent>
<FeatureStructs>
<FeatureStruct>
<FeatureType>FEATURE_JUNGLE</FeatureType>
<PrereqTech>TECH_FOREST_TECH</PrereqTech>
<iTime>0</iTime>
<iProduction>0</iProduction>
<bRemove>0</bRemove>
</FeatureStruct>
<FeatureStruct>
<FeatureType>FEATURE_FOREST</FeatureType>
<PrereqTech>TECH_FOREST_TECH</PrereqTech>
<iTime>0</iTime>
<iProduction>0</iProduction>
<bRemove>0</bRemove>
</FeatureStruct>
</FeatureStructs>
<HotKey>KB_S</HotKey>
<bAltDown>0</bAltDown>
<bShiftDown>1</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>1</iHotKeyPriority>
<Button>,Art/Interface/Buttons/TerrainFeatures/Forest.dds,Art/Interface/Buttons/BaseTerrain_TerrainFeatures_Atlas.dds,7,3</Button>
</BuildInfo>
<BuildInfo>
<Type>BUILD_NEW_FORESTW</Type>
<Description>TXT_KEY_BUILD_NEW_FOREST</Description>
<Help/>
<PrereqTech>TECH_PAPER</PrereqTech>
<iTime>3000</iTime>
<bKill>0</bKill>
<ImprovementType>IMPROVEMENT_NEW_FORESTW</ImprovementType>
<RouteType>NONE</RouteType>
<EntityEvent>ENTITY_EVENT_SHOVEL</EntityEvent>
<FeatureStructs>
<FeatureStruct>
<FeatureType>FEATURE_JUNGLE</FeatureType>
<PrereqTech>TECH_FOREST_TECH</PrereqTech>
<iTime>0</iTime>
<iProduction>0</iProduction>
<bRemove>0</bRemove>
</FeatureStruct>
<FeatureStruct>
<FeatureType>FEATURE_FOREST</FeatureType>
<PrereqTech>TECH_FOREST_TECH</PrereqTech>
<iTime>0</iTime>
<iProduction>0</iProduction>
<bRemove>0</bRemove>
</FeatureStruct>
</FeatureStructs>
<HotKey>KB_S</HotKey>
<bAltDown>0</bAltDown>
<bShiftDown>1</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>1</iHotKeyPriority>
<Button>,Art/Interface/Buttons/TerrainFeatures/Forest.dds,Art/Interface/Buttons/BaseTerrain_TerrainFeatures_Atlas.dds,7,3</Button>
</BuildInfo>
3) Added Lines in
Warlords\Mods\ForestMod\Assets\XML\ArtCIV4ArtDefines_Improvement.xml
Code:
[INDENT][INDENT][INDENT]<ImprovementArtInfo>[/INDENT][/INDENT][/INDENT]
<Type>ART_DEF_IMPROVEMENT_NEW_FOREST</Type>
<bExtraAnimations>0</bExtraAnimations>
<fScale>0.0</fScale>
<fInterfaceScale>0.0</fInterfaceScale>
<NIF>Art/Structures/Cities/destroyed_city.nif</NIF>
<KFM/>
<Button>,Art/Interface/Buttons/TerrainFeatures/Forest.dds,Art/Interface/Buttons/BaseTerrain_TerrainFeatures_Atlas.dds,3,3</Button>
</ImprovementArtInfo>
4) Added Lines in
Warlords\Mods\ForestMod\Assets\XML\Units\CIV4UnitInfos.xml
in
<Type>UNIT_WORKER</Type>
and
<Type>UNIT_INDIAN_FAST_WORKER</Type>
search 2 times for
Code:
[INDENT][INDENT][INDENT][INDENT][INDENT][INDENT][INDENT]<Build>[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT]
<BuildType>BUILD_SCRUB_FALLOUT</BuildType>
<bBuild>1</bBuild>
</Build>
Afterwards fill in:
Code:
[INDENT][INDENT][INDENT][INDENT][INDENT][INDENT][INDENT]<Build>[/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT][/INDENT]
<BuildType>BUILD_NEW_FOREST</BuildType>
<bBuild>1</bBuild>
</Build>
<Build>
<BuildType>BUILD_NEW_FORESTW</BuildType>
<bBuild>1</bBuild>
</Build>
\Warlords\Mods\ForestMod\Assets\XML\Text\ForestMod_GameTextInfos.xml
contains
Code:
<Civ4GameText xmlns="http://www.firaxis.com">
<TEXT>
<Tag>TXT_KEY_IMPROVEMENT_NEW_FOREST</Tag>
<English>Cultivate new forest</English>
<French>
<Text>Planter foret nouvelle</Text>
<Gender>Male</Gender>
<Plural>0</Plural>
</French>
<German>
<Text>Neuen Wald anpflanzen</Text>
<Gender>Male</Gender>
<Plural>0</Plural>
</German>
<Italian>
<Text>Coltivi nuova foresta</Text>
<Gender>Male</Gender>
<Plural>0</Plural>
</Italian>
<Spanish>
<Text>Cultive nuevo bosque</Text>
<Gender>Female</Gender>
<Plural>0</Plural>
</Spanish>
</TEXT>
</Civ4GameText>
6) Added new file
\Warlords\Mods\ForestMod\Assets\XML\Text\ForestMod_GameTextInfos_Objects.xml
contains
Code:
<Civ4GameText xmlns="http://www.firaxis.com">
<TEXT>
<Tag>TXT_KEY_BUILD_NEW_FOREST</Tag>
<English>Cultivate new forest</English>
<French>Planter foret nouvelle</French>
<German>Neuen Wald anpflanzen</German>
<Italian>Coltivi nuova foresta</Italian>
<Spanish>Cultive nuevo bosque</Spanish>
</TEXT>
<TEXT>
<Tag>TXT_KEY_BUILD_EXPLORETEMPLE</Tag>
<English>Examine</English>
<French>Examiner</French>
<German>Untersuchen</German>
<Italian>Esaminare</Italian>
<Spanish>Prueba</Spanish>
</TEXT>
</Civ4GameText>
7) Added following lines in
\Warlords\Mods\ForestMod\Assets\Python\CvEventManager.py
7.1) added
in the header of file
after
Code:
def __init__(self):
add
Code:
#ForestMod Sevo's Worker Fix
self.pPlot_remembered = [-1,""]
7.2) in the mainbody
after
Code:
def onBeginPlayerTurn(self, argsList):
'Called at the beginning of a players turn'
iGameTurn, iPlayer = argsList
add
Code:
# ForestMod Sevo's Worker Fix - is checking all tiles whether some of them had the forest planted in last turn and then removes improvement
if (self.pPlot_remembered[0] != -1):
self.pPlot_remembered[0] += 1
if (self.pPlot_remembered[0] > 3):
self.pPlot_remembered[1].setImprovementType(-1)
self.pPlot_remembered = [-1,""]
#Forest Mod ends
after
Code:
def onImprovementBuilt(self, argsList):
'Improvement Built'
iImprovement, iX, iY = argsList
add
Code:
#ForestMod : when improvement finished then remove improvement(delayed) and create a feature
pPlot = CyMap().plot(iX,iY)
if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_NEW_FOREST')):
pPlot.setFeatureType(4, 0)
CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'A new forest has been planted!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),iX,iY,True,True)
self.pPlot_remembered = [1,pPlot]
if(iImprovement==gc.getInfoTypeForString('IMPROVEMENT_NEW_FORESTW')):
pPlot.setFeatureType(4, 1)
CyInterface().addMessage(CyGame().getActivePlayer(),True,25,'A new forest has been planted!','AS2D_DISCOVERBONUS',1,'Art/Interface/Buttons/TerrainFeatures/Forest.dds',ColorTypes(8),iX,iY,True,True)
self.pPlot_remembered = [1,pPlot]
#ForestMod ends
Warlords\Mods\ForestMod\Assets\XML\Technologies\CIV4TechInfos.xml
Code:
<TechInfo>
<Type>TECH_FOREST_TECH</Type>
<Description>TXT_KEY_TECH_FUTURE_TECH</Description>
<Civilopedia>TXT_KEY_TECH_FUTURE_TECH_PEDIA</Civilopedia>
<Help/>
<Strategy>TXT_KEY_TECH_FUTURE_TECH_STRATEGY</Strategy>
<Advisor>ADVISOR_SCIENCE</Advisor>
<iAIWeight>0</iAIWeight>
<iAITradeModifier>0</iAITradeModifier>
<iCost>10000</iCost>
<Era>ERA_FUTURE</Era>
<FirstFreeUnitClass>NONE</FirstFreeUnitClass>
<iFeatureProductionModifier>0</iFeatureProductionModifier>
<iWorkerSpeedModifier>0</iWorkerSpeedModifier>
<iTradeRoutes>0</iTradeRoutes>
<iHealth>0</iHealth>
<iHappiness>0</iHappiness>
<iFirstFreeTechs>0</iFirstFreeTechs>
<iAsset>0</iAsset>
<iPower>0</iPower>
<bRepeat>0</bRepeat>
<bTrade>0</bTrade>
<bDisable>1</bDisable>
<bGoodyTech>0</bGoodyTech>
<bExtraWaterSeeFrom>0</bExtraWaterSeeFrom>
<bMapCentering>0</bMapCentering>
<bMapVisible>0</bMapVisible>
<bMapTrading>0</bMapTrading>
<bTechTrading>0</bTechTrading>
<bGoldTrading>0</bGoldTrading>
<bOpenBordersTrading>0</bOpenBordersTrading>
<bDefensivePactTrading>0</bDefensivePactTrading>
<bPermanentAllianceTrading>0</bPermanentAllianceTrading>
<bVassalTrading>0</bVassalTrading>
<bBridgeBuilding>0</bBridgeBuilding>
<bIrrigation>0</bIrrigation>
<bIgnoreIrrigation>0</bIgnoreIrrigation>
<bWaterWork>0</bWaterWork>
<iGridX>19</iGridX>
<iGridY>12</iGridY>
<DomainExtraMoves/>
<CommerceFlexible/>
<TerrainTrades/>
<Flavors>
<Flavor>
<FlavorType>FLAVOR_MILITARY</FlavorType>
<iFlavor>1</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_RELIGION</FlavorType>
<iFlavor>1</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_PRODUCTION</FlavorType>
<iFlavor>1</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_GOLD</FlavorType>
<iFlavor>1</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_SCIENCE</FlavorType>
<iFlavor>1</iFlavor>
</Flavor>
<Flavor>
<FlavorType>FLAVOR_CULTURE</FlavorType>
<iFlavor>1</iFlavor>
</Flavor>
</Flavors>
<OrPreReqs>
<PrereqTech>TECH_FUTURE_TECH</PrereqTech>
</OrPreReqs>
<AndPreReqs>
<PrereqTech>TECH_FUTURE_TECH</PrereqTech>
</AndPreReqs>
<Quote>TXT_KEY_TECH_FUTURE_TECH_QUOTE</Quote>
<Sound>AS2D_TECH_FUTURE</Sound>
<SoundMP>AS2D_TECH_MP_FUTURE</SoundMP>
<Button>,Art/Interface/Buttons/TechTree/Future Tech.dds,Art/Interface/Buttons/TechTree_Atlas.dds,2,4</Button>
</TechInfo>
and here comes the file itself. As usual you can unpack it in your mod folder :
ForestMod 1.01 for Warlords 2.08
(fixed two bugs and one virus problem)