event modding - simple help needed!

Spillsandstains

Warlord
Joined
Mar 31, 2008
Messages
273
hi chickens/bunnies

trying to mod events but utter fail due to almost total inability to code. I'm sure it's been done before but -

how do you identify a civ's leader by, say, their traits or favourite religion? for an event that only affects a charismatically - led civ, for example

also, how do you identify a civ's artstyle type in an event?

there's loads more but I haven't had any coffee yet. would be great to have some help on this, and some randomeventinterface.py example would be great too so I could study them for ideas
 
The questions are not asked very well because it's not clear what you already have. I can give a few pointers, but I can't give a "do this" without spending time on doing some research on my own. I'm not going to answer event specific issues because I'm not very familiar with those. However I can tell how you in general fetch data, which applies to events as well as all other python files.

First of all, be aware of the python function list: http://civ4bug.sourceforge.net/PythonAPI/index.html

Those are also written in the DLL source code in files called Cy*Interface.cpp. This location is useful if you need mod specific functions (I don't think you need that for your questions).

Example: you want to get the artstyle for a specific player. In CyPlayer in the python API, it says
Code:
ArtStyleType getArtStyleType ()
int () - Returns the ArtStyleType for this player (e.g. European)
Assuming you already have the player as a variable called player, you get the artstyle with this line:
Code:
artstyle = player.getArtStyleType()

Likewise CyPlayer has
Code:
LeaderHeadType getLeaderType ()
int ()

CyGlobalContents has
Code:
CvLeaderHeadInfo getLeaderHeadInfo (INT i)
(LeaderHeadID) - CvInfo for LeaderHeadID
This means you can write
Code:
leader = gc.getLeaderHeadInfo(player.getLeaderType())

You can then use leader to access LeaderHead xml data (http://civ4bug.sourceforge.net/PythonAPI/AllClasses.html#CvLeaderHeadInfo), like
Code:
if leader.hasTrait(5):

Instead of a fixed number like 5, you should use gc.getDefineINT("TRAIT_CHARISMATIC") or whatever string you want. What this function does is that it converts a text string into what index that type has in xml, which is then used to look up the xml data at that index.

I hope I wrote this correctly. I mainly work in pure C++ (read: the DLL). Doing the same in python is often sort of the same thing, but not always.
 
Back
Top Bottom