Mercenaries Mod - BTS - Multiplayer compatible

Korelios

Chieftain
Joined
Dec 29, 2007
Messages
8
Hi,
This is a Multiplayer compatible version of the Mercenaries Mod (by The Lopez) updated to work with Beyond the Sword (patch 3.13 tested).

This mod will only work in single player and LAN multiplayer games for now (since it involves a parallel network bridge i added into python scripts which is using Multicast UDP which does not work over the internet).
I integrated some of the modifications made by Rhye in the RFC mod to make the gameplay of the mercenaries proposed by the mod a little more usable (lower recruit cost and maintenance cost).

Here is the link :
http://dunad.dyndns.org/civ4/Mercenaries Mod-V0.6.1-BTS-MP-Alpha.zip

This is still alpha version, you have been warned.
Nevertheless, any feedback would help me improve it.
 
* Bug fix added : The original "Mercenaries Mod" had a flaw, when a hired mercenary is "disbanded" it would remain partly in the game, the owning player would pay some maintenance cost for a mercenary which did not exist anymore. I detected this bug after adding some of the improvement from the Rhye's and Fall mod (base maintenance cost for all units : 2 gp), i don't know how it is handled in it.
 
Good work on the conversion of this mod.

Found a bug for you in MercenaryUtils.getRandomCityWithBuildings(self, iPlayer): The method PyCity.hasBuilding(self, buildingInfoTypeID) has been removed in BTS.
Use PyCity.getNumBuilding(self, buildingInfoTypeID) instead.

Spoiler Old Code :
Code:
	def getRandomCityWithBuildings(self, iPlayer):
		'CyCity - the city containing at least one or more buildings set in the g_buildingInfoTypeList variable'
		# Get the player
		pyPlayer = PyPlayer(iPlayer)

		# Get the player's cities
		cityList = pyPlayer.getCityList()

		possibleCityList = []			

		# Go through the player's cities and get the ones that contain one or more buildings
		# set in the g_buildingInfoTypeList variable.			
		for city in cityList:
		
			# Go through the buildings set in the g_buildingInfoTypeList
			for buildingInfoTypeID in g_buildingInfoTypeList:

				# Append the city to the possibleCityList for each match found
				# this way the cities that are matched more have a better chance
				# of being the city where the mercenary will appear.
				if(city.hasBuilding(buildingInfoTypeID)):
					possibleCityList.append(city)
					
		# If no cities were found containing one or more buildings set in the 
		# g_buildingInfoTypeList variable then return None
		if(len(possibleCityList) == 0):
			return None

		# return a random city containing one or more buildings set in the 
		# g_buildingInfoTypeList variable.
		return possibleCityList[gc.getGame().getMapRand().get(len(possibleCityList), "Random City")].GetCy()

Spoiler Fixed Code :
Code:
	def getRandomCityWithBuildings(self, iPlayer):
		'CyCity - the city containing at least one or more buildings set in the g_buildingInfoTypeList variable'
		# Get the player
		pyPlayer = PyPlayer(iPlayer)

		# Get the player's cities
		cityList = pyPlayer.getCityList()

		possibleCityList = []			

		# Go through the player's cities and get the ones that contain one or more buildings
		# set in the g_buildingInfoTypeList variable.			
		for city in cityList:
		
			# Go through the buildings set in the g_buildingInfoTypeList
			for buildingInfoTypeID in g_buildingInfoTypeList:

				# Append the city to the possibleCityList for each match found
				# this way the cities that are matched more have a better chance
				# of being the city where the mercenary will appear.
				if(city.getNumBuilding(buildingInfoTypeID) > 0):
					possibleCityList.append(city)
					
		# If no cities were found containing one or more buildings set in the 
		# g_buildingInfoTypeList variable then return None
		if(len(possibleCityList) == 0):
			return None

		# return a random city containing one or more buildings set in the 
		# g_buildingInfoTypeList variable.
		return possibleCityList[gc.getGame().getMapRand().get(len(possibleCityList), "Random City")].GetCy()
 
I found another bug.
When you configure the merc mod to search for a building in the g_strMercenaryStartingLocation list to place a hired merc, and none of your cities have any of the buildings on the list, it tries to place the merc on the map at location -1, -1, which causes the game to CTD. As a fix, I suggest to default the location to the players capital if none of the buildings on the list exist in the player's cities.

Original Code:
Spoiler MercenaryUtils.getRandomCityWithBuildings(self, iPlayer) :
Code:
	# Returns a random city that has one or more buildings set in the g_buildingInfoTypeList
	# variable
	def getRandomCityWithBuildings(self, iPlayer):
		'CyCity - the city containing at least one or more buildings set in the g_buildingInfoTypeList variable'
		# Get the player
		pyPlayer = PyPlayer(iPlayer)

		# Get the player's cities
		cityList = pyPlayer.getCityList()

		possibleCityList = []			

		# Go through the player's cities and get the ones that contain one or more buildings
		# set in the g_buildingInfoTypeList variable.			
		for city in cityList:
		
			# Go through the buildings set in the g_buildingInfoTypeList
			for buildingInfoTypeID in g_buildingInfoTypeList:

				# Append the city to the possibleCityList for each match found
				# this way the cities that are matched more have a better chance
				# of being the city where the mercenary will appear.
				if(city.hasBuilding(buildingInfoTypeID)):
					possibleCityList.append(city)
					
		# If no cities were found containing one or more buildings set in the 
		# g_buildingInfoTypeList variable then return None
		if(len(possibleCityList) == 0):
			return None

		# return a random city containing one or more buildings set in the 
		# g_buildingInfoTypeList variable.
		return possibleCityList[gc.getGame().getMapRand().get(len(possibleCityList), "Random City")].GetCy()

My proposed code fix (As will be implemented in the Dragonia II mod):
Spoiler MercenaryUtils.getRandomCityWithBuildings(self, iPlayer) :
Code:
	# Returns a random city that has one or more buildings set in the g_buildingInfoTypeList
	# variable
	def getRandomCityWithBuildings(self, iPlayer):
		'CyCity - the city containing at least one or more buildings set in the g_buildingInfoTypeList variable'
		# Get the player
		pyPlayer = PyPlayer(iPlayer)

		# Get the player's cities
		cityList = pyPlayer.getCityList()

		possibleCityList = []			

		# Go through the player's cities and get the ones that contain one or more buildings
		# set in the g_buildingInfoTypeList variable.			
		for city in cityList:
		
			# Go through the buildings set in the g_buildingInfoTypeList
			for buildingInfoTypeID in g_buildingInfoTypeList:

				# Append the city to the possibleCityList for each match found
				# this way the cities that are matched more have a better chance
				# of being the city where the mercenary will appear.
				if(city.getNumBuilding(buildingInfoTypeID) > 0):
					possibleCityList.append(city)
					
		# If no cities were found containing one or more buildings set in the 
		# g_buildingInfoTypeList variable then return None
		if(len(possibleCityList) == 0):
			return gc.getPlayer(iPlayer).getCapitalCity()

		# return a random city containing one or more buildings set in the 
		# g_buildingInfoTypeList variable.
		return possibleCityList[gc.getGame().getMapRand().get(len(possibleCityList), "Random City")].GetCy()
 
Am I correct in assuming that this is the same system as that used in Rhye's mod. And if so, would it be possible for me to mod this so that a player would put the unit up for sale instead of just leasing it out. This being so a player would pay a set price for the unit in the beginning and gain complete control over it without having to pay any additional gold per turn?
If this is possible, could you explain how or maybe do it for me?
 
what does this mod do? allows mercenaries? u can sell units? u can keep the unit say like if you had a great general unit and u sold it can you get it back?
 
what does this mod do? allows mercenaries? u can sell units? u can keep the unit say like if you had a great general unit and Well if it works like the one in Rhye's mod, u can rent out units for cash but if it dies, u don't get it back.
 
Am I correct in assuming that this is the same system as that used in Rhye's mod. And if so, would it be possible for me to mod this so that a player would put the unit up for sale instead of just leasing it out. This being so a player would pay a set price for the unit in the beginning and gain complete control over it without having to pay any additional gold per turn?
If this is possible, could you explain how or maybe do it for me?

Any responses?
 
how big are we talkin? Because all I want to do is have a set price at the beginning instead of a per turn price.
 
what are the hidden .svn folders for ? I see that they are all duplicates and they occur in every folder. I'm deleting them but why are they there ? Am I missing something here ?
 
Links to files for this mod no longer work ... or at least that website is down at the moment (?). Could you upload to CivFanatics? Or could someone who has a copy of this post it in the thread?

This sounds like a worthy update, and I'd really like to integrate mercenaries into HephMod, but digging around through Rhye's code and trying to make it work for me is a bit over my head!:(
 
What I'd strongly suggest to some modder is to make mercenaries have a sort of mercenary marketplace. Instead of buying randomly-generated mercenaries, it would be nice to have civs put units for hire, which can be hired by other civs. This could simulate slave trading :)

Kevin
 
I would also like to check out this code. The network bridge part interests me as I don't think anything so drastic is nessessary to make TheLopez's old Merc mod work in MP games.
 
Back
Top Bottom