World Congress Resolution Triggers

Gazebo

Lord of the Community Patch
Supporter
Joined
Sep 26, 2010
Messages
18,400
Location
Little Rock
Hey all,
So I've been tinkering with new World Congress events in the dll, and I've got one almost finished. The resolution shows up in the congress window, I can choose the city-state I want to target, and it all succeeds, except, well, the influence gain I was aiming for isn't working. Here's the relevant code:

Code:
if (GetEffects()->bRaiseCityStateInfluenceToAlly)
	{
		if (!GET_PLAYER(ePlayer).isMinorCiv())
		{
			for (int iMinor = MAX_MAJOR_CIVS; iMinor < MAX_CIV_PLAYERS; iMinor++)
			{
				PlayerTypes eMinor = (PlayerTypes) iMinor;
				if (GET_PLAYER(eMinor).isAlive())
				{
					if (pLeague->IsMember(eMinor))
					{
						GET_PLAYER(eMinor).GetMinorCivAI()->SetFriendshipWithMajor(ePlayer, 120);
					}
				}
			}
		}
	}

The idea is this:
Code:
<Row Tag="TXT_KEY_RESOLUTION_SOI_HELP">
			<Text>Demand a Sphere of Influence over a Minor Civilization. If successful, your [ICON_INFLUENCE] Influence will become 120 with the Minor Civilization.</Text>
		</Row>

Any ideas why it isn't working?

Note: the 'bRaiseCityStateInfluenceToAlly' is a custom attribute I added, and it is appearing in the SQL database correctly.
 
Updated it, but it still doesn't work:
Code:
if (GetEffects()->bRaiseCityStateInfluenceToAlly)
	{
		if (!GET_PLAYER(eTargetPlayer).isMinorCiv())
		{
			if (GET_PLAYER(eMinor).isAlive()isMinorCiv)
				{
					GET_PLAYER(eMinor).GetMinorCivAI()->SetFriendshipWithMajor(ePlayer, 120);
				}
		}
	}

I think I know why- I haven't identified what eMinor is. How would I go about ensuring that the eMinor here is just the one that was voted on, and not all minor civs?
 
Update to my own work. Definitely a trial and error situation, but I feel like I'm getting close. Here's my addition to CvVotingClases.cpp:

Code:
if (GetEffects()->bRaiseCityStateInfluenceToAlly)
	{
		if (!GET_PLAYER(ePlayer).isMinorCiv())
		{
			if (GET_PLAYER(eTargetPlayer).isAlive())
			{
				GET_PLAYER(eTargetPlayer).GetMinorCivAI()->ChangeFriendshipWithMajor(ePlayer, 120);
			}
		}
	}

And here is the context for the code:
Spoiler :
Code:
void CvActiveResolution::DoEffects(PlayerTypes ePlayer)
{
	CvPlayer* pPlayer = &GET_PLAYER(ePlayer);
	CvAssertMsg(pPlayer != NULL, "Player is null when doing effects of an active resolution. Please send Anton your save file and version.");
	if (pPlayer == NULL) return;

	CvLeague* pLeague = GC.getGame().GetGameLeagues()->GetLeague(GetLeague());
	CvAssertMsg(pLeague != NULL, "League is null when doing effects of an active resolution. Please send Anton your save file and version.");
	if (pLeague == NULL) return;

	// == Proposer Choices ==
	ResolutionDecisionTypes eProposerDecision = GetProposerDecision()->GetType();
	PlayerTypes eTargetPlayer = NO_PLAYER;
	if (eProposerDecision == RESOLUTION_DECISION_ANY_MEMBER ||
		eProposerDecision == RESOLUTION_DECISION_MAJOR_CIV_MEMBER ||
		eProposerDecision == RESOLUTION_DECISION_OTHER_MAJOR_CIV_MEMBER ||
		eProposerDecision == RESOLUTION_DECISION_CITY)
	{
		eTargetPlayer = (PlayerTypes) GetProposerDecision()->GetDecision();
	}
	ResourceTypes eTargetLuxury = NO_RESOURCE;
	if (eProposerDecision == RESOLUTION_DECISION_ANY_LUXURY_RESOURCE)
	{
		CvResourceInfo* pInfo = GC.getResourceInfo((ResourceTypes) GetProposerDecision()->GetDecision());
		if (pInfo && pInfo->getResourceUsage() == RESOURCEUSAGE_LUXURY)
		{
			eTargetLuxury = (ResourceTypes) GetProposerDecision()->GetDecision();
		}
	}
	ReligionTypes eTargetReligion = NO_RELIGION;
	if (eProposerDecision == RESOLUTION_DECISION_RELIGION)
	{
		eTargetReligion = (ReligionTypes) GetProposerDecision()->GetDecision();
	}
	PolicyBranchTypes eTargetIdeology = NO_POLICY_BRANCH_TYPE;
	if (eProposerDecision == RESOLUTION_DECISION_IDEOLOGY)
	{
		eTargetIdeology = (PolicyBranchTypes) GetProposerDecision()->GetDecision();
	}

	// == Voter Choices ==
	ResolutionDecisionTypes eVoterDecision = GetVoterDecision()->GetType();
	PlayerTypes eVotedPlayer = NO_PLAYER;
	if (eVoterDecision == RESOLUTION_DECISION_ANY_MEMBER ||
		eVoterDecision == RESOLUTION_DECISION_MAJOR_CIV_MEMBER ||
		eVoterDecision == RESOLUTION_DECISION_OTHER_MAJOR_CIV_MEMBER
		)
	{
		eVotedPlayer = (PlayerTypes) GetVoterDecision()->GetDecision();
	}

	// == One Time Effects ==
	if (GetEffects()->bDiplomaticVictory)
	{
		CvAssertMsg(eTargetPlayer != NO_PLAYER || eVotedPlayer != NO_PLAYER, "Diplomatic Victory voted for NO_PLAYER. Please send Anton your save file and version.");
		CvAssertMsg(eTargetPlayer == NO_PLAYER || eVotedPlayer == NO_PLAYER, "Ambiguous target when setting Diplomatic Victory. Please send Anton your save file and version");
		if (ePlayer == eVotedPlayer || ePlayer == eTargetPlayer)
		{
			GC.getGame().GetGameLeagues()->SetDiplomaticVictor(ePlayer);
		}
	}
	if (GetEffects()->bChangeLeagueHost)
	{
		CvAssertMsg(eTargetPlayer != NO_PLAYER || eVotedPlayer != NO_PLAYER, "Changing host to NO_PLAYER. Please send Anton your save file and version.");
		CvAssertMsg(eTargetPlayer == NO_PLAYER || eVotedPlayer == NO_PLAYER, "Ambiguous target when changing host. Please send Anton your save file and version");
		if (ePlayer == eVotedPlayer || ePlayer == eTargetPlayer)
		{
			pLeague->SetHostMember(ePlayer);
		}
	}
	if (GetEffects()->iOneTimeGold != 0)
	{
		pPlayer->GetTreasury()->ChangeGold(GetEffects()->iOneTimeGold);
	}
	if (GetEffects()->iOneTimeGoldPercent != 0)
	{
		int iGold = pPlayer->GetTreasury()->GetGold();
		int iChange = (iGold * GetEffects()->iOneTimeGoldPercent) / 100;
		pPlayer->GetTreasury()->ChangeGold(iChange);
	}
	if (GetEffects()->bRaiseCityStateInfluenceToNeutral)
	{
		if (!GET_PLAYER(ePlayer).isMinorCiv())
		{
			int iNeutral = GC.getMINOR_FRIENDSHIP_ANCHOR_DEFAULT();
			for (int iMinor = MAX_MAJOR_CIVS; iMinor < MAX_CIV_PLAYERS; iMinor++)
			{
				PlayerTypes eMinor = (PlayerTypes) iMinor;
				if (GET_PLAYER(eMinor).isAlive() && GET_PLAYER(eMinor).GetMinorCivAI()->GetBaseFriendshipWithMajor(ePlayer) < iNeutral)
				{
					if (pLeague->IsMember(eMinor))
					{
						GET_PLAYER(eMinor).GetMinorCivAI()->SetFriendshipWithMajor(ePlayer, iNeutral);
					}
				}
			}
		}
	}
	if (GetEffects()->bRaiseCityStateInfluenceToAlly)
	{
		if (!GET_PLAYER(ePlayer).isMinorCiv())
		{
			if (GET_PLAYER(eTargetPlayer).isAlive())
			{
				GET_PLAYER(eTargetPlayer).GetMinorCivAI()->ChangeFriendshipWithMajor(ePlayer, 120);
			}
		}
	}

Any thoughts on this? It seems pretty simple, though I may be using eplayer, etargetplayer etc. incorrectly.
 
Yet another update!

It works!! Sweet thrilla of manila it works. Here's the final code:

Code:
if (GetEffects()->bRaiseCityStateInfluenceToAlly)
	{
		if (!GET_PLAYER(ePlayer).isMinorCiv())
		{
			if (GET_PLAYER(eTargetPlayer).isMinorCiv() && GET_PLAYER(eTargetPlayer).isAlive())
			{
				if (pLeague->IsMember(eTargetPlayer))
				{
					GET_PLAYER(eTargetPlayer).GetMinorCivAI()->SetFriendshipWithMajor(ePlayer, 150);
				}
			}
		}
	}

There are more tweaks that I can explain later, but this is the first on many new World Congress Resolutions I plan on making.
 
Back
Top Bottom