A little help with CvTeam::getResearchCost

JediClemente

Prince
Joined
Jan 21, 2004
Messages
446
Location
Madrid, Spain
Hi.

I've looked for this desperately and still no luck.

I want to change CvTeam::getResearchCost for a Rhye's and Fall of Civilization modmod. But nevermind this.

The point is to increase the research cost, if having more than 10 cities, by the base research from the 11th and so on lesser-science cities.

I don't know how to access the city list for the player. I need to sort all base researches from them in a list, sum up from the 11th to the end, and add that number to the final research cost the function returns.

I think I got that idea right. But I searched the SDK and still don't know how to access the cities from CvTeam.

Of course the goal here is to research mainly from each player's 10 better scientific cities, so that empires with a lot of cities don't get an advantage. Rhye achieves this by increasing a 10% of the research cost for each city the player has above 10. But this solution (which isn't mine, BTW) would not overpenalize.

Also, as it only takes into account base research, it would still make sense to build libraries or universities out of the 10 best cities (even though the extra research would be little).

So, can anyone give me any good pointers? :confused:
 
I know nothing about the SDK, but you should note that Team and Players don't always match - by design. (They happen to do in RFC though, but that doesn't help you much.)

So I think you need to start with a Player and not a Team. Because you can make a Player city list yourself - I would be surprised if there is such a thing pre-set. Only then do you need to worry about doing stuff to the Player's Team.
 
In C++ you have to do this stuff manually, basically. This is how it would look like based on CvTeam::changeObsoleteBuildingCount - first find the player whose team it is by looping through all players and comparing IDs, then find his cities by looping through all cities and comparing IDs, then do your stuff. Technically in RFC only you could skip looping through players because in RFC player ID = team ID, but it's safer to do it properly.

Code:
CvCity* pLoopCity;
int iLoop;
int iI;

for (iI = 0; iI < MAX_PLAYERS; iI++)
{
    if (GET_PLAYER((PlayerTypes)iI).isAlive())
    {
        if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
        {
            for (pLoopCity = GET_PLAYER((PlayerTypes)iI).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iI).nextCity(&iLoop))
            {
                ... do your stuff with pLoopCity->getCommerceRate(COMMERCE_RESEARCH) ...
            }
        }
    }
}
 
Top Bottom