PHP-Code:
void CvUnit::doTurn()
{
PROFILE("CvUnit::doTurn()")
FAssertMsg(!isDead(), "isDead did not return false as expected");
FAssertMsg(getGroup() != NULL, "getGroup() is not expected to be equal with NULL");
//rucivfan_unit_generate_profit rugp[
updateGenerateProfitChanges();
//]rucivfan_unit_generate_profit rugp
// rucivfan_bug_fix[
// Populistisch Erfahrung -> Autobeförderung
// testPromotionReady();
// siehe unten
// ]rucivfan_bug_fix
if(getOriginalOwner() != NO_PLAYER)
{
if (!GET_PLAYER(getOriginalOwner()).isAlive())
{
m_eOriginalOwner = NO_PLAYER;
}
}
if (isBlockading())
{
collectBlockadeGold();
}
if (isSpy() && isIntruding() && !isCargo())
{
TeamTypes eTeam = plot()->getTeam();
if (NO_TEAM != eTeam)
{
// rucivfan_espionage_bug_fix rebf[
// old code[
//if (GET_TEAM(getTeam()).isOpenBorders(eTeam))
//{
// testSpyIntercepted(plot()->getOwnerINLINE(), GC.getDefineINT("ESPIONAGE_SPY_NO_INTRUDE_INTERCEPT_MOD"));
//}
//else
//{
// testSpyIntercepted(plot()->getOwnerINLINE(), GC.getDefineINT("ESPIONAGE_SPY_INTERCEPT_MOD"));
//}
// ]old code
// new code[
if (GET_TEAM(getTeam()).isOpenBorders(eTeam))
{
testSpyIntercepted(plot()->getOwnerINLINE(), GC.getESPIONAGE_SPY_NO_INTRUDE_INTERCEPT_MOD());
}
else
{
testSpyIntercepted(plot()->getOwnerINLINE(), GC.getESPIONAGE_SPY_INTERCEPT_MOD());
}
// ]new code
// rucivfan_espionage_bug_fix rebf
}
}
if (baseCombatStr() > 0)
{
FeatureTypes eFeature = plot()->getFeatureType();
if (NO_FEATURE != eFeature)
{
if (0 != GC.getFeatureInfo(eFeature).getTurnDamage())
{
changeDamage(GC.getFeatureInfo(eFeature).getTurnDamage(), NO_PLAYER);
}
}
}
// Cybah - BASE für 6.1 E: ZE: Karthago - +10% allgemeine Heilung außerhalb kultureller Grenzen, auch nach Bewegung START
if (getDamage() > 0)
{
CvPlot* pPlot = plot();
if ((GET_PLAYER(getOwnerINLINE()).getCivilizationType() == BASE.getCIVILIZATION_CARTHAGE()) && (GET_TEAM(getTeam()).isHasTech((TechTypes)(BASE.getTECH_CARTHAGE()))) && (pPlot->getOwnerINLINE() != getOwnerINLINE()))
{
changeDamage(-10);
}
// Cybah - BASE für 6.2 D: Schützend - +20% allgemeine Heilung, auch nach Bewegung START // deaktiviert, jetzt Heilung nach siegreichen Kämpfen
if (GET_PLAYER(getOwnerINLINE()).hasTrait((TraitTypes)BASE.getTRAIT_PROTECTIVE()) && getDamage() > 0)
{
changeDamage(-10);
}
// Cybah - BASE für 6.2 D: Schützend - +20% allgemeine Heilung, auch nach Bewegung END
}
// Cybah - BASE für 6.1 E: ZE: Karthago - +10% allgemeine Heilung außerhalb kultureller Grenzen, auch nach Bewegung END
if (hasMoved())
{
// rucivfan_bug_fix rbf[
if(isHurt())
{
// ]rucivfan_bug_fix rbf
// Cybah: BASE für 5.6 - Tiere heilen sich auch in Bewegung START
// Original Code
// if (isAlwaysHeal())
//
if (isAlwaysHeal() || isAnimal())
// Cybah: BASE für 5.6 - Tiere heilen sich auch in Bewegung END
{
doHeal();
}
// rucivfan_bug_fix rbf[
}
// ]rucivfan_bug_fix rbf
}
else
{
if (isHurt())
{
doHeal();
}
if (!isCargo())
{
// Cybah - BASE: ZE: Osmanen ehemals Tibet START
// rucivfan_code_optimization rco[
if ((GET_PLAYER(getOwnerINLINE()).getCivilizationType() == BASE.getCIVILIZATION_OTTOMAN()) && (GET_TEAM(getTeam()).isHasTech((TechTypes)(BASE.getTECH_OTTOMAN()))))
// ]rucivfan_code_optimization rco
{
setFortifyTurns(GC.getMAX_FORTIFY_TURNS());
//Cybah: BASE für 6.1 F - Überlebenskünstler III START
if (isHasPromotion((PromotionTypes)BASE.getPROMOTION_SURVIVOR3()))
{
setFortifyTurns(GC.getMAX_FORTIFY_TURNS() + GC.getMAX_FORTIFY_TURNS());
}
//Cybah: BASE für 6.1 F - Überlebenskünstler III END
}
else
{
changeFortifyTurns(1);
}
// Cybah - BASE: ZE: Osmanen ehemals Tibet END
// rucivfan_espionage_system_extended rese[
if(canObservation())
{
changeObservationTurns(1);
}
// rucivfan_espionage_system_extended rese
}
}
changeImmobileTimer(-1);
setMadeInterception(false);
setReconPlot(NULL);
// rucivfan_movement_system_extended rmse[
// old code[
//setMadeAttack(false);
//setMoves(0);
// ]old code
// new code[
setTempFlatMoves(0);
setAttackCount(0);
setMoves(0);
setMoveDenominator(1);
// ]new code
// ]rucivfan_movement_system_extended rmse
// rucivfan_bug_fix[
// Populistisch Erfahrung -> Autobeförderung
testPromotionReady();
// ]rucivfan_bug_fix
/************************************************************************************************/
/* Afforess Start 08/20/10 */
/* */
/* Advanced Automations */
/************************************************************************************************/
if (canDiscover(NULL))
{
if (getDesiredDiscoveryTech() == getDiscoveryTech())
{
getGroup()->setActivityType(ACTIVITY_AWAKE);
setDesiredDiscoveryTech(NO_TECH);
discover();
}
}
if (isAutoUpgrading())
{
// rucivfan_code_optimization rco[
if (plot()->isCity() || !GET_PLAYER(getOwnerINLINE()).AI_isAnyPlotDanger(plot(), 3))
// ]rucivfan_code_optimization rco
{
AI_upgrade();
//Could Delete Unit!!!
}
}
/************************************************************************************************/
/* Afforess END */
/************************************************************************************************/
// < M.A.D. Nukes Start >
if (isMADEnabled())
{
if (isMADTargetSet())
{
if (getMADTargetPlot() != NULL)
{
//If the owner of the target plot changed, set our target plot to NULL
if (getMADTargetPlot()->getOwner() != getMADTargetPlotOwner())
{
setMADTargetPlot(NULL);
}
//If we're no longer able to nuke the target plot,
//set our target plot to NULL
if (!canMADNukeAt(getMADTargetPlot()))
{
setMADTargetPlot(NULL);
}
}
// rucivfan_ai_auto_play raap[
//if (isHuman())
if (isHumanActive())
// ]rucivfan_ai_auto_play raap
{
//If finishMoves is called here for the AI, our AI handler AI_ICBMMove
//will not be reached.
finishMoves();
}
}
}
// < M.A.D. Nukes End >
// Cybah - BASE für 5.6: ZE: Persien START (siehe auch CvPlayer.cpp)
if ((getDomainType() == DOMAIN_LAND) && (getCombatStr() > 0) && (GET_PLAYER(getOwnerINLINE()).isGoldenAge()) && (GET_PLAYER(getOwnerINLINE()).getCivilizationType() == BASE.getCIVILIZATION_PERSIA()) && (GET_TEAM(getTeam()).isHasTech((TechTypes)(BASE.getTECH_PERSIA()))))
{
changeTempFlatMoves(1);
}
// Cybah - BASE für 5.6: ZE: Persien END
// Cybah - BASE für 6.1 E: ZE: Indien START - deaktiviert
// if ((getUnitClassType() == GC.getUNITCLASS_WORKER()) && (GET_PLAYER(getOwnerINLINE()).isGoldenAge()) && (GET_PLAYER(getOwnerINLINE()).getCivilizationType() == GC.getCIVILIZATION_INDIA()) && (GET_TEAM(getTeam()).isHasTech((TechTypes)(GC.getTECH_INDIA()))))
// {
// changeTempFlatMoves(1);
// }
// Cybah - BASE für 6.1 E: ZE: Indien END
// Cybah - BASE für 6.1 E: ZE: Nordreich START
if ((getUnitCombatType() == (UnitCombatTypes)BASE.getUNITCOMBAT_NAVAL()) && (GET_PLAYER(getOwnerINLINE()).getCivilizationType() == BASE.getCIVILIZATION_VIKING()) && (GET_TEAM(getTeam()).isHasTech((TechTypes)(BASE.getTECH_VIKING()))))
{
changeTempFlatMoves(1);
}
// Cybah - BASE für 6.1 E: ZE: Nordreich END
// Cybah - BASE für 5.6: Charismatisch START - DEAKTIVIERT
// if ((getUnitCombatType() == (UnitCombatTypes)GC.getUNITCOMBAT_WORKER()) && (GET_PLAYER(getOwnerINLINE()).hasTrait((TraitTypes)GC.getTRAIT_CHARISMATIC())))
// {
// changeTempFlatMoves(1);
// }
// Cybah - BASE für 5.6: Charismatisch END
// Cybah: BASE für 6.3 C - Schützend Trait START
if (GET_PLAYER(getOwnerINLINE()).hasTrait((TraitTypes)BASE.getTRAIT_PROTECTIVE()))
{
if(!isReadyForUpgrade())
{
return;
}
int iRandomRange = 10000;
// Game Speed Skalierung
iRandomRange *= (GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getTrainPercent() + GC.getGameSpeedInfo(GC.getGameINLINE().getGameSpeedType()).getResearchPercent());
iRandomRange /= 200;
// Auswürfeln
int iValue = (1 + GC.getGameINLINE().getSorenRandNum(iRandomRange, "Auto Upgrade Chance"));
// 10% Wahrscheinlichkeit (times 100)
int iBreakpoint = 1000;
// 2% Wahrscheinlichkeit pro Ära (times 100) (DEAKTIVIERT)
// int iBreakpoint = (200 * (GET_PLAYER(getOwnerINLINE()).getCurrentEra() + 1));
if (iValue < iBreakpoint)
{
CvPlot* pPlot = plot();
if (pPlot->isCity(true, getTeam()))
{
CvCity* pCity = pPlot->getPlotCity();
if ((getOwnerINLINE() == pCity->getOwnerINLINE()) && (!pCity->isDisorder()))
{
UnitTypes eBestUnit;
std::vector<UnitTypes> vctiUnitUpgrades;
if(getAvailableUpgrades(vctiUnitUpgrades, getUnitType()))
{
// Zufällige Wahl des Upgrade Typs
int iUnitUpgradeChosen = GC.getGameINLINE().getSorenRandNum(vctiUnitUpgrades.size(), "Auto Upgrade UnitType");
eBestUnit = (UnitTypes)vctiUnitUpgrades[iUnitUpgradeChosen];
if (eBestUnit != NO_UNIT)
{
// upgrade(eBestUnit);
//--------------------------------------------------------------------------------------------------------------------
CvUnit* pUpgradeUnit;
// Stadt muss Upgradetyp ausbilden können
if (!pCity->canTrain(eBestUnit))
{
return;
}
// // Stadt muss Hauptstadt sein oder verbunden zur Hauptstadt sein
// if ((!pCity->isConnectedToCapital()) && (!pCity->isCapital()))
// {
// return;
// }
FAssertMsg(eBestUnit > NO_UNIT, "eBestUnit is not assigned a valid value");
//rucivfan_switch_promotion_button rspb[
for(int iI = 0; iI < GC.getNumSwitchPromotionInfos(); ++iI)
{
if(GC.getSwitchPromotionInfo((SwitchPromotionTypes)iI).isUnitUpgradeTurnSwitch() && isSwitchPromotionTurnValid((SwitchPromotionTypes)iI))
{
setHasSwitchPromotion((SwitchPromotionTypes)iI, false);
}
}
//]rucivfan_switch_promotion_button rspb
pUpgradeUnit = GET_PLAYER(getOwnerINLINE()).initUnit(eBestUnit, getX_INLINE(), getY_INLINE(), AI_getUnitAIType());
FAssertMsg(pUpgradeUnit != NULL, "UpgradeUnit is not assigned a valid value");
// Nachricht vorbereiten
CvWString szBuffer;
if (m_szName.empty())
{
szBuffer = gDLL->getText("TXT_KEY_PROTECTIVE_UNIT_UPGRADED_NONAME", pUpgradeUnit->getNameKey(), getNameKey());
}
else
{
szBuffer = gDLL->getText("TXT_KEY_PROTECTIVE_UNIT_UPGRADED_NAME", pUpgradeUnit->getNameKey(), m_pUnitInfo->getDescription(), getNameKey());
}
pUpgradeUnit->joinGroup(getGroup());
pUpgradeUnit->convert(this);
pUpgradeUnit->finishMoves();
// Cybah - BASE für 6.1: Vollständige Heilung bei Modernisierung (erhöhte Kosten bei Schaden siehe oben) START
pUpgradeUnit->setDamage(0);
// Cybah - BASE für 6.1: Vollständige Heilung bei Modernisierung (erhöhte Kosten bei Schaden siehe oben) END
//rucivfan_code_optimization rco[
// Cybah: BASE Überläufer wird entfernt Start
if (pUpgradeUnit->isHasPromotion((PromotionTypes)BASE.getPROMOTION_DEFECTOR_LAND()))
{
pUpgradeUnit->setHasPromotion((PromotionTypes)BASE.getPROMOTION_DEFECTOR_LAND(), false);
}
if (pUpgradeUnit->isHasPromotion((PromotionTypes)BASE.getPROMOTION_DEFECTOR_SEA()))
{
pUpgradeUnit->setHasPromotion((PromotionTypes)BASE.getPROMOTION_DEFECTOR_SEA(), false);
}
// Cybah: BASE Überläufer wird entfernt End
// Cybah: BASE Rage / Raserei wird entfernt Start
if (pUpgradeUnit->isHasPromotion((PromotionTypes)BASE.getPROMOTION_RAGE()))
{
pUpgradeUnit->setHasPromotion((PromotionTypes)BASE.getPROMOTION_RAGE(), false);
}
// Cybah: BASE Rage / Raserei wird entfernt End
// Cybah: BASE Generalsbeförderung reicht aus Start
// if (pUpgradeUnit->getLeaderUnitType() == NO_UNIT)
if (!isHasPromotion((PromotionTypes)BASE.getPROMOTION_LEADER()))
// Cybah: BASE Generalsbeförderung reicht aus End
// ]rucivfan_code_optimization rco
{
// Cybah: BASE für 6.1 D - Organisiert Trait START
//if (pUpgradeUnit->getExperience() > GC.getUNIT_UPGRADE_MAX_EXPERIENCE_AFTER_UPGRADE())
if (!GET_PLAYER(getOwnerINLINE()).hasTrait((TraitTypes)BASE.getTRAIT_ORGANIZED()))
// Cybah: BASE für 6.1 D - Organisiert Trait END
{
// Cybah: BASE für 6.2 - Halbierte Erfahrung anstelle gekappter Erfahrung START
// pUpgradeUnit->setExperience(GC.getUNIT_UPGRADE_MAX_EXPERIENCE_AFTER_UPGRADE());
// Aufrunden, deshalb minus
// int iXPLoss = (getExperience() / 2);
// BASE für 6.3 (obiger Code wurde durch unteren Code ersetzt)
int iXPLoss = (std::max(0, getExperience() - 10) / 2);
pUpgradeUnit->setExperience(getExperience() - iXPLoss);
// Cybah: BASE für 6.2 - Halbierte Erfahrung anstelle gekappter Erfahrung END
}
}
/************************************************************************************************/
/* BETTER_BTS_AI_MOD 02/24/10 jdog5000 */
/* */
/* AI Logging */
/************************************************************************************************/
if(GC.getLogging())
{
if( gUnitLogLevel > 2 )
{
CvWString szString;
getUnitAIString(szString, AI_getUnitAIType());
logBBAI(" %S spends %d to upgrade %S to %S, unit AI %S", GET_PLAYER(getOwnerINLINE()).getCivilizationDescription(0), upgradePrice(eBestUnit), getName(0).GetCString(), pUpgradeUnit->getName(0).GetCString(), szString.GetCString());
}
}
/************************************************************************************************/
/* BETTER_BTS_AI_MOD END */
/************************************************************************************************/
//--------------------------------------------------------------------------------------------------------------------
gDLL->getInterfaceIFace()->addMessage(pUpgradeUnit->getOwnerINLINE(), false, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNITGIFTED", MESSAGE_TYPE_INFO, pUpgradeUnit->getButton(), (ColorTypes)/*rucivfan_code_optimization rco[*/GC.getCOLOR_WHITE() /*] rucivfan_code_optimization rco*/, pUpgradeUnit->getX_INLINE(), pUpgradeUnit->getY_INLINE(), true, true);
doDelayedDeath();
return;
}
}
}
}
}
}
// Cybah: BASE für 6.3 C - Schützend Trait END
}