View Full Version : Growable forest, like cottage....
MattPilot
October 28, 2005, 22:37
Looked over the file CIV4Improvementinfos.xml
It should be fairly easy to add an improvement that uses the same structure as cottages, and similar graphics as the forest.
The thing is, however, the game would recognize it as an improvement, and not as a forest "special feature". Therefore you could not cut it down (which i assume would be a good thing). The other thing is, however, it wouldn't give off health benefits - the number one reason to planting forests in the first place. Perhaps inserting the phrase " < iHealthPercent> 40< /iHealthPercent > " into the improvements file will work, but alas i haven't tried.
Backpack
October 29, 2005, 00:12
It would be pillagable..... (But you don't profit from pillaging your own structures.... I tried that)
-----------------
Backpack
rezaf
November 3, 2005, 16:41
As this thread kinda died down even though I figure there are some people who would want such feature, I'm taking the libery of bumping it.
I introduced "Tree Schools" into my game, which allow a tree school improvement which does not yield any resource gain, but after being worked on for 40 turns will transform into a regular forest.
It's NOT an improvement, it's a real forest.
Here's what needs to be coded in in order to pull it off:
Edit: If you just wanna use the feature, scroll down a few posts to where I provided a mod download that doesn't require you to touch any game files yourself any longer.
In CvEventManager.py:
def onImprovementBuilt(self, argsList):
'Improvement Built'
iImprovement, iX, iY = argsList
iPlayer = CyGame().getActivePlayer()
pPlot = CyMap().plot(iX,iY)
player = gc.getPlayer(iPlayer)
if(iImprovement==25):
Plot.setFeatureType(CyGlobalContext().getInfoTypeForString("FEATURE_FOREST"),-1)
pPlot.setImprovementType(-1)
if (not self.__LOG_IMPROVEMENT):
return
CvUtil.pyPrint('Improvement %s was built at %d, %d'
%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
In CIV4BuildInfos.xml
<BuildInfo>
<Type>BUILD_TREESCHOOL</Type>
<Description>TXT_KEY_BUILD_TREESCHOOL</Description>
<Help/>
<PrereqTech>TECH_BIOLOGY</PrereqTech>
<iTime>500</iTime>
<bKill>0</bKill>
<ImprovementType>IMPROVEMENT_TREESCHOOL</ImprovementType>
<RouteType>NONE</RouteType>
<EntityEvent>ENTEVENT_BUILD</EntityEvent>
<FeatureStructs/>
<HotKey>KB_P</HotKey>
<bAltDown>0</bAltDown>
<bShiftDown>1</bShiftDown>
<bCtrlDown>0</bCtrlDown>
<iHotKeyPriority>1</iHotKeyPriority>
<Button>,Art/Interface/Buttons/TerrainFeatures/Forest.dds,Art/Interface/Buttons/Actions_Builds_LeaderHeads_Specialists_Atlas.dds,1,9</Button>
</BuildInfo>
In CIV4GameTextInfos.xml
<TEXT>
<Tag>TXT_KEY_BUILD_TREESCHOOL</Tag>
<English>Build a Tree School</English>
<French>construire une plantation</French>
<German>Baumschule bauen</German>
<Italian>Costruisci una piantagione</Italian>
<Spanish>Construir una plantación</Spanish>
</TEXT>
In CIV4ImprovementInfos.xml
<ImprovementInfo>
<Type>IMPROVEMENT_TREESCHOOL</Type>
<Description>TXT_KEY_IMPROVEMENT_TREESCHOOL</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_PLANTATION_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_PLANTATION</ArtDefineTag>
<PrereqNatureYields/>
<YieldChanges/>
<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>
<bUseLSystem>1</bUseLSystem>
<iTilesPerGoody>0</iTilesPerGoody>
<iGoodyRange>0</iGoodyRange>
<iUpgradeTime>40</iUpgradeTime>
<iAirBombDefense>5</iAirBombDefense>
<iDefenseModifier>0</iDefenseModifier>
<iPillageGold>5</iPillageGold>
<TerrainMakesValids>
<TerrainMakesValid>
<TerrainType>TERRAIN_GRASS</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_PLAINS</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_TUNDRA</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
</TerrainMakesValids>
<FeatureMakesValids/>
<ImprovementPillage/>
<ImprovementUpgrade>IMPROVEMENT_TREESCHOOL_II</ImprovementUpgrade>
<TechYieldChanges/>
<RouteYieldChanges/>
<bGraphicalOnly>0</bGraphicalOnly>
</ImprovementInfo>
<ImprovementInfo>
<Type>IMPROVEMENT_TREESCHOOL_II</Type>
<Description>TXT_KEY_IMPROVEMENT_TREESCHOOL</Description>
<Civilopedia>TXT_KEY_IMPROVEMENT_PLANTATION_PEDIA</Civilopedia>
<ArtDefineTag>ART_DEF_IMPROVEMENT_PLANTATION</ArtDefineTag>
<PrereqNatureYields/>
<YieldChanges/>
<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>
<bUseLSystem>1</bUseLSystem>
<iTilesPerGoody>0</iTilesPerGoody>
<iGoodyRange>0</iGoodyRange>
<iUpgradeTime>1</iUpgradeTime>
<iAirBombDefense>5</iAirBombDefense>
<iDefenseModifier>0</iDefenseModifier>
<iPillageGold>5</iPillageGold>
<TerrainMakesValids>
<TerrainMakesValid>
<TerrainType>TERRAIN_GRASS</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_PLAINS</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
<TerrainMakesValid>
<TerrainType>TERRAIN_TUNDRA</TerrainType>
<bMakesValid>1</bMakesValid>
</TerrainMakesValid>
</TerrainMakesValids>
<FeatureMakesValids/>
<ImprovementPillage/>
<ImprovementUpgrade/>
<TechYieldChanges/>
<RouteYieldChanges/>
<bGraphicalOnly>0</bGraphicalOnly>
</ImprovementInfo>
And in CIV4GameTextInfos_Objects.xml
<TEXT>
<Tag>TXT_KEY_IMPROVEMENT_TREESCHOOL</Tag>
<English>Tree School</English>
<French>
<Text>Tree School</Text>
<Gender>Female</Gender>
<Plural>0</Plural>
</French>
<German>
<Text>Baumschule</Text>
<Gender>Female</Gender>
<Plural>0</Plural>
</German>
<Italian>
<Text>Piantagione:Piantagioni</Text>
<Gender>Female</Gender>
<Plural>0:1</Plural>
</Italian>
<Spanish>
<Text>Plantación:Plantaciones</Text>
<Gender>Female</Gender>
<Plural>0:1</Plural>
</Spanish>
</TEXT>
Sorry, but the tabs kinda fail to show up in the post. :(
I put this into the game by replacing the appropriate section in the .py file and by backing up and then modifying the xml files. If anybody can tell me how to make this a mod I can choose and then start a custom game like I do in a vanilla game, please kindly reply to this thread.
Also, I'd like to have the "A Forest has grown near xxx" to show, along with the pointer on the map. Any hint on how to make this happen would also be appreciated.
Finally, there are no proper texts in the French, Italian and Spanish tags. Native speakers, feel free to post the correct translations. :)
As it stands, you can make the above modifications and upon discovering Biology, you will gain the ability to construct Tree Schools. If you work these for 40 turns, they will convert to a forest. That's it, basically.
As soon as anyone tells me how to put this stuff into seperate xml/py files, I will create and attach those.
Cheers
_____
rezaf
MattPilot
November 3, 2005, 17:43
YOU sir... ARE THE MAN!
Can i simply copy and paste or must i format it?
dearmad
November 3, 2005, 17:45
Why not just use a lumbermill- it accomplishes the same darned thing as far as gaining resoucres- except it uses pop and seems better balanced than this idea.
MattPilot
November 3, 2005, 17:54
Originally posted by dearmad
Why not just use a lumbermill- it accomplishes the same darned thing as far as gaining resoucres- except it uses pop and seems better balanced than this idea.
Uhh.. say what?
YOu realize you can't build a lumbermill if you don't have a forest, right?
rezaf
November 3, 2005, 17:57
Originally posted by MattPilot
YOU sir... ARE THE MAN!
Can i simply copy and paste or must i format it?
I'd guess basic formating is necessary, but just look into the appropriate files and how often you need to hit tab is evident.
Why not just use a lumbermill- it accomplishes the same darned thing as far as gaining resoucres- except it uses pop and seems better balanced than this idea.
Erm ... what? A lumbermill is something completely different. It can enhance the productive capabilities of a forest square. What I posted is meant to accomplish something completely different: Enable you to plant a forest in a Plain, Grassland or Tundra tile.
I'll be trying to come up with more terraforming based bits like this one, to bring back basic terraforming options like you had back in Civ1/2. I was really disappointed how Civ3 cut back on this front, and Civ4 went along, obviously. But as it's rather easy to mod in in Civ4, I just went ahead and did it. ;)
_____
rezaf
ChaotikVisions
November 3, 2005, 17:59
Nice idea and mod, it makes sense for it take awhile before it becomes a forest and balances it doing it that way as well. Also you might want to check the Desert War/American Revolution mod, they use custom python files for some of their stuff.
dearmad
November 3, 2005, 18:20
Originally posted by MattPilot
Uhh.. say what?
YOu realize you can't build a lumbermill if you don't have a forest, right?
Thus conservation...? The game *choice*.
JDexter
November 3, 2005, 18:40
Great mod! Really makes it a little more realistic - in the middle ages so many forrests have been chopped down, look outside now (maybe after you finish one game and before starting another ;) ), there are some forrests again, yes, because of reforestation programs.
I think your concept is just right, although 40 turns seem to be a little long (especially in the late game) - maybe 20 turns would be better. Also, a tree school should be buildable on hills, too, IMO.
*thumbs-up*
rezaf
November 3, 2005, 18:55
Originally posted by ChaotikVisions
Nice idea and mod, it makes sense for it take awhile before it becomes a forest and balances it doing it that way as well. Also you might want to check the Desert War/American Revolution mod, they use custom python files for some of their stuff.
While I agree that having a regrow time makes sense, I have to say that I actually read this in a thread somewhere on these boards back when I didn't have the game yet. (Failed to locate it now, though).
I did check the other mods, but I'm under the impression that you can only put in rules when you include a map. However, I want the Forest planting to be in some files you can just include and then play a custom game like you used to. Hope somebody will eventually hint me how.
Originally posted by dearmad
Thus conservation...? The game *choice*.
Nobody's forcing you to use these modifications. I liked the ability to replant forests, though, so I'm glad to have it back.
Originally posted by JDexter
I think your concept is just right, although 40 turns seem to be a little long (especially in the late game) - maybe 20 turns would be better. Also, a tree school should be buildable on hills, too, IMO.
I agree with that to some extent. I figured even if I have 1yr=1turn, 40 years would be a realistic time for a forest to regrow, but I also agree that in gameplay terms, it's a bit slow. I might lower that number after some playtesting.
Also agree on the hills statement. I was under the impression that this should be possible, due to a non-existant RequiresFlatGround variable, but appearently it is not. What did I miss to adjust?
_____
rezaf
Eric Snyder
November 4, 2005, 04:15
Actually, I have been thinking about forests lately also, albeit along different lines. When the British Empire was in it's heyday, naval stores were considered a vital resource. Most large timber was purchased from the Baltic regions, as well as shipped from the New World. In fact, the cutting of large timber in the English American colonies was very illegal. It was reserved for the Royal Navy.
I had thought of adding a "Large Timber" strategic resource that would be required for the larger ships of sail. The twist would be to make it depletable over time of use, and growing over time in forests that are not being used. Maybe after the age of sail, it becomes a commercial luxery item? I think that I would have to do a study in order to determine the characteristics of trees suitable for naval use, because they certainly could not be found everywhere, even in old growth forests. For instance, it takes around 150 years for an Eastern American hardwood forest to be considered "old growth".
After reading this thread, I thought that these two ideas are somewhat similiar, and could possibly work well together. I would like to offer a suggestion though. Instead of having your forests grow in turns, could you not make it time dependant in years? This would model the modern age much more accurately (cutting trees can happen much faster than growing).
Nice job on the script rezaf!
rezaf
November 4, 2005, 07:32
Originally posted by Eric Snyder
I had thought of adding a "Large Timber" strategic resource <snip>
Instead of having your forests grow in turns, could you not make it time dependant in years?
<snip>
Nice job on the script rezaf!
Thanks on the last one. Though I feel this is rather crude, as far as scripting goes, I'm glad I managed to get it working at all, with almost no documentation available.
About the strategic resource idea ... I'd love to have more of those, and timber seems like a very rational addition, but as far as I understand, it's impossible to add new map objects for them as of now. Sure, you could just scavenge existing art like I did, for example utiliting the banana tree artwork, but still...
Finally, about upgrade time ... it's coded in the XML file as of now and there it only gives you UpgradeTime=x, which I figure translates into turns. I guess having it take x years instead would be possible, but would require more extensive python coding.
One more thing: cheers go to ChaotikVisions who displayed how to properly add code as a mod to me with his faith mod. Thus, I created the necessary files, and now you can extract my Forestry Mod into your mod directoy and then activate it in the Advanced setting from within the game. No longer need you modify any files yourself.
Edit: btw, I lowered the growth time from Tree School to forest from 40 to 25 and changed the required technology from Biology to Guilds.
Edit: I posted an upgraded version of this mod in a thread of it's own. Linky link. (http://apolyton.net/forums/showthread.php?s=&threadid=142723)
MattPilot
November 4, 2005, 10:54
Thx for the files! IT made copy & pasting easier. But i do appreciate you also giving instructions, otherwise i could of never incorporated it into my mod without deleting my other changes.
Anyway, there is one little mistake i found while copy&pasting.
You forgot to give the Indian Fastworker the ability to build it too. :)
CIV4UnitInfos.xml
MattPilot
November 4, 2005, 11:29
hmm....
I don't think its working :(
I started up a modern age game and started building 2 tree farms.
After 6 turns they turned into tree schools (stage 2, i suppose).
But after that, nothing happened.
Just to make something sure - the idea is for it to grow into a regular old forest, with no improvement on it, right?
MattPilot
November 4, 2005, 11:39
correction.... Your mod does work. My copy&pasting doesn't.
:(
ah well - gotta troubleshoot it.
rezaf
November 4, 2005, 11:43
Thanks for the info on the indian fastworker, I will incorporate that and re-up a fixed file asap.
As for the non-working issue ... I'm playing that mod right now, and it works. Did you use the provided archive or did you try the version you incorporated into your mod?
The Python code is extremely picky, and minimal anomalities can lead to failure, unfortunately.
Another likely reason for the mod failing to work could be in your version of CIV there are additional improvements, which can lead to the upgraded Treeschool getting a different ID, thus not causing the Python event to fire correctly. Like I said before, the code is pretty crude as of now, but I'm still strugging to get a basic grip on the API.
Anone else having issues with that one? I'd be happy to provide a relief, but it'd be nice to have some more feedback first.
_____
rezaf
MattPilot
November 4, 2005, 14:00
It works now... I screwed up the python file. :)
One thing i noticed that, perhaps you are able to fix, is that with the civic Emancipation (which lets cottages grow +100%) the trees grow twice as fast too. :) I guess the trees feel emancipated too... :lol:
Btw... you might want to create a new thread with your mod - lots of people wanted it, and i'm not sure they will find it in this thread.
Anyhow - here's your next project: Create ZOC ala Civ2 for forts.... Trip already gave some advice on it in my other thread :naughty: :b: :love:
please? pretty please? i'll give ya a cookie :cute:
rezaf
November 4, 2005, 14:48
I'll look into the emancipation thingie, though I'm not sure whether it can be resolved.
And ... what exactly is the Civ2 style ZOC effect of a fort?
Btw, I alread AM working on a new project, besides the continued work on this one in order to provide more terraforming possibilites. But it's still SECRET! ;)
_____
rezaf
Jon Shafer
November 4, 2005, 14:50
Originally posted by rezaf
Also, I'd like to have the "A Forest has grown near xxx" to show, along with the pointer on the map. Any hint on how to make this happen would also be appreciated.
Check out CyInterface().addMessage(). There are quite a few arguments but it shouldn't be too hard to get working.
MattPilot
November 4, 2005, 15:43
And ... what exactly is the Civ2 style ZOC effect of a fort?
_____
rezaf
;)
ZOC = Zone of Control. SMAC & CIV2 had it. If you occupy one square and the unit has ZOC ability (or in this mods case, the fortress provides ZOC ability to the units occupying it), the enemy can't move from one square next to your ZOC unit to another square next to the same ZOC unit.
rezaf
November 4, 2005, 16:32
Wow, a reply from a firaxian programmer. What an honor. :cool:
Thanks for the heads up, I'll incorporate the message into the next release, provided I get it working.
And ... Matt, I do know what ZOC is, I just wondered what the special effect of forts regarding to that was.
Didn't all units have a ZOC in Civ2, fort or not?
And does CIV have ZOC at all? I haven't waged many wars so far, and for some reason I never tried to move around an enemy unit yet.
_____
rezaf
MattPilot
November 4, 2005, 16:45
Nope... Civ4 does not have it. The naysayers say it shouldn't be included because the AI "can't" deal with it.
Trip added some comments about it here - scroll 4th from above:
http://apolyton.net/forums/showthread.php?s=&threadid=141271
Nevs23
November 4, 2005, 17:39
@rezaf:
If i replace the original code:
def onImprovementBuilt(self, argsList):
'Improvement Built'
iImprovement, iX, iY = argsList
if (not self.__LOG_IMPROVEMENT):
return
CvUtil.pyPrint('Improvement %s was built at %d, %d'
%(PyInfo.ImprovementInfo(iImprovement).getDescription(), iX, iY))
with yours then i get that error message:
Failed to load python module CvEventInterface
Dunno what's wrong...
rezaf
November 4, 2005, 18:30
Well, I don't know either. :rolleyes:
I'd guess you made some mistake when pasting. If you fail to find your error, post your py file here, but without it, there's nothing I can do.
_____
rezaf
Nevs23
November 4, 2005, 18:44
Originally posted by rezaf
If you fail to find your error, post your py file here, but without it, there's nothing I can do.
Just rename it to "CvEventManager.py"
Thank you in advance.
userqwerty
November 8, 2005, 00:37
http://apolyton.net/forums/showthread.php?postid=4121775#post4121775
this allows workers to move onto mountains and with your mod they will be able to grow forests there. Yeeehaaaaa
Imminence
November 11, 2005, 16:12
@ Rezaf
When I saw this thread, I was happy, because I thought, I might be able to "terraform" those many desert and tundra tiles. But as it seems, this was not your intention.
Anyway I use the mod, but I guess, I have not really understood your concept.
Let me see:
I can put the tree nursery on any tile, where I could build other improvements, too, right?
When I do it, it grows it's 25 or so turns and is then a "full" tree nursery (if worked by a nearby city).
But what now? I have some since centuries, and all are "full" tree nurseries, but nothing else happens. Shouldn't there be a wood, which I can then improve with a woodcutter cottage? Or is it a random thingie, if and when a wood will be there?
MattPilot
November 11, 2005, 16:38
But what now? I have some since centuries, and all are "full" tree nurseries, but nothing else happens. Shouldn't there be a wood, which I can then improve with a woodcutter cottage? Or is it a random thingie, if and when a wood will be there?
Had the same problem.
I screwed up the python copy & pasting. Try to use his file or make sure you did your copy& pasting right. Then it will work.
Imminence
November 12, 2005, 00:20
I'm quite sure, that I copied and pasted anything as it should be. Just about the ini-file I was unsure; should it be in a directory, too, and if yes, in which?
Just to make sure, we talk about the same file:
I downloaded a "forestry mod.rar"
Unpacked it contained
1 folder "assets"
1 Forestry mod.ini
In the assets folder are 2 more folders:
1 Python, containing CvEventManager.py
1 XML, containing 3 more folders:
Terrain, Text, units
The latter contained files, which I copied and pasted into the appropriate civ4-folders.
Perhaps I see things too narrow...the tiles, where I have the tree nurseries since ages could be upgraded with woodcutter cottages, by destroying the nursery, of course..
Maybe that's it? It counts as "wood" but only does not show a wood?
MattPilot
November 12, 2005, 00:37
no no.... there will actually be a Forest there instead of that little house after X turns.
WHen i had that problem, my .py file was edited wrong. By replacing it with the one from the mod, it worked.
Are you trying to add this mod to an existing mod, or as a stand alone?
Download the newest version from here:
http://apolyton.net/forums/showthread.php?s=&threadid=142723
Unpack the folder into your "mods" folder in Civ4. Load up the mod during the game and test it if it works (start a game in the modern age, and it will go quite fast).
If this doesn't work, perhaps you messed around with your original files?
Imminence
November 12, 2005, 08:28
Indeed, I just copied the files into my original folders and started a new game, as the old one "refused" to start and CTD'ed. I didn't even think about putting it into the mod folder. I thought, it's just an enhancement to our normal games. Oh well......:o
BTW, I suspect the creator of merging evil things into this mod! Within 30 minutes I had 3 meltdowns of nuclear powerplants in major cities! I bet, he is a green peace activist!
:D :D :D
EDIT:
I deleted all my installation, installed new, unpacked the mod into the mod folder. Loaded the mod. All ran without any problem.
But then the same happened again: For centuries all I get are those cottages.
What did you mean "your .py file was wrong edited and you replaced it with the one of the mod? I use the one of the mod in my mod folder, as it came. Should I put it somewhere else?
vBulletin® v3.8.2, Copyright ©2000-2010, Jelsoft Enterprises Ltd.