Smilingrogue
Raging Barbarian
Thank you for the explanation, Damerell.
A unit is healed one-half the damage it has taken when promoted. (Additionally, it might then receive the normal benefits from promotions such as March).
Oh haha. My bad! Thanks!!
int CvPlayer::getSingleCivicUpkeep(CivicTypes eCivic, bool bIgnoreAnarchy) const
{
int iUpkeep;
if (eCivic == NO_CIVIC)
{
return 0;
}
if (isNoCivicUpkeep((CivicOptionTypes)(GC.getCivicInfo(eCivic).getCivicOptionType())))
{
return 0;
}
if (GC.getCivicInfo(eCivic).getUpkeep() == NO_UPKEEP)
{
return 0;
}
if (!bIgnoreAnarchy)
{
if (isAnarchy())
{
return 0;
}
}
iUpkeep = 0;
iUpkeep += ((std::max(0, (getTotalPopulation() + GC.getDefineINT("UPKEEP_POPULATION_OFFSET") - GC.getCivicInfo(eCivic).getCivicOptionType())) * GC.getUpkeepInfo((UpkeepTypes)(GC.getCivicInfo(eCivic).getUpkeep())).getPopulationPercent()) / 100);
iUpkeep += ((std::max(0, (getNumCities() + GC.getDefineINT("UPKEEP_CITY_OFFSET") + GC.getCivicInfo(eCivic).getCivicOptionType() - (GC.getNumCivicOptionInfos() / 2))) * GC.getUpkeepInfo((UpkeepTypes)(GC.getCivicInfo(eCivic).getUpkeep())).getCityPercent()) / 100);
iUpkeep *= std::max(0, (getUpkeepModifier() + 100));
iUpkeep /= 100;
iUpkeep *= GC.getHandicapInfo(getHandicapType()).getCivicUpkeepPercent();
iUpkeep /= 100;
if (!isHuman() && !isBarbarian())
{
iUpkeep *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAICivicUpkeepPercent();
iUpkeep /= 100;
iUpkeep *= std::max(0, ((GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIPerEraModifier() * getCurrentEra()) + 100));
iUpkeep /= 100;
}
return std::max(0, iUpkeep);
}
Government civics upkeep:
[D * [ O * ( [ P * (N-8) ] + [ C * (M-1) ] ) ] ]
Legal civics upkeep:
[D * [ O * ( [ P * (N-9) ] + [ C * M ] ) ] ]
Labor civics upkeep:
[D * [ O * ( [ P * (N-10) ] + [ C * (M+1) ] ) ] ]
Economy civics upkeep:
[D * [ O * ( [ P * (N-11) ] + [ C * (M+2) ] ) ] ]
Religion civics upkeep:
[D * [ O * ( [ P * (N-12) ] + [ C * (M+3) ] ) ] ]
Can the values P and C be found somewhere in the xml files? Or are they hardcoded?
Edit: I suppose they wanted to weigh population and the number of cities differently, P only influencing the population part and C only influencing the number of cities part.
void CvPlayerAI::AI_doSplit()
{
PROFILE_FUNC();
if (!canSplitEmpire())
{
return;
}
int iLoop;
std::map<int, int> mapAreaValues;
for (CvArea* pLoopArea = GC.getMapINLINE().firstArea(&iLoop); pLoopArea != NULL; pLoopArea = GC.getMapINLINE().nextArea(&iLoop))
{
mapAreaValues[pLoopArea->getID()] = 0;
}
for (CvCity* pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
{
mapAreaValues[pLoopCity->area()->getID()] += pLoopCity->AI_cityValue();
}
std::map<int, int>::iterator it;
for (it = mapAreaValues.begin(); it != mapAreaValues.end(); ++it)
{
if (it->second < 0)
{
int iAreaId = it->first;
if (canSplitArea(iAreaId))
{
splitEmpire(iAreaId);
for (CvUnit* pUnit = firstUnit(&iLoop); pUnit != NULL; pUnit = nextUnit(&iLoop))
{
if (pUnit->area()->getID() == iAreaId)
{
TeamTypes ePlotTeam = pUnit->plot()->getTeam();
if (NO_TEAM != ePlotTeam)
{
CvTeam& kPlotTeam = GET_TEAM(ePlotTeam);
if (kPlotTeam.isVassal(getTeam()) && GET_TEAM(getTeam()).isParent(ePlotTeam))
{
pUnit->gift();
}
}
}
}
break;
}
}
}
}
mapAreaValues[pLoopCity->area()->getID()] += pLoopCity->[COLOR="SeaGreen"][B]AI_cityValue()[/B][/COLOR];
if (kPlotTeam.isVassal(getTeam()) && GET_TEAM(getTeam()).isParent(ePlotTeam))
{
pUnit->gift();
}
And then you can't get less pops than cities, ZZZ.
That's ZZZ's empire after conquering the world.
I know, I was being sarcastic, but serious. x]
But yes my empire does look like that, except for my Capital will be 16-20 pop. But that is the only non 2 pop city I will have.
No Heroic Epic City?
============================================
============================================
Knowing my semi-articles are boring as hell, I put some friendly images about AI creating colonies.
Then he must conquer fast or raze everything otherwise war cash won't sustain his empire long.
bool CvPlayerAI::AI_isFinancialTrouble() const
{
//if (getCommercePercent(COMMERCE_GOLD) > 50)
{
int iNetCommerce = 1 + getCommerceRate(COMMERCE_GOLD) + getCommerceRate(COMMERCE_RESEARCH) + std::max(0, getGoldPerTurn());
int iNetExpenses = calculateInflatedCosts() + std::min(0, getGoldPerTurn());
int iFundedPercent = (100 * (iNetCommerce - iNetExpenses)) / std::max(1, iNetCommerce);
int iSafePercent = 40;
if (AI_avoidScience()) //Mostly when AI is going culture or future techs
{
iSafePercent -= 8;
}
if (GET_TEAM(getTeam()).getAnyWarPlanCount(true)) //Under WHEOOH or a true active war state
{ //Minor civ eternal war count is ignored
iSafePercent -= 12;
}
if (isCurrentResearchRepeat()) //Only applied for future techs
{
iSafePercent -= 10;
}
if (iFundedPercent < iSafePercent)
{
return true;
}
}
return false;
}
=====================================================================================
=====================================================================================
bool CvPlayer::isCurrentResearchRepeat() const
{
TechTypes eCurrentResearch;
eCurrentResearch = getCurrentResearch();
if (eCurrentResearch == NO_TECH)
{
return false;
}
return GC.getTechInfo(eCurrentResearch).isRepeat(); //Only Future Techs return "TRUE" in XML
}
======================================================================================
======================================================================================
int CvTeam::getAnyWarPlanCount(bool bIgnoreMinors) const
{
int iCount;
int iI;
iCount = 0;
for (iI = 0; iI < MAX_CIV_TEAMS; iI++)
{
if (GET_TEAM((TeamTypes)iI).isAlive())
{
if (!bIgnoreMinors || !(GET_TEAM((TeamTypes)iI).isMinorCiv())) //Minor civ ignored!
{
if (AI_getWarPlan((TeamTypes)iI) != NO_WARPLAN)
{
FAssert(iI != getID());
iCount++;
}
}
}
}
FAssert(iCount >= getAtWarCount(bIgnoreMinors));
return iCount;
}
=======================================================================================
=======================================================================================
WarPlanTypes CvTeamAI::AI_getWarPlan(TeamTypes eIndex) const
{
FAssert(eIndex >= 0);
FAssert(eIndex < MAX_TEAMS);
FAssert(eIndex != getID() || m_aeWarPlan[eIndex] == NO_WARPLAN);
return m_aeWarPlan[eIndex]; //To clarify, it's either a WHEOOH or an active war
}
bool CvTeamAI::AI_isChosenWar(TeamTypes eIndex) const
{
switch (AI_getWarPlan(eIndex)) //The function is irrelevant, but shows possible war plans.
{
case WARPLAN_ATTACKED_RECENT:
case WARPLAN_ATTACKED:
return false;
break;
case WARPLAN_PREPARING_LIMITED:
case WARPLAN_PREPARING_TOTAL:
case WARPLAN_LIMITED:
case WARPLAN_TOTAL:
case WARPLAN_DOGPILE:
return true;
break;
}
return false;
}
========================================================================
========================================================================
bool CvPlayerAI::AI_avoidScience() const
{
if (AI_isDoStrategy(AI_STRATEGY_CULTURE4)) //Last level in AI masterplan for culture
{
return true;
}
if (isCurrentResearchRepeat()) //Only for future techs
{
return true;
}
if (isNoResearchAvailable()) //Always ignored in the unmodded game
{
return true;
}
return false;
}
====================================================================
====================================================================
bool CvPlayer::isNoResearchAvailable() const //Never encountered as true unless some mods without
{ //future techs
int iI;
if (getCurrentResearch() != NO_TECH)
{
return false;
}
for (iI = 0; iI < GC.getNumTechInfos(); iI++)
{
if (canResearch((TechTypes)iI))
{
return false;
}
}
return true;
}
int CvPlayerAI::AI_getTradeAttitude(PlayerTypes ePlayer) const
{
// XXX human only?
return range(((AI_getPeacetimeGrantValue(ePlayer) + std::max(0, (AI_getPeacetimeTradeValue(ePlayer) - GET_PLAYER(ePlayer).AI_getPeacetimeTradeValue(getID())))) / ((GET_TEAM(getTeam()).AI_getHasMetCounter(GET_PLAYER(ePlayer).getTeam()) + 1) * 5)), 0, 4);
}
void CvDeal::doTurn()
{
int iValue;
if (!isPeaceDeal())
{
if (getLengthSecondTrades() > 0)
{
iValue = (GET_PLAYER(getFirstPlayer()).AI_dealVal(getSecondPlayer(), getSecondTrades()) / GC.getDefineINT("PEACE_TREATY_LENGTH"));
if (getLengthFirstTrades() > 0)
{
GET_PLAYER(getFirstPlayer()).AI_changePeacetimeTradeValue(getSecondPlayer(), iValue);
}
else
{
GET_PLAYER(getFirstPlayer()).AI_changePeacetimeGrantValue(getSecondPlayer(), iValue);
}
}
if (getLengthFirstTrades() > 0)
{
iValue = (GET_PLAYER(getSecondPlayer()).AI_dealVal(getFirstPlayer(), getFirstTrades()) / GC.getDefineINT("PEACE_TREATY_LENGTH"));
if (getLengthSecondTrades() > 0)
{
GET_PLAYER(getSecondPlayer()).AI_changePeacetimeTradeValue(getFirstPlayer(), iValue);
}
else
{
GET_PLAYER(getSecondPlayer()).AI_changePeacetimeGrantValue(getFirstPlayer(), iValue);
}
}
}
}
case TRADE_TECHNOLOGIES:
iValue += GET_TEAM(getTeam()).AI_techTradeVal((TechTypes)(pNode->m_data.m_iData), GET_PLAYER(ePlayer).getTeam());
break;
int CvTeamAI::AI_techTradeVal(TechTypes eTech, TeamTypes eTeam) const
{
FAssert(eTeam != getID());
int iKnownCount;
int iPossibleKnownCount;
int iCost;
int iValue;
int iI;
iCost = std::max(0, (getResearchCost(eTech) - getResearchProgress(eTech)));
iValue = ((iCost * 3) / 2);
iKnownCount = 0;
iPossibleKnownCount = 0;
for (iI = 0; iI < MAX_CIV_TEAMS; iI++)
{
if (GET_TEAM((TeamTypes)iI).isAlive())
{
if (iI != getID())
{
if (isHasMet((TeamTypes)iI))
{
if (GET_TEAM((TeamTypes)iI).isHasTech(eTech))
{
iKnownCount++;
}
iPossibleKnownCount++;
}
}
}
}
iValue += (((iCost / 2) * (iPossibleKnownCount - iKnownCount)) / iPossibleKnownCount);
iValue *= std::max(0, (GC.getTechInfo(eTech).getAITradeModifier() + 100));
iValue /= 100;
iValue -= (iValue % GC.getDefineINT("DIPLOMACY_VALUE_REMAINDER"));
if (isHuman())
{
return std::max(iValue, GC.getDefineINT("DIPLOMACY_VALUE_REMAINDER"));
}
else
{
return iValue;
}
}
iValue -= (iValue % GC.getDefineINT("DIPLOMACY_VALUE_REMAINDER"));