I'd recommend that anyone with qestions about python functions look them up
here in the BtS API first. It does not cover the functions added by FfH2 or MNAI, but it is easier than searching
the MNAI DLL source code.
QUESTIONS:
(A) I'm not sure what if not CyGame().isUnitClassMaxedOut(gc.getInfoTypeForString('UNITCLASS_ORTHUS'), 0): means - is it possibly checking if Orthus has been killed already (does anyone know what this line means)?
It is checking to see whether Orthus has been created yet.
The function is:
CvGame.cpp:
Code:
bool CvGame::isUnitClassMaxedOut(UnitClassTypes eIndex, int iExtra)
{
FAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");
FAssertMsg(eIndex < GC.getNumUnitClassInfos(), "eIndex is expected to be within maximum bounds (invalid Index)");
if (!isWorldUnitClass(eIndex))
{
return false;
}
// Tholal Note - Barnaxus is causing this assert error because he can be created many times - not sure an easy workaround is available
// FAssertMsg(getUnitClassCreatedCount(eIndex) <= GC.getUnitClassInfo(eIndex).getMaxGlobalInstances(), "Index is expected to be within maximum bounds (invalid Index)");
return ((getUnitClassCreatedCount(eIndex) + iExtra) >= GC.getUnitClassInfo(eIndex).getMaxGlobalInstances());
}
eIndex is an integer representing the index (position in the file) of the UnitClass in question. (You can get the index from the string using gc.getInfoTypeForString("whatever").)
iExtra is how many more units are allowed before the limit is reached. (The game uses this function to determine whether you are allowed to build another unit of this class. In counts the number of such units your cities are already building as passes them along as iExtra.)
Since iExtra is 0 in this case, the question is whether the number of such units that have already been created has yet reached the limit.
The World Unit limits count all units that have ever been created by any player.
There are equivalent functions under CyTeam and CyPlayer to check for Team and National unit limits. Those only check how many units the team or player currently controls.
(B) I'm not sure what these lines mean:
if not CyGame().isOption(gc.getInfoTypeForString('GAMEOPTION_NO_PLOT_COUNTER')):
cf.doHellTerrain()
if CyGame().getWBMapScript():
sf.doTurn()
The first line is asking whether or not the Hallowed Ground (Removes the Armageddon Counter from the Game) game option is active. If it is not, then it calls the def doHellTerrain() function found in CustomFunctions.py. That function is what controls the spread of hell and causes resources to change to and from their hell equivalents.
I believe that the second conditional is asking whether the game is a scenario. If it is then it runs the def doTurn() function found in ScenarioFunctions.py. That in turn would check for the various dummy game options that Kael added in order allow the game to know what special code to apply to what scenario.
(C) How does it know where to place Orthus on the map (so that he is placed on a valid land tile)?
cf.addUnit(iUnit) calls this code found in CustomFunctions.py:
Code:
def addUnit(self, iUnit):
pBestPlot = -1
iBestPlot = -1
for i in range (CyMap().numPlots()):
pPlot = CyMap().plotByIndex(i)
iPlot = -1
if pPlot.isWater() == False:
if pPlot.getNumUnits() == 0:
if pPlot.isCity() == False:
if pPlot.isImpassable() == False:
iPlot = CyGame().getSorenRandNum(500, "Add Unit")
iPlot = iPlot + (pPlot.area().getNumTiles() * 10)
if pPlot.isBarbarian():
iPlot = iPlot + 200
if pPlot.isOwned():
iPlot = iPlot / 2
if iPlot > iBestPlot:
iBestPlot = iPlot
pBestPlot = pPlot
if iBestPlot != -1:
bPlayer = gc.getPlayer(gc.getBARBARIAN_PLAYER())
newUnit = bPlayer.initUnit(iUnit, pBestPlot.getX(), pBestPlot.getY(), UnitAITypes.UNITAI_ATTACK, DirectionTypes.DIRECTION_SOUTH)
(D) How does it define what Orthus is (so that this can be the part easily changed to suit individual scenario makers)? If I were to guess, it might be the reference to Orthus in the Civ4UnitInfos.xml or possibly Civ4UnitClassInfos.xml.
iUnit = gc.getInfoTypeForString('UNIT_ORTHUS')
gc.getInfoTypeForString finds the index of "UNIT_ORTHUS", i.e., the position in CIV4UnitInfos.xml where the unit is found. (The first unit is 0, the second 1, the third 3, etc). This index is what is needed in order to initialize the unit.
Edit: I just saw that Tholal already answered most of this:
Plot Counter = Armageddon Counter.
While the rest of your explanation was right, this is statement is technically false and could confuse people. The Plot Counter and the Armageddon counter as different, but related, things.
The Armageddon counter applies to the game as a whole. It is what causes the various Armageddon events to be triggered, and it is one criteria used to determined whether hell is allowed to spread.
The Plot Counter is what determines whether any individual tile should be considered hell. (The terrain types change automatically based o Plot Counter, although feature and resource changes rely on python.) When doHellTerrain() runs, it does not simply turn a tile to hell. The Armageddon Counter and the alignment of the plot's owner are used to determine whether hell is allowed to spread. The spread of hell is however an increase in a plot's Plot Counter, and will only actually happen if the plot is adjacent to a tile with a high enough Plot Counter (or is Infernal Territory).
I believe that you could technically still use the Plot Counter in a scenario where the Armageddon counter and doHellTerrain are turned off. Your scenario-specific code would make the changes instead.
I just saw something I didn't know before - in the lore for Ice Golem (age of ice scenario) it implies that Mulcarn captured Barnaxus and had him work for him. Maybe something interesting that could be used in a story??
This is indeed the case.
(If you look carefully, you'll see that Barnaxus's artwork bears the makr of the White Hand.)
Mulcarn did not merely recruit or control Barnaxus. He took a broken piece of enchanted machinery and breathed life into it. Barnaxus became an intelligent being capable of independent thought because he was given a divine spark, a small fragment of Mulcarn's own soul.
The Beneath the Hell scenario already touches on the subject. The whole point of the scenario is to capture Barnaxus (or the pieces thereof) so that Auric can release the only surviving part of Mulcarn from the machine and absorb it into himself. This was probably the most important step on his path towards godhood.
(In my modmod, Auric has the "Inhale Mulcarn's Last Breath" ability, which lets him sacrifice The Pieces of Barnaxus in order to hurry The Draw or The Ascension ritual. The Illians are also allowed to rebuilt him from the pieces, if they do not wish to sacrifice them. Under Illian control, Barnaxus has the Craft Ice Golem ability. Since I gave Barnaxus The White Hand religion, he may defect to serve Auric once The Draw is completed. Barnaxus would not fight the God of Winter any more than Bambur would fight against Kilmorph.)