isenchine
Empress
We have all experienced games with Civilizations completely lagging and way behind the calendar. As you know, it depends so much on options at the start, map sizes, game speeds. It's a never-ending process of adjusting Tech costs.
As a remedy, I wanted to have this for my mod: at specific given Years, all Players (including Barbarians) receive a specific Technology if they have not researched it yet. I have certain technologies which are dated (Like 400 BC, AD 1, AD 500, ...). I find it easier to attribute certain Buildings, Units etc related to a period of time rather than a certain technology, but this Python solution is valid for all technologies actually.
I don't really know Python but I can play with it. I started with a piece of code made by The_J which was granting something at a given Year. I completed it with bits of a code from OrionVeteran's Techs by Conquest and started a very long process of trials and errors...
In the end, this is what I have. Amazingly, it works!
Of course, the two Years and two Technologies are here just for examples, for easier testing. A minus Year means BC.
What I would like now is that a more experienced person in Python look at the code and make any adjustment necessary.
Some questions:
1) is the function onBeginPlayerTurn the best one for this?
2) is the if-elif-else way the most efficient way to do this?
3) ... can't remember right now!...
One problem, depending on game speeds, is that the given Year might not be reached precisely, so I intend to have it rather like iYear >= 1800 and iYear < 1900 for example.
All comments, observations appreciated.
Thank you.
Edit: this is an excerpt from CvEventManager.py. Obvious to some...
As a remedy, I wanted to have this for my mod: at specific given Years, all Players (including Barbarians) receive a specific Technology if they have not researched it yet. I have certain technologies which are dated (Like 400 BC, AD 1, AD 500, ...). I find it easier to attribute certain Buildings, Units etc related to a period of time rather than a certain technology, but this Python solution is valid for all technologies actually.
I don't really know Python but I can play with it. I started with a piece of code made by The_J which was granting something at a given Year. I completed it with bits of a code from OrionVeteran's Techs by Conquest and started a very long process of trials and errors...
In the end, this is what I have. Amazingly, it works!
Spoiler :
PHP:
def onBeginPlayerTurn(self, argsList):
'Called at the beginning of a players turn'
iGameTurn, iPlayer = argsList
# Isantique
#iTurn = CyGame().getGameTurn ()
iTurn = iGameTurn
iTurn = iTurn+1
iYear = gc.getGame().getTurnYear(iTurn)
pPlayer = gc.getPlayer(iPlayer)
pTeam = gc.getTeam(pPlayer.getTeam())
if iYear == -3900:
iTechnologygiven = gc.getInfoTypeForString("TECH_MEDITATION")
if not pTeam.isHasTech(iTechnologygiven):
pTeam.setHasTech(iTechnologygiven, True, iPlayer, False, False)
# Show tech splash
if not CyInterface().noTechSplash():
if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
if not gc.getGame().isNetworkMultiPlayer():
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
popupInfo.setData1(iTechnologygiven)
popupInfo.setText(u"showTechSplash")
popupInfo.addPopup(iPlayer)
elif iYear == -3800:
iTechnologygiven = gc.getInfoTypeForString("TECH_WRITING")
if not pTeam.isHasTech(iTechnologygiven):
pTeam.setHasTech(iTechnologygiven, True, iPlayer, False, False)
# Show tech splash
if not CyInterface().noTechSplash():
if (gc.getGame().isFinalInitialized() and not gc.getGame().GetWorldBuilderMode()):
if not gc.getGame().isNetworkMultiPlayer():
popupInfo = CyPopupInfo()
popupInfo.setButtonPopupType(ButtonPopupTypes.BUTTONPOPUP_PYTHON_SCREEN)
popupInfo.setData1(iTechnologygiven)
popupInfo.setText(u"showTechSplash")
popupInfo.addPopup(iPlayer)
else: return
# End Isantique
What I would like now is that a more experienced person in Python look at the code and make any adjustment necessary.
Some questions:
1) is the function onBeginPlayerTurn the best one for this?
2) is the if-elif-else way the most efficient way to do this?
3) ... can't remember right now!...
One problem, depending on game speeds, is that the given Year might not be reached precisely, so I intend to have it rather like iYear >= 1800 and iYear < 1900 for example.
All comments, observations appreciated.
Thank you.
Edit: this is an excerpt from CvEventManager.py. Obvious to some...