int CvDiplomacyAI::GetVictoryDisputeLevelScore(PlayerTypes ePlayer) const
{
int iOpinionWeight = 0;
// Don't stack!
if ((int)GetVictoryBlockLevel(ePlayer) > (int)GetVictoryDisputeLevel(ePlayer))
return 0;
switch (GetVictoryDisputeLevel(ePlayer))
{
case DISPUTE_LEVEL_FIERCE:
iOpinionWeight += /*40*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_FIERCE);
break;
case DISPUTE_LEVEL_STRONG:
iOpinionWeight += /*30*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_STRONG);
break;
case DISPUTE_LEVEL_WEAK:
iOpinionWeight += /*20*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_WEAK);
break;
case DISPUTE_LEVEL_NONE:
iOpinionWeight = /*0*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_NONE);
break;
}
if (iOpinionWeight > 0)
{
iOpinionWeight += GET_PLAYER(ePlayer).GetCurrentEra() * /*4*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_PER_ERA);
iOpinionWeight *= GetVictoryCompetitiveness();
iOpinionWeight *= GET_PLAYER(ePlayer).isHuman() ? GET_PLAYER(ePlayer).getHandicapInfo().getVictoryDisputePercent() : GC.getGame().getHandicapInfo().getVictoryDisputePercent();
iOpinionWeight /= 250;
}
return iOpinionWeight;
}
int CvDiplomacyAI::GetVictoryBlockLevelScore(PlayerTypes ePlayer) const
{
int iOpinionWeight = 0;
// Don't stack!
if ((int)GetVictoryDisputeLevel(ePlayer) >= (int)GetVictoryBlockLevel(ePlayer))
return 0;
switch (GetVictoryBlockLevel(ePlayer))
{
case BLOCK_LEVEL_FIERCE:
iOpinionWeight += /*40*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_BLOCK_FIERCE);
break;
case BLOCK_LEVEL_STRONG:
iOpinionWeight += /*30*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_BLOCK_STRONG);
break;
case BLOCK_LEVEL_WEAK:
iOpinionWeight += /*20*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_BLOCK_WEAK);
break;
case BLOCK_LEVEL_NONE:
iOpinionWeight = /*0*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_BLOCK_NONE);
break;
}
if (iOpinionWeight > 0)
{
iOpinionWeight += GET_PLAYER(ePlayer).GetCurrentEra() * /*4*/ GD_INT_GET(OPINION_WEIGHT_VICTORY_BLOCK_PER_ERA);
iOpinionWeight *= GetVictoryCompetitiveness();
iOpinionWeight *= GET_PLAYER(ePlayer).isHuman() ? GET_PLAYER(ePlayer).getHandicapInfo().getVictoryBlockPercent() : GC.getGame().getHandicapInfo().getVictoryBlockPercent();
iOpinionWeight /= 500;
}
return iOpinionWeight;
}
(...)
/// Updates what our level of Dispute is with all players over Victory
void CvDiplomacyAI::DoUpdateVictoryDisputeLevels()
{
if (GetPlayer()->isHuman())
return;
//Don't do this at the start of the game.
if (GC.getGame().getGameTurn() <= 150)
return;
AIGrandStrategyTypes eMyGrandStrategy = GetPlayer()->GetGrandStrategyAI()->GetActiveGrandStrategy();
bool bDontCare = !IsCompetingForVictory() || eMyGrandStrategy == NO_AIGRANDSTRATEGY || GetPlayer()->GetGrandStrategyAI()->GetGrandStrategyPriority(eMyGrandStrategy) <= 500;
int iGameEra = GC.getGame().getCurrentEra();
if (bDontCare)
{
for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
{
PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop;
SetVictoryDisputeLevel(eLoopPlayer, DISPUTE_LEVEL_NONE);
}
return;
}
// Loop through all (valid) Players
for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
{
PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop;
if (IsPlayerValid(eLoopPlayer) && GET_PLAYER(eLoopPlayer).isMajorCiv())
{
AIGrandStrategyTypes eTheirGrandStrategy = GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategy(eLoopPlayer);
if (eTheirGrandStrategy == NO_AIGRANDSTRATEGY)
{
SetVictoryDisputeLevel(eLoopPlayer, DISPUTE_LEVEL_NONE);
continue;
}
if (!IsAtWar(eLoopPlayer) && GetCivOpinion(eLoopPlayer) == CIV_OPINION_ALLY)
{
SetVictoryDisputeLevel(eLoopPlayer, DISPUTE_LEVEL_NONE);
continue;
}
DisputeLevelTypes eDisputeLevel = DISPUTE_LEVEL_NONE;
int iVictoryDisputeWeight = 0;
// Does the other player's (estimated) Grand Strategy match our own?
if (GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategy(eLoopPlayer) == eMyGrandStrategy)
{
switch (GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategyConfidence(eLoopPlayer))
{
case GUESS_CONFIDENCE_POSITIVE:
iVictoryDisputeWeight = /*25*/ GD_INT_GET(VICTORY_DISPUTE_GRAND_STRATEGY_MATCH_POSITIVE);
break;
case GUESS_CONFIDENCE_LIKELY:
iVictoryDisputeWeight = /*15*/ GD_INT_GET(VICTORY_DISPUTE_GRAND_STRATEGY_MATCH_LIKELY);
break;
case GUESS_CONFIDENCE_UNSURE:
iVictoryDisputeWeight = /*5*/ GD_INT_GET(VICTORY_DISPUTE_GRAND_STRATEGY_MATCH_UNSURE);
break;
}
}
// Reduce competitiveness in earlier eras
iVictoryDisputeWeight -= (6 - iGameEra);
if (iVictoryDisputeWeight > 0)
{
int DifficultyModifier = GET_PLAYER(eLoopPlayer).isHuman() ? GET_PLAYER(eLoopPlayer).getHandicapInfo().getVictoryDisputeMod() : GC.getGame().getHandicapInfo().getVictoryDisputeMod();
// Add weight for Player's competitiveness (1 - 10)
iVictoryDisputeWeight *= GetVictoryCompetitiveness();
iVictoryDisputeWeight += DifficultyModifier;
// Now see what our new Dispute Level should be
if (iVictoryDisputeWeight >= /*80*/ GD_INT_GET(VICTORY_DISPUTE_FIERCE_THRESHOLD))
eDisputeLevel = DISPUTE_LEVEL_FIERCE;
else if (iVictoryDisputeWeight >= /*50*/ GD_INT_GET(VICTORY_DISPUTE_STRONG_THRESHOLD))
eDisputeLevel = DISPUTE_LEVEL_STRONG;
else if (iVictoryDisputeWeight >= /*30*/ GD_INT_GET(VICTORY_DISPUTE_WEAK_THRESHOLD))
eDisputeLevel = DISPUTE_LEVEL_WEAK;
}
// Actually set the Level
SetVictoryDisputeLevel(eLoopPlayer, eDisputeLevel);
}
else
{
SetVictoryDisputeLevel(eLoopPlayer, DISPUTE_LEVEL_NONE);
}
}
}
/// Updates what our level of Dispute is with all players over Victory
void CvDiplomacyAI::DoUpdateVictoryBlockLevels()
{
if (GetPlayer()->isHuman())
return;
//Don't do this at the start of the game.
if (GC.getGame().getGameTurn() <= 150)
return;
AIGrandStrategyTypes eMyGrandStrategy = GetPlayer()->GetGrandStrategyAI()->GetActiveGrandStrategy();
bool bDontCare = !IsCompetingForVictory() || eMyGrandStrategy == NO_AIGRANDSTRATEGY || GetPlayer()->GetGrandStrategyAI()->GetGrandStrategyPriority(eMyGrandStrategy) <= 500;
int iGameEra = GC.getGame().getCurrentEra();
if (bDontCare)
{
for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
{
PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop;
SetVictoryBlockLevel(eLoopPlayer, BLOCK_LEVEL_NONE);
}
return;
}
AIGrandStrategyTypes eConquestGrandStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CONQUEST");
AIGrandStrategyTypes eCultureGrandStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_CULTURE");
AIGrandStrategyTypes eUNGrandStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_UNITED_NATIONS");
AIGrandStrategyTypes eSpaceshipGrandStrategy = (AIGrandStrategyTypes) GC.getInfoTypeForString("AIGRANDSTRATEGY_SPACESHIP");
// Loop through all (valid) Players
for (int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)
{
PlayerTypes eLoopPlayer = (PlayerTypes) iPlayerLoop;
if (IsPlayerValid(eLoopPlayer) && GET_PLAYER(eLoopPlayer).isMajorCiv())
{
AIGrandStrategyTypes eTheirGrandStrategy = GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategy(eLoopPlayer);
if (eTheirGrandStrategy == NO_AIGRANDSTRATEGY)
{
SetVictoryBlockLevel(eLoopPlayer, BLOCK_LEVEL_NONE);
continue;
}
if (!IsAtWar(eLoopPlayer) && GetCivOpinion(eLoopPlayer) >= CIV_OPINION_FRIEND)
{
SetVictoryBlockLevel(eLoopPlayer, BLOCK_LEVEL_NONE);
continue;
}
BlockLevelTypes eBlockLevel = BLOCK_LEVEL_NONE;
int iVictoryBlockWeight = 0;
CvLeague* pLeague = GC.getGame().GetGameLeagues()->GetActiveLeague();
bool bLeagueCompetitor = false;
bool bSpaceRace = false;
bool bCulture = false;
bool bWar = false;
if (pLeague != NULL)
{
int iVotes = pLeague->CalculateStartingVotesForMember(eLoopPlayer);
int iNeededVotes = GC.getGame().GetVotesNeededForDiploVictory();
if (iNeededVotes > 0)
{
// 33% there? Close!
if (iVotes >= (iNeededVotes / 3))
{
bLeagueCompetitor = true;
}
}
}
int iProjectCount = GET_TEAM(GET_PLAYER(eLoopPlayer).getTeam()).GetSSProjectCount();
if (iProjectCount > 0)
{
bSpaceRace = true;
iVictoryBlockWeight += iProjectCount * 10;
}
else
{
int iTheirTechNum = GET_TEAM(GET_PLAYER(eLoopPlayer).getTeam()).GetTeamTechs()->GetNumTechsKnown();
int iNumOtherPlayers = 0;
int iNumPlayersAheadInTech = 0;
for (int iOtherPlayerLoop = 0; iOtherPlayerLoop < MAX_MAJOR_CIVS; iOtherPlayerLoop++)
{
PlayerTypes eOtherPlayer = (PlayerTypes) iOtherPlayerLoop;
if (GET_PLAYER(eOtherPlayer).getTeam() == GET_PLAYER(eLoopPlayer).getTeam())
continue;
if (!IsPlayerValid(eOtherPlayer))
continue;
iNumOtherPlayers++;
int iNumTechs = GET_TEAM(GET_PLAYER(eOtherPlayer).getTeam()).GetTeamTechs()->GetNumTechsKnown();
if (iTheirTechNum > iNumTechs)
{
iNumPlayersAheadInTech++;
}
}
if (iNumPlayersAheadInTech >= iNumOtherPlayers)
{
bSpaceRace = true;
}
if (GetTechBlockLevel(eLoopPlayer) >= BLOCK_LEVEL_STRONG)
{
bSpaceRace = true;
}
}
if (GetWarmongerThreat(eLoopPlayer) >= THREAT_SEVERE || (GetPlayerNumMajorsConquered(eLoopPlayer) >= (GC.getGame().countMajorCivsEverAlive() / 3)))
{
bWar = true;
}
if (IsPlayerWonderSpammer(eLoopPlayer) || GET_PLAYER(eLoopPlayer).GetCulture()->GetNumCivsInfluentialOn() > 1)
{
bCulture = true;
}
else if (GetPolicyBlockLevel(eLoopPlayer) >= BLOCK_LEVEL_STRONG)
{
bCulture = true;
}
if ((eConquestGrandStrategy == eTheirGrandStrategy) && !bWar)
{
SetVictoryBlockLevel(eLoopPlayer, BLOCK_LEVEL_NONE);
continue;
}
if ((eCultureGrandStrategy == eTheirGrandStrategy) && !bCulture)
{
SetVictoryBlockLevel(eLoopPlayer, BLOCK_LEVEL_NONE);
continue;
}
if ((eUNGrandStrategy == eTheirGrandStrategy) && !bLeagueCompetitor)
{
SetVictoryBlockLevel(eLoopPlayer, BLOCK_LEVEL_NONE);
continue;
}
if ((eSpaceshipGrandStrategy == eTheirGrandStrategy) && !bSpaceRace)
{
SetVictoryBlockLevel(eLoopPlayer, BLOCK_LEVEL_NONE);
continue;
}
// Does the other player's (estimated) Grand Strategy differ from ours? If so, how positive are we about this?
if (eTheirGrandStrategy != eMyGrandStrategy)
{
switch (GetPlayer()->GetGrandStrategyAI()->GetGuessOtherPlayerActiveGrandStrategyConfidence(eLoopPlayer))
{
case GUESS_CONFIDENCE_POSITIVE:
iVictoryBlockWeight += /*20*/ GD_INT_GET(VICTORY_BLOCK_GRAND_STRATEGY_DIFFERENCE_POSITIVE);
break;
case GUESS_CONFIDENCE_LIKELY:
iVictoryBlockWeight += /*15*/ GD_INT_GET(VICTORY_BLOCK_GRAND_STRATEGY_DIFFERENCE_LIKELY);
break;
case GUESS_CONFIDENCE_UNSURE:
iVictoryBlockWeight += /*5*/ GD_INT_GET(VICTORY_BLOCK_GRAND_STRATEGY_DIFFERENCE_UNSURE);
break;
}
}
if (iVictoryBlockWeight > 0)
{
int DifficultyModifier = GET_PLAYER(eLoopPlayer).isHuman() ? GET_PLAYER(eLoopPlayer).getHandicapInfo().getVictoryBlockMod() : GC.getGame().getHandicapInfo().getVictoryBlockMod();
// Add weight for Player's victory competitiveness, meanness and diplobalance desires (1 - 10)
// Average of each is 5, and era goes up by one throughout game.
iVictoryBlockWeight += GetVictoryCompetitiveness() + GetMeanness() + GetDiploBalance() + iGameEra;
iVictoryBlockWeight += DifficultyModifier;
// Now see what our new Block Level should be
if (iVictoryBlockWeight >= /*40*/ GD_INT_GET(VICTORY_BLOCK_FIERCE_THRESHOLD))
{
eBlockLevel = BLOCK_LEVEL_FIERCE;
}
else if (iVictoryBlockWeight >= /*30*/ GD_INT_GET(VICTORY_BLOCK_STRONG_THRESHOLD))
{
eBlockLevel = BLOCK_LEVEL_STRONG;
}
else if (iVictoryBlockWeight >= /*20*/ GD_INT_GET(VICTORY_BLOCK_WEAK_THRESHOLD))
{
eBlockLevel = BLOCK_LEVEL_WEAK;
}
}
// Actually set the new level
SetVictoryBlockLevel(eLoopPlayer, eBlockLevel);
}
else
{
SetVictoryBlockLevel(eLoopPlayer, BLOCK_LEVEL_NONE);
}
}
}