Trying to make Apo Palace and UN elections choose from more than 2 candidates

DutchTed

Chieftain
Joined
Feb 23, 2009
Messages
11
As the title says, my aim is to increase the number of candidates offered by the game when choosing leaders for the AP and UN. I've had a look through the code and my assumptions are made below. (Please feel free to correct me if I have made a mistake).

I have looked in the VoteInfo.xml file and can see that for VOTE_POPE and VOTE_SECRETARY_GENERAL, the value of bSecretaryGeneral is set to 1 so both these voteInfo types will set a secretary general (or pope) when invoked.

Looking at CvGame.cpp in the doVoteSelection() procedure I can see that there is a timer which is initialised by the value of DIPLO_VOTE_SECRETARY_GENERAL_INTERVAL and decremented each turn until it is zero. At zero the game compares voteTypes to make sure that they match the respective voteInfo requirements, ie voteType is DIPLOVOTE_POPE and voteInfo is VOTE_POPE.

A VoteSelectionSubData struct is now initialised and AddVoteTriggered is then called passing the VoteSource and VoteSelectionSubData structs as parameters.

:crazyeye:This is where my confusion starts. At no time has the game set which two players are to be selected as candidates.:crazyeye:

If we then move to the addVoteTriggered function, these parameters are assigned to a VoteTriggeredData struct and the game then iterates through MAX_CIV_PLAYERS checking to see if each player can vote and if that player is human, it then provides them with a popup. If they are AI then the AI player casts its vote using the AI_diploVote function.

My two questions are:

  • How does the game provide the choices to the player
  • Where does the AI choose between the two players when voting for a leader (I assumed AI_chooseElection but since the game uses the word 'election' to mean a choice in general, things aren't always as they appear)

I was hoping to alter the popup to provide more leaders (in a 64 player game I find a choice of 2 leaders a bit silly) and also to get the AI to make a choice between those leaders using their attitude towards them.

Thanks in advance for any advice you can offer :)

~Ted
 
The pop up will be a python function to set up the buttons and list who to vote for. Check there to see what it is calling; it should direct you to where in the SDK the choices are being picked, or it may very well be done in the interface through python (of course if the choices are made in Python Entirely I'd be curios how the AI decision is made in terms of who to vote for, but I know davidallen has written some AI logic entirely in Python, so it's still possible).
 
  • How does the game provide the choices to the player
  • Where does the AI choose between the two players when voting for a leader (I assumed AI_chooseElection but since the game uses the word 'election' to mean a choice in general, things aren't always as they appear)

the second is done in CvPlayerAI::AI_diploVote

however, you could also just change the TEAM_VOTE_MIN_CANDIDATES value in the GlobalDefines.xml to a higher number than 2. but i think that that would also affect the diplomatic victory vote...
 
however, you could also just change the TEAM_VOTE_MIN_CANDIDATES value in the GlobalDefines.xml to a higher number than 2. but i think that that would also affect the diplomatic victory vote...

Thanks, evertebrate it worked perfectly. I changed the value to 6 and made the iPopulationThreshold for VOTE_POPE and VOTE_SECRETARY_GENERAL (in Civ4VoteInfo.xml) to 15 so that the election always finds a winner.

I guess that will teach me to look in the global XML settings before trying to write code which modifies constants. :mischief:
 
Back
Top Bottom