Beginner Questions for a ModMod

Ri-Hatz

Chieftain
Joined
Jun 23, 2008
Messages
93
My first Mod is in developement.
Unfortunately I'm still new to the code, so help here is very welcome.

All I need to know is the following:
(All in the SDK)

1. Check how many cities the active player has.
(there must be an existing sdk function, i guess)

2. Those buttons in the game for upgrading units show you a price. Where's the code for that?
(I found the calculation for the price but not where the price shows during the game)

thanks in advance
RiHatz
 
Everything that displays in the game is in CvGameText.cpp (unless it is in CvDLLWidgetData.cpp, but that typically refers to something in the other).

Number of cities owned, or specifically which cities?
CvPlayer::getNumCities()
Or
CvPlayer::firstCity
&
CvPlayer::nextCity


So for the latter, you would loop like:
for (CvCity* pCity = firstCity(&iLoop); NULL != pCity; pCity = nextCity(&iLoop))

(this loop is from inside CvPlayer, so doesn't have to refer to a specific player)
 
thanks! It works allready as planed. This makes me so happy:)
At least the number of cities part.

The CvGameTextMgr.cpp is so huge. I scrolled through there but cant find the texts for the buttons.

Im especially interested in the found city button the settlers have.
 
So you want to add more text to the hint for the "Found City" button then? Buttons wind up being an interesting beast in most cases. What you are seeking there would be a mission (one of the main areas where CvDLLWidgetData doesn't call out to CvGameTextMgr).

The function you want is CvDLLWidgetData::parseActionHelp, which is HUGE, so search for MISSION_FOUND. It currently only gives a text output for mouseover if you can NOT found a city, and leaves the key for when you CAN found a city to whatever is in the <Help> field only. But you should easily be able to do whatever you want with it, the main catch was just figuring out where to look (as is always the case. Quick hint on that, start with the XML field name, that leads you to CvInfos.cpp and points to a variable, which leads to a function, which will get called somewhere else and either point you at the text key, or a new function/variable to start tracing as well. It takes a while to get used to, but eventually you won't need a map, compass, and divine intervention to find your way through ;))

For finding text keys you can switch it up slightly and search in GameText.xml files for the words you want to change and see what the txt_key actually is, then find where it is called from. Doesn't always work so well as normally these are called by XML fields like Help or Civilopedia. Then you are stuck searching the DLL for cases of getHelp() or getCivilopedia() (of which there are hundreds)
 
Sorry, the <help> field is in the XML. In the SDK it is called using .getHelp(). I cannot recall if that particular call is before or after the NOT found text key, but before seems to make sense. You are looking for the call to be made on a MissionType object. Though in reality it doesn't matter too much where that call is since you only want to add information to the MISSION_FOUND case, I was just rambling extra information for the sake of looking it up myself. All you should need to do is include your extra information in the NOT FOUND case, or an else statement after that for the case of CAN FOUND.
 
Back
Top Bottom