[BtS MODCOMP] Enhanced Tech Conquest

Grave

1 Goat = 400 Horses
Joined
May 5, 2002
Messages
1,530
Location
Louisiana
Enhanced Tech Conquest v0.6
By: Grave, Jeckel


Patch Compatibility: Beyond the Sword v3.03 and v3.13
MP Compatible: ?

Description:

The Enhanced Tech Conquest Mod is designed to give a tech boost from conquering
enemy cities. When an enemy city is conquered, a list of techs the enemy has
that your empire doesn't is created. From that list a random tech is selected.


Installation Instructions:

Spoiler :
1) Unzip this into the "warlords_install_folder\Mods\" folder.
2) Open the CivilizationIV.ini configuration file
3) Change the Mod line to read: Mod = Mods\Enhanced Tech Conquest
4) Load the game.
5) Then play as normal.


-----Game Play-----

Spoiler :
- Captured cities always give a minimum of 25% towards the cost of a tech plus
a random amount

- The random amount is from 0 to <city size * 5>%. For example a city of size 4
would give between 25% and 45% of the tech cost. This assumes the default
configuration values have not been changed

- Cities greater than size 15 increase the chance of getting a full tech. For
example a city of size 20 would give between 25% and 125% of the tech cost.
This assumes the default configuration value has not been changed.

- Several configurable options allow tuning of how technology will get
transfered from the conquered city to the conquering civilization.



-----Notes to Modmakers-----

Spoiler :
In the Python files I have added # < Enhanced Tech Conquest Start > and
# < Enhanced Tech Conquest End > in all of the places that I have made changes
to the original files.



-----Version Information-----

Spoiler :
-----v0.6------

- Certified to work with Beyond the Sword v3.13!

- Updated all code to be compatible with Beyond the Sword v3.02

-----v0.5w------

- Updated all code to be compatible with Warlords v2.0.0.0

- Fixed several areas of the code that were not working correctly leading to
technology being given from one civ to another civ with the mod is configured
to prevent this.


-----v0.4.x------

- Integrated Dr. Elmer Jiggle's event handler and INI parser code

- Added the configurable option allowing players to specify if technology
should be handed completely over from the conquered city to their new owners
or not.

- Added the configurable option allowing players to specify the number of or
part of technologies conquered cities will hand over to their new owners.

- Added the configurable option allowing players to specify the amount of
technologies conquered cities will hand over to their new owners should not
be random.

- Added the configurable option allowing players to specify if the conquering
civilization can receive technology without the appropriate prerequisites or
ignore their civilization technology restrictions.

- Added the configurable option allowing players to specify if full technology
transfer should be allowed. By setting the value to true this will force
players to spend at least one turn researching pillaged technology.

- Added the configurable option allowing players to specify the base technology
transfer percentage amount.

- Added the configurable option allowing players to specify the percent amount
per city population that will be used to transfer technology to the new owners
of the conquered city.

- Added the popup informing players that they did not learn anything from a
conquered city if there was nothing to learn. Requested by woodelf.

- Changed removed the popups from the mod and replaced them with messages
instead. The popups are displayed for all human players even if they are not
the currently active players. Requested by Shqype, reported by TheLopez.


-----v0.3------

- base tech cost wasn't reflecting modifications from game speed/map size/difficulty level

- altered percentages to give higher tech points for smaller cities

- fixed a bug preventing the popup from displaying

- only techs for which the player has the prerequisites are included in tech list


-----v0.2------

- changed from a flat percentage system to one based on the city size


-----v0.1------

- first release



----- To Do List -----

- Add a configurable option allowing players to choose which technology to
receive from a conquered city.

-----===Credits & Thanks===-----

- Jeckel
Without his help, the BtS version wouldn't be possible!

- TheLopez
For the Warlords version this is based off of

- Bhruic
For his original Tech Conquest code

- Dr Elmer Jiggle
For providing the INI file parser code allowing for players to
customize this mod without having to touch the python code!!!
 
Congrats on getting this done! I'm glad to see you were able to do it. I really enjoyed this aspect of the game, and I think it gives a great opportunity for less technologically-advanced civs to get back on their feet by swamping a more high-tech enemy.
 
Great to see this mod converted to BTS. Meabee you can extend you Mod with Improved technology stealing

What about the following ideas:
- spies near rival cities will slowly steal their technology
- Make rival spies near cities visible by inteligence agents
- inteligence agents can kill spies with a high chance of succes in owned territory
- inteligence agents can kill spies with a average chance of succes in allied territory
- inteligence agents can kill spies with a low chance of succes in neutral territory
 
Congrats for me too :goodjob:

Can't wait to use it. Right now I'm eagerly awaiting the next patch though.

\Skodkim
 
I'm afraid the patch is going to break a lot of mods :(


Do you know this for fact, or is it speculation?

It's a pure Python mod... unless they do drastic changes to Python, it shouldn't be affected.


I guess we shall all have to wait and see. If it needs adjusted, no biggie.
 
I'm about half done getting the popup so you can choose which tech(s) you want when you conquer a city. :)
 
Thanks a lot!! :goodjob: Good to have this feature again. I looking forward to trying your mod comp.!!
CellKu
 
Great idea, however, is there any way to incorporate a percentage chance of acquiring a tech? I don't think it would be too hard, but I'm not exactly sure what part of the file to change to add this.
It seems a bit too powerful/unrealistic to be able to just get a tech from conquering any city...
 
Great idea, however, is there any way to incorporate a percentage chance of acquiring a tech? I don't think it would be too hard, but I'm not exactly sure what part of the file to change to add this.
It seems a bit too powerful/unrealistic to be able to just get a tech from conquering any city...

Download it and check out the Config INI file. It allows you to incorporate a percent chance to acquiring a tech. It further breaks it down by giving a base percent chance, plus a bonus percent chances based off of the size of the city, all configurable by the end user.

See the "Game Play" spoiler in the original post for a more detailed description. :)
 
Could you remove the "echo" text in red when a city is concured? It says something about OnCityAquired=true and possible techs.

\Skodkim
 
Could you remove the "echo" text in red when a city is concured? It says something about OnCityAquired=true and possible techs.

\Skodkim


Several people have asked me about that. I'll have to see if Jeckel can do that, as I'm not entirely sure on how to go about it.
 
Several people have asked me about that. I'll have to see if Jeckel can do that, as I'm not entirely sure on how to go about it.


turn off debug in EnhancedTechConquest you will see all I did was place in front of all words that said debug # and #alert.debug(0, sText, xValue)


Spoiler :
## Sid Meier's Civilization 4
## Copyright Firaxis Games 2005
##
## TechConquest by Bhruic
## Updated by TheLopez
##
from CvPythonExtensions import *
import CvUtil
import PyHelpers
import Popup as PyPopup
import CvConfigParser
import CvAlertManager
# globals
gc = CyGlobalContext()
alert = CvAlertManager.CvAlertManager()
# Change the value to true if technology should be handed completely over from
# the conquered city to their new owners.
# Default value is False
g_bCompleteTechnologyDiscovery = False
# Increase or decrease the value to change the number of or part of
# technologies conquered cities will hand over to their new owners.
# Default value is 1
g_iTechnologyTransferCount = 1
# Change the value to true if the amount of technologies conquered cities will
# hand over to their new owners should be random.
# Default value is False
g_bRandomTechnologyTransferAmount = False
# Change the value to true if the conquering civilization can receive
# technology without the appropriate prerequisites or ignore their civilization
# technology restrictions.
# Default value is False
g_bTechnologyTransferIgnorePrereq = False
# Change the value to False if full technology transfer should be allowed. By
# setting the value to true this will force players to spend at least one turn
# researching pillaged technology.
# Default value is true
g_bDisableFullTechnologyTransfer = true
# Increase or decrease the value to change the base technology transfer
# percentage amount.
# Default value is 25
g_iBaseTechnologyTransferPercent = 25
# Increase or decrease the value to change the percent amount per city
# population that will be used to transfer technology to the new owners of
# the conquered city.
# Default value is 5
g_iPercentagePerCityPopulation = 5

#def debug(sText, xValue = True):
#alert.debug(0, sText, xValue)

def loadConfigurationData():
global g_bCompleteTechnologyDiscovery
global g_iTechnologyTransferCount
global g_bRandomTechnologyTransferAmount
global g_bTechnologyTransferIgnorePrereq
global g_bDisableFullTechnologyTransfer
global g_iBaseTechnologyTransferPercent
global g_iPercentagePerCityPopulation

config = CvConfigParser.CvConfigParser("Enhanced Tech Conquest Config.ini")
if(config != None):
g_bCompleteTechnologyDiscovery = config.getboolean("Enhanced Tech Conquest", "Complete Technology Discovery", False)
g_iTechnologyTransferCount = config.getint("Enhanced Tech Conquest", "Technology Transfer Count", 1)
g_bRandomTechnologyTransferAmount = config.getboolean("Enhanced Tech Conquest", "Random Technology Transfer Amount", False)
g_bTechnologyTransferIgnorePrereq = config.getboolean("Enhanced Tech Conquest", "Technology Transfer Ignore Prereq", False)
g_bDisableFullTechnologyTransfer = config.getboolean("Enhanced Tech Conquest", "Disable Full Technology Transfer", True)
g_iBaseTechnologyTransferPercent = config.getint("Enhanced Tech Conquest", "Base Technology Transfer Percent", 25)
g_iPercentagePerCityPopulation = config.getint("Enhanced Tech Conquest", "Percentage Per City Population", 5)

class EnhancedTechConquest:
def onCityAcquired(self, argsList):
iPreviousOwner, iNewOwner, pCity, bConquest, bTrade = argsList
#debug("onCityAcquired")
# Return immediately if the city was not conquered
if (not bConquest):
return None
#debug("isConquest")

# Get the map random object
pMapRand = gc.getGame().getMapRand()
# Get the conquering player
pPlayer = gc.getPlayer(iNewOwner)

# Get the conquerer's team
pNewTeam = gc.getTeam(pPlayer.getTeam())
# Get the old city owner
pOldCityOwner = gc.getPlayer(iPreviousOwner)
lDiscoveredTechs = []
lDiscoveredTechStrs = ""
iTotalTechPoints = 0

# Go through and try to get as many technologies as allowed
iCountTechs = 0
for i in range(gc.getNumTechInfos()):
# If we have enough techs then break
if (iCountTechs >= g_iTechnologyTransferCount):
break
# Get the possible technologies that could be transfered
lPossibleTechnology = self.getPossibleTechnologyList(pOldCityOwner, pCity, lDiscoveredTechs)
#debug("lPossibleTechnology", lPossibleTechnology)

# Break if there are no possible technologies that can be transfered
if (len(lPossibleTechnology) < 1):
break
# Pick a technology randomly from the list
iRandTechPos = pMapRand.get(len(lPossibleTechnology), "TechConquest")
#debug("iRandTechPos", iRandTechPos)
# Get the tech type from the list
iRandTech = lPossibleTechnology[iRandTechPos]
#debug("iRandTech", iRandTech)
# Get the total number of technology points that will be transfered
# to the new city owner
iTotalTechPoints = self.getTechnologyTransferAmount(iRandTech, pNewTeam, pCity)
#debug("iTotalTechPoints", iTotalTechPoints)
# Don't need to do anything if no points are to be transfered
if (iTotalTechPoints < 1):
continue
iCountTechs += 1
lDiscoveredTechs.append(iRandTech)
# Increase the research progress for the new city owner
pNewTeam.changeResearchProgress(iRandTech, iTotalTechPoints, iNewOwner)
if (iCountTechs == 1):
#lDiscoveredTechStrs += gc.getTechInfo(iRandTech).getDescription()
lDiscoveredTechStrs += "\n\t\t" + gc.getTechInfo(iRandTech).getDescription()
else:
#lDiscoveredTechStrs += ", " + gc.getTechInfo(iRandTech).getDescription()
lDiscoveredTechStrs += "\n\t\t" + gc.getTechInfo(iRandTech).getDescription()
strMessage = ""
# Inform the player they didn't get any new technologies
if (iCountTechs < 1):
strMessage = "You find nothing worth learning from the inhabitants of %s" %(pCity.getName())
# Inform the player they got some new technology points
else:
strMessage = "From the inhabitants of %s, you learn some of the secrets of: %s" %(pCity.getName(), lDiscoveredTechStrs)

CyInterface().addMessage(pPlayer.getID(), True, 20, strMessage, "", 0, gc.getCivilizationInfo(pOldCityOwner.getCivilizationType()).getButton(), ColorTypes(0), pCity.getX(), pCity.getY(), True, True)

# Returns the amount of technology points of that should be transfered from
# the old owners of the city to the new owners of the city.
def getTechnologyTransferAmount(self, iTechType, pNewTeam, pCity):
# Return zero immediately if the tech info passed in is invalid
if (iTechType < 0):
return 0
# Return zero immediately if the new team passed in is invalid
elif (pNewTeam == None) or (pNewTeam.isNone()):
return 0
# Return zero immediately if the city passed in is invalid
elif (pCity == None) or (pCity.isNone()):
return 0

pMapRand = gc.getGame().getMapRand()
iTechCost = pNewTeam.getResearchCost(iTechType)
iCurrentTechPoints = pNewTeam.getResearchProgress(iTechType)
iTempCost = (iTechCost - iCurrentTechPoints)
# Return the full tech cost if the mod has been configured to do so
if (g_bCompleteTechnologyDiscovery):
if(g_bDisableFullTechnologyTransfer) and (iTempCost > 1):
return iTempCost - 1
return iTempCost

# Get the percentage amount of tech points that is given by the population
iTempPercent = pCity.getPopulation() * g_iPercentagePerCityPopulation
iPercent = min(max(0, iTempPercent), 100)
iExtraTechPoints = 0
# Get the base percentage amount of tech points
iBaseTechPoints = int(iTechCost * (g_iBaseTechnologyTransferPercent/100.0))
if (g_bRandomTechnologyTransferAmount):
iExtraTechPoints = pMapRand.get(iPercent, "TechConquest")
else :
iExtraTechPoints = int(iTechCost * (iPercent/100.0))
# Get the total amount of tech points to be transfered
iTotalTechPoints = iBaseTechPoints + iExtraTechPoints
if (iTotalTechPoints >= iTempCost):
if (g_bDisableFullTechnologyTransfer) and (iTempCost > 1):
return iTempCost - 1
return iTempCost
return iTotalTechPoints


# Returns the list of technologies the conquering player could get from
# their newly conquered city.
def getPossibleTechnologyList(self, pOldCityOwner, pCity, lDiscoveredTechs):
lPossibleTechnology = []
# Return an empty list if the old city owner passed in is invalid
if (pOldCityOwner == None) or (pOldCityOwner.isNone()):
return []
# Return an empty list if the city passed in is invalid
elif (pCity == None) or (pCity.isNone()):
return []

# Get the team from the old owner of the city
pOldCityOwnerTeam = gc.getTeam(pOldCityOwner.getTeam())
# Get the conquering player of the city
pConquerer = gc.getPlayer(pCity.getOwner())
# Get the conquering team of the city
pConquererTeam = gc.getTeam(pConquerer.getTeam())

# Go through each technology in the game
for iTechType in range(gc.getNumTechInfos()):

# CvUtil.pyPrint("%s %s %s" %(gc.getTechInfo(iTechType).getType(), pConquerer.canResearch(iTechType, False), g_bTechnologyTransferIgnorePrereq) )
# Continue if the conquerer cannot research the technology
if (not pConquerer.canResearch(iTechType, False) and (not g_bTechnologyTransferIgnorePrereq)):
continue
# Continue if the old team doesn't have the tech
elif (not pOldCityOwnerTeam.isHasTech(iTechType)):
continue
# Continue if the conquering team does have the tech
elif (pConquererTeam.isHasTech(iTechType)):
continue
# Continue if the tech is in the discovered tech list
elif (iTechType in lDiscoveredTechs):
continue
# Append the technology to the possible technology list
elif(g_bDisableFullTechnologyTransfer):
iConquererProgress = pConquererTeam.getResearchProgress(iTechType)
if (iConquererProgress >= (pConquererTeam.getResearchCost(iTechType) - 1)):
continue
# Append the technology to the possible technology list
lPossibleTechnology.append(iTechType)
return lPossibleTechnology
 
Roamty. I tried copy pasting your bit of code. Didn't work. Maybe I just did it wrong...

Could you upload it if you've got a working version?

\Skodkim
 
Top Bottom