Dom Pedro II
Modder For Life
Dom Pedro's Mod Helper
or How I learned to stop worrying and love Python
or How I learned to stop worrying and love Python
Anybody who has talked to me for any length of time about modding knows I have hated python for a long time. While I still don't like its form, I've come to realize that python has a number of important advantages over the SDK. I've started working on scenarios that require small, unique tweaks that don't really justify tinkering with C++, but I've still found python to either be too cumbersome or not powerful enough to do everything I want. This mod comp attempts to strengthen python by using the SDK and XML to work more effectively with it. I designed it for my own needs, but I figured I would share it with the world.
Enclosed in the file and attached separately below is a quick and dirty tutorial for how to use this mod comp.
I am currently accepting suggestions for other things they would like to see python able to do, so let me know.
WHAT IT DOES:This mod component does not change gameplay. It is specifically to make the lives of modders who can use python easier, and give them greater power over the code. Hopefully, this simplified system will also encourage people to go a step further in their modding beyond XML and try their hand at python scripting.
This code takes the system used for calling python methods for Events and expands it to other areas of the game. Modders can attach new python methods to units, promotions, specialists, buildings, civics, civilizations, leaders, religions and more in the XML that will be read from python. This allows players to create small, self-contained python methods that are executed at the appropriate time without complicated checks in python.
With this mod component, you will be able to have specialists give the same benefits as buildings, allow Wonders all the effects of Civics, and virtually any other possible combination. You can have buildings that automatically spawn units in regular intervals, and much much more. Many of the SDK functions that were previously not exposed to python have now been exposed so modders can use the new system to its full potential.
EDIT: I also forgot to mention, I threw in some code to the TechInfos that lets you give announcements to all players who have met the first discoverer of a tech. This has no gameplay consequences, I just liked the idea of having messages appearing like "A Sumerian inventor has become the first person to build a heavier-than-air aircraft!" or something like that.
Enclosed in the file and attached separately below is a quick and dirty tutorial for how to use this mod comp.
I am currently accepting suggestions for other things they would like to see python able to do, so let me know.
WHAT IT DOES:This mod component does not change gameplay. It is specifically to make the lives of modders who can use python easier, and give them greater power over the code. Hopefully, this simplified system will also encourage people to go a step further in their modding beyond XML and try their hand at python scripting.
This code takes the system used for calling python methods for Events and expands it to other areas of the game. Modders can attach new python methods to units, promotions, specialists, buildings, civics, civilizations, leaders, religions and more in the XML that will be read from python. This allows players to create small, self-contained python methods that are executed at the appropriate time without complicated checks in python.
With this mod component, you will be able to have specialists give the same benefits as buildings, allow Wonders all the effects of Civics, and virtually any other possible combination. You can have buildings that automatically spawn units in regular intervals, and much much more. Many of the SDK functions that were previously not exposed to python have now been exposed so modders can use the new system to its full potential.
EDIT: I also forgot to mention, I threw in some code to the TechInfos that lets you give announcements to all players who have met the first discoverer of a tech. This has no gameplay consequences, I just liked the idea of having messages appearing like "A Sumerian inventor has become the first person to build a heavier-than-air aircraft!" or something like that.
Changes in v 0.3:
Added code to easily script new Action Buttons based in part on talchas's Action Buttons 2.0
Added CIV4ActionButtonInfos.xml
Updated the Tutorial
Changes in v 0.2:
PythonAIWeights:
Added <PythonAIWeight> tag to UnitInfos, PromotionInfos, BuildingInfos, CivicInfos, ReligionInfos, SpecialistInfos.
Added <iAIWeight> to PromotionInfos, ReligionInfos, and SpecialistInfos
Added new tags to CIV4EventTriggerInfos.xml:
<TriggerImages> - Allows for random, era-specific images be displayed with the event popup
<TriggerSounds> - Allows for random, era-specific sounds to play with the event popup
<PrereqOrEvents> - Prerequisite OR Events allows either/or event prerequisites
<PythonProbability> - Allows modders to have the probability of
<PythonCityTriggerValue> - Gives modders control over what criteria makes a city better or worse for a trigger... allows more fine tuning beyond the existing PythonCanDoCity tag
<PythonPickBuilding> - Select a building based on any criteria rather than letting the computer randomly pick one.
<PythonPickCivic> - Select a civic
<PythonPickBonus> - Select a bonus based on any critiera
<PythonPickReligion> - Select a religion based on any criteria
<PythonPickCorporation> - Select a corporation based on any criteria
<PythonPickCulture> - Select a particular culture (i.e. Player) in a particular city
<PythonPickOtherPlayer> - Select other player based on any criteria rather than being randomly selected by the computer
<PythonPickTech> - Select a tech
<PythonText> - Can create display text dynamically.
Added new tags to CIV4EventInfos.xml
<PythonText> - Dynamic display text for the event popup buttons
<PythonGold> - Dynamically set gold cost/reward
<PythonBestTech> - Choose a tech to be awarded
<PythonBestCivic> - Choose a civic to switch to