Scenario making can be done on different levels, from very simple to very complex. Look at the Earth 1000 AD scenario for a very simple but still fun and replayable scenario: it's entirely made with the World Builder, no XML or Python changes there. Anyone who knows how to use a mouse and keyboard and is a little bit creative could design something like that, no real technical skills are required. The Greek World scenario involves some a fair amount of XML modding but very little Python, the scenario would be entirely playable and enjoyable if you deleted the Python folder. Anyone could still design something like that but you have to dive into some XML files to accomplish it, which may require some getting used to, but it's not hard to do at all. The Revolutionary War scenario contains more complex Python code, although as far as Python goes, it's still fairly straight-forward and easy to adjust for your own purposes. The Desert War scenario is another step up in complexity and it requires some skill and experience to create something similar. But I'm in the process of writing a detailed Python guide that should make Python modding a lot easier for everyone from novices to expert programmers.
Announcement
Collapse
No announcement yet.
Initial Python reference
Collapse
This is a sticky topic.
X
X
-
Thanks Locutus
I speak from experience, you are a very helpful individual
I have called on you for many years in CTP and have had untold hours of fun modding
Looking forward after Amazon gets done abusing my Presell edition of CIV IV to doing some modding
Thanks a lot
GrampsHi, I'm RAH and I'm a Benaholic.-rah
Comment
-
Originally posted by Peter Triggs
I don't remember a lot of the Civ2 scenarios I used to play as having a lot of scripting. But this was in the last millenium and I'm sure that the ones that have come out more recently are way more sophisticated.
Comment
-
Originally posted by sgrig
There were a few extremely sophisticated Civ2 scenarios released at one point - these used multiple event files etc. For example, Red Front is a classic example. It is still my all-time favourite Civ game. Hopefully with the new tools in Civ4 this can be surpassed!
Comment
-
Originally posted by Locutus
The Revolutionary War scenario contains more complex Python code, although as far as Python goes, it's still fairly straight-forward and easy to adjust for your own purposes. The Desert War scenario is another step up in complexity and it requires some skill and experience to create something similar.
Comment
-
Originally posted by sgrig
There were a few extremely sophisticated Civ2 scenarios released at one point - these used multiple event files etc. For example, Red Front is a classic example. It is still my all-time favourite Civ game. Hopefully with the new tools in Civ4 this can be surpassed!
Comment
-
Originally posted by Trip
Hey now... the functions I wrote to spawn rebel barbarian units randomly within a certain radius of any plot while also moving enemy units currently on that plot aside to a random plot in a list of the closest friendly ones is just as complicated as anything in DesertWar.
Either way, both our scenarios are just the tip of the iceberg in terms of what can be done with Python, it'll be very exciting to see what the community will do in the coming years with the tools they've been given. If previous moddable games such as Civ2 and the CtP series are any indication, the only thing we know for sure that it'll surpass all our expectations
Comment
-
Re: Initial Python reference
Originally posted by Locutus
Example
Finally, I'll give one simple example of how to use all this code in practice. For more examples, see the Python code in the Mods folder, the various scenarios come with a lot of interesting code.
Code:def onGameStart(self, argsList): 'Create a popup message at the start of the game' popup = PyPopup.PyPopup() popup.setBodyString( 'Hello World' ) popup.launch() def onCityBuilt(self, argsList): 'For player 1, create a Warrior (index 17) in every city that is built' city = argsList[0] if city.getOwner() == 1: city.getOwner().initUnit(17, city.getX(), city.getY(), UnitAITypes.NO_UNITAI)
Comment
-
How do I edit properties of the cities? I want to add bonuses to the cities based on resources, health, ect, but I'm not sure what event to use to keep them up to date, plus to make sure it processes for every city.
I'm thinking I can add something like this, but it has to be called for each city every turn, just to make sure it's up to date, so I'm not sure where to add it (or if I'm calling/editing the write variables).
Code:if (Pycity.getFoodRate() * (getGoodHealth() - getBadHealth()) * 0.05 > 0): YieldTypes.YIELD_FOOD = Pycity.getFoodRate() * (getGoodHealth() - getBadHealth()) * 0.05:
Mylon Mod - Adressing game pace and making big cities bigger.
Inquisition Mod - Exterminating heretic religions since 1200 AD
Comment
-
Re: Initial Python reference
Originally posted by Locutus
4) Overrides - some game functions can be overwritten, for example what can be built in what cities, what civics/techs/religions/etc are available to who
I'm a super newbie at python/xml but I've been spending a fair amount of time poking around the files trying to get a sense of how to set something like this up. Any ideas would be greatly appreciated.
Comment
-
map scripts with static terrain
I want to create a map script that recreates the same map every time, but randomizes resource placement. Can I simply input coordinates for each terrain type in the relevant portion of the script(cutting and pasting from the BMP-WBS converter values), or is it more complex than that? Can I preplace cities, units, and generate tech levels in the map script, as well?
Why I ask, is I want to create a scenario, but want certain factors randomized, but keep the same map. In civ III, I'd simply randomize the resource placement in the editor... but not having the game yet, I'm uncertain is the worldbuilder allows me to do this.
Comment
-
Re: Initial Python reference
Originally posted by Locutus
A note of caution: please do NOT, I repeat, do NOT mess with the Python files in the default Assets folder, this will cause all kinds of problems with future patching, MP play, tournaments, etc. Please use the mod setup that's also used for the in-game scenarios, see the Mods folder. Here you only need to keep the things you add/change, files that remain unchanged you can leave out, the game will just take the version from the default Assets folder for any file it's missing (similar to CtP modding, for those familiar with it -- only this time it actually works). More detailed info will follow but I think most people will be able to figure this out soon enough, it's pretty simple.
This is my first time modding Civ, so if my question sits better in another thread, please direct me to it... IF there is a Newbie's guide to Modding Civ, I'd love to read it. Thanks.XP SP2; 1280MB w/3200MB virtual memory
AMD Athlon 1700+; 500W power, 2HD's
Radeon 9600pro 256MB (Dec 2005 Catalyst)
SoundBlaster X-Fi (8.8.05 driver)
Comment
-
Originally posted by TheDarkside
Any idea how to attach a vertical scrollbar to an existing panel?
I printed some stuff on a panel which goes beyond it's clip boundary, so I need to somehow put a scrollbar on that panel...
Originally posted by Nevs23
I'm a bit confused... in which file i have to add those lines (for example)? "CvEventManager.py"?
Originally posted by Mylon
Would I put this in onEndTurn? And how would I make sure it processes for every city?
You can't just change the value of YieldTypes.YIELD_FOOD though, that's just the index of the food value, not the actual food value. You can't manipulate in-game variables such as food, hitpoints, etc directly, you have to do so through functions. The onCityDoTurn event gives you a city argument, so the second line in your example would have to be something like:
Code:pCity.changeFood(Pycity.getFoodRate() * (getGoodHealth() - getBadHealth()) * 0.05)
Originally posted by Fintilgin
Anyone have any suggestion on how I can forbid certain civs from getting certain religions?
Originally posted by craig_sutter
I want to create a map script that recreates the same map every time, but randomizes resource placement. Can I simply input coordinates for each terrain type in the relevant portion of the script(cutting and pasting from the BMP-WBS converter values), or is it more complex than that? Can I preplace cities, units, and generate tech levels in the map script, as well?
That said, I think this was actually discussed by some of the testers and it was concluded that it would require some serious changes to the current setup. It would probably be best to just create a pre-set WBS map without resources and write a seperate Python routine (that could probably be very similar to the ones used in the map scripts) to place resources at the start of the game. Doing it the other way around of having a map script and just removing all the randomness in it would likely be much harder, but as said, I'm not the guy to ask.
Originally posted by Spocko
So, if I want to modify a certain PY file, I should copy it to the MODS folder, edit that copy in the mods folder, and leave it there, while keeping the original PY file in its original directory? This sounds like the system first grabs PY's in the Mods folder and then collects from the original folders any PYs that are not found in the Mods, right?
Comment
Comment