def getSpecificMercenary(self, iPlayer, iUnitType, strName, iX, iY):
' Mercenary - the mercenary'
# returns a specific mercenary with a name but no promotions
# Setup the mercenary data structure if it hasn't been setup yet.
# if(sdEntityExists("Mercenaries Mod","MercenaryData") == False): # edead
# self.setupMercenaryData() # edead
# return immediately if the iEra doesn't contain a valid value for an era
#if(gc.getEraInfo(iEra) == None):
#return
# Initialize the prereqTechEra so it doesn't equal the iEra
#prereqTechEra = iEra * -1
# If iEra is set to 0 then the game just began and set the prereqTechEra
# to -1
#if(prereqTechEra == iEra):
#prereqTechEra = -1
# Get the current active player, this use to get the barbarian player but
# it had to be changed since barbarians will not always exist in games.
# Yes, I know I should change the variable name, but alas I am lazy ...
# well maybe not so lazy since I at least took the time to document this
# and I could have used the time instead to change the variable name but
# I did not ... so live with it.
barbarianPlayer = gc.getPlayer(gc.getGame().getActivePlayer())
mercenary = None
promotionList = []
# Loop until we get a unit with at least some promotions
#while(len(promotionList) < g_iMinimumStartingMercenaryPromotionCount):
#bLoop = True #Rhye
#iLoopCounter = 0 #Rhye
# Loop until we get a unit that matches the required era
#while(prereqTechEra != iEra): #Rhye
#while(bLoop): #Rhye
#promotionList = []
#Rhye - start loopfix (infinite loop happens if renaissance+ techs that offer no units are enabled by WB while in the ancient age)
#iLoopCounter += 1
#if (iLoopCounter > 5000):
#return None
#Rhye - end
# The random type of unit that will be created
#iUnitType = gc.getGame().getMapRand().get(gc.getNumUnitInfos(), "Random Unit Info")
#iUnitType = con.lMercenaries[gc.getGame().getSorenRandNum(len(con.lMercenaries), "Random Unit Info")] # edead: merc whitelist
# Get the PyUnitInfo for the iUnitType
pUnitInfo = PyInfo.UnitInfo(iUnitType)
# Create the mercenary unit if we have a valid iUnitType value
if(iUnitType != -1):
#Rhye - start bugfix
# Create the mercenary unit
#tmpUnit = barbarianPlayer.initUnit(iUnitType, 0, 0, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH)
tmpUnit = barbarianPlayer.initUnit(iUnitType, con.iMercX, con.iMercY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_SOUTH) # edead
# Create the actual mercenary object, we do not pass in the tmpUnit object itself
# because we do not want to accidentally set it as the CyUnit in the Mercenary class
#Rhye - start
#mercenary = Mercenary(MercenaryNameUtils.getRandomMercenaryName(), gc.getUnitInfo(iUnitType), promotionList, tmpUnit.getExperience(), tmpUnit.experienceNeeded())
mercenary = Mercenary(strName, gc.getUnitInfo(iUnitType), promotionList, tmpUnit.getExperience(), tmpUnit.experienceNeeded())
#Rhye - end
# Kill off the tmpUnit since it does not need to exist in the game until someone hires the
# mercenary
tmpUnit.kill(false,PlayerTypes.NO_PLAYER)
#edead - start
for x in range(con.iMercX-1, con.iMercX+2):
for y in range(con.iMercY-1, con.iMercY+2):
gc.getMap().plot(x, y).setRevealed(gc.getGame().getActivePlayer(), False, True, -1);
#edead - end
# Debug code - start
if(g_bDebug):
self.printMercenaryDataToLog(mercenary)
# Debug code - end
# Get the starting location for the mercenary if we are not delaying their
# placement
#city = None
#if(not g_bDelayMercenaryPlacement):
# edead: start naval mercenaries
#if mercenary.getUnitInfo().getDomainType() == gc.getInfoTypeForString("DOMAIN_LAND"):
#city = self.getMercenaryStartingLocation(iPlayer)
#else:
#city = self.getCoastalStartingLocation(iPlayer)
mercenary.spothire(iPlayer, iX, iY)
# Saves the mercenary in the global mercenary pool
self.saveMercenary(mercenary)
# Finally return the mercenary
#return mercenary