45°38'N-13°47'E
Deity
I'm thinking about improving Mastery Victory but I need some help from some DLL guru. As some of you might remember, I'm working on Rise of Mankind - A New Dawn, but I've seen the code for Mastery Victory is the same for C2C;
here's the code found in CvTeam.cpp
Now my question is: I'd like to add 100 points for building "Ascension Gate" which gives Scientific Victory. As you know, Ascension Gate gives -30 population in every city and grants Scientific Victory. But if you use Mastery Victory, it's totally useless to build AG: on the contrary, it makes you lose points because you lose population! So my idea is to give +100 points in Mastery Victory for building AG, hence making it useful again. Given the code above, I would think it would be easy enough but it looks like I'm not able to do it.
I suppose I'd have to add something like
if (BLAH BLAH BLAH)
{
iTotalVictoryScore += 100;
}
where BLAH BLAH BLAH is a check of existance of the Ascension Gate wonder. The problem is that I don't know which code should I use to check if Ascension Gate has been built. Is there a command which works like "If building x exists"?
I hope someone can help me, thanks in advance.
here's the code found in CvTeam.cpp
Spoiler :
int CvTeam::getTotalVictoryScore()
{
int iI, iK, iL;
CvCity* pLoopCity;
int iLoop;
int iTotalVictoryScore = 0;
int globalCulture = 0;
int globalThreeCityCulture = 0;
int globalLand = 0;
int globalPopulation = 0;
int globalWonderScore = 0;
int teamWonderScore = 0;
int tempScore = 0;
int totalTeamReligion = 0;
int totalTeamLegendaryCities = 0;
int tempReligion = 0;
long globalPowerHistory =0;
long teamPowerHistory =0;
long tempPower =0;
globalLand = GC.getMap().getLandPlots();
for (iK = 0; iK < GC.getNumBuildingClassInfos(); iK++)
{
if (GC.getBuildingClassInfo((BuildingClassTypes)iK).getMaxGlobalInstances() == 1)
{
globalWonderScore ++;
}
}
// Get the Religion Info First
// By definition, global religion percent is 100, so we don't need a variable for it.
// Note: This detects whether the TEAM has the holy city.
for (iK = 0; iK < GC.getNumReligionInfos(); iK++)
{
if (hasHolyCity((ReligionTypes)iK))
{
// Player has holy city
tempReligion = GC.getGame().calculateReligionPercent((ReligionTypes)iK);
if (tempReligion > totalTeamReligion)
{
totalTeamReligion = tempReligion;
}
}
}
// Get land, population, culture totals for player and globally.
// Also get the starship launches and diplovictories achieved.
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
//Calculate global totals while looping through
globalCulture += GET_PLAYER((PlayerTypes)iI).countTotalCulture();
globalPopulation += GET_PLAYER((PlayerTypes)iI).getTotalPopulation();
if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
{
teamWonderScore += GET_PLAYER((PlayerTypes)iI).getSevoWondersScore(0);
}
}
}
// Get the power history sums
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
//Calculate global totals while looping through
tempPower = 0;
for (iL = 0; iL <= GC.getGame().getGameTurn(); iL++)
{
tempPower += GET_PLAYER((PlayerTypes)iI).getPowerHistory(iL);
}
if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
{
teamPowerHistory += tempPower;
}
globalPowerHistory += tempPower;
}
}
// Get the number of legendary cities owned by this team
for (iK = 0; iK < MAX_CIV_PLAYERS; iK++)
{
if ((GET_PLAYER((PlayerTypes)iK).getTeam() == getID()) && (GET_PLAYER((PlayerTypes)iK).isAlive()))
{
for (pLoopCity = GET_PLAYER((PlayerTypes)iK).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iK).nextCity(&iLoop))
{
// -2 is correct. We need -1 to change from 'total num' to 'last index', and -1 to get the top level.
if (pLoopCity->getCultureLevel() > GC.getNumCultureLevelInfos() - 2)
{
totalTeamLegendaryCities++;
}
}
}
}
// Add the WonderScore component
if (globalWonderScore > 0)
{
iTotalVictoryScore += int(teamWonderScore * 100 / globalWonderScore);
}
// Add the population score component
if (globalPopulation > 0)
{
iTotalVictoryScore += int(getTotalPopulation() * 100 / globalPopulation);
}
// Add the land score component
if (globalLand > 0)
{
iTotalVictoryScore += int(getTotalLand() * 100 / globalLand);
}
// Add the culture score component
if (globalCulture > 0)
{
iTotalVictoryScore += int(countTotalCulture() * 100 / globalCulture);
}
// Add the legendary cities component
if (totalTeamLegendaryCities > 0)
{
iTotalVictoryScore += (30 * totalTeamLegendaryCities);
}
// Add the Power component
if (globalPowerHistory > 0)
{
iTotalVictoryScore += (teamPowerHistory * 100 / globalPowerHistory);
}
// Add the Religion component
iTotalVictoryScore += totalTeamReligion;
//Starship points! Big money.
if (GC.getGame().getStarshipLaunched(getID()))
{
iTotalVictoryScore += 100;
}
return iTotalVictoryScore;
}
{
int iI, iK, iL;
CvCity* pLoopCity;
int iLoop;
int iTotalVictoryScore = 0;
int globalCulture = 0;
int globalThreeCityCulture = 0;
int globalLand = 0;
int globalPopulation = 0;
int globalWonderScore = 0;
int teamWonderScore = 0;
int tempScore = 0;
int totalTeamReligion = 0;
int totalTeamLegendaryCities = 0;
int tempReligion = 0;
long globalPowerHistory =0;
long teamPowerHistory =0;
long tempPower =0;
globalLand = GC.getMap().getLandPlots();
for (iK = 0; iK < GC.getNumBuildingClassInfos(); iK++)
{
if (GC.getBuildingClassInfo((BuildingClassTypes)iK).getMaxGlobalInstances() == 1)
{
globalWonderScore ++;
}
}
// Get the Religion Info First
// By definition, global religion percent is 100, so we don't need a variable for it.
// Note: This detects whether the TEAM has the holy city.
for (iK = 0; iK < GC.getNumReligionInfos(); iK++)
{
if (hasHolyCity((ReligionTypes)iK))
{
// Player has holy city
tempReligion = GC.getGame().calculateReligionPercent((ReligionTypes)iK);
if (tempReligion > totalTeamReligion)
{
totalTeamReligion = tempReligion;
}
}
}
// Get land, population, culture totals for player and globally.
// Also get the starship launches and diplovictories achieved.
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
//Calculate global totals while looping through
globalCulture += GET_PLAYER((PlayerTypes)iI).countTotalCulture();
globalPopulation += GET_PLAYER((PlayerTypes)iI).getTotalPopulation();
if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
{
teamWonderScore += GET_PLAYER((PlayerTypes)iI).getSevoWondersScore(0);
}
}
}
// Get the power history sums
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
if (GET_PLAYER((PlayerTypes)iI).isAlive())
{
//Calculate global totals while looping through
tempPower = 0;
for (iL = 0; iL <= GC.getGame().getGameTurn(); iL++)
{
tempPower += GET_PLAYER((PlayerTypes)iI).getPowerHistory(iL);
}
if (GET_PLAYER((PlayerTypes)iI).getTeam() == getID())
{
teamPowerHistory += tempPower;
}
globalPowerHistory += tempPower;
}
}
// Get the number of legendary cities owned by this team
for (iK = 0; iK < MAX_CIV_PLAYERS; iK++)
{
if ((GET_PLAYER((PlayerTypes)iK).getTeam() == getID()) && (GET_PLAYER((PlayerTypes)iK).isAlive()))
{
for (pLoopCity = GET_PLAYER((PlayerTypes)iK).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER((PlayerTypes)iK).nextCity(&iLoop))
{
// -2 is correct. We need -1 to change from 'total num' to 'last index', and -1 to get the top level.
if (pLoopCity->getCultureLevel() > GC.getNumCultureLevelInfos() - 2)
{
totalTeamLegendaryCities++;
}
}
}
}
// Add the WonderScore component
if (globalWonderScore > 0)
{
iTotalVictoryScore += int(teamWonderScore * 100 / globalWonderScore);
}
// Add the population score component
if (globalPopulation > 0)
{
iTotalVictoryScore += int(getTotalPopulation() * 100 / globalPopulation);
}
// Add the land score component
if (globalLand > 0)
{
iTotalVictoryScore += int(getTotalLand() * 100 / globalLand);
}
// Add the culture score component
if (globalCulture > 0)
{
iTotalVictoryScore += int(countTotalCulture() * 100 / globalCulture);
}
// Add the legendary cities component
if (totalTeamLegendaryCities > 0)
{
iTotalVictoryScore += (30 * totalTeamLegendaryCities);
}
// Add the Power component
if (globalPowerHistory > 0)
{
iTotalVictoryScore += (teamPowerHistory * 100 / globalPowerHistory);
}
// Add the Religion component
iTotalVictoryScore += totalTeamReligion;
//Starship points! Big money.
if (GC.getGame().getStarshipLaunched(getID()))
{
iTotalVictoryScore += 100;
}
return iTotalVictoryScore;
}
Now my question is: I'd like to add 100 points for building "Ascension Gate" which gives Scientific Victory. As you know, Ascension Gate gives -30 population in every city and grants Scientific Victory. But if you use Mastery Victory, it's totally useless to build AG: on the contrary, it makes you lose points because you lose population! So my idea is to give +100 points in Mastery Victory for building AG, hence making it useful again. Given the code above, I would think it would be easy enough but it looks like I'm not able to do it.
I suppose I'd have to add something like
if (BLAH BLAH BLAH)
{
iTotalVictoryScore += 100;
}
where BLAH BLAH BLAH is a check of existance of the Ascension Gate wonder. The problem is that I don't know which code should I use to check if Ascension Gate has been built. Is there a command which works like "If building x exists"?
I hope someone can help me, thanks in advance.