leaderhead customization questions

davidlallen

Deity
Joined
Apr 28, 2008
Messages
4,743
Location
California
Starting with The_J's civ spawning code, I would like to have a number of different minor civs appear during the game. I have some questions about how to accomplish the customization of their leaders.

a. I want to have a number of different leader names, like fifty or a hundred so there is little repetition; but I don't want to have a full LeaderHeadInfo section for each name. The only difference is the name, all the stats are identical. I can create the civ with the proper leaderhead. My question is, can I set the name of the leader afterwards? There will be multiple instances of the same leaderhead, and I would like each to have a different name.

b. I can't quite see how to get started on customizing the diplomacy screen. The particular thing I would like to do is give a list of resources, which are the only resources the leaderhead is interested in. Gold and cows are always interesting, for example, but none of the other resources are interesting. Is there access to accept and reject possible trade items off the list in python? If it is only in sdk, where can I go to find that? I can add an xml tag to the resources, if needed, but I'd prefer to do some list processing in python.

I will probably add some other questions as I think of them.
 
Starting with The_J's civ spawning code, I would like to have a number of different minor civs appear during the game. I have some questions about how to accomplish the customization of their leaders.

a. I want to have a number of different leader names, like fifty or a hundred so there is little repetition; but I don't want to have a full LeaderHeadInfo section for each name. The only difference is the name, all the stats are identical. I can create the civ with the proper leaderhead. My question is, can I set the name of the leader afterwards? There will be multiple instances of the same leaderhead, and I would like each to have a different name.

Sounds very very similar to the Dynamics Civs mod. That changes the Nations Description instead of Leaders Description, but the way they work should be identical. It uses some SDK, some python, but no XML; sounds like what you are looking for.

b. I can't quite see how to get started on customizing the diplomacy screen. The particular thing I would like to do is give a list of resources, which are the only resources the leaderhead is interested in. Gold and cows are always interesting, for example, but none of the other resources are interesting. Is there access to accept and reject possible trade items off the list in python? If it is only in sdk, where can I go to find that? I can add an xml tag to the resources, if needed, but I'd prefer to do some list processing in python.

I will probably add some other questions as I think of them.

Look at

Code:
bool CvPlayer::canTradeItem(PlayerTypes eWhoTo, TradeData item, bool bTestDenial) const
{
...
	case TRADE_RESOURCES:
		FAssertMsg(item.m_iData > -1, "iData is expected to be non-negative");

		if (canTradeNetworkWith(eWhoTo))
		{
			if (!GET_TEAM(GET_PLAYER(eWhoTo).getTeam()).isBonusObsolete((BonusTypes) item.m_iData) && !GET_TEAM(getTeam()).isBonusObsolete((BonusTypes) item.m_iData))
			{
				bool bCanTradeAll = (isHuman() || getTeam() == GET_PLAYER(eWhoTo).getTeam() || GET_TEAM(getTeam()).isVassal(GET_PLAYER(eWhoTo).getTeam()));
				if (getNumTradeableBonuses((BonusTypes) item.m_iData) > (bCanTradeAll ? 0 : 1))
				{
					// if (GET_PLAYER(eWhoTo).getNumAvailableBonuses(eBonus) == 0)
					{
						return true;
					}
				}
			}
		}
		break;
...
}
 
Thanks for the pointers! The good news is, Dynamic Civ Names is inside RevDCM, so it is easy to access. The bad news is, this directly changes the *civ* name ("America"), not the leaderhead name ("Abraham Lincoln"). If there is no other lead, I will have to trace out where the LH name is stored, and add a field in CvPlayer "similar" to the way that DCN works.

Regarding trade, the function you point to and also canTradeNetworkWith let me do what I needed. I can now offers cows and sheep and gold to these civs, even if I have not built roads to them.
 
For changing the leader name, looks like Jdog beat you to it


Code:
const wchar* CvPlayer::getName(uint uiForm) const
{
/************************************************************************************************/
/* REVOLUTION_MOD                         01/01/08                                jdog5000      */
/*                                                                                              */
/* dynamic civ names                                                                            */
/************************************************************************************************/
/* original code
	if (GC.getInitCore().getLeaderName(getID(), uiForm).empty() || (GC.getGameINLINE().isMPOption(MPOPTION_ANONYMOUS) && isAlive() && GC.getGameINLINE().getGameState() == GAMESTATE_ON))
	{
		return GC.getLeaderHeadInfo(getLeaderType()).getDescription(uiForm);
	}
	else
	{
		return GC.getInitCore().getLeaderName(getID(), uiForm);
	}
*/
	if( !(m_szName.empty()) )
	{
		return m_szName;
	}
	else if( GC.getInitCore().getLeaderName(getID(), uiForm).empty() || (GC.getGameINLINE().isMPOption(MPOPTION_ANONYMOUS) && isAlive() && GC.getGameINLINE().getGameState() == GAMESTATE_ON))
	{
		return GC.getLeaderHeadInfo(getLeaderType()).getDescription(uiForm);
	}
	else
	{
		return GC.getInitCore().getLeaderName(getID(), uiForm);
	}
/************************************************************************************************/
/* REVOLUTION_MOD                          END                                                  */
/************************************************************************************************/
}

I'm not exactly sure what it is doing, but I know that it is using a new string that was added to CvPlayer, and I would bet that the string is being set via python. Worth a look.
 
You are right, revdcm provides CyPlayer.setName(). It is working! Interestingly, even small places where I copy code from others can have unexpected side effects. When I first copied the code it was not working. But, it turns out I was founding a city, and then setting the LH name to the same as the city. There is a line in the revdcm setName which compares against all current and previous cities, and silently rejects the name change if there is a match. But using a different, non-city name it is working.
 
Top Bottom