MagisterCultuum
Great Sage
Just glancing at the code, it does not seem like a Lanun civ generated later through a revolution or through initNewEmpire on would be granted its unique Seafaring tech unless it was brought into the game by another Lanun player.
(Edit: I just tested this by changing CIVILIZATION_INFERNAL to CIVILIZATION_LANUN in the Infernal Pact code. Hyborem of the Lanun did not stat with Seafaring, but was able to research it within a turn.)
I think that in order to fix that the initNewEmpire should probably be more like this:
And the revolutions code more like this:
You could then ensure that the Infernals start with the Infernal Pact technology by adding thsi to their CIV4CivilizationInfox.xml define:
It is possible that that could create a problem in games that start out with the Infernals present (which would pretty much only be scenarios unless someone edits the game to make the playable from the start). The game could try to create a second copy of the Infernals when the first copy is given Infernal Pact before anyone else.
You could easily prevent that by editing CvEventManager.py and placing either if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_INFERNAL'): or if not CyGame().isCivEverActive(gc.getInfoTypeForString('CIVILIZATION_INFERNAL')): around line 1742.
(Edit: I just tested a game after giving the Infernals this starting tech and making them playable. A duplicate Hyborem was indeed spawned at the start of the game.
I also tested and found that both of the suggestions to prevent this do indeed work.)
Personally would suggest you simplify the code like this:
(Edit: I just tested this by changing CIVILIZATION_INFERNAL to CIVILIZATION_LANUN in the Infernal Pact code. Hyborem of the Lanun did not stat with Seafaring, but was able to research it within a turn.)
I think that in order to fix that the initNewEmpire should probably be more like this:
Code:
PlayerTypes CvPlayer::initNewEmpire(LeaderHeadTypes eNewLeader, CivilizationTypes eNewCiv)
{
FAssert(eNewLeader != NO_LEADER);
FAssert(eNewCiv != NO_CIVILIZATION);
PlayerTypes eNewPlayer = getOpenPlayer();
FAssert(eNewPlayer != NO_PLAYER);
FAssert(!GET_TEAM(GET_PLAYER(eNewPlayer).getTeam()).isAlive());
if (eNewPlayer != NO_PLAYER)
{
// remove leftover culture from old recycled player
for (int iPlot = 0; iPlot < GC.getMapINLINE().numPlotsINLINE(); ++iPlot)
{
CvPlot* pLoopPlot = GC.getMapINLINE().plotByIndexINLINE(iPlot);
pLoopPlot->setCulture(eNewPlayer, 0, false, false);
}
GC.getGameINLINE().addPlayer(eNewPlayer, eNewLeader, eNewCiv);
GC.getInitCore().setLeaderName(eNewPlayer, GC.getLeaderHeadInfo(eNewLeader).getTextKeyWide());
CvTeam& kNewTeam = GET_TEAM(GET_PLAYER(eNewPlayer).getTeam());
for (int i = 0; i < GC.getNumTechInfos(); ++i)
{
[COLOR="Red"]if ((GC.getCivilizationInfo(eNewCiv).isCivilizationFreeTechs((TechTypes)i)))
{
kNewTeam.setHasTech((TechTypes)i, true, eNewPlayer, false, false);
}
elif (GET_TEAM(getTeam()).isHasTech((TechTypes)i) && GET_PLAYER(eNewPlayer).canEverResearch((TechTypes)i))[/COLOR]
{
kNewTeam.setHasTech((TechTypes)i, true, eNewPlayer, false, false);
if (GET_TEAM(getTeam()).isNoTradeTech((TechTypes)i) || GC.getGameINLINE().isOption(GAMEOPTION_NO_TECH_BROKERING))
{
kNewTeam.setNoTradeTech((TechTypes)i, true);
}
}
}
ReligionTypes eFavorite = getFavoriteReligion();
ReligionTypes eNewFavorite = GET_PLAYER(eNewPlayer).getFavoriteReligion();
if (eFavorite != NO_RELIGION)
{
if (eNewFavorite == NO_RELIGION)
{
GET_PLAYER(eNewPlayer).setFavoriteReligion(eFavorite);
}
}
for (int iTeam = 0; iTeam < GC.getMAX_TEAMS(); iTeam++)
{
CvTeam& kLoopTeam = GET_TEAM((TeamTypes)iTeam);
if (kLoopTeam.isAlive())
{
kNewTeam.setEspionagePointsAgainstTeam((TeamTypes)iTeam, GET_TEAM(getTeam()).getEspionagePointsAgainstTeam((TeamTypes)iTeam));
kLoopTeam.setEspionagePointsAgainstTeam(GET_PLAYER(eNewPlayer).getTeam(), kLoopTeam.getEspionagePointsAgainstTeam(getTeam()));
}
}
kNewTeam.setEspionagePointsEver(GET_TEAM(getTeam()).getEspionagePointsEver());
AI_updateBonusValue();
}
return eNewPlayer;
And the revolutions code more like this:
Code:
def giveTechs( toPlayer, fromPlayer, expensiveVars = [1,3], doTakeAway = True ) :
# Give all techs known by fromPlayer, except a few of the most expensive
knownTechs = list()
mostExpensive = list()
minMostExpensive = 0
numMostExpensive = expensiveVars[0] + game.getSorenRandNum(expensiveVars[1],'Rev: Pick num techs')
fromPlayerTeam = gc.getTeam( fromPlayer.getTeam() )
toPlayerTeam = gc.getTeam( toPlayer.getTeam() )
for techID in range(0,gc.getNumTechInfos()) :
[COLOR="Red"]
if gc.getCivilizationInfo(toPlayer.getCivilizationType()).isCivilizationFreeTechs(techID):
knownTechs.append( techID )
elif toPlayer.canEverResearch( techID):[/COLOR]
if( fromPlayerTeam.isHasTech( techID ) ) :
knownTechs.append( techID )
if( gc.getTechInfo( techID ).getResearchCost() > minMostExpensive ) :
if( len(mostExpensive) < numMostExpensive ) :
mostExpensive.append( techID )
else :
for j in range(0,len(mostExpensive)) :
if( gc.getTechInfo( mostExpensive[j] ).getResearchCost() == minMostExpensive ) :
mostExpensive.remove( mostExpensive[j] )
break
mostExpensive.append( techID )
minMostExpensive = gc.getTechInfo( mostExpensive[0] ).getResearchCost()
for j in range(0,len(mostExpensive)) :
if( gc.getTechInfo( mostExpensive[j] ).getResearchCost() < minMostExpensive ) :
minMostExpensive = gc.getTechInfo( mostExpensive[j] ).getResearchCost()
if( doTakeAway and toPlayerTeam.isHasTech(techID) and toPlayerTeam.getNumMembers() == 1 ) :
# take away all techs
#if( LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Taking away %s"%(PyInfo.TechnologyInfo(techID).getDescription()))
toPlayerTeam.setHasTech(techID,False,toPlayer.getID(),False,False)
if( doTakeAway ) :
if( not toPlayer.getTechScore() == 0 ) :
# Shouldn't have to do this, but tech scores never came out to zero for reincarnated civs ...
if( LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Resetting tech score ...")
toPlayer.changeTechScore( -toPlayer.getTechScore() )
for techID in knownTechs :
if( not techID in mostExpensive ) :
#if( LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - Giving rev %s"%(PyInfo.TechnologyInfo(techID).getDescription()))
toPlayerTeam.setHasTech(techID,True,toPlayer.getID(),False,False)
else :
if( LOG_DEBUG ) : CvUtil.pyPrint(" Revolt - NOT giving rev all of %s"%(PyInfo.TechnologyInfo(techID).getDescription()))
techCost = toPlayerTeam.getResearchCost( techID )
maxFreeResearch = techCost*0.75
toPlayerTeam.setResearchProgress( techID, game.getSorenRandNum(int(maxFreeResearch),'RevUtils: free research'), toPlayer.getID() )
You could then ensure that the Infernals start with the Infernal Pact technology by adding thsi to their CIV4CivilizationInfox.xml define:
Code:
<FreeTechs>
<FreeTech>
<TechType>TECH_INFERNAL_PACT</TechType>
<bFreeTech>1</bFreeTech>
</FreeTech>
</FreeTechs>
It is possible that that could create a problem in games that start out with the Infernals present (which would pretty much only be scenarios unless someone edits the game to make the playable from the start). The game could try to create a second copy of the Infernals when the first copy is given Infernal Pact before anyone else.
You could easily prevent that by editing CvEventManager.py and placing either if pPlayer.getCivilizationType() != gc.getInfoTypeForString('CIVILIZATION_INFERNAL'): or if not CyGame().isCivEverActive(gc.getInfoTypeForString('CIVILIZATION_INFERNAL')): around line 1742.
(Edit: I just tested a game after giving the Infernals this starting tech and making them playable. A duplicate Hyborem was indeed spawned at the start of the game.
I also tested and found that both of the suggestions to prevent this do indeed work.)
Personally would suggest you simplify the code like this:
Code:
if not gc.getGame().isOption(GameOptionTypes.GAMEOPTION_NO_HYBOREM_OR_BASIUM):
if (iTechType == gc.getInfoTypeForString('TECH_INFERNAL_PACT') and iPlayer != -1):
# iCount = 0
# for iTeam in range(gc.getMAX_TEAMS()):
# pTeam = gc.getTeam(iTeam)
# if pTeam.isHasTech(gc.getInfoTypeForString('TECH_INFERNAL_PACT')):
# iCount = iCount + 1
# if iCount == 1:
if not CyGame().isCivEverActive(gc.getInfoTypeForString('CIVILIZATION_INFERNAL')):