Modified:
/trunk/317DLL/CvGameCoreDLL/CvCity.cpp
/trunk/317DLL/CvGameCoreDLL/CvDLLButtonPopup.cpp
/trunk/317DLL/CvGameCoreDLL/CvEnums.h
/trunk/317DLL/CvGameCoreDLL/CvGame.cpp
/trunk/317DLL/CvGameCoreDLL/CvGame.h
/trunk/317DLL/CvGameCoreDLL/CvGameTextMgr.cpp
/trunk/317DLL/CvGameCoreDLL/CvGlobals.cpp
/trunk/317DLL/CvGameCoreDLL/CvGlobals.h
/trunk/317DLL/CvGameCoreDLL/CvInfos.cpp
/trunk/317DLL/CvGameCoreDLL/CvInfos.h
/trunk/317DLL/CvGameCoreDLL/CvPlayer.cpp
/trunk/317DLL/CvGameCoreDLL/CvPlayer.h
/trunk/317DLL/CvGameCoreDLL/CvPlayerAI.cpp
/trunk/317DLL/CvGameCoreDLL/CvPlot.cpp
/trunk/317DLL/CvGameCoreDLL/CvSelectionGroup.cpp
/trunk/317DLL/CvGameCoreDLL/CvTeam.cpp
/trunk/317DLL/CvGameCoreDLL/CvTeamAI.cpp
/trunk/317DLL/CvGameCoreDLL/CvUnit.cpp
/trunk/317DLL/CvGameCoreDLL/CvUnit.h
/trunk/317DLL/CvGameCoreDLL/CvUnitAI.cpp
/trunk/317DLL/CvGameCoreDLL/CyEnumsInterface.cpp
/trunk/317DLL/CvGameCoreDLL/CyGame.cpp
/trunk/317DLL/CvGameCoreDLL/CyGame.h
/trunk/317DLL/CvGameCoreDLL/CyGameInterface.cpp
/trunk/317DLL/CvGameCoreDLL/CyGlobalContext.cpp
/trunk/317DLL/CvGameCoreDLL/CyGlobalContext.h
/trunk/317DLL/CvGameCoreDLL/CyGlobalContextInterface4.cpp
/trunk/317DLL/CvGameCoreDLL/CyPlayer.cpp
/trunk/317DLL/CvGameCoreDLL/CyPlayer.h
/trunk/317DLL/CvGameCoreDLL/CyPlayerInterface2.cpp
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvCity.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvCity.cpp Fri Oct 16 02:15:14 2009
@@ -11824,6 +11824,10 @@
}
}
}
+ else if (pPlot->isCity())
+ {
+ return true;
+ }
}
}
}
@@ -11874,6 +11878,26 @@
{
changeFreePromotionCount(eFreePromotion, 1);
}
+
+ // tutorial, start, by poyuzhe 09.27.09
+ if (GC.getCityPerkInfo(eCityPerk).getUniqueUnit() != -1)
+ {
+ if
(!GET_PLAYER(getOwnerINLINE()).isFeatAccomplished(FEAT_GAIN_CITY_PERK))
+ {
+ GET_PLAYER(getOwnerINLINE()).setFeatAccomplished(FEAT_GAIN_CITY_PERK,
true);
+ if (GET_PLAYER(getOwnerINLINE()).isFeatPopup())
+ {
+ CyArgsList argsList;
+
+ argsList.add(getOwnerINLINE());
+ argsList.add(getID());
+ argsList.add(eCityPerk);
+
+
gDLL->getPythonIFace()->callFunction(PYSanguoModule, "doGainCityPerkFeat",
argsList.makeFunctionArgs());
+ }
+ }
+ }
+ // Tutorial, end
}
else if (!bNewValue && iter != m_aHasCityPerks.end())
{
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvDLLButtonPopup.cpp Tue Sep 22 03:53:27
2009
+++ /trunk/317DLL/CvGameCoreDLL/CvDLLButtonPopup.cpp Fri Oct 16 02:15:14
2009
@@ -1403,6 +1403,7 @@
szBuffer = gDLL->getText("TXT_KEY_POPUP_RETURN_ALLIED_CITY",
GET_PLAYER(eHighestCulturePlayer).getCivilizationDescriptionKey());
gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup, szBuffer, NULL,
2, WIDGET_GENERAL, 2, eHighestCulturePlayer);
}
+ gDLL->getInterfaceIFace()->popupAddGenericButton(pPopup,
gDLL->getText("TXT_KEY_CITY_WARNING_ANSWER3").c_str(), NULL, 3,
WIDGET_GENERAL, -1, -1);
gDLL->getInterfaceIFace()->popupLaunch(pPopup, false,
POPUPSTATE_IMMEDIATE);
gDLL->getInterfaceIFace()->playGeneralSound("AS2D_CITYCAPTURE");
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvEnums.h Sat Sep 26 22:57:14 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvEnums.h Fri Oct 16 02:15:14 2009
@@ -742,7 +742,10 @@
GAMEOPTION_NO_ESPIONAGE,
// Sanguo Mod Hero, start, added by poyuzhe 02.08.09
GAMEOPTION_NO_HERO_DEATH_FROM_COMBAT,
- //GAMEOPTION_NO_HERO_DEATH_FROM_AGE,
+ GAMEOPTION_NO_HERO_DEATH_FROM_AGE,
+ GAMEOPTION_NO_HERO_EXECUTION,
+ GAMEOPTION_ENABLE_ARMY,
+ GAMEOPTION_HIGH_HERO_DEATH_CHANCE,
GAMEOPTION_NO_SETTLER,
// Sanguo Mod Hero, end
@@ -2125,6 +2128,15 @@
FEAT_POPULATION_2_BILLION,
FEAT_CORPORATION_ENABLED,
FEAT_PAD,
+ // Sanguo Mod Tutorial, start, by poyuzhe 09.27.09
+ FEAT_CAPTURE_EMPEROR,
+ FEAT_CAPTURE_HERO,
+ FEAT_FORM_LEGION,
+ FEAT_FORM_ADVANCED_LEGION,
+ FEAT_CREATE_RANDOM_HERO,
+ FEAT_BUILD_CITY_WONDER,
+ FEAT_GAIN_CITY_PERK,
+ // Sanguo Mod Tutorial, end
#ifdef _USRDLL
NUM_FEAT_TYPES
@@ -2843,6 +2855,12 @@
{
NO_SURRENDER = -1,
};
+
+// Random leader
+enum RandomLeaderTypes // exposed to python
+{
+ NO_RANDOMLEADER = -1,
+};
// Sanguo Mod XML, end
#endif // CVENUMS_h
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvGame.cpp Sat Sep 26 22:57:14 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvGame.cpp Fri Oct 16 02:15:14 2009
@@ -295,7 +295,7 @@
}
for (iJ = 0; iJ < GC.getNumPromotionInfos(); iJ++)
{
- setHeroPromotionStatus((HeroTypes)iI, (PromotionTypes)iJ,
GC.getHeroInfo((HeroTypes)iI).getUnitPromotionStatus(iJ));
+ setHeroPromotionStatus((HeroTypes)iI, (PromotionTypes)iJ,
GC.getHeroInfo((HeroTypes)iI).getUnitPromotionStatus(iJ), false);
}
if (GC.getHeroInfo((HeroTypes)iI).getHistoricalDieYear() <=
getGameTurnYear())
@@ -487,7 +487,7 @@
// Sanguo Mod Hero, start, added by poyuzhe 08.10.09
while(m_paNewLeaders.size() > 0)
{
- GC.getLeaderHeadInfo().pop_back();
+ GC.getRandomLeaderInfo().pop_back();
GC.setInfoTypeFromString(m_paNewLeaders.back()->getType(), -1);
m_paNewLeaders.pop_back();
}
@@ -545,6 +545,10 @@
m_szScriptData = "";
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ m_iTutorialID = -1;
+ // Sanguo Mod tutorial, end
+
for (iI = 0; iI < MAX_PLAYERS; iI++)
{
m_aiEndTurnMessagesReceived[iI] = 0;
@@ -5536,17 +5540,6 @@
m_paiReligionGameTurnFounded[eIndex] = getGameTurn();
gDLL->getEventReporterIFace()->religionFounded(eIndex, ePlayer);
-
- // Sanguo Mod Performance start, added by poyuzhe 07.26.09
- for (int iI = 0; iI < GC.getMAX_PLAYERS(); iI++)
- {
- if (GET_PLAYER((PlayerTypes)iI).isAlive() &&
GET_PLAYER((PlayerTypes)iI).getStateReligion() == eIndex)
- {
- GET_PLAYER(ePlayer).AI_invalidateAttitudeCache((PlayerTypes)iI);
- GET_PLAYER((PlayerTypes)iI).AI_invalidateAttitudeCache(ePlayer);
- }
- }
- // Sanguo Mod Performance, end
}
}
@@ -6608,10 +6601,7 @@
iY = pUnit->getY_INLINE();
}
- CvUnit* pHero =
kPlayer.initUnit((UnitTypes)GC.getHeroInfo((HeroTypes)iI).getUnitType(),
iX, iY);
- pHero->setHeroType((HeroTypes)iI);
- setHeroUnitID((HeroTypes)iI, pHero->getID());
- kPlayer.changeHeroMaintenance((HeroTypes)iI, true,
false, 0);
+ kPlayer.initHero((HeroTypes)iI, iX, iY, true);
}
}
@@ -8393,8 +8383,8 @@
CvLeaderHeadInfo* pNewLeaderHeadInfo = new CvLeaderHeadInfo;
pNewLeaderHeadInfo->read(pStream);
m_paNewLeaders.push_back(pNewLeaderHeadInfo);
- GC.getLeaderHeadInfo().push_back(pNewLeaderHeadInfo);
- GC.setInfoTypeFromString(pNewLeaderHeadInfo->getType(),
GC.getLeaderHeadInfo().size() - 1);
+ GC.getRandomLeaderInfo().push_back(pNewLeaderHeadInfo);
+ GC.setInfoTypeFromString(pNewLeaderHeadInfo->getType(),
GC.getRandomLeaderInfo().size() - 1);
}
}
@@ -9991,6 +9981,7 @@
FAssert (eUnitCombat > -1 && eUnitCombat < GC.getNumUnitCombatInfos());
bool bReformLegion = false;
bool bReformAdvancedLegion = false;
+ bool bLeader = false;
if (iNewValue == m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat])
{
@@ -10003,17 +9994,23 @@
{
CvUnit* pHero = getHeroUnit(eHero);
FAssert (pHero != NULL);
- if (pHero->getHeroType() == eHero)
+ if (pHero->getLeaderHero() == NO_HERO)
{
if (pHero->getUnitCombatType() == eUnitCombat)
{
bReformLegion = true;
}
}
- else
+ else if (pHero->getLeaderHero() == eHero)
{
bReformAdvancedLegion = true;
- }
+ bLeader = true;
+ }
+ else
+ {
+ bReformAdvancedLegion = true;
+ bLeader = false;
+ }
}
}
@@ -10033,7 +10030,39 @@
}
else
{
- if (iNewValue > m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat])
+ if (bLeader)
+ {
+ CvUnit* pLeader = getHeroUnit(eHero);
+ FAssert (pLeader != NULL);
+ CvUnit* pHero = pLeader->dismissAdvancedLegion(true);
+ m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat] = iNewValue;
+ swapHeroLegionList(eHero);
+ pHero->formAdvancedLegion(false, true);
+ }
+ else
+ {
+ CvUnit* pCore = getHeroUnit(eHero);
+ FAssert (pCore != NULL);
+ if (pCore->getUnitCombatType() == eUnitCombat)
+ {
+ HeroTypes eLeaderHero = pCore->getLeaderHero();
+ int iLeaderID = getHeroUnitID(eLeaderHero);
+ bool bLeaderTroop = (iLeaderID == pCore->getID());
+ pCore->quitAdvancedLegion(true);
+ backUpHeroLegionMember(eHero);
+ FAssert (pCore->getHeroType() >= 0 && pCore->getHeroType() <
GC.getNumHeroInfos());
+ pCore->processLegion(false, true, false, false);
+ m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat] = iNewValue;
+ pCore->processLegion(false, false, true, false);
+ pCore->joinAdvancedLegion(getHeroUnitID(eLeaderHero), bLeaderTroop);
+ }
+ else
+ {
+ m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat] = iNewValue;
+ }
+ }
+
+ /*if (iNewValue > m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat])
{
for (int iI = 0; iI < getHeroLegionSize(eHero); iI++)
{
@@ -10107,7 +10136,7 @@
}
}
}
- m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat] = iNewValue;
+ m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat] = iNewValue;*/
}
FAssert (m_ppaiHeroUnitCombatLevel[eHero][eUnitCombat] <=
GC.getHeroInfo(eHero).getPotentialUnitCombatLevel(eUnitCombat));
@@ -10125,16 +10154,33 @@
return m_ppaiHeroPromotionStatus[eHero][ePromotion];
}
-void CvGame::setHeroPromotionStatus(HeroTypes eHero, PromotionTypes
ePromotion, int iNewValue)
+void CvGame::setHeroPromotionStatus(HeroTypes eHero, PromotionTypes
ePromotion, int iNewValue, bool bFromNineTransformation)
{
FAssert (eHero > -1 && eHero < GC.getNumHeroInfos());
FAssert (ePromotion > -1 && ePromotion < GC.getNumPromotionInfos());
bool bReformLegion = false;
bool bReformAdvancedLegion = false;
+ bool bLeader = false;
if (m_ppaiHeroPromotionStatus[eHero][ePromotion] == iNewValue)
{
- return;
+ if (isHeroNineTransformationPromotion(eHero, ePromotion))
+ {
+ CvHeroMap::iterator iter = m_mapHeroes.find(eHero);
+ if (find((iter->second).aNineTransformationPromotions.begin(),
(iter->second).aNineTransformationPromotions.end(), ePromotion) !=
(iter->second).aNineTransformationPromotions.end())
+ {
+ return;
+ }
+ else
+ {
+ (iter->second).m_eCurrentNineTransformationPromotion = NO_PROMOTION;
+ return;
+ }
+ }
+ else
+ {
+ return;
+ }
}
int iChange = 0;
@@ -10158,13 +10204,17 @@
if (getHeroLegionSize(eHero) > 0)
{
CvUnit* pCoreTroop =
GET_PLAYER((PlayerTypes)getHeroDebutStatus(eHero)).getUnit(getHeroCoreTroop(eHero));
- if (pCoreTroop->getHeroType() == eHero)
+ if (pCoreTroop->getLeaderHero() == NO_HERO)
{
bReformLegion = true;
}
else
{
bReformAdvancedLegion = true;
+ if (pCoreTroop->getLeaderHero() == eHero)
+ {
+ bLeader = true;
+ }
}
}
}
@@ -10185,7 +10235,90 @@
}
else
{
- CvUnit* pHero = getHeroUnit(eHero);
+ if (bLeader)
+ {
+ // If it's a core troop promotion, then only add/remove with the
guardian unit
+ if (iNewValue == 1 || m_ppaiHeroPromotionStatus[eHero][ePromotion] == 1)
+ {
+ CvUnit* pLeader = getHeroUnit(eHero);
+ FAssert (pLeader != NULL);
+ if (getHeroPromotionStatus(pLeader->getHeroType(), ePromotion) != 1)
+ {
+ pLeader->setHasPromotion(ePromotion, iNewValue == 1 ? true : false);
+ }
+ m_ppaiHeroPromotionStatus[eHero][ePromotion] = iNewValue;
+ }
+ // this should rarely be called: remove a previously possessed member
promotion
+ else if (m_ppaiHeroPromotionStatus[eHero][ePromotion] == 2)
+ {
+ m_ppaiHeroPromotionStatus[eHero][ePromotion] = iNewValue;
+ for (int iI = 0; iI < getHeroLegionSize(eHero); iI++)
+ {
+ CvUnit* pLoopHero =
GET_PLAYER((PlayerTypes)getHeroDebutStatus(eHero)).getUnit(getHeroLegionMemberAt(eHero,
iI));
+ HeroTypes eLoopHero = pLoopHero->getHeroType();
+
+ // check to see if that promotion is set as member legion's nine
transformation promotion
+ if (!bFromNineTransformation &&
getHeroCurrentNineTransformationPromotion(eLoopHero) == ePromotion)
+ {
+ if (!isHeroNineTransformationPromotion(eLoopHero, ePromotion))
+ {
+ setHeroCurrentNineTransformationPromotion(eLoopHero, NO_PROMOTION);
+ }
+ }
+ }
+ }
+ else
+ {
+ m_ppaiHeroPromotionStatus[eHero][ePromotion] = iNewValue;
+ }
+ }
+ else
+ {
+ CvUnit* pCore = getHeroUnit(eHero);
+ FAssert (pCore != NULL);
+ // if it's a core troop promotion, then check the leader hero's
promotion status, and add/remove where fit
+ // note that in rare cases this could be a nine transformation
promotion: a hero who has nine transformation as innate ability
+ if (iNewValue == 1 || m_ppaiHeroPromotionStatus[eHero][ePromotion] == 1)
+ {
+ if (!pCore->isLeaderTroop() ||
getHeroPromotionStatus(pCore->getLeaderHero(), ePromotion) != 1)
+ {
+ pCore->setHasPromotion(ePromotion, iNewValue == 1 ? true : false);
+ }
+ m_ppaiHeroPromotionStatus[eHero][ePromotion] = iNewValue;
+ }
+ else if (iNewValue == 2 || m_ppaiHeroPromotionStatus[eHero][ePromotion]
== 2)
+ {
+ if (iNewValue == 2 && !bFromNineTransformation &&
getHeroCurrentNineTransformationPromotion(eHero) == ePromotion)
+ {
+ setHeroCurrentNineTransformationPromotion(eHero, NO_PROMOTION);
+ }
+ HeroTypes eLeader = pCore->getLeaderHero();
+ int iLeaderID = getHeroUnitID(eLeader);
+ bool bLeaderTroop = (iLeaderID == pCore->getID());
+ pCore->quitAdvancedLegion(true);
+ CvUnit* pLeaderTroop = getHeroUnit(eLeader);
+ backUpHeroLegionMember(eHero);
+ FAssert (pCore->getHeroType() >= 0 && pCore->getHeroType() <
GC.getNumHeroInfos());
+ pCore->processLegion(false, true, false, false);
+ m_ppaiHeroPromotionStatus[eHero][ePromotion] = iNewValue;
+ pCore->processLegion(false, false, true, false);
+ if (pLeaderTroop->isNakedHero())
+ {
+ addHeroCoreTroop(eLeader, pCore->getID());
+ pLeaderTroop->formAdvancedLegion(false, true);
+ }
+ else
+ {
+ pCore->joinAdvancedLegion(getHeroUnitID(eLeader), bLeaderTroop);
+ }
+ }
+ else
+ {
+ m_ppaiHeroUnitCombatLevel[eHero][ePromotion] = iNewValue;
+ }
+ }
+
+ /*CvUnit* pHero = getHeroUnit(eHero);
FAssert (pHero != NULL);
FAssert (pHero->isLeaderTroop());
if (iNewValue == 1 || m_ppaiHeroPromotionStatus[eHero][ePromotion]
== 1)
@@ -10223,7 +10356,7 @@
}
}
}
- }
+ }*/
}
if (iChange != 0)
@@ -10289,6 +10422,13 @@
void CvGame::setHeroUnitID(HeroTypes eHero, int iID)
{
FAssert (eHero > -1 && eHero < GC.getNumHeroInfos());
+#ifdef _DEBUG
+ if (iID != -1)
+ {
+ CvUnit* pUnit =
GET_PLAYER((PlayerTypes)getHeroDebutStatus(eHero)).getUnit(iID);
+ FAssert(pUnit->getHeroType() != NO_HERO);
+ }
+#endif
m_mapHeroes[eHero].m_iUnitID = iID;
}
@@ -10363,7 +10503,7 @@
if (GC.getPromotionInfo(ePromotion).getHeroPromotionStatus() > 0)
{
- setHeroPromotionStatus(eHero, ePromotion,
GC.getPromotionInfo(ePromotion).getHeroPromotionStatus());
+ setHeroPromotionStatus(eHero, ePromotion,
GC.getPromotionInfo(ePromotion).getHeroPromotionStatus(), false);
}
CvUnit* pHero = getHeroUnit(eHero);
@@ -10404,7 +10544,18 @@
if (!bNineTransformation && !bRandom && getHeroPromotionStatus(eHero,
ePromotion) != 3)
{
- return false;
+ if (isHeroNineTransformationPromotion(eHero, ePromotion))
+ {
+ CvHeroMap::const_iterator iter = m_mapHeroes.find(eHero);
+ if (find((iter->second).aNineTransformationPromotions.begin(),
(iter->second).aNineTransformationPromotions.end(), ePromotion) !=
(iter->second).aNineTransformationPromotions.end())
+ {
+ return false;
+ }
+ }
+ else
+ {
+ return false;
+ }
}
if (GC.getPromotionInfo(ePromotion).getHeroUnitCombatLevelChange() != 0)
@@ -10529,7 +10680,7 @@
if (ePlayer > -1)
{
CvUnit* pHero = GET_PLAYER(ePlayer).getUnit(getHeroUnitID(eHero));
- if (pHero != NULL && pHero->getHeroType() != eHero)
+ if (pHero != NULL && pHero->getHeroType() != eHero &&
pHero->getHeroType() != NO_HERO)
{
if (isHeroPromotionReady(pHero->getHeroType()))
{
@@ -10559,7 +10710,7 @@
if (getSorenRandNum(GC.getNumPromotionInfos(), "Random Promotion
Pick") < 5)
{
GC.getHeroInfo(eHero).setUnitPromotionStatus(ePromotion, 3);
- setHeroPromotionStatus(eHero, ePromotion, 3);
+ setHeroPromotionStatus(eHero, ePromotion, 3, false);
iNumSet++;
}
}
@@ -10814,7 +10965,7 @@
m_mapHeroes[eHero].aNineTransformationPromotions.pop_back();
if (getHeroCurrentNineTransformationPromotion(eHero) == ePromotion)
{
- setHeroPromotionStatus(eHero, ePromotion, 0);
+ setHeroPromotionStatus(eHero, ePromotion, 0, true);
}
iLevelChange++;
}
@@ -10874,12 +11025,12 @@
if (eOldPromotion != NO_PROMOTION)
{
- setHeroPromotionStatus(eHero, eOldPromotion, 0);
+ setHeroPromotionStatus(eHero, eOldPromotion, 0, true);
}
if (ePromotion != NO_PROMOTION)
{
- setHeroPromotionStatus(eHero, ePromotion,
GC.getPromotionInfo(ePromotion).getHeroPromotionStatus());
+ setHeroPromotionStatus(eHero, ePromotion,
GC.getPromotionInfo(ePromotion).getHeroPromotionStatus(), true);
}
}
@@ -11227,6 +11378,11 @@
CvHeroInfo* pNewHeroInfo = new CvHeroInfo;
FAssert (pNewHeroInfo != NULL);
FAssert (GET_PLAYER(ePlayer).isAlive());
+
+ if (!GET_PLAYER(ePlayer).isAlive())
+ {
+ return NO_HERO;
+ }
pNewHeroInfo->setRandom(true);
@@ -11646,10 +11802,7 @@
kData.aSeeInvisibleCount.push_back(0);
}
- CvUnit* pHero =
GET_PLAYER(ePlayer).initUnit((UnitTypes)pNewHeroInfo->getUnitType(), iX,
iY);
- setHeroUnitID((HeroTypes)iIndex, pHero->getID());
- pHero->setHeroType((HeroTypes)iIndex);
- GET_PLAYER(ePlayer).changeHeroMaintenance((HeroTypes)iIndex, true, false,
0);
+ GET_PLAYER(ePlayer).initHero((HeroTypes)iIndex, iX, iY, true);
m_paNewHeroes.push_back(pNewHeroInfo);
@@ -11672,6 +11825,22 @@
}
}
}
+
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ if (!GET_PLAYER(ePlayer).isFeatAccomplished(FEAT_CREATE_RANDOM_HERO))
+ {
+ GET_PLAYER(ePlayer).setFeatAccomplished(FEAT_CREATE_RANDOM_HERO, true);
+ if (GET_PLAYER(ePlayer).isFeatPopup())
+ {
+ CyArgsList argsList;
+
+ argsList.add(ePlayer);
+ argsList.add((HeroTypes)iIndex);
+
+
gDLL->getPythonIFace()->callFunction(PYSanguoModule, "doCreateRandomHeroFeat",
argsList.makeFunctionArgs());
+ }
+ }
+ // Sanguo Mod Tutorial, end
return (HeroTypes)iIndex;
}
@@ -11876,12 +12045,14 @@
FAssert (GET_PLAYER(ePlayer).isAlive());
FAssert (eHero > -1 && eHero < GC.getNumHeroInfos());
+ pNewLeaderHeadInfo->initRandomLeader();
+
pNewLeaderHeadInfo->setRandom(true);
// find the random portrait
// set portrait, button, civilopedia, strategy, help
CvString szBuffer;
- szBuffer.Format("LEADERHEAD_RANDOM_%d", (int)m_paNewLeaders.size() + 1);
+ szBuffer.Format("LEADERHEAD_RANDOM_%d", (int)GC.getNumRandomLeaderInfos()
+ 1);
pNewLeaderHeadInfo->setType(szBuffer);
pNewLeaderHeadInfo->setText(GC.getHeroInfo(eHero).getText());
@@ -11914,28 +12085,35 @@
if (-1 == iIndex)
{
- GC.getLeaderHeadInfo().push_back(pNewLeaderHeadInfo);
+ GC.getRandomLeaderInfo().push_back(pNewLeaderHeadInfo);
if (NULL != pNewLeaderHeadInfo->getType())
{
- GC.setInfoTypeFromString(pNewLeaderHeadInfo->getType(),
(int)GC.getLeaderHeadInfo().size() - 1); // add type to global info type
hash map
+ GC.setInfoTypeFromString(pNewLeaderHeadInfo->getType(),
(int)GC.getRandomLeaderInfo().size() - 1); // add type to global info type
hash map
}
}
else
{
- SAFE_DELETE((GC.getLeaderHeadInfo())[iIndex]);
- (GC.getLeaderHeadInfo())[iIndex] = pNewLeaderHeadInfo;
+ SAFE_DELETE((GC.getRandomLeaderInfo())[iIndex]);
+ (GC.getRandomLeaderInfo())[iIndex] = pNewLeaderHeadInfo;
}
- iIndex = GC.getInfoTypeForString(pNewLeaderHeadInfo->getType());
+ iIndex = GC.getInfoTypeForString(pNewLeaderHeadInfo->getType()) +
GC.getNumLeaderHeadInfos();
GC.getHeroInfo(eHero).setLeaderType(iIndex);
-
GC.getCivilizationInfo(GET_PLAYER(ePlayer).getCivilizationType()).pushNewLeader(iIndex);
+
GC.getCivilizationInfo(GET_PLAYER(ePlayer).getCivilizationType()).pushNewLeader(iIndex,
false);
+ for (int iI = 0; iI < GC.getNumCivilizationInfos(); iI++)
+ {
+ if (iI != GET_PLAYER(ePlayer).getCivilizationType())
+ {
+ GC.getCivilizationInfo((CivilizationTypes)iI).pushNewLeader(iIndex,
true);
+ }
+ }
return (LeaderHeadTypes)iIndex;
}
-void CvGame::doHeroDeath(HeroTypes eHero)
+void CvGame::doHeroDeath(HeroTypes eHero, bool bKillUnit)
{
PROFILE_FUNC();
@@ -11944,7 +12122,7 @@
PlayerTypes ePlayer = (PlayerTypes)getHeroDebutStatus(eHero);
- if (ePlayer != NO_PLAYER)
+ if (ePlayer >= 0)
{
setHeroDebutStatus(eHero, -3);
GET_PLAYER(ePlayer).recalculateGreatGeneralThreshold();
@@ -11952,8 +12130,11 @@
}
else
{
- setHeroDebutStatus(eHero, -3);
- setHeroUnitID(eHero, -1);
+ if (!bKillUnit)
+ {
+ setHeroDebutStatus(eHero, -3);
+ setHeroUnitID(eHero, -1);
+ }
return;
}
@@ -12033,8 +12214,11 @@
}
HeroTypes eHero = createRandomHero(ePlayer, iX, iY);
- eNewLeader = createRandomLeader(ePlayer, eHero);
- }
+ if (eHero != NO_HERO)
+ {
+ eNewLeader = createRandomLeader(ePlayer, eHero);
+ }
+ }
FAssert (eNewLeader != NO_LEADER);
@@ -12057,15 +12241,9 @@
if (getHeroDebutStatus((HeroTypes)iI) < 0)
{
FAssert (getHeroDebutStatus((HeroTypes)iI) > -3);
- CvCity* pCapital = GET_PLAYER(ePlayer).getCapitalCity();
- FAssert (pCapital != NULL);
- UnitTypes eUnit =
(UnitTypes)GC.getHeroInfo((HeroTypes)iI).getUnitType();
- FAssert (eUnit != NO_UNIT);
- CvUnit* pUnit = GET_PLAYER(ePlayer).initUnit(eUnit,
pCapital->getX_INLINE(), pCapital->getY_INLINE());
- FAssert (NULL != pUnit);
- pUnit->setHeroType((HeroTypes)iI);
- setHeroDebutStatus((HeroTypes)iI, ePlayer);
- setHeroUnitID((HeroTypes)iI, pUnit->getID());
+ int iX, iY;
+ GET_PLAYER(ePlayer).findXY(&iX, &iY);
+ GET_PLAYER(ePlayer).initHero((HeroTypes)iI, iX, iY, true);
break;
}
}
@@ -12149,28 +12327,48 @@
}
}
+ GC.getGameINLINE().setHeroVitality(eHero, 0);
if (getHeroUnitID(eHero) != -1)
{
CvUnit* pHeroUnit =
GET_PLAYER(ePlayer).getUnit(getHeroUnitID(eHero));
- GC.getGameINLINE().setHeroVitality(eHero, 0);
if (pHeroUnit->isCoreTroop())
{
- pHeroUnit = pHeroUnit->dismissLegion();
- FAssert (pHeroUnit != NULL);
- pHeroUnit->kill(false);
+ pHeroUnit = pHeroUnit->dismissLegion(!bKillUnit);
+ if (bKillUnit && pHeroUnit != NULL)
+ {
+ pHeroUnit->kill(false);
+ }
}
else if (pHeroUnit->isNakedHero())
{
- pHeroUnit->kill(false);
- }
+ if (bKillUnit)
+ {
+ pHeroUnit->kill(false);
+ }
+ }
else
{
FAssert(false);
}
}
- else
+
+ if (!bKillUnit)
{
setHeroDebutStatus(eHero, -3);
+ setHeroUnitID(eHero, -1);
+ GET_PLAYER(ePlayer).changeHeroMaintenance(eHero, false, true, 0);
}
}
// Sanguo Mod Hero, end
+
+// Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+int CvGame::getTutorialID() const
+{
+ return m_iTutorialID;
+}
+
+void CvGame::setTutorialID(int iNewValue)
+{
+ m_iTutorialID = iNewValue;
+}
+// Sanguo Mod tutorial, end
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvGame.h Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvGame.h Fri Oct 16 02:15:14 2009
@@ -530,7 +530,7 @@
void setHeroUnitCombatLevel(HeroTypes eHero, UnitCombatTypes
eUnitCombat, int iNewValue); // Exposed to Python
void changeHeroUnitCombatLevel(HeroTypes eHero, UnitCombatTypes
eUnitCombat, int iChange); // Exposed to Python
int getHeroPromotionStatus(HeroTypes eHero, PromotionTypes ePromotion)
const; // Exposed to Python
- void setHeroPromotionStatus(HeroTypes eHero, PromotionTypes
ePromotion, int iNewValue); // Exposed to Python
+ void setHeroPromotionStatus(HeroTypes eHero, PromotionTypes
ePromotion, int iNewValue, bool bFromNineTransformation = false); //
Exposed to Python
int getHeroUnitID(HeroTypes eHero) const; // Exposed to Python
void setHeroUnitID(HeroTypes eHero, int iID); // Exposed to Python
float getHeroExperience(HeroTypes eHero) const; // Exposed to
Python
@@ -598,9 +598,14 @@
void swapHeroLegionList(HeroTypes eHero);
LeaderHeadTypes createRandomLeader(PlayerTypes ePlayer, HeroTypes
eHero);
- void doHeroDeath(HeroTypes eHero);
+ void doHeroDeath(HeroTypes eHero, bool bKillUnit = true);
// Sanguo Mod Hero, end
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ int getTutorialID() const; // Exposed to Python
+ void setTutorialID(int iNewValue); // Exposed to Python
+ // Sanguo Mod tutorial, end
+
protected:
int m_iEndTurnMessagesSent;
@@ -706,6 +711,10 @@
std::vector<CvLeaderHeadInfo*> m_paNewLeaders;
// Sanguo Mod Hero, end
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ int m_iTutorialID;
+ // Sanguo Mod tutorial, end
+
// CACHE: cache frequently used values
int m_iShrineBuildingCount;
int* m_aiShrineBuilding;
@@ -761,4 +770,8 @@
void doUpdateCacheOnTurn();
};
+// Sanguo Mod helper, start, by poyuzhe 10.15.09
+#define GAME GC.getGameINLINE()
+// Sanguo Mod helper, end
+
#endif
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvGameTextMgr.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvGameTextMgr.cpp Fri Oct 16 02:15:14 2009
@@ -2057,6 +2057,29 @@
case DOMAIN_LAND:
bValid = !(pPlot->isWater());
+
+ // Sanguo Mod Danyang Armies, start, by poyzuhe 09.29.09
+ if (!bValid)
+ {
+ int iOdds;
+
+ pAttacker =
gDLL->getInterfaceIFace()->getSelectionList()->AI_getBestGroupAttacker(pPlot,
false, iOdds);
+
+ if (pAttacker == NULL)
+ {
+ pAttacker =
gDLL->getInterfaceIFace()->getSelectionList()->AI_getBestGroupAttacker(pPlot,
false, iOdds, true);
+ }
+
+ if (pAttacker != NULL)
+ {
+ if (pAttacker->getUnitInfo().isCanMoveAllTerrain())
+ {
+ bValid = true;
+ }
+ }
+ }
+ // Sanguo Mod Danyang Armies, end
+
break;
case DOMAIN_IMMOBILE:
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvGlobals.cpp Sat Sep 19 06:38:49 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvGlobals.cpp Fri Oct 16 02:15:14 2009
@@ -1191,8 +1191,18 @@
CvLeaderHeadInfo& CvGlobals::getLeaderHeadInfo(LeaderHeadTypes
eLeaderHeadNum)
{
FAssert(eLeaderHeadNum > -1);
- FAssert(eLeaderHeadNum < GC.getNumLeaderHeadInfos());
- return *(m_paLeaderHeadInfo[eLeaderHeadNum]);
+ // Sanguo Mod Random Leader, start, by poyuzhe 09.30.09
+ //FAssert(eLeaderHeadNum < GC.getNumLeaderHeadInfos());
+ //return *(m_paLeaderHeadInfo[eLeaderHeadNum]);
+ FAssert(eLeaderHeadNum < (GC.getNumLeaderHeadInfos() +
GC.getNumRandomLeaderInfos()));
+ if (eLeaderHeadNum < GC.getNumLeaderHeadInfos())
+ {
+ return *(m_paLeaderHeadInfo[eLeaderHeadNum]);
+ }
+ else
+ {
+ return *(m_paRandomLeaderInfo[eLeaderHeadNum -
GC.getNumLeaderHeadInfos()]);
+ }
}
@@ -2456,6 +2466,24 @@
FAssert (eSurrenderNum < GC.getNumSurrenderInfos());
return *(m_paSurrenderInfo[eSurrenderNum]);
}
+
+// Random leader
+int CvGlobals::getNumRandomLeaderInfos()
+{
+ return (int)m_paRandomLeaderInfo.size();
+}
+
+std::vector<CvLeaderHeadInfo*>& CvGlobals::getRandomLeaderInfo()
+{
+ return m_paRandomLeaderInfo;
+}
+
+CvLeaderHeadInfo& CvGlobals::getRandomLeaderInfo(RandomLeaderTypes
eRandomLeader)
+{
+ FAssert (eRandomLeader > -1);
+ FAssert (eRandomLeader < GC.getNumRandomLeaderInfos());
+ return *(m_paRandomLeaderInfo[eRandomLeader]);
+}
// Sanguo Mod XML, end
int& CvGlobals::getNumEntityEventTypes()
@@ -3156,16 +3184,34 @@
int CvGlobals::getUSE_ON_UNIT_SELECTED_CALLBACK()
{
+ // Sanguo Mod Tutorial, start, by poyuzhe 09.28.09
+ if (GC.getGameINLINE().getTutorialID() > -1)
+ {
+ return 1;
+ }
+ // Sanguo Mod Tutorial, end
return m_iUSE_ON_UNIT_SELECTED_CALLBACK;
}
int CvGlobals::getUSE_ON_UPDATE_CALLBACK()
{
+ // Sanguo Mod Tutorial, start, by poyuzhe 09.28.09
+ if (GC.getGameINLINE().getTutorialID() > -1)
+ {
+ return 1;
+ }
+ // Sanguo Mod Tutorial, end
return m_iUSE_ON_UPDATE_CALLBACK;
}
int CvGlobals::getUSE_ON_UNIT_CREATED_CALLBACK()
{
+ // Sanguo Mod Tutorial, start, by poyuzhe 09.28.09
+ if (GC.getGameINLINE().getTutorialID() > -1)
+ {
+ return 1;
+ }
+ // Sanguo Mod Tutorial, end
return m_iUSE_ON_UNIT_CREATED_CALLBACK;
}
@@ -3593,6 +3639,10 @@
deleteInfoArray(m_paSurrenderInfo);
// Sanguo Mod XML, end
+ // Sanguo MOd Random Leader, start, by poyuzhe 09.30.09
+ deleteInfoArray(m_paRandomLeaderInfo);
+ // Sanguo Mod Random Leader, end
+
clearTypesMap();
m_aInfoVectors.clear();
}
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvGlobals.h Sat Sep 19 06:38:49 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvGlobals.h Fri Oct 16 02:15:14 2009
@@ -646,6 +646,12 @@
CvSurrenderInfo& getSurrenderInfo(SurrenderTypes eSurrender);
// Sanguo Mod XML, end
+ // Random Leader, start, by poyuzhe 09.30.09
+ int getNumRandomLeaderInfos();
+ std::vector<CvLeaderHeadInfo*>& getRandomLeaderInfo();
+ CvLeaderHeadInfo& getRandomLeaderInfo(RandomLeaderTypes eRandomLeader);
+ // Random Leader, end
+
//
// Global Types
// All type strings are upper case and are kept in this hash map for fast
lookup
@@ -1107,6 +1113,10 @@
std::vector<CvSurrenderInfo*> m_paSurrenderInfo;
// Sanguo Mod XML, end
+ // Random Leader, start, by poyuzhe 09.30.09
+ std::vector<CvLeaderHeadInfo*> m_paRandomLeaderInfo;
+ // Random Leader, end
+
// Game Text
std::vector<CvGameText*> m_paGameTextXML;
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvInfos.cpp Sat Sep 26 22:57:14 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvInfos.cpp Fri Oct 16 02:15:14 2009
@@ -10270,7 +10270,10 @@
bool CvCivilizationInfo::isLeaders(int i) const
{
- FAssertMsg(i < GC.getNumLeaderHeadInfos(), "Index out of bounds");
+ // Sanguo Mod Hero, start, added by poyuzhe 03.06.09
+ //FAssertMsg(i < GC.getNumLeaderHeadInfos(), "Index out of bounds");
+ FAssertMsg(i < GC.getNumLeaderHeadInfos() +
GC.getNumRandomLeaderInfos(), "Index out of bounds");
+ // Sanguo Mod Hero, end
FAssertMsg(i > -1, "Index out of bounds");
// Sanguo Mod Hero, start, added by poyuzhe 03.06.09
// return m_pbLeaders ? m_pbLeaders[i] : false;
@@ -10336,11 +10339,12 @@
}
// Sanguo Mod random hero, start, by poyuzhe 09.19.09
-void CvCivilizationInfo::pushNewLeader(int i)
-{
+void CvCivilizationInfo::pushNewLeader(int i, bool bExtendOnly)
+{
+ FAssert (i == GC.getNumLeaderHeadInfos() + GC.getNumRandomLeaderInfos() -
1);
std::vector<bool> aTempList;
int iCount = 0;
- for (int iI = 0; iI < GC.getNumLeaderHeadInfos() - 1; iI++)
+ for (int iI = 0; iI < GC.getNumLeaderHeadInfos() +
GC.getNumRandomLeaderInfos() - 1; iI++)
{
aTempList.push_back(m_piLeaders[iI]);
if (m_piLeaders[iI] > 0)
@@ -10349,12 +10353,19 @@
}
}
SAFE_DELETE_ARRAY(m_piLeaders);
- m_piLeaders = new int[GC.getNumLeaderHeadInfos()];
- for (int iI = 0; iI < GC.getNumLeaderHeadInfos() - 1; iI++)
+ m_piLeaders = new int[GC.getNumLeaderHeadInfos() +
GC.getNumRandomLeaderInfos()];
+ for (int iI = 0; iI < GC.getNumLeaderHeadInfos() +
GC.getNumRandomLeaderInfos() - 1; iI++)
{
m_piLeaders[iI] = aTempList[iI];
}
- m_piLeaders[i] = iCount + 1;
+ if (!bExtendOnly)
+ {
+ m_piLeaders[i] = iCount + 1;
+ }
+ else
+ {
+ m_piLeaders[i] = 0;
+ }
aTempList.clear();
}
@@ -10410,8 +10421,8 @@
// m_pbLeaders = new bool[GC.getNumLeaderHeadInfos()];
// stream->Read(GC.getNumLeaderHeadInfos(), m_pbLeaders);
SAFE_DELETE_ARRAY(m_piLeaders);
- m_piLeaders = new int[GC.getNumLeaderHeadInfos()];
- stream->Read(GC.getNumLeaderHeadInfos(), m_piLeaders);
+ m_piLeaders = new int[GC.getNumLeaderHeadInfos() +
GC.getNumRandomLeaderInfos()];
+ stream->Read(GC.getNumLeaderHeadInfos() + GC.getNumRandomLeaderInfos(),
m_piLeaders);
// Sanguo Mod Hero, end
SAFE_DELETE_ARRAY(m_pbCivilizationFreeBuildingClass);
@@ -10466,7 +10477,7 @@
stream->Write(GC.getNumCivicOptionInfos(), m_piCivilizationInitialCivics);
// Sanguo Mod Hero, start, added by poyuzhe 03.06.09
// stream->Write(GC.getNumLeaderHeadInfos(), m_pbLeaders);
- stream->Write(GC.getNumLeaderHeadInfos(), m_piLeaders);
+ stream->Write(GC.getNumLeaderHeadInfos() + GC.getNumRandomLeaderInfos(),
m_piLeaders);
// Sanguo Mod Hero, end
stream->Write(GC.getNumBuildingClassInfos(),
m_pbCivilizationFreeBuildingClass);
stream->Write(GC.getNumTechInfos(), m_pbCivilizationFreeTechs);
@@ -15450,6 +15461,74 @@
}
}
+void CvLeaderHeadInfo::initRandomLeader()
+{
+ SAFE_DELETE_ARRAY(m_pbTraits);
+ SAFE_DELETE_ARRAY(m_piFlavorValue);
+ SAFE_DELETE_ARRAY(m_piContactRand);
+ SAFE_DELETE_ARRAY(m_piContactDelay);
+ SAFE_DELETE_ARRAY(m_piMemoryDecayRand);
+ SAFE_DELETE_ARRAY(m_piMemoryAttitudePercent);
+ SAFE_DELETE_ARRAY(m_piNoWarAttitudeProb);
+ SAFE_DELETE_ARRAY(m_piUnitAIWeightModifier);
+ SAFE_DELETE_ARRAY(m_piImprovementWeightModifier);
+ SAFE_DELETE_ARRAY(m_piDiploPeaceIntroMusicScriptIds);
+ SAFE_DELETE_ARRAY(m_piDiploPeaceMusicScriptIds);
+ SAFE_DELETE_ARRAY(m_piDiploWarIntroMusicScriptIds);
+ SAFE_DELETE_ARRAY(m_piDiploWarMusicScriptIds);
+
+ int iI;
+ m_pbTraits = new bool[GC.getNumTraitInfos()];
+ for(iI=0; iI<GC.getNumTraitInfos(); iI++)
+ {
+ m_pbTraits[iI]=false;
+ }
+ m_piFlavorValue = new int[GC.getNumFlavorTypes()];
+ for (iI=0;iI<GC.getNumFlavorTypes();iI++)
+ {
+ m_piFlavorValue[iI]=-1;
+ }
+ m_piContactRand = new int[NUM_CONTACT_TYPES];
+ m_piContactDelay = new int[NUM_CONTACT_TYPES];
+ for(iI=0;iI<NUM_CONTACT_TYPES;iI++)
+ {
+ m_piContactRand[iI]=-1;
+ m_piContactDelay[iI]=-1;
+ }
+ m_piMemoryDecayRand = new int[NUM_MEMORY_TYPES];
+ m_piMemoryAttitudePercent = new int[NUM_MEMORY_TYPES];
+ for(iI=0;iI<NUM_MEMORY_TYPES;iI++)
+ {
+ m_piMemoryDecayRand[iI]=-1;
+ m_piMemoryAttitudePercent[iI]=-1;
+ }
+ m_piNoWarAttitudeProb = new int[NUM_ATTITUDE_TYPES];
+ for(iI=0;iI<NUM_ATTITUDE_TYPES;iI++)
+ {
+ m_piNoWarAttitudeProb[iI]=-1;
+ }
+ m_piUnitAIWeightModifier = new int[NUM_UNITAI_TYPES];
+ for(iI=0;iI<NUM_UNITAI_TYPES;iI++)
+ {
+ m_piUnitAIWeightModifier[iI]=-1;
+ }
+ m_piImprovementWeightModifier = new int[GC.getNumImprovementInfos()];
+ for(iI=0;iI<GC.getNumImprovementInfos();iI++)
+ {
+ m_piImprovementWeightModifier[iI]=-1;
+ }
+ m_piDiploPeaceIntroMusicScriptIds = new int[GC.getNumEraInfos()];
+ m_piDiploPeaceMusicScriptIds = new int[GC.getNumEraInfos()];
+ m_piDiploWarIntroMusicScriptIds = new int[GC.getNumEraInfos()];
+ m_piDiploWarMusicScriptIds = new int[GC.getNumEraInfos()];
+ for(iI=0;iI<GC.getNumEraInfos();iI++)
+ {
+ m_piDiploWarMusicScriptIds[iI]=-1;
+ m_piDiploWarIntroMusicScriptIds[iI]=-1;
+ m_piDiploPeaceMusicScriptIds[iI]=-1;
+ m_piDiploPeaceIntroMusicScriptIds[iI]=-1;
+ }
+}
// Sanguo Mod end
// Arrays
@@ -15675,58 +15754,55 @@
// Sanguo Mod random leader, start, by poyuzhe 09.20.09
stream->Read(&m_bRandom);
stream->ReadString(m_szPortrait);
-
- if (!isRandom())
- {
- SAFE_DELETE_ARRAY(m_piFlavorValue);
- m_piFlavorValue = new int[GC.getNumFlavorTypes()];
- stream->Read(GC.getNumFlavorTypes(), m_piFlavorValue);
-
- SAFE_DELETE_ARRAY(m_piContactRand);
- m_piContactRand = new int[NUM_CONTACT_TYPES];
- stream->Read(NUM_CONTACT_TYPES, m_piContactRand);
-
- SAFE_DELETE_ARRAY(m_piContactDelay);
- m_piContactDelay = new int[NUM_CONTACT_TYPES];
- stream->Read(NUM_CONTACT_TYPES, m_piContactDelay);
-
- SAFE_DELETE_ARRAY(m_piMemoryDecayRand);
- m_piMemoryDecayRand = new int[NUM_MEMORY_TYPES];
- stream->Read(NUM_MEMORY_TYPES, m_piMemoryDecayRand);
-
- SAFE_DELETE_ARRAY(m_piMemoryAttitudePercent);
- m_piMemoryAttitudePercent = new int[NUM_MEMORY_TYPES];
- stream->Read(NUM_MEMORY_TYPES, m_piMemoryAttitudePercent);
-
- SAFE_DELETE_ARRAY(m_piNoWarAttitudeProb);
- m_piNoWarAttitudeProb = new int[NUM_ATTITUDE_TYPES];
- stream->Read(NUM_ATTITUDE_TYPES, m_piNoWarAttitudeProb);
-
- SAFE_DELETE_ARRAY(m_piUnitAIWeightModifier);
- m_piUnitAIWeightModifier = new int[NUM_UNITAI_TYPES];
- stream->Read(NUM_UNITAI_TYPES, m_piUnitAIWeightModifier);
-
- SAFE_DELETE_ARRAY(m_piImprovementWeightModifier);
- m_piImprovementWeightModifier = new int[GC.getNumImprovementInfos()];
- stream->Read(GC.getNumImprovementInfos(),
m_piImprovementWeightModifier);
-
- SAFE_DELETE_ARRAY(m_piDiploPeaceIntroMusicScriptIds);
- m_piDiploPeaceIntroMusicScriptIds = new int[GC.getNumEraInfos()];
- stream->Read(GC.getNumEraInfos(), m_piDiploPeaceIntroMusicScriptIds);
-
- SAFE_DELETE_ARRAY(m_piDiploPeaceMusicScriptIds);
- m_piDiploPeaceMusicScriptIds = new int[GC.getNumEraInfos()];
- stream->Read(GC.getNumEraInfos(), m_piDiploPeaceMusicScriptIds);
-
- SAFE_DELETE_ARRAY(m_piDiploWarIntroMusicScriptIds);
- m_piDiploWarIntroMusicScriptIds = new int[GC.getNumEraInfos()];
- stream->Read(GC.getNumEraInfos(), m_piDiploWarIntroMusicScriptIds);
-
- SAFE_DELETE_ARRAY(m_piDiploWarMusicScriptIds);
- m_piDiploWarMusicScriptIds = new int[GC.getNumEraInfos()];
- stream->Read(GC.getNumEraInfos(), m_piDiploWarMusicScriptIds);
- }
- // Sanguo Mod random leader, end
+ // Sanguo Mod random leader, end
+
+ SAFE_DELETE_ARRAY(m_piFlavorValue);
+ m_piFlavorValue = new int[GC.getNumFlavorTypes()];
+ stream->Read(GC.getNumFlavorTypes(), m_piFlavorValue);
+
+ SAFE_DELETE_ARRAY(m_piContactRand);
+ m_piContactRand = new int[NUM_CONTACT_TYPES];
+ stream->Read(NUM_CONTACT_TYPES, m_piContactRand);
+
+ SAFE_DELETE_ARRAY(m_piContactDelay);
+ m_piContactDelay = new int[NUM_CONTACT_TYPES];
+ stream->Read(NUM_CONTACT_TYPES, m_piContactDelay);
+
+ SAFE_DELETE_ARRAY(m_piMemoryDecayRand);
+ m_piMemoryDecayRand = new int[NUM_MEMORY_TYPES];
+ stream->Read(NUM_MEMORY_TYPES, m_piMemoryDecayRand);
+
+ SAFE_DELETE_ARRAY(m_piMemoryAttitudePercent);
+ m_piMemoryAttitudePercent = new int[NUM_MEMORY_TYPES];
+ stream->Read(NUM_MEMORY_TYPES, m_piMemoryAttitudePercent);
+
+ SAFE_DELETE_ARRAY(m_piNoWarAttitudeProb);
+ m_piNoWarAttitudeProb = new int[NUM_ATTITUDE_TYPES];
+ stream->Read(NUM_ATTITUDE_TYPES, m_piNoWarAttitudeProb);
+
+ SAFE_DELETE_ARRAY(m_piUnitAIWeightModifier);
+ m_piUnitAIWeightModifier = new int[NUM_UNITAI_TYPES];
+ stream->Read(NUM_UNITAI_TYPES, m_piUnitAIWeightModifier);
+
+ SAFE_DELETE_ARRAY(m_piImprovementWeightModifier);
+ m_piImprovementWeightModifier = new int[GC.getNumImprovementInfos()];
+ stream->Read(GC.getNumImprovementInfos(),
m_piImprovementWeightModifier);
+
+ SAFE_DELETE_ARRAY(m_piDiploPeaceIntroMusicScriptIds);
+ m_piDiploPeaceIntroMusicScriptIds = new int[GC.getNumEraInfos()];
+ stream->Read(GC.getNumEraInfos(), m_piDiploPeaceIntroMusicScriptIds);
+
+ SAFE_DELETE_ARRAY(m_piDiploPeaceMusicScriptIds);
+ m_piDiploPeaceMusicScriptIds = new int[GC.getNumEraInfos()];
+ stream->Read(GC.getNumEraInfos(), m_piDiploPeaceMusicScriptIds);
+
+ SAFE_DELETE_ARRAY(m_piDiploWarIntroMusicScriptIds);
+ m_piDiploWarIntroMusicScriptIds = new int[GC.getNumEraInfos()];
+ stream->Read(GC.getNumEraInfos(), m_piDiploWarIntroMusicScriptIds);
+
+ SAFE_DELETE_ARRAY(m_piDiploWarMusicScriptIds);
+ m_piDiploWarMusicScriptIds = new int[GC.getNumEraInfos()];
+ stream->Read(GC.getNumEraInfos(), m_piDiploWarMusicScriptIds);
}
void CvLeaderHeadInfo::write(FDataStreamBase* stream)
@@ -15834,21 +15910,20 @@
// Sanguo Mod random leader, start, by poyuzhe 09.20.09
stream->Write(m_bRandom);
stream->WriteString(m_szPortrait);
- if (!isRandom())
- {
- stream->Write(GC.getNumFlavorTypes(), m_piFlavorValue);
- stream->Write(NUM_CONTACT_TYPES, m_piContactRand);
- stream->Write(NUM_CONTACT_TYPES, m_piContactDelay);
- stream->Write(NUM_MEMORY_TYPES, m_piMemoryDecayRand);
- stream->Write(NUM_MEMORY_TYPES, m_piMemoryAttitudePercent);
- stream->Write(NUM_ATTITUDE_TYPES, m_piNoWarAttitudeProb);
- stream->Write(NUM_UNITAI_TYPES, m_piUnitAIWeightModifier);
- stream->Write(GC.getNumImprovementInfos(),
m_piImprovementWeightModifier);
- stream->Write(GC.getNumEraInfos(), m_piDiploPeaceIntroMusicScriptIds);
- stream->Write(GC.getNumEraInfos(), m_piDiploPeaceMusicScriptIds);
- stream->Write(GC.getNumEraInfos(), m_piDiploWarIntroMusicScriptIds);
- stream->Write(GC.getNumEraInfos(), m_piDiploWarMusicScriptIds);
- }
+ // Sanguo Mod random leader, end
+
+ stream->Write(GC.getNumFlavorTypes(), m_piFlavorValue);
+ stream->Write(NUM_CONTACT_TYPES, m_piContactRand);
+ stream->Write(NUM_CONTACT_TYPES, m_piContactDelay);
+ stream->Write(NUM_MEMORY_TYPES, m_piMemoryDecayRand);
+ stream->Write(NUM_MEMORY_TYPES, m_piMemoryAttitudePercent);
+ stream->Write(NUM_ATTITUDE_TYPES, m_piNoWarAttitudeProb);
+ stream->Write(NUM_UNITAI_TYPES, m_piUnitAIWeightModifier);
+ stream->Write(GC.getNumImprovementInfos(),
m_piImprovementWeightModifier);
+ stream->Write(GC.getNumEraInfos(), m_piDiploPeaceIntroMusicScriptIds);
+ stream->Write(GC.getNumEraInfos(), m_piDiploPeaceMusicScriptIds);
+ stream->Write(GC.getNumEraInfos(), m_piDiploWarIntroMusicScriptIds);
+ stream->Write(GC.getNumEraInfos(), m_piDiploWarMusicScriptIds);
}
const CvArtInfoLeaderhead* CvLeaderHeadInfo::getArtInfo() const
@@ -20943,8 +21018,20 @@
{
FAssertMsg(i < getNumResponses(), "Index out of bounds");
FAssertMsg(i > -1, "Index out of bounds");
- FAssertMsg(j < GC.getNumLeaderHeadInfos(), "Index out of bounds");
+
+ // Sanguo Mod random leader,start
+ FAssertMsg(j < GC.getNumLeaderHeadInfos() +
GC.getNumRandomLeaderInfos(), "Index out of bounds");
+ // Sanguo Mod random leader, end
+
FAssertMsg(j > -1, "Index out of bounds");
+
+ // Sanguo Mod random leader, start, by poyuzhe 09.20.09
+ if (GC.getLeaderHeadInfo((LeaderHeadTypes)j).isRandom())
+ {
+ return true;
+ }
+ // Sanguo Mod random leader, end
+
return m_pResponses[i].m_pbLeaderHeadTypes[j];
}
@@ -20999,7 +21086,8 @@
{
if((int)aTempList.size() > iI)
{
- m_pbLeaderHeadTypes[iI] = aTempList[iI];
+ //m_pbLeaderHeadTypes[iI] = aTempList[iI];
+ m_pbLeaderHeadTypes[iI] = true;
}
else
{
@@ -21041,7 +21129,7 @@
stream->Write(GC.getNumCivilizationInfos(), m_pbCivilizationTypes);
// Sanguo Mod random leader, start, by poyuzhe 09.20.09
- reInitLeaderHead();
+ // reInitLeaderHead();
// Sanguo Mod random leader, end
stream->Write(GC.getNumLeaderHeadInfos(), m_pbLeaderHeadTypes);
stream->Write(NUM_ATTITUDE_TYPES, m_pbAttitudeTypes);
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvInfos.h Sat Sep 26 22:57:14 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvInfos.h Fri Oct 16 02:15:14 2009
@@ -2416,7 +2416,7 @@
// Sanguo Mod Hero, end
// Sanguo Mod random hero, start, by poyuzhe 09.19.09
- void pushNewLeader(int i);
+ void pushNewLeader(int i, bool bExtendOnly);
// Sanguo Mod random hero, end
DllExport bool isCivilizationFreeBuildingClass(int i) const; //
Exposed to Python
@@ -3864,6 +3864,7 @@
void setFavoriteReligion(int i);
void setFavoriteCivic(int i);
void setHasTrait(int i, bool bNewValue);
+ void initRandomLeader();
// Sanguo Mod random leader, end
DllExport bool hasTrait(int i) const; // Exposed to Python
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvPlayer.cpp Sat Sep 26 22:57:14 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvPlayer.cpp Fri Oct 16 02:15:14 2009
@@ -36,6 +36,7 @@
/** General
AI
*/
/*************************************************************************************************/
#include "CvDLLFlagEntityIFaceBase.h"
+#include "Math.h"
/*************************************************************************************************/
/** BETTER_BTS_AI_MOD
END */
/*************************************************************************************************/
@@ -1842,14 +1843,7 @@
{
if (GC.getHeroInfo((HeroTypes)iI).getLeaderType() ==
getLeaderType() && GC.getGameINLINE().getHeroDebutStatus((HeroTypes)iI) < 0)
{
- CvUnit* pHero =
initUnit((UnitTypes)GC.getHeroInfo((HeroTypes)iI).getUnitType(),
m_iStartingX, m_iStartingY);
- pHero->setHeroType((HeroTypes)iI);
- if (GC.getGameINLINE().getHeroDebutStatus((HeroTypes)iI) != getID())
- {
- GC.getGameINLINE().setHeroDebutStatus((HeroTypes)iI,
getID());
- changeHeroMaintenance((HeroTypes)iI, true, false, 0);
- }
- GC.getGameINLINE().setHeroUnitID((HeroTypes)iI,
pHero->getID());
+ initHero((HeroTypes)iI, m_iStartingX, m_iStartingY,
GC.getGameINLINE().getHeroDebutStatus((HeroTypes)iI) != getID());
}
}
recalculateGreatGeneralThreshold();
@@ -3877,6 +3871,11 @@
{
return false;
}
+
+ if (GC.getGameINLINE().getHeroCapturePlayer(eHero) != NO_PLAYER)
+ {
+ return false;
+ }
if (getGold() < (bDiscount ? getRecruitHeroGold(eHero) / 2 :
getRecruitHeroGold(eHero)))
{
@@ -3888,20 +3887,15 @@
void CvPlayer::recruitHero(HeroTypes eHero, bool bDiscount)
{
- CvCity* pCity = getCapitalCity();
- if (NULL != pCity)
- {
- CvUnit* pUnit =
initUnit((UnitTypes)(GC.getHeroInfo(eHero).getUnitType()),
pCity->getX_INLINE(), pCity->getY_INLINE());
- FAssert (pUnit != NULL);
- pUnit->setHeroType(eHero);
- if (GC.getGameINLINE().getHeroDebutStatus(eHero) != getID())
- {
- GC.getGameINLINE().setHeroDebutStatus(eHero, getID());
- changeHeroMaintenance(eHero, true, false, 0);
- }
- GC.getGameINLINE().setHeroUnitID(eHero, pUnit->getID());
- CvWString szBuffer = gDLL->getText("TXT_KEY_HERO_RECRUITED",
pUnit->getName().GetCString());
- gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_MAJOR_EVENT, pUnit->getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_UNIT_TEXT"),
pCity->getX_INLINE(), pCity->getY_INLINE(), true, true);
+ int iX, iY;
+ findXY(&iX, &iY);
+
+ if (iX > -1 && iY > -1)
+ {
+ initHero(eHero, iX, iY,
GC.getGameINLINE().getHeroDebutStatus(eHero) != getID());
+
+ CvWString szBuffer = gDLL->getText("TXT_KEY_HERO_RECRUITED",
GC.getHeroInfo(eHero).getDescription());
+ gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_MAJOR_EVENT, GC.getHeroInfo(eHero).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_UNIT_TEXT"), iX, iY, true, true);
changeGold(-(bDiscount ? getRecruitHeroGold(eHero) / 2 :
getRecruitHeroGold(eHero)));
// Temporary: give a crappy loyalty if XML default is zero
if (GC.getHeroInfo(eHero).getCivilizationLoyalty(getCivilizationType())
== 0)
@@ -3969,36 +3963,21 @@
GET_PLAYER(ePlayer).AI_invalidateAttitudeCache(getID());
}
- CvCity* pCity = getCapitalCity();
int iX, iY;
- if (NULL != pCity)
- {
- iX = pCity->getX_INLINE();
- iY = pCity->getY_INLINE();
- }
- else
- {
- int iLoop;
- CvUnit* pLoopUnit = firstUnit(&iLoop);
- iX = pLoopUnit->getX_INLINE();
- iY = pLoopUnit->getY_INLINE();
- }
-
- CvUnit* pUnit =
initUnit((UnitTypes)(GC.getHeroInfo(eHero).getUnitType()), iX, iY);
- FAssert (pUnit != NULL);
- pUnit->setHeroType(eHero);
+ findXY(&iX, &iY);
+
+ initHero(eHero, iX, iY, ePlayer != getID());
+
if (ePlayer != getID())
{
- CvWString szBuffer = gDLL->getText("TXT_KEY_HERO_PERSUADED",
pUnit->getName().GetCString());
- gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_MAJOR_EVENT, pUnit->getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_UNIT_TEXT"), iX, iY, true, true);
- FAssert (GC.getGameINLINE().getHeroDebutStatus(eHero) >= 0)
- szBuffer = gDLL->getText("TXT_KEY_HERO_BETRAYED",
pUnit->getName().GetCString(), getCivilizationDescription());
- gDLL->getInterfaceIFace()->addMessage(ePlayer, false,
GC.getEVENT_MESSAGE_TIME(), szBuffer,
GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitDefeatScript(),
MESSAGE_TYPE_INFO, pUnit->getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_WARNING_TEXT"));
-
- GC.getGameINLINE().setHeroDebutStatus(eHero, getID());
- changeHeroMaintenance(eHero, true, false, 0);
- }
- GC.getGameINLINE().setHeroUnitID(eHero, pUnit->getID());
+ CvWString szBuffer = gDLL->getText("TXT_KEY_HERO_PERSUADED",
GC.getHeroInfo(eHero).getDescription());
+ gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_MAJOR_EVENT, GC.getHeroInfo(eHero).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_UNIT_TEXT"), iX, iY, true, true);
+ if (ePlayer >= 0 && GET_PLAYER(ePlayer).isAlive())
+ {
+ szBuffer = gDLL->getText("TXT_KEY_HERO_BETRAYED",
GC.getHeroInfo(eHero).getDescription(), getCivilizationDescription());
+ gDLL->getInterfaceIFace()->addMessage(ePlayer, false,
GC.getEVENT_MESSAGE_TIME(), szBuffer,
GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitDefeatScript(),
MESSAGE_TYPE_INFO, GC.getHeroInfo(eHero).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_WARNING_TEXT"));
+ }
+ }
GC.getGameINLINE().setHeroCapturePlayer(eHero, NO_PLAYER);
// Temporary: give a crappy loyalty if XML default is zero
@@ -4034,7 +4013,7 @@
}
}
- GC.getGameINLINE().doHeroDeath(eHero);
+ GC.getGameINLINE().doHeroDeath(eHero, false);
GC.getGameINLINE().setHeroCapturePlayer(eHero, NO_PLAYER);
@@ -4062,32 +4041,15 @@
{
GET_PLAYER(ePlayer).AI_changeMemoryCount(getID(), MEMORY_RELEASED_HERO,
1);
- CvCity* pCity = GET_PLAYER(ePlayer).getCapitalCity();
- FAssert (pCity != NULL);
int iX, iY;
- if (pCity != NULL)
- {
- iX = pCity->getX_INLINE();
- iY = pCity->getY_INLINE();
- }
- else
- {
- int iLoop;
- CvUnit* pLoopUnit = GET_PLAYER(ePlayer).firstUnit(&iLoop);
- iX = pLoopUnit->getX_INLINE();
- iY = pLoopUnit->getY_INLINE();
- }
-
- CvUnit* pUnit =
GET_PLAYER(ePlayer).initUnit((UnitTypes)(GC.getHeroInfo(eHero).getUnitType()),
iX, iY);
- FAssert (pUnit != NULL);
- pUnit->setHeroType(eHero);
- CvWString szBuffer = gDLL->getText("TXT_KEY_YOU_RELEASE_HERO",
pUnit->getName().GetCString());
+ GET_PLAYER(ePlayer).findXY(&iX, &iY);
+
+ GET_PLAYER(ePlayer).initHero(eHero, iX, iY, true);
+
+ CvWString szBuffer = gDLL->getText("TXT_KEY_YOU_RELEASE_HERO",
GC.getHeroInfo(eHero).getDescription());
gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_POSITIVE_DINK",
MESSAGE_TYPE_INFO);
- szBuffer = gDLL->getText("TXT_KEY_HERO_RELEASED",
pUnit->getName().GetCString(), getCivilizationDescription());
- gDLL->getInterfaceIFace()->addMessage(ePlayer, false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_POSITIVE_DINK",
MESSAGE_TYPE_INFO, pUnit->getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_YELLOW"), iX, iY, true, true);
-
- GET_PLAYER(ePlayer).changeHeroMaintenance(eHero, true, false, 0);
- GC.getGameINLINE().setHeroUnitID(eHero, pUnit->getID());
+ szBuffer = gDLL->getText("TXT_KEY_HERO_RELEASED",
GC.getHeroInfo(eHero).getDescription(), getCivilizationDescription());
+ gDLL->getInterfaceIFace()->addMessage(ePlayer, false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_POSITIVE_DINK",
MESSAGE_TYPE_INFO, GC.getHeroInfo(eHero).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_YELLOW"), iX, iY, true, true);
GC.getGameINLINE().setHeroCapturePlayer(eHero, NO_PLAYER);
@@ -4113,29 +4075,15 @@
if (GET_PLAYER(ePlayer).isAlive())
{
int iX, iY;
- CvCity* pCapital = GET_PLAYER(ePlayer).getCapitalCity();
- if (pCapital != NULL)
- {
- iX = pCapital->getX_INLINE();
- iY = pCapital->getY_INLINE();
- }
- else
- {
- int iLoop;
- CvUnit* pLoopUnit = GET_PLAYER(ePlayer).firstUnit(&iLoop);
- FAssert(pLoopUnit!= NULL);
- iX = pLoopUnit->getX_INLINE();
- iY = pLoopUnit->getY_INLINE();
- }
- CvUnit* pHero =
GET_PLAYER(ePlayer).initUnit((UnitTypes)GC.getHeroInfo(eHero).getUnitType(),
iX, iY);
- pHero->setHeroType(eHero);
- GC.getGameINLINE().setHeroUnitID(eHero, pHero->getID());
+ GET_PLAYER(ePlayer).findXY(&iX, &iY);
+ GET_PLAYER(ePlayer).initHero(eHero, iX, iY, true);
GC.getGameINLINE().setHeroCapturePlayer(eHero, NO_PLAYER);
CvWString szBuffer = gDLL->getText("TXT_KEY_HERO_FREED",
GC.getHeroInfo(eHero).getDescription());
- gDLL->getInterfaceIFace()->addMessage(ePlayer, false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_POSITIVE_DINK",
MESSAGE_TYPE_INFO, pHero->getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), iX, iY, true, true);
+ gDLL->getInterfaceIFace()->addMessage(ePlayer, false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_POSITIVE_DINK",
MESSAGE_TYPE_INFO, GC.getHeroInfo(eHero).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), iX, iY, true, true);
if (isAlive())
{
- gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_NEGATIVE_DINK",
MESSAGE_TYPE_INFO, pHero->getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_RED"), iX, iY, true, true);
+ szBuffer = gDLL->getText("TXT_KEY_HERO_BEEN_FREED",
GET_PLAYER(ePlayer).getCivilizationDescription(),
GC.getHeroInfo(eHero).getDescription());
+ gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_NEGATIVE_DINK",
MESSAGE_TYPE_INFO, GC.getHeroInfo(eHero).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_RED"), iX, iY, true, true);
}
}
else
@@ -4144,6 +4092,50 @@
GC.getGameINLINE().setHeroCapturePlayer(eHero, NO_PLAYER);
}
}
+
+CvUnit* CvPlayer::initHero(HeroTypes eHero, int iX, int iY, bool
bUpdateMaintenance)
+{
+ CvUnit *pHero = initUnit((UnitTypes)GC.getHeroInfo(eHero).getUnitType(),
iX, iY);
+ if (pHero == NULL)
+ {
+ return NULL;
+ }
+
+ pHero->setHeroType(eHero);
+ GC.getGameINLINE().setHeroDebutStatus(eHero, getID());
+ GC.getGameINLINE().setHeroUnitID(eHero, pHero->getID());
+ if (bUpdateMaintenance)
+ {
+ changeHeroMaintenance(eHero, true, false, 0);
+ }
+
+ return pHero;
+}
+
+void CvPlayer::findXY(int* iX, int* iY, bool bUnitOnly)
+{
+ if (!isAlive())
+ {
+ *iX = -1;
+ *iY = -1;
+ }
+ else
+ {
+ CvCity* pCity = getCapitalCity();
+ if (NULL != pCity && !bUnitOnly)
+ {
+ *iX = pCity->getX_INLINE();
+ *iY = pCity->getY_INLINE();
+ }
+ else
+ {
+ int iLoop;
+ CvUnit* pLoopUnit = firstUnit(&iLoop);
+ *iX = pLoopUnit->getX_INLINE();
+ *iY = pLoopUnit->getY_INLINE();
+ }
+ }
+}
// Sanguo Mod Hero, end
// Sanguo Mod Hero, join legion, start, by poyuzhe 09.14.08
@@ -4178,6 +4170,82 @@
}
// Sanguo Mod Hero, end
+// Sanguo Mod Tutorial, start, by poyuzhe 09.27.09
+bool CvPlayer::isFeatPopup() const
+{
+ if (!isOption(PLAYEROPTION_ADVISOR_POPUPS))
+ {
+ return false;
+ }
+
+ if (!isHuman())
+ {
+ return false;
+ }
+
+ if (GC.getGameINLINE().isNetworkMultiPlayer())
+ {
+ return false;
+ }
+
+ /*if (GC.getGameINLINE().getElapsedGameTurns() == 0)
+ {
+ return false;
+ }*/
+
+ return true;
+}
+// Sanguo Mod Tutorial, end
+
+// Sanguo Mod Performance, start, by poyuzhe 09.28.09
+int CvPlayer::getScoreComponent(int iRawScore, int iInitial, int iMax, int
iFactor, bool bExponential, bool bFinal, bool bVictory) const
+{
+ if (GC.getGameINLINE().getEstimateEndTurn() == 0)
+ {
+ return 0;
+ }
+ float fTurnRatio;
+ float fMax;
+
+ if (bFinal && bVictory)
+ {
+ fTurnRatio = (float)(GC.getGameINLINE().getGameTurn()) /
(float)(GC.getGameINLINE().getEstimateEndTurn());
+ }
+ if (bExponential && (iInitial != 0))
+ {
+ float fRatio = (float)iMax / (float)iInitial;
+ fMax = iInitial * pow(fRatio, fTurnRatio);
+ }
+ else
+ {
+ fMax = iInitial + fTurnRatio * (iMax - iInitial);
+ }
+
+ float iFree = (GC.getDefineINT("SCORE_FREE_PERCENT") * fMax) / 100;
+ float iScore;
+ if ((iFree + fMax) != 0)
+ {
+ iScore = (iFactor * (iRawScore + iFree)) / (iFree + fMax);
+ }
+ else
+ {
+ iScore = (float)iFactor;
+ }
+
+ if (bVictory)
+ {
+ iScore = ((100 + GC.getDefineINT("SCORE_VICTORY_PERCENT")) * iScore) /
100;
+ }
+
+ if (bFinal)
+ {
+ iScore = ((100 + GC.getDefineINT("SCORE_HANDICAP_PERCENT_OFFSET") +
(GC.getGameINLINE().getHandicapType() *
GC.getDefineINT("SCORE_HANDICAP_PERCENT_PER"))) * iScore) / 100;
+ }
+
+ return (int)iScore;
+}
+// Sanguo Mod Performance, end
+
/*************************************************************************************************/
/** AI_AUTO_PLAY_MOD
07/09/08 jdog5000 */
/**
*/
@@ -5044,6 +5112,12 @@
{
return 0;
}
+
+ /*int iPopulationScore = getScoreComponent(getPopScore(),
GC.getGameINLINE().getInitPopulation(),
GC.getGameINLINE().getMaxPopulation(),
GC.getDefineINT("SCORE_POPULATION_FACTOR"), true, bFinal, bVictory);
+ int iLandScore = getScoreComponent(getLandScore(),
GC.getGameINLINE().getInitLand(), GC.getGameINLINE().getMaxLand(),
GC.getDefineINT("SCORE_LAND_FACTOR"), true, bFinal, bVictory);
+ int iTechScore = getScoreComponent(getTechScore(),
GC.getGameINLINE().getInitTech(), GC.getGameINLINE().getMaxTech(),
GC.getDefineINT("SCORE_TECH_FACTOR"), true, bFinal, bVictory);
+ int iWondersScore = getScoreComponent(getWondersScore(),
GC.getGameINLINE().getInitWonders(), GC.getGameINLINE().getMaxWonders(),
GC.getDefineINT("SCORE_WONDER_FACTOR"), false, bFinal, bVictory);
+ return (iPopulationScore + iLandScore + iWondersScore + iTechScore);*/
long lScore = 0;
@@ -11635,7 +11709,7 @@
// break;
// }
// }
- if (!isHuman())
+ if (!isHuman() && isAlive())
{
int iRandOffset = 0;
std::vector<HeroTypes> OwnFactionHeroIDs;
@@ -11748,7 +11822,7 @@
}
setCombatExperience(getCombatExperience() - iExperienceThreshold);
}
- else
+ else if (isAlive())
{
// If the human player is not currently active, do not show create
champion screen, it would be out of sync
//if (GC.getGameINLINE().getActivePlayer() == getID())
@@ -11897,21 +11971,14 @@
gDLL->openSlot(getID());
-/*************************************************************************************************/
-/** BETTER_BTS_AI_MOD 09/03/09
poyuzhe & jdog5000 */
-/**
*/
-/**
Efficiency
*/
-/*************************************************************************************************/
- // From Sanguo Mod Performance, ie the CAR Mod
+ // Sanguo Mod Performance, start, by poyuzhe and jdog5000, 09.03.09
// Attitude cache
- for( int iI = 0; iI < MAX_PLAYERS; iI++ )
+ for( iI = 0; iI < MAX_PLAYERS; iI++ )
{
GET_PLAYER((PlayerTypes)iI).AI_invalidateAttitudeCache(getID());
GET_PLAYER(getID()).AI_invalidateAttitudeCache((PlayerTypes)iI);
}
-/*************************************************************************************************/
-/** BETTER_BTS_AI_MOD
END */
-/*************************************************************************************************/
+ // Sanguo Mod Performance, end
}
else
{
@@ -11925,14 +11992,25 @@
{
if (GC.getGameINLINE().getHeroCapturePlayer((HeroTypes)iI) == getID())
{
- if (GC.getGameINLINE().getHeroDebutStatus((HeroTypes)iI) >= 0)
- {
-
freePlayerHeroes((PlayerTypes)GC.getGameINLINE().getHeroDebutStatus((HeroTypes)iI),
(HeroTypes)iI);
+ if (GAME.getHeroDebutStatus((HeroTypes)iI) >= 0)
+ {
+
freePlayerHeroes((PlayerTypes)GAME.getHeroDebutStatus((HeroTypes)iI),
(HeroTypes)iI);
}
else
{
- GC.getGameINLINE().setHeroDebutStatus((HeroTypes)iI, -2);
- GC.getGameINLINE().setHeroCapturePlayer((HeroTypes)iI, NO_PLAYER);
+ GAME.setHeroDebutStatus((HeroTypes)iI, -2);
+ GAME.setHeroCapturePlayer((HeroTypes)iI, NO_PLAYER);
+ }
+ }
+ // set our heroes who have been captured by other faction to unemployed
+ else if (GAME.getHeroDebutStatus((HeroTypes)iI) == getID())
+ {
+ GAME.setHeroDebutStatus((HeroTypes)iI, -2);
+ // This is when last city is captured but hero is not, so set the
hero debut status to unemployed.
+ if (GAME.getHeroCapturePlayer((HeroTypes)iI) == NO_PLAYER)
+ {
+ GAME.setHeroUnitID((HeroTypes)iI, -1);
+ //changeHeroMaintenance((HeroTypes)iI, false, true, 0);
}
}
}
@@ -18570,19 +18648,6 @@
pStream->Read(&m_iPopRushHurryCount);
pStream->Read(&m_iInflationModifier);
-
- // Sanguo Mod Temporary, start, added by poyzuhe 08.27.09
- // for the purpose of save game compatibility with V2.4 (This is
unrelease patch D)
- recalculateGreatGeneralThreshold();
- m_iExtraUnitCost = 0;
- for (int iI = 0; iI < GC.getNumHeroInfos(); iI++)
- {
- if (GC.getGameINLINE().getHeroDebutStatus((HeroTypes)iI) == getID())
- {
- changeHeroMaintenance((HeroTypes)iI, true, false, 0);
- }
- }
- // Sanguo Mod Temporary, end
}
//
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvPlayer.h Sat Sep 26 22:57:14 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvPlayer.h Fri Oct 16 02:15:14 2009
@@ -1069,7 +1069,9 @@
void executeHero(HeroTypes eHero); // Exposed to Python
void releaseHero(HeroTypes eHero); // Exposed to Python
void freePlayerHeroes(PlayerTypes ePlayer, HeroTypes eHero);
- // Sanguo Mod Hero, end
+ CvUnit* initHero(HeroTypes eHero, int iX, int iY, bool
bUpdateMaintenance = true); // Exposed to Python
+ void findXY(int* iX, int* iY, bool bUnitOnly = false);
+ // Sanguo Mod Hero, end
// Sanguo Mod Hero, join legion, start, by poyuzhe 09.14.08
void clearJoinLegionTempHeroList(); // Exposed to Python
@@ -1078,6 +1080,14 @@
int getJoinLegionTempHeroIDAt(int iIndex) const; // Exposed to Python
// Sanguo Mod Hero, end
+ // Sanguo Mod Tutorial, start, by poyuzhe 09.27.09
+ bool isFeatPopup() const;
+ // Sanguo Mod Tutorial, end
+
+ // Sanguo Mod Performance, start, by poyuzhe 09.28.09
+ int getScoreComponent(int iRawScore, int iInitial, int iMax, int iFactor,
bool bExponential, bool bFinal, bool bVictory) const;
+ // Sanguo Mod Performance, end
+
virtual void AI_init() = 0;
virtual void AI_reset(bool bConstructor) = 0;
virtual void AI_doTurnPre() = 0;
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvPlayerAI.cpp Sat Sep 26 22:57:14 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvPlayerAI.cpp Fri Oct 16 02:15:14 2009
@@ -20030,18 +20030,13 @@
{
if (GC.getHeroInfo((HeroTypes)iI).getFamily() == getCivilizationType())
{
- CvCity* pCity = getCapitalCity();
- if (NULL != pCity)
- {
- CvUnit* pUnit =
initUnit((UnitTypes)(GC.getHeroInfo((HeroTypes)iI).getUnitType()),
pCity->getX_INLINE(), pCity->getY_INLINE());
- FAssert (pUnit != NULL);
- pUnit->setHeroType((HeroTypes)iI);
- GC.getGameINLINE().setHeroDebutStatus((HeroTypes)iI, getID());
- changeHeroMaintenance((HeroTypes)iI, true, false, 0);
- GC.getGameINLINE().setHeroUnitID((HeroTypes)iI, pUnit->getID());
- CvWString szBuffer = gDLL->getText("TXT_KEY_HERO_JOIN_FAMILY",
pUnit->getName().GetCString());
- gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_MAJOR_EVENT, pUnit->getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_UNIT_TEXT"),
pCity->getX_INLINE(), pCity->getY_INLINE(), true, true);
- }
+ int iX, iY;
+ findXY(&iX, &iY);
+
+ initHero((HeroTypes)iI, iX, iY, true);
+
+ CvWString szBuffer = gDLL->getText("TXT_KEY_HERO_JOIN_FAMILY",
GC.getHeroInfo((HeroTypes)iI).getDescription());
+ gDLL->getInterfaceIFace()->addMessage(getID(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_MAJOR_EVENT, GC.getHeroInfo((HeroTypes)iI).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_UNIT_TEXT"), iX, iY, true, true);
}
}
@@ -20054,7 +20049,11 @@
if (!isHuman())
{
int iRand = GC.getGameINLINE().getSorenRandNum(100, "deal
with hero");
- if (GC.getGameINLINE().willHeroJoinFaction((HeroTypes)iI,
getID()))
+ if (GC.getHeroInfo((HeroTypes)iI).getMurdererCiv() ==
getCivilizationType()
&& !GC.getGameINLINE().isOption(GAMEOPTION_NO_HERO_EXECUTION))
+ {
+ executeHero((HeroTypes)iI);
+ }
+ else if
(GC.getGameINLINE().willHeroJoinFaction((HeroTypes)iI, getID()))
{
if (iRand < 90)
{
@@ -20063,7 +20062,7 @@
}
else if
(GC.getSurrenderInfo((SurrenderTypes)GC.getHeroInfo((HeroTypes)iI).getSurrenderType()).getNeverSurrenderToFaction()
== getCivilizationType() ||
GC.getSurrenderInfo((SurrenderTypes)GC.getHeroInfo((HeroTypes)iI).getSurrenderType()).getNeverSurrenderToLeader()
== getPersonalityType())
{
- if (iRand < 30)
+ if (iRand <
(GC.getGameINLINE().isOption(GAMEOPTION_HIGH_HERO_DEATH_CHANCE) ? 60 : 30)
&& !GC.getGameINLINE().isOption(GAMEOPTION_NO_HERO_EXECUTION))
{
executeHero((HeroTypes)iI);
}
@@ -20074,7 +20073,7 @@
}
else if
(GC.getHeroInfo((HeroTypes)iI).getCivilizationLoyalty(getID()) < 80)
{
- if (iRand < 15)
+ if (iRand <
(GC.getGameINLINE().isOption(GAMEOPTION_HIGH_HERO_DEATH_CHANCE) ? 30 : 15)
&& !GC.getGameINLINE().isOption(GAMEOPTION_NO_HERO_EXECUTION))
{
executeHero((HeroTypes)iI);
}
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvPlot.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvPlot.cpp Fri Oct 16 02:15:14 2009
@@ -6435,14 +6435,13 @@
{
if (eBonus != NO_BONUS &&
GET_TEAM(GET_PLAYER(ePlayer).getTeam()).isHasTech((TechTypes)(GC.getBonusInfo(eBonus).getTechReveal())))
{
- std::map<UnitTypes, int> aUnitYieldChange; // so that more
than 1 unit of the same type will not accumulatively affect the plot's yield
CLLNode<IDInfo>* pUnitNode = headUnitNode();
+ int iBestYield = 0;
while (pUnitNode != NULL)
{
CvUnit* pLoopUnit = ::getUnit(pUnitNode->m_data);
pUnitNode = nextUnitNode(pUnitNode);
UnitTypes eUnitType = NO_UNIT;
- int iYieldChange = 0;
if (NULL != pLoopUnit && getOwnerINLINE() ==
pLoopUnit->getOwnerINLINE())
{
eUnitType = pLoopUnit->getUnitType();
@@ -6452,22 +6451,16 @@
if (eCamp != NO_SANGUOCAMP)
{
- iYieldChange =
GC.getSanguoCampInfo(eCamp).getBonusYieldChange(eBonus, eYield);
- if (iYieldChange != 0)
- {
- aUnitYieldChange[eUnitType] = iYieldChange;
+ if
(GC.getSanguoCampInfo(eCamp).getBonusYieldChange(eBonus, eYield) >
iBestYield)
+ {
+ iBestYield =
GC.getSanguoCampInfo(eCamp).getBonusYieldChange(eBonus, eYield);
}
}
}
}
}
- std::map<UnitTypes, int>::iterator iter;
- for (iter = aUnitYieldChange.begin(); iter!=
aUnitYieldChange.end(); ++iter)
- {
- iYield += iter->second;
- }
- aUnitYieldChange.clear();
+ iYield += iBestYield;
}
}
@@ -6501,6 +6494,14 @@
}
}
}
+
+ // Sanguo Mod City Loyalty, start, by poyuzhe 10.15.09
+ /*if (ePlayer != NO_PLAYER)
+ {
+ iYield *= calculateCulturePercent(ePlayer);
+ iYield /= 100;
+ }*/
+ // Sanguo Mod City Loyalty, end
return std::max(0, iYield);
}
@@ -6524,6 +6525,8 @@
void CvPlot::updateYield()
{
+ PROFILE_FUNC();
+
CvCity* pWorkingCity;
bool bChange;
int iNewYield;
@@ -6711,6 +6714,10 @@
{
pCity->AI_setAssignWorkDirty(true);
}
+
+ // Sanguo Mod City Loyalty, start, by poyuzhe 10.15.09
+ //updateYield();
+ // Sanguo Mod City Loyalty, end
}
}
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvSelectionGroup.cpp Tue Sep 22 03:53:27
2009
+++ /trunk/317DLL/CvGameCoreDLL/CvSelectionGroup.cpp Fri Oct 16 02:15:14
2009
@@ -1057,37 +1057,57 @@
}
break;
case MISSION_NINE_TRANSFORMATION:
- if (pLoopUnit->canNineTransformation())
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->canNineTransformation())
{
return true;
}
break;
case MISSION_FORM_ADVANCED_LEGION:
- if (pLoopUnit->canFormAdvancedLegion(pPlot))
+ if (!GC.getGameINLINE().isOption(GAMEOPTION_ENABLE_ARMY))
+ {
+ return false;
+ }
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->canFormAdvancedLegion(pPlot))
{
return true;
}
break;
case MISSION_JOIN_ADVANCED_LEGION:
- if (pLoopUnit->canJoinAdvancedLegion(pPlot))
+ if (!GC.getGameINLINE().isOption(GAMEOPTION_ENABLE_ARMY))
+ {
+ return false;
+ }
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->canJoinAdvancedLegion(pPlot))
{
return true;
}
break;
case MISSION_REGROUP_ADVANCED_LEGION:
- if (pLoopUnit->canRegroupAdvancedLegion(pPlot))
+ if (!GC.getGameINLINE().isOption(GAMEOPTION_ENABLE_ARMY))
+ {
+ return false;
+ }
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->canRegroupAdvancedLegion(pPlot))
{
return true;
}
break;
case MISSION_DISMISS_ADVANCED_LEGION:
- if (pLoopUnit->canDismissAdvancedLegion())
+ if (!GC.getGameINLINE().isOption(GAMEOPTION_ENABLE_ARMY))
+ {
+ return false;
+ }
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->canDismissAdvancedLegion())
{
return true;
}
break;
case MISSION_QUIT_ADVANCED_LEGION:
- if (pLoopUnit->canQuitAdvancedLegion())
+ if (!GC.getGameINLINE().isOption(GAMEOPTION_ENABLE_ARMY))
+ {
+ return false;
+ }
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->canQuitAdvancedLegion())
{
return true;
}
@@ -1555,37 +1575,37 @@
}
break;
case MISSION_NINE_TRANSFORMATION:
- if (pLoopUnit->nineTransformation())
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->nineTransformation())
{
bAction = true;
}
break;
case MISSION_FORM_ADVANCED_LEGION:
- if (pLoopUnit->formAdvancedLegion(false, false))
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->formAdvancedLegion(false, false))
{
bAction = true;
}
break;
case MISSION_JOIN_ADVANCED_LEGION:
- if (pLoopUnit->joinAdvancedLegion(-1))
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->joinAdvancedLegion(-1))
{
bAction = true;
}
break;
case MISSION_REGROUP_ADVANCED_LEGION:
- if (pLoopUnit->formAdvancedLegion(true, false))
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->formAdvancedLegion(true, false))
{
bAction = true;
}
break;
case MISSION_DISMISS_ADVANCED_LEGION:
- if (pLoopUnit->dismissAdvancedLegion())
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->dismissAdvancedLegion(false))
{
bAction = true;
}
break;
case MISSION_QUIT_ADVANCED_LEGION:
- if (pLoopUnit->quitAdvancedLegion())
+ if ((!pLoopUnit->isHuman() || pLoopUnit ==
gDLL->getInterfaceIFace()->getHeadSelectedUnit()) &&
pLoopUnit->quitAdvancedLegion(false))
{
bAction = true;
}
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvTeam.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvTeam.cpp Fri Oct 16 02:15:14 2009
@@ -1631,7 +1631,7 @@
{
for (int iJ = 0; iJ < GET_TEAM(eTeam).getPlayerMemberListSize(); iJ++)
{
- for (int iK = 0; iJ <
GET_TEAM((TeamTypes)iI).getPlayerMemberListSize(); iJ++)
+ for (int iK = 0; iK <
GET_TEAM((TeamTypes)iI).getPlayerMemberListSize(); iK++)
{
GET_PLAYER(GET_TEAM(eTeam).getPlayerMemberAt(iJ)).AI_invalidateAttitudeCache(GET_TEAM((TeamTypes)iI).getPlayerMemberAt(iK));
GET_PLAYER(GET_TEAM((TeamTypes)iI).getPlayerMemberAt(iK)).AI_invalidateAttitudeCache(GET_TEAM(eTeam).getPlayerMemberAt(iJ));
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvTeamAI.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvTeamAI.cpp Fri Oct 16 02:15:14 2009
@@ -997,7 +997,7 @@
int iCount;
int iI, iJ;
- FAssertMsg(eTeam != getID(), "shouldn't call this function on ourselves");
+ //FAssertMsg(eTeam != getID(), "shouldn't call this function on
ourselves");
iAttitude = 0;
iCount = 0;
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvUnit.cpp Sat Sep 26 22:57:14 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvUnit.cpp Fri Oct 16 02:15:14 2009
@@ -251,31 +251,6 @@
}
// Sanguo Mod Hero, start, added by poyuzhe 01.08.09
- if (m_pUnitInfo->isHero())
- {
- std::vector<int> Candidates;
- for (iI = 0; iI < GC.getNumHeroInfos(); iI++)
- {
- if (GC.getHeroInfo((HeroTypes)iI).getUnitType() == m_eUnitType)
- {
- Candidates.push_back(iI);
- }
- }
- if (Candidates.size() == 1)
- {
- m_eHeroType = (HeroTypes)Candidates.front();
- }
- if (m_eHeroType != NO_HERO)
- {
- if (GC.getGameINLINE().getHeroDebutStatus(m_eHeroType) !=
getOwnerINLINE())
- {
- GC.getGameINLINE().setHeroDebutStatus(m_eHeroType,
getOwnerINLINE());
-
GET_PLAYER(getOwnerINLINE()).changeHeroMaintenance(m_eHeroType, true,
false, 0);
- }
- GC.getGameINLINE().setHeroUnitID(m_eHeroType, getID());
- }
- }
-
if (m_pUnitInfo->isHiddenNationality())
{
changeHiddenNationalityCount(1);
@@ -289,6 +264,26 @@
AI_init(eUnitAI);
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ // Temporary, why unit created event do not work?
+ if (AI_getUnitAIType() == UNITAI_EMPEROR)
+ {
+ if
(!GET_PLAYER(getOwnerINLINE()).isFeatAccomplished(FEAT_CAPTURE_EMPEROR))
+ {
+ GET_PLAYER(getOwnerINLINE()).setFeatAccomplished(FEAT_CAPTURE_EMPEROR,
true);
+ if (GET_PLAYER(getOwnerINLINE()).isFeatPopup())
+ {
+ CyArgsList argsList;
+
+ argsList.add(getOwnerINLINE());
+ argsList.add(getID());
+
+
gDLL->getPythonIFace()->callFunction(PYSanguoModule, "doUnitCreatedFeat",
argsList.makeFunctionArgs());
+ }
+ }
+ }
+ // Sanguo Mod Tutorial, end
+
gDLL->getEventReporterIFace()->unitCreated(this);
}
@@ -727,6 +722,7 @@
// Sanguo Mod Hero, start, added by poyuzhe 01.18.09
// if we killed our own core troop for some weird reason
// actually not weird enough, it happens when we are eliminated
+ // It's not an enemy core troop because doLegionMemberDefeated() is
called before kill()
if (isCoreTroop())
{
if (GC.getGameINLINE().getHeroLegionSize(getHeroType()) == 1)
@@ -735,18 +731,10 @@
CvUnit* pHero = NULL;
if (GET_PLAYER(getOwnerINLINE()).getNumCities() > 0 |
| !GET_PLAYER(getOwnerINLINE()).isFoundedFirstCity())
{
- pHero =
GET_PLAYER(getOwnerINLINE()).initUnit((UnitTypes)GC.getHeroInfo(getHeroType()).getUnitType(),
plot()->getX_INLINE(), plot()->getY_INLINE());
+ pHero = GET_PLAYER(getOwnerINLINE()).initHero(getHeroType(),
plot()->getX_INLINE(), plot()->getY_INLINE(),
GC.getGameINLINE().getHeroDebutStatus(getHeroType()) != getOwnerINLINE());
}
if (pHero != NULL)
{
- pHero->setHeroType(getHeroType());
- if
(GC.getGameINLINE().getHeroDebutStatus(getHeroType()) != getOwnerINLINE())
- {
- GC.getGameINLINE().setHeroDebutStatus(getHeroType(),
getOwnerINLINE());
-
GET_PLAYER(getOwnerINLINE()).changeHeroMaintenance(getHeroType(), true,
false, 0);
- }
- GC.getGameINLINE().setHeroUnitID(getHeroType(),
pHero->getID());
-
if (!plot()->isValidDomainForLocation(*pHero))
{
CvCity* pCapital = GET_PLAYER(getOwnerINLINE()).getCapitalCity();
@@ -782,6 +770,7 @@
setLegionHero(NO_HERO);
}
// if we killed our own naked hero (most likely to happen when our civ is
destroyed and have to kill every unit alive)
+ // another case would be when our hero is executed, died in combat or of
natural age
else if (ePlayer == NO_PLAYER && isNakedHero() &&
GC.getGameINLINE().getHeroUnitID(getHeroType()) == getID())
{
if (GC.getGameINLINE().getHeroVitality(getHeroType()) > 0)
@@ -798,85 +787,64 @@
if (ePlayer != NO_PLAYER && isNakedHero())
{
- FAssert (GC.getGameINLINE().getHeroUnitID(getHeroType()) == getID());
-
- // If it's a naked hero unit
- // Do the hero escape and surrender stuff and else
- int iDieRand = GC.getGameINLINE().getSorenRandNum(100, "Hero Die
Rand");
- bool bHeroProcessed = false;
- bool bCurrentLeader =
(GC.getHeroInfo(getHeroType()).getLeaderType() ==
GET_PLAYER(getOwnerINLINE()).getLeaderType());
- bool bCurrentCiv =
(GC.getGameINLINE().getCurrentDefaultCivilization(getHeroType()) ==
getCivilizationType());
-
- if (!bHeroProcessed && ((GET_PLAYER(ePlayer).isBarbarian())
- ? true : (iDieRand < (isBarbarian() ? 0 :
GC.getDefineINT("HERO_ESCAPE_CHANCE")))))
- {
- CvCity* pCity = GET_PLAYER(getOwnerINLINE()).getCapitalCity();
- if (pCity)
- {
- // note that if the hero is at capital city, which means
the capital has fallen, the hero will surrender
- if (!at(pCity->getX_INLINE(), pCity->getY_INLINE()) ||
GET_PLAYER(getOwnerINLINE()).getNumCities() > 1)
- {
- CvCity* pNearestCity =
GC.getMapINLINE().findCity(getX_INLINE(), getY_INLINE(), getOwnerINLINE(),
NO_TEAM, !(plot()->isWater()), false, NO_TEAM, NO_DIRECTION,
(plot()->isCity() ? plot()->getPlotCity() : NULL));
- if (pNearestCity == NULL)
- {
- pNearestCity = GC.getMapINLINE().findCity(plot()->getX_INLINE(),
plot()->getY_INLINE(), getOwnerINLINE(), NO_TEAM, false, false, NO_TEAM,
NO_DIRECTION, (plot()->isCity() ? plot()->getPlotCity() : NULL));
- }
- FAssert (pNearestCity != NULL);
- setXY(pNearestCity->getX_INLINE(), pNearestCity->getY_INLINE());
- bHeroProcessed = true;
- }
-
- if (bHeroProcessed)
- {
- setDamage(0);
- finishMoves();
- m_eCapturingPlayer = NO_PLAYER;
- szBuffer = gDLL->getText("TXT_KEY_MISC_HERO_ESCAPED",
getNameKey());
- gDLL->getInterfaceIFace()->addMessage(ePlayer, false,
GC.getEVENT_MESSAGE_TIME(), szBuffer,
GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitDefeatScript(),
MESSAGE_TYPE_MAJOR_EVENT);
-
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer,
GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitVictoryScript(),
MESSAGE_TYPE_MAJOR_EVENT);
- return;
- }
- }
- else
- {
- GC.getGameINLINE().setHeroUnitID(getHeroType(), -1);
- GC.getGameINLINE().setHeroDebutStatus(getHeroType(), -2);
-
- m_eCapturingPlayer = NO_PLAYER;
-
- bHeroProcessed = true;
- }
- }
-
- // Hero Surrender
- if (!bHeroProcessed)
- {
- if (!GET_PLAYER(ePlayer).isHuman() &&
GC.getHeroInfo(getHeroType()).getMurdererCiv() ==
GET_PLAYER(ePlayer).getCivilizationType())
- {
- GC.getGameINLINE().setHeroUnitID(getHeroType(), -1);
- GC.getGameINLINE().setHeroDebutStatus(getHeroType(), -3);
-
- for (int iI = 0; iI < MAX_PLAYERS; iI++)
- {
- if (GET_PLAYER((PlayerTypes)iI).isAlive())
- {
- szBuffer =
gDLL->getText("TXT_KEY_MISC_HERO_EXECUTED", getNameKey());
-
gDLL->getInterfaceIFace()->addMessage(((PlayerTypes)iI), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer,
GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitDefeatScript(),
MESSAGE_TYPE_MAJOR_EVENT);
- }
- }
-
-
GET_PLAYER(getOwnerINLINE()).changeHeroMaintenance(getHeroType(), false,
true, 0);
-
- // I think this will prevent the hero from being captured
later
- m_eCapturingPlayer = NO_PLAYER;
-
- bHeroProcessed = true;
- }
- else
- {
- FAssert (!GET_PLAYER(ePlayer).isBarbarian());
- GC.getGameINLINE().setHeroUnitID(getHeroType(), -1);
-
GET_PLAYER(getOwnerINLINE()).changeHeroMaintenance(getHeroType(), false,
true, 0);
+ if (GC.getGameINLINE().getHeroVitality(getHeroType()) > 0)
+ {
+ FAssert (GC.getGameINLINE().getHeroUnitID(getHeroType()) == getID());
+
+ // If it's a naked hero unit
+ // Do the hero escape and surrender stuff and else
+ int iDieRand = GC.getGameINLINE().getSorenRandNum(100, "Hero Die Rand");
+ bool bHeroProcessed = false;
+ bool bCurrentLeader = (GC.getHeroInfo(getHeroType()).getLeaderType() ==
GET_PLAYER(getOwnerINLINE()).getLeaderType());
+ bool bCurrentCiv =
(GC.getGameINLINE().getCurrentDefaultCivilization(getHeroType()) ==
getCivilizationType());
+
+ if (!bHeroProcessed && !isBarbarian() &&
((GET_PLAYER(ePlayer).isBarbarian())
+ ? true : (iDieRand < (isBarbarian() ? 0 :
GC.getDefineINT("HERO_ESCAPE_CHANCE")))))
+ {
+ CvCity* pCity = GET_PLAYER(getOwnerINLINE()).getCapitalCity();
+ if (pCity)
+ {
+ // note that if the hero is at capital city, which means the capital
has fallen, the hero will be captured if we only have 1 city left
+ if (!at(pCity->getX_INLINE(), pCity->getY_INLINE()) ||
GET_PLAYER(getOwnerINLINE()).getNumCities() > 1)
+ {
+ CvCity* pNearestCity = GC.getMapINLINE().findCity(getX_INLINE(),
getY_INLINE(), getOwnerINLINE(), NO_TEAM, !(plot()->isWater()), false,
NO_TEAM, NO_DIRECTION, (plot()->isCity() ? plot()->getPlotCity() : NULL));
+ if (pNearestCity == NULL)
+ {
+ pNearestCity = GC.getMapINLINE().findCity(plot()->getX_INLINE(),
plot()->getY_INLINE(), getOwnerINLINE(), NO_TEAM, false, false, NO_TEAM,
NO_DIRECTION, (plot()->isCity() ? plot()->getPlotCity() : NULL));
+ }
+ FAssert (pNearestCity != NULL);
+ setXY(pNearestCity->getX_INLINE(), pNearestCity->getY_INLINE());
+ bHeroProcessed = true;
+ }
+
+ if (bHeroProcessed)
+ {
+ setDamage(0);
+ finishMoves();
+ m_eCapturingPlayer = NO_PLAYER;
+ szBuffer = gDLL->getText("TXT_KEY_MISC_HERO_ESCAPED", getNameKey());
+ gDLL->getInterfaceIFace()->addMessage(ePlayer, false,
GC.getEVENT_MESSAGE_TIME(), szBuffer,
GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitDefeatScript(),
MESSAGE_TYPE_MAJOR_EVENT);
+ gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer,
GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitVictoryScript(),
MESSAGE_TYPE_MAJOR_EVENT);
+ return;
+ }
+ }
+ else
+ {
+ GC.getGameINLINE().setHeroUnitID(getHeroType(), -1);
+ GC.getGameINLINE().setHeroDebutStatus(getHeroType(), -2);
+
+ m_eCapturingPlayer = NO_PLAYER;
+
+ bHeroProcessed = true;
+ }
+ }
+
+ // Hero Capture
+ if (!bHeroProcessed)
+ {
+ FAssert (!GET_PLAYER(ePlayer).isBarbarian());
+ GC.getGameINLINE().setHeroUnitID(getHeroType(), -1);
+ GET_PLAYER(getOwnerINLINE()).changeHeroMaintenance(getHeroType(),
false, true, 0);
GC.getGameINLINE().setHeroCapturePlayer(eHero, ePlayer);
@@ -890,8 +858,24 @@
szBuffer = gDLL->getText("TXT_KEY_MISC_OUR_HERO_CAPTURED",
GC.getHeroInfo(eHero).getDescription(),
GET_PLAYER(ePlayer).getCivilizationDescription());
gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), false,
GC.getEVENT_MESSAGE_TIME(), szBuffer,
GC.getEraInfo(GC.getGameINLINE().getCurrentEra()).getAudioUnitDefeatScript(),
MESSAGE_TYPE_INFO);
}
- }
- }
+
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ if (!GET_PLAYER(ePlayer).isFeatAccomplished(FEAT_CAPTURE_HERO))
+ {
+ GET_PLAYER(ePlayer).setFeatAccomplished(FEAT_CAPTURE_HERO, true);
+ if (GET_PLAYER(ePlayer).isFeatPopup())
+ {
+ CyArgsList argsList;
+
+ argsList.add(getOwnerINLINE());
+ argsList.add(eHero);
+
+
gDLL->getPythonIFace()->callFunction(PYSanguoModule, "doCaptureHeroFeat",
argsList.makeFunctionArgs());
+ }
+ }
+ // Sanguo Mod Tutorial, end
+ }
+ }
}
// Sanguo Mod Hero, end
@@ -957,6 +941,7 @@
if (pkCapturedUnit != NULL)
{
// Sanguo Mod Hero, start, added by poyuzhe 02.08.09
+ // These lines should never execute now since heroes do not have a
capture unit class now. They are imprisoned by default
if (pkCapturedUnit->getUnitInfo().isHero())
{
if (eHero != NO_HERO)
@@ -1220,15 +1205,15 @@
}
if (GC.getGameINLINE().getHeroVitality(getHeroType()) == 0)
{
- GC.getGameINLINE().doHeroDeath(getHeroType());
+ GC.getGameINLINE().doHeroDeath(getHeroType(), true);
return;
}
- if (//!GC.getGameINLINE().isOption(GAMEOPTION_NO_HERO_DEATH_FROM_AGE) &&
+ if (!GC.getGameINLINE().isOption(GAMEOPTION_NO_HERO_DEATH_FROM_AGE) &&
GC.getGameINLINE().getGameTurnYear() >
GC.getHeroInfo(getHeroType()).getHistoricalDieYear())
{
- if (GC.getHeroInfo(getHeroType()).getMurdererCiv() == NO_CIVILIZATION |
| GC.getGameINLINE().getGameTurnYear() >
GC.getHeroInfo(getHeroType()).getStartingYear() + 45)
- {
- if (GC.getGameINLINE().getSorenRandNum(100, "Random Vitality
Decrease") <
GC.getDefineINT("HERO_OLD_AGE_DECERASE_VITALITY_CHANCE_PER_TURN"))
+ if (GC.getHeroInfo(getHeroType()).getMurdererCiv() == NO_CIVILIZATION |
| GC.getGameINLINE().getGameTurnYear() >
GC.getHeroInfo(getHeroType()).getStartingYear() +
(GC.getGameINLINE().isOption(GAMEOPTION_HIGH_HERO_DEATH_CHANCE) ? 35 : 45))
+ {
+ if (GC.getGameINLINE().getSorenRandNum(100, "Random Vitality
Decrease") <
GC.getDefineINT("HERO_OLD_AGE_DECERASE_VITALITY_CHANCE_PER_TURN") *
((GC.getGameINLINE().isOption(GAMEOPTION_HIGH_HERO_DEATH_CHANCE)) ? 2 : 1))
{
GC.getGameINLINE().changeHeroVitality(getHeroType(), -1);
}
@@ -3901,6 +3886,17 @@
setAttackPlot(pPlot, false);
+ // Sanguo Mod Hero, start, by poyuzhe 09.27.09
+ if (getLegionHero() != NO_HERO)
+ {
+ GC.getGameINLINE().setLegionUnitMoved(getLegionHero(), true);
+ if (getLeaderHero() != NO_HERO)
+ {
+ GC.getGameINLINE().setLegionUnitMoved(getLeaderHero(), true);
+ }
+ }
+ // Sanguo Mod Hero, end
+
// Sanguo Mod Hero, start, added by poyuzhe 02.05.09
// comment 1 line out
// updateCombat(bQuick);
@@ -10719,6 +10715,12 @@
bool CvUnit::canMoveAllTerrain() const
{
+ // Sanguo Mod Hero, start, by poyuzhe 10.15.09
+ if (m_pUnitInfo->isHero())
+ {
+ return true;
+ }
+ // Sanguo Mod Hero, end
return m_pUnitInfo->isCanMoveAllTerrain();
}
@@ -15343,7 +15345,7 @@
return false;
}
- if (GC.getGameINLINE().isHeroHasLegionMember(pUnit->getHeroType(),
getID()))
+ if (GAME.isHeroHasLegionMember(pUnit->getHeroType(), getID()))
{
return false;
}
@@ -15363,17 +15365,17 @@
return false;
}
- if (GC.getGameINLINE().getHeroLegionSize(pUnit->getHeroType()) > 0 &&
getUnitCombatType() !=
GET_PLAYER(getOwnerINLINE()).getUnit(GC.getGameINLINE().getHeroCoreTroop(pUnit->getHeroType()))->getUnitCombatType())
+ if (GAME.getHeroLegionSize(pUnit->getHeroType()) > 0 &&
getUnitCombatType() !=
GET_PLAYER(getOwnerINLINE()).getUnit(GAME.getHeroCoreTroop(pUnit->getHeroType()))->getUnitCombatType())
{
return false;
}
- if (GC.getGameINLINE().getHeroLegionSize(pUnit->getHeroType()) >=
GC.getGameINLINE().getHeroCapacity(pUnit->getHeroType()))
+ if (GAME.getHeroLegionSize(pUnit->getHeroType()) >=
GAME.getHeroCapacity(pUnit->getHeroType()))
{
return false;
}
- if (GC.getGameINLINE().isLegionUnitMoved(pUnit->getHeroType()))
+ if (GAME.isLegionUnitMoved(pUnit->getHeroType()))
{
return false;
}
@@ -15465,7 +15467,7 @@
if (!bRegroup)
{
FAssert (getHeroType() != NO_HERO);
- if (GC.getGameINLINE().getHeroLegionSize(getHeroType()) == 0)
+ if (GAME.getHeroLegionSize(getHeroType()) == 0)
{
CyArgsList argsList;
argsList.add(getHeroType());
@@ -15477,7 +15479,7 @@
{
CvUnit* pCoreTroop = processLegion(false, false, false, false);
FAssert (pCoreTroop != NULL);
- GC.getGameINLINE().setLegionUnitMoved(pCoreTroop->getHeroType(), true);
+ GAME.setLegionUnitMoved(pCoreTroop->getHeroType(), true);
if (plot()->isActiveVisible(false))
{
@@ -15488,6 +15490,22 @@
{
gDLL->getInterfaceIFace()->selectGroup(pCoreTroop, gDLL->shiftKey(),
gDLL->ctrlKey(), gDLL->altKey());
}
+
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ if (!GET_PLAYER(getOwnerINLINE()).isFeatAccomplished(FEAT_FORM_LEGION))
+ {
+ GET_PLAYER(getOwnerINLINE()).setFeatAccomplished(FEAT_FORM_LEGION,
true);
+ if (GET_PLAYER(getOwnerINLINE()).isFeatPopup())
+ {
+ CyArgsList argsList;
+
+ argsList.add(getOwnerINLINE());
+ argsList.add(pCoreTroop->getHeroType());
+
+
gDLL->getPythonIFace()->callFunction(PYSanguoModule, "doFormLegionFeat",
argsList.makeFunctionArgs());
+ }
+ }
+ // Sanguo Mod Tutorial, end
kill(false);
@@ -15499,7 +15517,7 @@
FAssert (isCoreTroop());
if (!bRegroupDone)
{
- GC.getGameINLINE().backUpHeroLegionMember(getHeroType());
+ GAME.backUpHeroLegionMember(getHeroType());
CyArgsList argsList;
argsList.add(getHeroType());
argsList.add(bRegroup);
@@ -15509,22 +15527,23 @@
else
{
HeroTypes eLeaderHero = getLeaderHero();
- int iAdvancedLegionSize = eLeaderHero != NO_HERO ?
GC.getGameINLINE().getHeroLegionSize(eLeaderHero) : 0;
+ bool bLeaderTroop = isLeaderTroop();
+ int iAdvancedLegionSize = eLeaderHero != NO_HERO ?
GAME.getHeroLegionSize(eLeaderHero) : 0;
int iLeaderTroopID = -1;
CvUnit* pLeaderHero = NULL;
- GC.getGameINLINE().swapHeroLegionList(getHeroType());
+ GAME.swapHeroLegionList(getHeroType());
if (eLeaderHero != NO_HERO)
{
if (iAdvancedLegionSize > 1)
{
- quitAdvancedLegion();
+ quitAdvancedLegion(true);
}
else
{
- pLeaderHero = dismissAdvancedLegion();
+ pLeaderHero = dismissAdvancedLegion(true);
}
}
- GC.getGameINLINE().swapHeroLegionList(getHeroType());
+ GAME.swapHeroLegionList(getHeroType());
CvUnit* pCoreTroop = processLegion(true, false, false, false);
@@ -15532,19 +15551,26 @@
if (!pCoreTroop->isNakedHero() && eLeaderHero != NO_HERO)
{
- iLeaderTroopID =
GC.getGameINLINE().getHeroCoreTroop(eLeaderHero);
+ iLeaderTroopID = GAME.getHeroCoreTroop(eLeaderHero);
if (iAdvancedLegionSize > 1)
{
- pCoreTroop->joinAdvancedLegion(iLeaderTroopID);
- }
+ if (bLeaderTroop)
+ {
+ pCoreTroop->joinAdvancedLegion(iLeaderTroopID, true);
+ }
+ else
+ {
+ pCoreTroop->joinAdvancedLegion(iLeaderTroopID);
+ }
+ }
else
{
- GC.getGameINLINE().addHeroLegionMember(eLeaderHero,
pCoreTroop->getID());
+ GAME.addHeroLegionMember(eLeaderHero,
pCoreTroop->getID());
pLeaderHero->formAdvancedLegion(false, true);
}
}
- GC.getGameINLINE().setLegionUnitMoved(pCoreTroop->getHeroType(),
true);
+ GAME.setLegionUnitMoved(pCoreTroop->getHeroType(), true);
if (isHuman() && getOwnerINLINE() ==
GC.getGame().getActivePlayer())
{
@@ -15597,13 +15623,13 @@
return false;
}
- if (GC.getGameINLINE().isLegionUnitMoved(getHeroType()))
+ if (GAME.isLegionUnitMoved(getHeroType()))
{
return false;
}
- FAssert (GC.getGameINLINE().getHeroLegionSize(getHeroType()) > 0);
- FAssert (GC.getGameINLINE().getHeroCoreTroop(getHeroType()) ==
getID());
+ FAssert (GAME.getHeroLegionSize(getHeroType()) > 0);
+ FAssert (GAME.getHeroCoreTroop(getHeroType()) == getID());
return true;
}
@@ -15623,7 +15649,7 @@
// pCoreTroop is:
// 1. We are naked hero, then is the unit we are going to attach to
// 2. We are a Core Troop, then is ourselves, or the new unit our hero
will abandon us for, or is NULL if legion is cleared
- CvUnit* pCoreTroop =
GET_PLAYER(getOwnerINLINE()).getUnit(GC.getGameINLINE().getHeroCoreTroop(eHero));
+ CvUnit* pCoreTroop =
GET_PLAYER(getOwnerINLINE()).getUnit(GAME.getHeroCoreTroop(eHero));
// Find the correct unitCombatType.
if (!bRegroup)
@@ -15648,16 +15674,16 @@
{
if
(GC.getPromotionInfo((PromotionTypes)iI).getPromotionUnitCombatType() ==
eUnitCombat)
{
- if
(GC.getPromotionInfo((PromotionTypes)iI).getPromotionUnitCombatLevel() ==
GC.getGameINLINE().getHeroUnitCombatLevel(eHero, eUnitCombat))
+ if
(GC.getPromotionInfo((PromotionTypes)iI).getPromotionUnitCombatLevel() ==
GAME.getHeroUnitCombatLevel(eHero, eUnitCombat))
{
eUnitCombatPromotion = (PromotionTypes)iI;
}
}
- else if (GC.getGameINLINE().getHeroPromotionStatus(eHero,
(PromotionTypes)iI) == 1)
+ else if (GAME.getHeroPromotionStatus(eHero, (PromotionTypes)iI) ==
1)
{
UniquePromotionVec.push_back((PromotionTypes)iI);
}
- else if (GC.getGameINLINE().getHeroPromotionStatus(eHero,
(PromotionTypes)iI) == 2)
+ else if (GAME.getHeroPromotionStatus(eHero, (PromotionTypes)iI) ==
2)
{
MemberPromotionVec.push_back((PromotionTypes)iI);
}
@@ -15666,7 +15692,7 @@
#ifdef _DEBUG
if (eUnitCombatPromotion == NO_PROMOTION)
{
- FAssert (GC.getGameINLINE().getHeroUnitCombatLevel(eHero,
eUnitCombat) <= 0);
+ FAssert (GAME.getHeroUnitCombatLevel(eHero, eUnitCombat) <= 0);
}
#endif
@@ -15674,9 +15700,9 @@
// If is Regrouping Mission, strip all old members' hero stats as well
if (bRegroup || bPrePromotion)
{
- for (int iI = 0; iI <
GC.getGameINLINE().getHeroLegionBackUpSize(eHero); iI++)
- {
- CvUnit* pLoopUnit =
GET_PLAYER(getOwnerINLINE()).getUnit(GC.getGameINLINE().getHeroLegionBackUpMemberAt(eHero,
iI));
+ for (int iI = 0; iI < GAME.getHeroLegionBackUpSize(eHero); iI++)
+ {
+ CvUnit* pLoopUnit =
GET_PLAYER(getOwnerINLINE()).getUnit(GAME.getHeroLegionBackUpMemberAt(eHero,
iI));
if (iI == 0)
{
if (bRegroup)
@@ -15685,7 +15711,7 @@
}
for (std::vector<PromotionTypes>::iterator iter1 =
UniquePromotionVec.begin(); iter1 != UniquePromotionVec.end(); ++iter1)
{
- if (getLeaderHero() == NO_HERO ||
GC.getGameINLINE().getHeroPromotionStatus(getLeaderHero(), *iter1) != 1)
+ if (getLeaderHero() == NO_HERO ||
GAME.getHeroPromotionStatus(getLeaderHero(), *iter1) != 1)
{
pLoopUnit->setHasPromotion((*iter1), false);
}
@@ -15702,7 +15728,7 @@
pLoopUnit->setHasPromotion((*iter2), false);
}
- if (bRegroup
&& !GC.getGameINLINE().isHeroHasLegionMember(eHero, pLoopUnit->getID()))
+ if (bRegroup && !GAME.isHeroHasLegionMember(eHero,
pLoopUnit->getID()))
{
pLoopUnit->setLegionHero(NO_HERO);
}
@@ -15723,17 +15749,10 @@
// if we are not under attack, then it's a peaceful regroup
legion mission; resurrect the hero
if (!bAttacked)
{
- CvUnit* pHero =
GET_PLAYER(getOwnerINLINE()).initUnit((UnitTypes)(GC.getHeroInfo(eHero).getUnitType()),
getX_INLINE(), getY_INLINE());
setLeaderUnitType(NO_UNIT);
- pHero->setHeroType(eHero);
- if (GC.getGameINLINE().getHeroDebutStatus(eHero) !=
getOwnerINLINE())
- {
- GC.getGameINLINE().setHeroDebutStatus(eHero,
getOwnerINLINE());
-
GET_PLAYER(getOwnerINLINE()).changeHeroMaintenance(eHero, true, false, 0);
- }
- GC.getGameINLINE().setHeroUnitID(eHero, pHero->getID());
- // set pCoreTroop = pHero so we could return a value that
is not NULL and means we have resurrect a hero
- pCoreTroop = pHero;
+
+ // set pCoreTroop = pHero so we could return a value that is not NULL
and means we have resurrect a hero
+ pCoreTroop = GET_PLAYER(getOwnerINLINE()).initHero(eHero,
getX_INLINE(), getY_INLINE(), GAME.getHeroDebutStatus(eHero) !=
getOwnerINLINE());
}
// since the legion is cleared, it's not necessary to do the
rest, stop here
@@ -15749,7 +15768,7 @@
{
if
(GC.getPromotionInfo((PromotionTypes)iI).getPromotionUnitCombatType() ==
eUnitCombat)
{
- if
(GC.getPromotionInfo((PromotionTypes)iI).getPromotionUnitCombatLevel() ==
GC.getGameINLINE().getHeroUnitCombatLevel(eHero, eUnitCombat))
+ if
(GC.getPromotionInfo((PromotionTypes)iI).getPromotionUnitCombatLevel() ==
GAME.getHeroUnitCombatLevel(eHero, eUnitCombat))
{
eUnitCombatPromotion = (PromotionTypes)iI;
}
@@ -15765,9 +15784,9 @@
pNewSelectionGroup->init(pNewSelectionGroup->getID(), getOwnerINLINE());
bool bOffenseWar = (area()->getAreaAIType(getTeam()) == AREAAI_OFFENSIVE);
- for (int iI = 0; iI < GC.getGameINLINE().getHeroLegionSize(eHero);
iI++)
- {
- CvUnit* pLoopUnit =
GET_PLAYER(getOwnerINLINE()).getUnit(GC.getGameINLINE().getHeroLegionMemberAt(eHero,
iI));
+ for (int iI = 0; iI < GAME.getHeroLegionSize(eHero); iI++)
+ {
+ CvUnit* pLoopUnit =
GET_PLAYER(getOwnerINLINE()).getUnit(GAME.getHeroLegionMemberAt(eHero, iI));
if (bOffenseWar && pLoopUnit->AI_getUnitAIType() == UNITAI_COUNTER)
{
pLoopUnit->AI_setUnitAIType(UNITAI_ATTACK);
@@ -15823,14 +15842,14 @@
{
//clearLegionMember();
setLeaderUnitType(NO_UNIT);
- GC.getGameINLINE().setHeroUnitID(eHero, pCoreTroop->getID());
+ GAME.setHeroUnitID(eHero, pCoreTroop->getID());
pCoreTroop->setLeaderUnitType((UnitTypes)GC.getHeroInfo(eHero).getUnitType());
}
}
// If is From Legion Mission, set the New Hero Unit ID
else
{
- GC.getGameINLINE().setHeroUnitID(eHero, pCoreTroop->getID());
+ GAME.setHeroUnitID(eHero, pCoreTroop->getID());
pCoreTroop->setLeaderUnitType((UnitTypes)GC.getHeroInfo(eHero).getUnitType());
}
@@ -15873,14 +15892,14 @@
return false;
}
- if (GC.getGameINLINE().isLegionUnitMoved(getHeroType()))
+ if (GAME.isLegionUnitMoved(getHeroType()))
{
return false;
}
- for (int iI = 0; iI <
GC.getGameINLINE().getHeroLegionSize(getHeroType()); iI++)
- {
- CvUnit* pMember =
GET_PLAYER(getOwnerINLINE()).getUnit(GC.getGameINLINE().getHeroLegionMemberAt(getHeroType(),
iI));
+ for (int iI = 0; iI < GAME.getHeroLegionSize(getHeroType()); iI++)
+ {
+ CvUnit* pMember =
GET_PLAYER(getOwnerINLINE()).getUnit(GAME.getHeroLegionMemberAt(getHeroType(),
iI));
FAssert (pMember != NULL);
if (pMember->isHurt())
{
@@ -15888,8 +15907,8 @@
}
}
- FAssert ( GC.getGameINLINE().getHeroLegionSize(getHeroType()) > 0);
- FAssert ( GC.getGameINLINE().getHeroCoreTroop(getHeroType()) ==
getID());
+ FAssert ( GAME.getHeroLegionSize(getHeroType()) > 0);
+ FAssert ( GAME.getHeroCoreTroop(getHeroType()) == getID());
return true;
}
@@ -15897,16 +15916,36 @@
CvUnit* CvUnit::dismissLegion(bool bAttacked)
{
FAssert (getHeroType() >= 0 && getHeroType() < GC.getNumHeroInfos());
- if (getLeaderHero() != NO_HERO)
- {
- quitAdvancedLegion();
+ bool bInArmy = (getLeaderHero() != NO_HERO);
+ PromotionTypes eNineTransformation = bInArmy ?
GAME.getHeroCurrentNineTransformationPromotion(getHeroType()) :
NO_PROMOTION;
+ if (bInArmy)
+ {
+ quitAdvancedLegion(true);
+ // if legion current sets a nine transformation promotion, then check to
see if after quiting army that nine tranformation promotion is still valid
+ if (eNineTransformation != NO_PROMOTION &&
GAME.isHeroNineTransformationPromotion(getHeroType(), eNineTransformation))
+ {
+ eNineTransformation = NO_PROMOTION;
+ }
}
- GC.getGameINLINE().backUpHeroLegionMember(getHeroType());
- GC.getGameINLINE().clearHeroLegionMember(getHeroType());
+ GAME.backUpHeroLegionMember(getHeroType());
+ GAME.clearHeroLegionMember(getHeroType());
CvUnit* pHero = processLegion(true, false, false, bAttacked);
+ // only take away nine transformation promotion that is not valid any more
+ if (eNineTransformation != NO_PROMOTION)
+ {
+ GAME.setHeroCurrentNineTransformationPromotion(pHero->getHeroType(),
NO_PROMOTION);
+ }
+
+#ifndef _DEBUG
+ if (pHero != NULL)
+ {
+ GAME.setLegionUnitMoved(pHero->getHeroType(), true);
+ }
+#endif
+
return pHero;
}
@@ -15962,8 +16001,8 @@
FAssert (pHero != NULL);
FAssert (pHero->getHeroType() >= 0 && pHero->getHeroType()
< GC.getNumHeroInfos());
- GC.getGameINLINE().backUpHeroLegionMember(pHero->getHeroType());
- GC.getGameINLINE().addHeroLegionMember(pHero->getHeroType(), getID());
+ GAME.backUpHeroLegionMember(pHero->getHeroType());
+ GAME.addHeroLegionMember(pHero->getHeroType(), getID());
pHero->processLegion(true, false, false, false);
return true;
@@ -15985,7 +16024,7 @@
{
pHero->setTempCheck(true);
GET_PLAYER(getOwnerINLINE()).pushToJoinLegionTempHeroList(pHero->getID());
- pInfo->addPythonButton(gDLL->getText("TXT_KEY_CHOOSE_LEGION_HELP",
GC.getHeroInfo(pHero->getHeroType()).getDescription(), pHero->getNameKey(),
GET_PLAYER(getOwnerINLINE()).getUnit(GC.getGameINLINE().getHeroCoreTroop(pHero->getHeroType()))->getLevel()), "");
+ pInfo->addPythonButton(gDLL->getText("TXT_KEY_CHOOSE_LEGION_HELP",
GC.getHeroInfo(pHero->getHeroType()).getDescription(), pHero->getNameKey(),
GET_PLAYER(getOwnerINLINE()).getUnit(GAME.getHeroCoreTroop(pHero->getHeroType()))->getLevel()), "");
pHero =
plot()->plotCheck(PUF_canAcceptLegionMember, getOwnerINLINE(), getID(),
NO_PLAYER, NO_TEAM, PUF_isNotTempCheck);
}
@@ -16012,34 +16051,35 @@
FAssert (pHero->getHeroType() >= 0 && pHero->getHeroType() <
GC.getNumHeroInfos());
HeroTypes eLeaderHero = pHero->getLeaderHero();
- int iAdvancedLegionSize = eLeaderHero != NO_HERO ?
GC.getGameINLINE().getHeroLegionSize(eLeaderHero) : 0;
+ int iAdvancedLegionSize = eLeaderHero != NO_HERO ?
GAME.getHeroLegionSize(eLeaderHero) : 0;
CvUnit* pLeaderHero = NULL;
+
if (eLeaderHero != NO_HERO)
{
if (iAdvancedLegionSize > 1)
{
- pHero->quitAdvancedLegion();
+ pHero->quitAdvancedLegion(true);
}
else
{
pLeaderHero = pHero->dismissAdvancedLegion();
}
- }
-
- GC.getGameINLINE().backUpHeroLegionMember(pHero->getHeroType());
- GC.getGameINLINE().addHeroLegionMember(pHero->getHeroType(),
getID());
+ }
+
+ GAME.backUpHeroLegionMember(pHero->getHeroType());
+ GAME.addHeroLegionMember(pHero->getHeroType(), getID());
pHero->processLegion(true, false, false, false);
if (eLeaderHero != NO_HERO)
{
if (iAdvancedLegionSize > 1)
{
- int iUnitID =
GC.getGameINLINE().getHeroCoreTroop(eLeaderHero);
+ int iUnitID = GAME.getHeroCoreTroop(eLeaderHero);
pHero->joinAdvancedLegion(iUnitID);
}
else
{
- GC.getGameINLINE().addHeroCoreTroop(eLeaderHero,
pHero->getID());
+ GAME.addHeroCoreTroop(eLeaderHero, pHero->getID());
pLeaderHero->formAdvancedLegion(false, true);
}
}
@@ -16061,7 +16101,7 @@
return false;
}
- if ( GC.getGameINLINE().getHeroLegionSize(getHeroType()) == 0)
+ if ( GAME.getHeroLegionSize(getHeroType()) == 0)
{
return false;
}
@@ -16071,21 +16111,21 @@
return false;
}
- FAssert (getID() ==
GC.getGameINLINE().getHeroCoreTroop(getHeroType()));
+ FAssert (getID() == GAME.getHeroCoreTroop(getHeroType()));
if (getUnitCombatType() != pUnit->getUnitCombatType())
{
return false;
}
- if ( GC.getGameINLINE().getHeroLegionSize(getHeroType()) >=
GC.getGameINLINE().getHeroCapacity(getHeroType()))
+ if ( GAME.getHeroLegionSize(getHeroType()) >=
GAME.getHeroCapacity(getHeroType()))
{
return false;
}
- FAssert ( GC.getGameINLINE().getHeroLegionSize(getHeroType()) <
GC.getGameINLINE().getHeroCapacity(getHeroType()));
-
- if (GC.getGameINLINE().isLegionUnitMoved(getHeroType()))
+ FAssert ( GAME.getHeroLegionSize(getHeroType()) <
GAME.getHeroCapacity(getHeroType()));
+
+ if (GAME.isLegionUnitMoved(getHeroType()))
{
return false;
}
@@ -16122,7 +16162,7 @@
return false;
}
- if (GC.getGameINLINE().isLegionUnitMoved(getLegionHero()))
+ if (GAME.isLegionUnitMoved(getLegionHero()))
{
return false;
}
@@ -16132,7 +16172,7 @@
return false;
}
- CvUnit* pHero = GC.getGameINLINE().getHeroUnit(getLegionHero());
+ CvUnit* pHero = GAME.getHeroUnit(getLegionHero());
FAssert (pHero != NULL);
if (pHero->hasMoved())
{
@@ -16144,7 +16184,7 @@
bool CvUnit::quitLegion(bool bAttacked)
{
- CvUnit* pCoreTroop = GC.getGameINLINE().getHeroUnit(getLegionHero());
+ CvUnit* pCoreTroop = GAME.getHeroUnit(getLegionHero());
FAssert (pCoreTroop != NULL);
FAssert (pCoreTroop->getHeroType() >= 0 && pCoreTroop->getHeroType() <
GC.getNumHeroInfos());
@@ -16153,40 +16193,50 @@
CvUnit* pLeaderHero = NULL;
if (eLeaderHero != NO_HERO)
{
- if (GC.getGameINLINE().getHeroLegionSize(eLeaderHero) > 1)
- {
- pCoreTroop->quitAdvancedLegion();
- }
+ // if the Army has more than 1 legion, then temp quit army
+ if (GAME.getHeroLegionSize(eLeaderHero) > 1)
+ {
+ pCoreTroop->quitAdvancedLegion(true);
+ }
+ // else then we are the only legion in army, temp dismiss army
else
{
- pLeaderHero = pCoreTroop->dismissAdvancedLegion();
+ pLeaderHero = pCoreTroop->dismissAdvancedLegion(true);
}
}
- GC.getGameINLINE().backUpHeroLegionMember(getLegionHero());
- GC.getGameINLINE().deleteHeroLegionMember(getLegionHero(), getID());
+ GAME.backUpHeroLegionMember(getLegionHero());
+ GAME.deleteHeroLegionMember(getLegionHero(), getID());
pCoreTroop = pCoreTroop->processLegion(true, false, false, bAttacked);
if (eLeaderHero != NO_HERO)
{
- if (pLeaderHero == NULL)
- {
- int iUnitID = GC.getGameINLINE().getHeroCoreTroop(eLeaderHero);
- FAssert (pCoreTroop != NULL && pCoreTroop->getHeroType() !=
NO_HERO);
- if (!bLeaderTroop)
- {
- pCoreTroop->joinAdvancedLegion(iUnitID);
- }
- else
- {
- pCoreTroop->joinAdvancedLegion(iUnitID, true);
- }
- }
- else if (pCoreTroop != NULL)
- {
- GC.getGame().swapHeroLegionList(eLeaderHero);
- pLeaderHero->formAdvancedLegion(false, true);
- }
+ if (pCoreTroop != NULL)
+ {
+ if (pLeaderHero == NULL)
+ {
+ // if army is not dismissed
+ int iUnitID = GAME.getHeroCoreTroop(eLeaderHero);
+ FAssert (pCoreTroop != NULL && pCoreTroop->getHeroType() != NO_HERO);
+ if (!bLeaderTroop)
+ {
+ // if we are not guardian of Army, join as member legion
+ pCoreTroop->joinAdvancedLegion(iUnitID);
+ }
+ else
+ {
+ // join as guardian legion
+ pCoreTroop->joinAdvancedLegion(iUnitID, true);
+ }
+ }
+ else
+ {
+ // eLeaderHero's back up list should have army heroes previous to temp
dismiss army
+ // if pCoreTroop == NULL, which means the legion has 0 member now,
then don't bother to form advanced legion
+ GC.getGame().swapHeroLegionList(eLeaderHero);
+ pLeaderHero->formAdvancedLegion(false, true);
+ }
+ }
}
return true;
@@ -16294,7 +16344,7 @@
if (bCoreTroop && bLoserCoreTroop && iStartGoldenAgeChancePerLevel > 0)
{
- if (GC.getGameINLINE().getSorenRandNum(100, "Start a Golden Age") <
iStartGoldenAgeChancePerLevel *
(GC.getGameINLINE().getHeroLevel(pLoser->getHeroType())))
+ if (GAME.getSorenRandNum(100, "Start a Golden Age") <
iStartGoldenAgeChancePerLevel * (GAME.getHeroLevel(pLoser->getHeroType())))
{
GET_PLAYER(getOwnerINLINE()).changeGoldenAgeTurns(GET_PLAYER(getOwnerINLINE()).getGoldenAgeLength());
if (isHuman())
@@ -16350,11 +16400,11 @@
{
if (pLoser->isHasPromotion((PromotionTypes)iI))
{
- if
(GC.getGameINLINE().canHeroAcquirePromotion(getHeroType(),
(PromotionTypes)iI, true))
- {
- if
(GC.getGameINLINE().getSorenRandNum(100, "Steal Hero Promotion") <
GC.getDefineINT("HERO_STEAL_PROMOTION_PERCENT"))
- {
-
GC.getGameINLINE().setHeroPromotionStatus(getHeroType(),
(PromotionTypes)iI,
GC.getPromotionInfo((PromotionTypes)iI).getHeroPromotionStatus());
+ if (GAME.canHeroAcquirePromotion(getHeroType(),
(PromotionTypes)iI, true))
+ {
+ if (GAME.getSorenRandNum(100, "Steal Hero
Promotion") < GC.getDefineINT("HERO_STEAL_PROMOTION_PERCENT"))
+ {
+ GAME.setHeroPromotionStatus(getHeroType(),
(PromotionTypes)iI,
GC.getPromotionInfo((PromotionTypes)iI).getHeroPromotionStatus(), false);
if (isHuman())
{
szBuffer =
gDLL->getText("TXT_KEY_HERO_STEALT_PROMOTION",
GC.getHeroInfo(getLegionHero()).getDescription(),
GC.getPromotionInfo((PromotionTypes)iI).getDescription(),
GC.getHeroInfo(pLoser->getLegionHero()).getDescription());
@@ -16374,63 +16424,63 @@
}
}
- if (iConvertWarlordChance > 0)
- {
- if (pLoser->getHeroType() == NO_HERO &&
pLoser->getLeaderUnitType() != NO_UNIT)
- {
- if (GC.getGameINLINE().getSorenRandNum(100, "Convert Warlord") <
iConvertWarlordChance)
- {
- CvUnit* pWarlord =
GET_PLAYER(getOwnerINLINE()).initUnit(pLoser->getLeaderUnitType(),
getX_INLINE(), getY_INLINE());
- if (pWarlord != NULL)
- {
-
GC.getGameINLINE().removeGreatPersonBornName(pWarlord->getNameNoDesc());
- CvWString szOldName = pLoser->getNameNoDesc();
- if (GC.getGameINLINE().isGreatPersonBorn(szOldName))
- {
- pWarlord->setName(szOldName);
- }
- if (isHuman())
- {
- szBuffer = gDLL->getText("TXT_KEY_WARLORD_CONVERTED",
GC.getHeroInfo(getLegionHero()).getDescription(),
pLoser->getNameNoDesc().GetCString());
- gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_INFO, GC.getHeroInfo(getLegionHero()).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), getX_INLINE(),
getY_INLINE(), true, true);
- }
- if (pLoser->isHuman())
- {
- szBuffer = gDLL->getText("TXT_KEY_WARLORD_BETRAYED",
pLoser->getNameNoDesc().GetCString(),
GC.getHeroInfo(getLegionHero()).getDescription());
- gDLL->getInterfaceIFace()->addMessage(pLoser->getOwnerINLINE(),
true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_CITYRAZED",
MESSAGE_TYPE_INFO, GC.getHeroInfo(getLegionHero()).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pLoser->getX_INLINE(),
pLoser->getY_INLINE(), true, true);
- }
- }
- }
- else
- {
- CvCity* pLoserCapital =
GET_PLAYER(pLoser->getOwnerINLINE()).getCapitalCity();
- if (pLoserCapital != NULL
&& !pLoser->atPlot(pLoserCapital->plot()))
- {
- CvUnit* pWarlord =
GET_PLAYER(pLoser->getOwnerINLINE()).initUnit(pLoser->getLeaderUnitType(),
pLoserCapital->getX_INLINE(), pLoserCapital->getY_INLINE());
- if (pWarlord != NULL)
- {
-
GC.getGameINLINE().removeGreatPersonBornName(pWarlord->getNameNoDesc());
- CvWString szOldName = pLoser->getNameNoDesc();
- if (GC.getGameINLINE().isGreatPersonBorn(szOldName))
- {
- pWarlord->setName(szOldName);
- }
-
- if (isHuman())
- {
- szBuffer = gDLL->getText("TXT_KEY_WARLORD_RELEASED",
GC.getHeroInfo(getLegionHero()).getDescription(),
pLoser->getNameNoDesc().GetCString());
- gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_INFO, GC.getHeroInfo(getLegionHero()).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), getX_INLINE(),
getY_INLINE(), true, true);
- }
- if (pLoser->isHuman())
- {
- szBuffer = gDLL->getText("TXT_KEY_WARLORD_BEEN_RELEASED",
pLoser->getNameNoDesc().GetCString(),
GC.getHeroInfo(getLegionHero()).getDescription());
- gDLL->getInterfaceIFace()->addMessage(pLoser->getOwnerINLINE(),
true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_CITYRAZED",
MESSAGE_TYPE_INFO, GC.getHeroInfo(getLegionHero()).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pLoser->getX_INLINE(),
pLoser->getY_INLINE(), true, true);
- }
- }
- }
- }
- }
- }
+ //if (iConvertWarlordChance > 0)
+ //{
+ // if (pLoser->getHeroType() == NO_HERO &&
pLoser->getLeaderUnitType() != NO_UNIT)
+ // {
+ // if (GAME.getSorenRandNum(100, "Convert Warlord") <
iConvertWarlordChance)
+ // {
+ // CvUnit* pWarlord =
GET_PLAYER(getOwnerINLINE()).initUnit(pLoser->getLeaderUnitType(),
getX_INLINE(), getY_INLINE());
+ // if (pWarlord != NULL)
+ // {
+ // GAME.removeGreatPersonBornName(pWarlord->getNameNoDesc());
+ // CvWString szOldName = pLoser->getNameNoDesc();
+ // if (GAME.isGreatPersonBorn(szOldName))
+ // {
+ // pWarlord->setName(szOldName);
+ // }
+ // if (isHuman())
+ // {
+ // szBuffer = gDLL->getText("TXT_KEY_WARLORD_CONVERTED",
GC.getHeroInfo(getLegionHero()).getDescription(),
pLoser->getNameNoDesc().GetCString());
+ // gDLL->getInterfaceIFace()->addMessage(getOwnerINLINE(), true,
GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_UNIT_GREATPEOPLE",
MESSAGE_TYPE_INFO, GC.getHeroInfo(getLegionHero()).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_GREEN"), getX_INLINE(),
getY_INLINE(), true, true);
+ // }
+ // if (pLoser->isHuman())
+ // {
+ // szBuffer = gDLL->getText("TXT_KEY_WARLORD_BETRAYED",
pLoser->getNameNoDesc().GetCString(),
GC.getHeroInfo(getLegionHero()).getDescription());
+ // gDLL->getInterfaceIFace()->addMessage(pLoser->getOwnerINLINE(),
true, GC.getEVENT_MESSAGE_TIME(), szBuffer, "AS2D_CITYRAZED",
MESSAGE_TYPE_INFO, GC.getHeroInfo(getLegionHero()).getButton(),
(ColorTypes)GC.getInfoTypeForString("COLOR_RED"), pLoser->getX_INLINE(),
pLoser->getY_INLINE(), true, true);
***The diff for this file has been truncated for email.***
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvUnit.h Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvUnit.h Fri Oct 16 02:15:14 2009
@@ -837,9 +837,9 @@
bool formAdvancedLegion(bool bRegroup, bool bRegroupDone); //
Exposed to Python
bool canFormAdvancedLegion(const CvPlot* pPlot = NULL) const; //
Exposed to Python
bool canDismissAdvancedLegion() const;
- CvUnit* dismissAdvancedLegion();
+ CvUnit* dismissAdvancedLegion(bool bTemp = false);
bool canJoinAdvancedLegion(const CvUnit* pUnit) const; // Exposed
to Python
- CvUnit* processAdvancedLegion(bool bRegroup, bool bAttacked);
+ CvUnit* processAdvancedLegion(bool bRegroup, bool bAttacked, bool
bKeepNineTransformation = false);
bool isLeaderTroop() const; // Exposed to Python
HeroTypes getLeaderHero() const; // Exposed to Python
void setLeaderHero(HeroTypes eHero); // Exposed to Python
@@ -849,7 +849,7 @@
bool joinAdvancedLegion(int iUnitID, bool bAsLeader = false);
bool canRegroupAdvancedLegion(const CvPlot* pPlot) const;
bool canQuitAdvancedLegion() const;
- bool quitAdvancedLegion();
+ bool quitAdvancedLegion(bool bTemp = false);
// Sanguo Mod Hero, end
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CvUnitAI.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CvUnitAI.cpp Fri Oct 16 02:15:14 2009
@@ -80,16 +80,16 @@
// Sanguo Mod Performance start, added by poyuzhe 07.21.09
// allow python to handle it
- //CyUnit* pyUnit = new CyUnit(this);
- //CyArgsList argsList;
- //argsList.add(gDLL->getPythonIFace()->makePythonObject(pyUnit)); // pass
in unit class
- //long lResult=0;
- //gDLL->getPythonIFace()->callFunction(PYGameModule, "AI_unitUpdate",
argsList.makeFunctionArgs(), &lResult);
- //delete pyUnit; // python fxn must not hold on to this pointer
- //if (lResult == 1)
- //{
- // return false;
- //}
+ CyUnit* pyUnit = new CyUnit(this);
+ CyArgsList argsList;
+ argsList.add(gDLL->getPythonIFace()->makePythonObject(pyUnit)); // pass
in unit class
+ long lResult=0;
+ gDLL->getPythonIFace()->callFunction(PYGameModule, "AI_unitUpdate",
argsList.makeFunctionArgs(), &lResult);
+ delete pyUnit; // python fxn must not hold on to this pointer
+ if (lResult == 1)
+ {
+ return false;
+ }
// Sanguo Mod Performance, end
if (getDomainType() == DOMAIN_LAND)
@@ -10611,6 +10611,13 @@
{
if (iPathTurns <= iMaxPath)
{
+ // Sanguo Mod Temporary, start, not sure why this happens.
generatePath() says the pathEndTurnPlot is the current plot
+ if (atPlot(getPathEndTurnPlot()))
+ {
+ //FAssert (false);
+ continue;
+ }
+ // Sanguo Mod Temporary, end
iValue = iPathTurns;
if (iValue < iBestValue)
@@ -13312,6 +13319,13 @@
// BBAI TODO: Other units targeting this already (if path turns >
1 or 0)?
if( iPathTurns <= iMaxPathTurns )
{
+ // Sanguo Mod Temporary, start, not sure why this happens.
generatePath() says the pathEndTurnPlot is the current plot
+ if (atPlot(getPathEndTurnPlot()))
+ {
+ //FAssert (false);
+ continue;
+ }
+ // Sanguo Mod Temporary, end
iValue *= 100;
iValue /= (2 + iPathTurns);
@@ -13372,6 +13386,14 @@
{
if (generatePath(pAdjacentPlot, 0, true))
{
+ // Sanguo Mod Temporary, start, not sure why this happens.
generatePath() says the pathEndTurnPlot is the current plot
+ if (atPlot(getPathEndTurnPlot()))
+ {
+ //FAssert (false);
+ continue;
+ }
+ // Sanguo Mod Temporary, end
+
iValue = (1 + GC.getGameINLINE().getSorenRandNum(10000, "AI
Patrol"));
if (isBarbarian())
@@ -14525,6 +14547,16 @@
{
if (!atPlot(pLoopPlot) && ((bFollow) ? canMoveInto(pLoopPlot,
true) : (generatePath(pLoopPlot, 0, true, &iPathTurns) && (iPathTurns <=
iRange))))
{
+ // Sanguo Mod Temporary, start, not sure why this happens.
generatePath() says the pathEndTurnPlot is the current plot
+ if (!bFollow)
+ {
+ if (atPlot(getPathEndTurnPlot()))
+ {
+ //FAssert (false);
+ continue;
+ }
+ }
+ // Sanguo Mod Temporary, end
iValue = getGroup()->AI_attackOdds(pLoopPlot, true);
if (iValue >= AI_finalOddsThreshold(pLoopPlot, iOddsThreshold))
@@ -24434,6 +24466,12 @@
{
return false;
}
+
+ /*if (plot()->isCity() && plot()->getOwnerINLINE() == getOwnerINLINE() &&
plot()->plotCount(PUF_canDefendGroupHead, -1, -1, getOwnerINLINE()) == 1)
+ {
+ quitLegion(getLegionHero());
+ return true;
+ }*/
CvUnit* pLoopUnit;
CvUnit* pBestUnit;
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyEnumsInterface.cpp Sat Sep 26 22:57:14
2009
+++ /trunk/317DLL/CvGameCoreDLL/CyEnumsInterface.cpp Fri Oct 16 02:15:14
2009
@@ -537,7 +537,10 @@
.value("GAMEOPTION_NO_ESPIONAGE", GAMEOPTION_NO_ESPIONAGE)
// Sanguo Mod Hero, start, added by poyuzhe 02.08.09
.value("GAMEOPTION_NO_HERO_DEATH_FROM_COMBAT",
GAMEOPTION_NO_HERO_DEATH_FROM_COMBAT)
- //.value("GAMEOPTION_NO_HERO_DEATH_FROM_AGE",
GAMEOPTION_NO_HERO_DEATH_FROM_AGE)
+ .value("GAMEOPTION_NO_HERO_DEATH_FROM_AGE",
GAMEOPTION_NO_HERO_DEATH_FROM_AGE)
+ .value("GAMEOPTION_NO_HERO_EXECUTION", GAMEOPTION_NO_HERO_EXECUTION)
+ .value("GAMEOPTION_ENABLE_ARMY", GAMEOPTION_ENABLE_ARMY)
+ .value("GAMEOPTION_HIGH_HERO_DEATH_CHANCE",
GAMEOPTION_HIGH_HERO_DEATH_CHANCE)
.value("GAMEOPTION_NO_SETTLER", GAMEOPTION_NO_SETTLER)
// Sanguo Mod Hero, end
.value("NUM_GAMEOPTION_TYPES", NUM_GAMEOPTION_TYPES)
@@ -1511,6 +1514,15 @@
.value("FEAT_POPULATION_2_BILLION", FEAT_POPULATION_2_BILLION)
.value("FEAT_CORPORATION_ENABLED", FEAT_CORPORATION_ENABLED)
.value("FEAT_PAD", FEAT_PAD)
+ // Sanguo Mod Tutorial, start, by poyuzhe 09.27.09
+ .value("FEAT_CAPTURE_EMPEROR", FEAT_CAPTURE_EMPEROR)
+ .value("FEAT_CAPTURE_HERO", FEAT_CAPTURE_HERO)
+ .value("FEAT_FORM_LEGION", FEAT_FORM_LEGION)
+ .value("FEAT_FORM_ADVANCED_LEGION", FEAT_FORM_ADVANCED_LEGION)
+ .value("FEAT_CREATE_RANDOM_HERO", FEAT_CREATE_RANDOM_HERO)
+ .value("FEAT_BUILD_CITY_WONDER", FEAT_BUILD_CITY_WONDER)
+ .value("FEAT_GAIN_CITY_PERK", FEAT_GAIN_CITY_PERK)
+ // Sanguo Mod Tutorial, end
.value("NUM_FEAT_TYPES", NUM_FEAT_TYPES)
;
@@ -2013,5 +2025,10 @@
python::enum_<SurrenderTypes>("SurrenderTypes")
.value("NO_SURRENDER", NO_SURRENDER)
;
+
+ // Random Leader
+ python::enum_<RandomLeaderTypes>("RandomLeaderTypes")
+ .value("NO_RANDOMLEADER", NO_RANDOMLEADER)
+ ;
// Sanguo Mod XML, end
}
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyGame.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CyGame.cpp Fri Oct 16 02:15:14 2009
@@ -1226,7 +1226,7 @@
{
if (m_pGame)
{
- m_pGame->setHeroPromotionStatus((HeroTypes)eHero,
(PromotionTypes)ePromotion, iNewValue);
+ m_pGame->setHeroPromotionStatus((HeroTypes)eHero,
(PromotionTypes)ePromotion, iNewValue, false);
}
}
@@ -1506,3 +1506,16 @@
return (NULL != m_pGame ?
m_pGame->getHeroExperienceNeededForNextCapacity((HeroTypes)eHero) : -1);
}
// Sanguo Mod Hero, end
+
+// Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+int CyGame::getTutorialID() const
+{
+ return (NULL != m_pGame ? m_pGame->getTutorialID() : -1);
+}
+
+void CyGame::setTutorialID(int iNewValue)
+{
+ if (m_pGame)
+ m_pGame->setTutorialID(iNewValue);
+}
+// Sanguo Mod tutorial, end
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyGame.h Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CyGame.h Fri Oct 16 02:15:14 2009
@@ -340,6 +340,11 @@
int getHeroExperienceNeededForNextCapacity(int /*HeroTypes*/ eHero)
const;
// Sanguo Mod Hero, end
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ int getTutorialID() const;
+ void setTutorialID(int iNewValue);
+ // Sanguo Mod tutorial, end
+
protected:
CvGame* m_pGame;
};
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyGameInterface.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CyGameInterface.cpp Fri Oct 16 02:15:14 2009
@@ -327,6 +327,11 @@
.def("getHeroCapacity", &CyGame::getHeroCapacity, "int (int
/*HeroTypes*/ eHero, bool bOverWrite, int /*HeroTypes*/ eOverWriteHero)")
.def("getHeroExperienceNeededForNextCapacity",
&CyGame::getHeroExperienceNeededForNextCapacity, "int (int /*HeroTypes*/
eHero)")
// Sanguo Mod Hero, end
+
+ // Sanguo Mod tutorial, start, by poyuzhe 09.27.09
+ .def("getTutorialID", &CyGame::getTutorialID, "int ()")
+ .def("setTutorialID", &CyGame::setTutorialID, "void (int iNewValue)")
+ // Sanguo Mod tutorial, end
;
python::class_<CyDeal>("CyDeal")
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyGlobalContext.cpp Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CyGlobalContext.cpp Fri Oct 16 02:15:14 2009
@@ -139,7 +139,10 @@
CvLeaderHeadInfo* CyGlobalContext::getLeaderHeadInfo(int i) const
{
- return (i>=0 && i<GC.getNumLeaderHeadInfos()) ?
&GC.getLeaderHeadInfo((LeaderHeadTypes) i) : NULL;
+ // Sanguo Mod random leader, start, by poyuzhe 09.30.09
+ //return (i>=0 && i<GC.getNumLeaderHeadInfos()) ?
&GC.getLeaderHeadInfo((LeaderHeadTypes) i) : NULL;
+ return (i>=0 && i< (GC.getNumLeaderHeadInfos() +
GC.getNumRandomLeaderInfos()) ) ? &GC.getLeaderHeadInfo((LeaderHeadTypes)
i) : NULL;
+ // Sanguo Mod random leader, end
}
@@ -667,4 +670,10 @@
{
return (i>=0 && i<GC.getNumSurrenderInfos()) ?
&GC.getSurrenderInfo((SurrenderTypes) i) : NULL;
}
+
+// Random Leader
+CvLeaderHeadInfo* CyGlobalContext::getRandomLeaderInfo(int i) const
+{
+ return (i>=0 && i<GC.getNumRandomLeaderInfos()) ?
&GC.getRandomLeaderInfo((RandomLeaderTypes) i) : NULL;
+}
// Sanguo Mod XML, end
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyGlobalContext.h Tue Sep 22 03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CyGlobalContext.h Fri Oct 16 02:15:14 2009
@@ -105,6 +105,9 @@
// Surrender Personality, added by poyuzhe 9.10.09
CvSurrenderInfo* getSurrenderInfo(int i) const;
+
+ // random leader
+ CvLeaderHeadInfo* getRandomLeaderInfo(int i) const;
// Sanguo Mod XML, end
int getInfoTypeForString(const char* szInfoType) const;
@@ -249,6 +252,9 @@
// Surrender Personality, added by poyuzhe 9.10.09
int getNumSurrenderInfos() const { return GC.getNumSurrenderInfos(); }
+
+ // Random Leader
+ int getNumRandomLeaderInfos() const { return
GC.getNumRandomLeaderInfos(); }
// Sanguo Mod XML, end
// ArtInfos
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyGlobalContextInterface4.cpp Tue Sep 22
03:53:27 2009
+++ /trunk/317DLL/CvGameCoreDLL/CyGlobalContextInterface4.cpp Fri Oct 16
02:15:14 2009
@@ -190,6 +190,10 @@
// Surrender Personality, added by poyuzhe 9.10.09
.def("getNumSurrenderInfos", &CyGlobalContext::getNumSurrenderInfos, "()
- Total Surrender Infos XML\\Sanguo\\CIV4SurrenderInfos.xml")
.def("getSurrenderInfo", &CyGlobalContext::getSurrenderInfo,
python::return_value_policy<python::reference_existing_object>(), "(SurrenderID)
- CvInfo for SurrenderID")
+
+ // Random Leader
+ .def("getNumRandomLeaderInfos",
&CyGlobalContext::getNumRandomLeaderInfos, "() - Total Random Leader Infos
XML\\Sanguo\\CIV4SurrenderInfos.xml")
+ .def("getRandomLeaderInfo", &CyGlobalContext::getRandomLeaderInfo,
python::return_value_policy<python::reference_existing_object>(), "(RandomLeaderID)
- CvInfo for RandomLeaderID")
// Sanguo Mod XML, end
;
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyPlayer.cpp Sat Sep 19 06:38:49 2009
+++ /trunk/317DLL/CvGameCoreDLL/CyPlayer.cpp Fri Oct 16 02:15:14 2009
@@ -2387,6 +2387,20 @@
if (m_pPlayer)
m_pPlayer->releaseHero((HeroTypes)eHero);
}
+
+CyUnit* CyPlayer::initHero(int /*HeroTypes*/ eHero, int iX, int iY, bool
bUpdateMaintenance)
+{
+ return m_pPlayer ? new CyUnit(m_pPlayer->initHero((HeroTypes)eHero, iX,
iY, bUpdateMaintenance)) : NULL;
+}
+
+python::tuple CyPlayer::findXY(bool bUnitOnly)
+{
+ int iX = -1, iY = -1;
+ if (m_pPlayer)
+ m_pPlayer->findXY(&iX, &iY, bUnitOnly);
+ python::tuple tup=python::make_tuple(iX, iY);
+ return tup;
+}
// Sanguo Mod Hero, end
// Sanguo Mod Hero, join legion, start, by poyuzhe 09.14.08
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyPlayer.h Sat Sep 19 06:38:49 2009
+++ /trunk/317DLL/CvGameCoreDLL/CyPlayer.h Fri Oct 16 02:15:14 2009
@@ -547,6 +547,8 @@
void persuadeHero(int /*HeroTypes*/ eHero);
void executeHero(int /*HeroTypes*/ eHero);
void releaseHero(int /*HeroTypes*/ eHero);
+ CyUnit* initHero(int /*HeroTypes*/ eHero, int iX, int iY, bool
bUpdateMaintenance);
+ python::tuple findXY(bool bUnitOnly);
// Sanguo Mod Hero, end
// Sanguo Mod Hero, join legion, start, by poyuzhe 09.14.08
=======================================
--- /trunk/317DLL/CvGameCoreDLL/CyPlayerInterface2.cpp Sat Sep 19 06:38:49
2009
+++ /trunk/317DLL/CvGameCoreDLL/CyPlayerInterface2.cpp Fri Oct 16 02:15:14
2009
@@ -94,6 +94,8 @@
.def("persuadeHero", &CyPlayer::persuadeHero, "void (int /*HeroTypes*/
eHero)")
.def("executeHero", &CyPlayer::executeHero, "void (int /*HeroTypes*/
eHero)")
.def("releaseHero", &CyPlayer::releaseHero, "void (int /*HeroTypes*/
eHero)")
+ .def("initHero", &CyPlayer::initHero,
python::return_value_policy<python::manage_new_object>(), "CyUnit*
initHero(int /*HeroTypes*/ eHero, int iX, int iY, bool bUpdateMaintenance)")
+ .def("findXY", &CyPlayer::findXY, "tuple(int iX, int iY) (bool
bUnitOnly) - gets the X and Y to initial a hero/unit")
// Sanguo Mod Hero, end
// Sanguo Mod Hero, join legion, start, by poyuzhe 09.14.08