...
i am having some crazy map bugs in the Warhammer mod which im working on and i havent a clue whats causing them or how to fix them.
i should point out i havent touched the terrain files, though i did fiddle with improvementinfo and featureinfo files a little, but the changes i mad worked fine (added some unique feature improvements and changed feature bonuses). then i moved a couple of techs around and changed the forest chopping tech, and all of a sudden im getting enourmous tracts of the 'Marsh' Terrain, as well as small spots of 'wetland' (including wetland hills) and Deep Jungle (wetland and deep jungle are taken from the Fall Further mod).
so basically im lost for thoughts and im begging you if you would take a look at my files and see if you can fix this mess for me?
thanks mate
void CvUnitAI::AI_scientistMove()
{PROFILE_FUNC();
if (AI_discover(true, true))
return;
if (AI_construct(MAX_INT, 1))
return;
if (GET_PLAYER(getOwnerINLINE()).getCurrentEra() < 3)
if (AI_join(2))
return;
if (GET_PLAYER(getOwnerINLINE()).getCurrentEra() <= (GC.getNumEraInfos() / 2))
if (AI_construct())
return;
int iGoldenAgeValue = (GET_PLAYER(getOwnerINLINE()).AI_calculateGoldenAgeValue() / (GET_PLAYER(getOwnerINLINE()).unitsRequiredForGoldenAge()));
int iDiscoverValue = std::max(1, getDiscoverResearch(NO_TECH));
if (((iGoldenAgeValue * 100) / iDiscoverValue) > 60)
{if (AI_goldenAge())
return;
if (iDiscoverValue > iGoldenAgeValue)
{if (AI_discover())
return;
if (GET_PLAYER(getOwnerINLINE()).getUnitClassCount(getUnitClassType()) > 1)
if (AI_join())
return;}}
else
{if (AI_discover())
return;
if (AI_join())
return;}
if ((GET_PLAYER(getOwnerINLINE()).AI_getPlotDanger(plot(), 2) > 0) || (getGameTurnCreated() < (GC.getGameINLINE().getGameTurn() - 25)))
if (AI_discover())
return;
if (AI_retreatToCity())
return;
if (AI_safety())
return;
getGroup()->pushMission(MISSION_SKIP);
return;}
int CvUnit::upgradePrice(UnitTypes eUnit) const
{int iPrice;
CyArgsList argsList;
argsList.add(getOwnerINLINE());
argsList.add(getID());
argsList.add((int) eUnit);
long lResult=0;
gDLL->getPythonIFace()->callFunction(PYGameModule, "getUpgradePriceOverride", argsList.makeFunctionArgs(), &lResult);
if (lResult >= 0)
return lResult;
if (isBarbarian())
return 0;
iPrice = GC.getDefineINT("BASE_UNIT_UPGRADE_COST");
iPrice += (std::max(0, (GET_PLAYER(getOwnerINLINE()).getProductionNeeded(eUnit) - GET_PLAYER(getOwnerINLINE()).getProductionNeeded(getUnitType()))) * GC.getDefineINT("UNIT_UPGRADE_COST_PER_PRODUCTION"));
if (!isHuman() && !isBarbarian())
{iPrice *= GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIUnitUpgradePercent();
iPrice /= 100;
iPrice *= std::max(0, ((GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAIPerEraModifier() * GET_PLAYER(getOwnerINLINE()).getCurrentEra()) + 100));
iPrice /= 100;}
iPrice -= (iPrice * getUpgradeDiscount()) / 100;
//FfH Traits: Added by Kael 08/02/2007
iPrice += (iPrice * GET_PLAYER(getOwnerINLINE()).getUpgradeCostModifier()) / 100;
CvCity* pCity = getUpgradeCity(eUnit, true);
if (pCity != NULL)
iPrice += (iPrice * pCity->getUpgradeCostModifier()) / 100;
//FfH: End Add
return iPrice;}
void CvPlayerAI::AI_doEnemyUnitData()
{std::vector<int> aiUnitCounts(GC.getNumUnitInfos(), 0);
std::vector<int> aiDomainSums(NUM_DOMAIN_TYPES, 0);
CLLNode<IDInfo>* pUnitNode;
CvUnit* pLoopUnit;
int iI;
int iOldTotal = 0;
int iNewTotal = 0;
for (iI = 0; iI < GC.getMapINLINE().numPlotsINLINE(); iI++)
{CvPlot* pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iI);
int iAdjacentAttackers = -1;
if (pLoopPlot->isVisible(getTeam(), false))
{pUnitNode = pLoopPlot->headUnitNode();
while (pUnitNode != NULL)
{pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = pLoopPlot->nextUnitNode(pUnitNode);
if (pLoopUnit->canFight())
{int iUnitValue = 1;
if (atWar(getTeam(), pLoopUnit->getTeam()))
{iUnitValue += 10;
if ((pLoopPlot->getOwnerINLINE() == getID()))
iUnitValue += 15;
else if (atWar(getTeam(), pLoopPlot->getTeam()))
{if (iAdjacentAttackers == -1)
iAdjacentAttackers = GET_PLAYER(pLoopPlot->getOwnerINLINE()).AI_adjacentPotentialAttackers(pLoopPlot);
if (iAdjacentAttackers > 0)
iUnitValue += 15;}}
else if (pLoopUnit->getOwnerINLINE() != getID())
{iUnitValue += pLoopUnit->canAttack() ? 4 : 1;
if (pLoopPlot->getCulture(getID()) > 0)
iUnitValue += pLoopUnit->canAttack() ? 4 : 1;}
if (m_aiUnitClassWeights[pLoopUnit->getUnitClassType()] == 0)
iUnitValue *= 4;
iUnitValue *= pLoopUnit->baseCombatStr();
aiUnitCounts[pLoopUnit->getUnitType()] += iUnitValue;
aiDomainSums[pLoopUnit->getDomainType()] += iUnitValue;
iNewTotal += iUnitValue;}}}}
if (iNewTotal == 0)
return;
//Decay
for (iI = 0; iI < GC.getNumUnitClassInfos(); iI++)
{m_aiUnitClassWeights[iI] -= 100;
m_aiUnitClassWeights[iI] *= 3;
m_aiUnitClassWeights[iI] /= 4;
m_aiUnitClassWeights[iI] = std::max(0, m_aiUnitClassWeights[iI]);}
for (iI = 0; iI < GC.getNumUnitInfos(); iI++)
{if (aiUnitCounts[iI] > 0)
{UnitTypes eLoopUnit = (UnitTypes)iI;
TechTypes eTech = (TechTypes)GC.getUnitInfo((UnitTypes)iI).getPrereqAndTech();
int iEraDiff = (eTech == NO_TECH) ? 4 : std::min(4, getCurrentEra() - GC.getTechInfo(eTech).getEra());
if (iEraDiff > 1)
{iEraDiff -= 1;
aiUnitCounts[iI] *= 3 - iEraDiff;
aiUnitCounts[iI] /= 3;}
FAssert(aiDomainSums[GC.getUnitInfo(eLoopUnit).getDomainType()] > 0);
m_aiUnitClassWeights[GC.getUnitInfo(eLoopUnit).getUnitClassType()] += (5000 * aiUnitCounts[iI]) / std::max(1, aiDomainSums[GC.getUnitInfo(eLoopUnit).getDomainType()]);}}
for (iI = 0; iI < GC.getNumUnitCombatInfos(); ++iI)
m_aiUnitCombatWeights[iI] = 0;
for (iI = 0; iI < GC.getNumUnitClassInfos(); iI++)
if (m_aiUnitClassWeights[iI] > 0)
{UnitTypes eUnit = (UnitTypes)GC.getUnitClassInfo((UnitClassTypes)iI).getDefaultUnitIndex();
m_aiUnitCombatWeights[GC.getUnitInfo(eUnit).getUnitCombatType()] += m_aiUnitClassWeights[iI];}
for (iI = 0; iI < GC.getNumUnitCombatInfos(); iI++)
{if (m_aiUnitCombatWeights[iI] > 25)
{m_aiUnitCombatWeights[iI] += 2500;}
else if (m_aiUnitCombatWeights[iI] > 0)
m_aiUnitCombatWeights[iI] += 1000;}}
int CvPlayerAI::AI_getTotalFloatingDefendersNeeded(CvArea* pArea)
{PROFILE_FUNC();
int iDefenders;
int iCurrentEra = getCurrentEra();
int iAreaCities = pArea->getCitiesPerPlayer(getID());
iCurrentEra = std::max(0, iCurrentEra - GC.getGame().getStartEra() / 2);
iDefenders = 1 + ((iCurrentEra + ((GC.getGameINLINE().getMaxCityElimination() > 0) ? 3 : 2)) * iAreaCities);
iDefenders /= 3;
iDefenders += pArea->getPopulationPerPlayer(getID()) / 7;
if (pArea->getAreaAIType(getTeam()) == AREAAI_DEFENSIVE)
iDefenders *= 2;
else if ((pArea->getAreaAIType(getTeam()) == AREAAI_OFFENSIVE) || (pArea->getAreaAIType(getTeam()) == AREAAI_MASSING))
{iDefenders *= 2;
iDefenders /= 3;}
if (AI_getTotalAreaCityThreat(pArea) == 0)
iDefenders /= 2;
if (!GC.getGameINLINE().isOption(GAMEOPTION_AGGRESSIVE_AI))
{iDefenders *= 2;
iDefenders /= 3;}
if (AI_isDoStrategy(AI_STRATEGY_GET_BETTER_UNITS) && (pArea->getAreaAIType(getTeam()) != AREAAI_DEFENSIVE))
iDefenders /= 2;
if (AI_isDoStrategy(AI_STRATEGY_CULTURE3))
{iDefenders += 2 * iAreaCities;
if (pArea->getAreaAIType(getTeam()) == AREAAI_DEFENSIVE)
iDefenders *= 2; //go crazy}
iDefenders *= 60;
iDefenders /= std::max(30, (GC.getHandicapInfo(GC.getGameINLINE().getHandicapType()).getAITrainPercent() - 20));
if ((iCurrentEra < 3) && (GC.getGameINLINE().isOption(GAMEOPTION_RAGING_BARBARIANS)))
iDefenders += 2;
if (getCapitalCity() != NULL)
if (getCapitalCity()->area() != pArea)
iDefenders = std::min(iDefenders, iAreaCities * iAreaCities - 1); ///Note: Bad for the Lanun here.
return iDefenders;}
int CvPlayerAI::AI_getCultureVictoryStage()
{int iValue;
if (!GC.getGameINLINE().culturalVictoryValid())
return 0;
if (getCapitalCity() == NULL)
return 0;
if (getCapitalCity()->getGameTurnFounded() > (10 + GC.getGameINLINE().getStartTurn()))
return 0;
if (GC.getGame().getStartEra() > 1)
return 0;
iValue = 0;
if (GC.getGameINLINE().isOption(GAMEOPTION_ALWAYS_PEACE))
iValue += 4;
for (int iI = 0; iI < GC.getNumTraitInfos(); iI++)
if (hasTrait((TraitTypes)iI))
{iValue += ((GC.getTraitInfo((TraitTypes)iI).getMaxAnarchy() == 0) ? 4 : 0);
iValue += (GC.getTraitInfo((TraitTypes)iI).getCommerceChange(COMMERCE_CULTURE) * 2);
iValue += (GC.getTraitInfo((TraitTypes)iI).getCommerceModifier(COMMERCE_CULTURE) / 6);
iValue += (GC.getTraitInfo((TraitTypes)iI).getGreatPeopleRateModifier() / 25);
iValue += (GC.getTraitInfo((TraitTypes)iI).getExtraYieldThreshold(YIELD_COMMERCE)) * 2 * GC.getDefineINT("EXTRA_YIELD");
iValue += (GC.getTraitInfo((TraitTypes)iI).getTradeYieldModifier(YIELD_COMMERCE)) / 25;
iValue += ((GC.getTraitInfo((TraitTypes)iI).getMaxGlobalBuildingProductionModifier() / 25));}
iValue += (GC.getGameINLINE().isOption(GAMEOPTION_AGGRESSIVE_AI) ? -3 : 0);
CivicTypes eCivic = (CivicTypes)GC.getLeaderHeadInfo(getPersonalityType()).getFavoriteCivic();
if ((eCivic != NO_CIVIC) && (GC.getCivicInfo(eCivic).isNoNonStateReligionSpread()))
iValue -= 3;
iValue += countHolyCities();
if ((GET_TEAM(getTeam()).isAVassal()) && (getNumCities() > 5))
{int iReligionCount = countTotalHasReligion();
if (((iReligionCount * 100) / getNumCities()) > 250)
{iValue += 1;
iValue += ((2 * iReligionCount) + 1) / getNumCities();}}
int iNonsense = 0;
iNonsense += getCapitalCity()->getX();
iNonsense += getCapitalCity()->getY();
iValue += (iNonsense % 7);
if (iValue < 10)
return 0;
if (getCurrentEra() >= (GC.getNumEraInfos() - (2 + iNonsense % 2)))
if (countTotalHasReligion() >= getNumCities() * 3)
return 3;
int iHighCultureCount = 0;
int iLoop;
CvCity* pLoopCity;
for (pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))
{if (pLoopCity->getBaseCommerceRate(COMMERCE_CULTURE) > 100)
iHighCultureCount++;
else if (pLoopCity->getCultureLevel() >= (GC.getGameINLINE().culturalVictoryCultureLevel() - 1))
iHighCultureCount++;}
if (iHighCultureCount >= GC.getGameINLINE().culturalVictoryNumCultureCities())
return 3;
}
if (getCurrentEra() >= ((GC.getNumEraInfos() / 3) + iNonsense % 2))
return 2;
else
return 1;
FAssert(false);}
Ya know, if you released something I would be far more inclined to work on simple tweaks and changes which you have plans for, or if Vehem and I do not think it belongs in FF I would at least help walk you through how to code it so you can get a feel for how to handle some of your crazier ideas on your own.
Right now though, I am working on quite a few things which are quite possibly impossible, and have a 1 kB .txt file of other ideas for future development which need sorted before I go off on wild tangents.