## Original by Roamty http://forums.civfanatics.com/showthread.php?t=255237 ##
## Modified by:- ##
## StrategyOnly - made it modular (BUG standard) ##
## see also line in config/init.xml that "initializes" it. ##
## DancingHoskuld - individualized the animals so that "normal" animal ##
## units could not enter territory as in default BtS. ##
## - extended BUG modularity ##
## - merged in and generalised AnimalBonus mod by NotSoGood. ##
## - added code to give food and hammers from animal kills ##
## To do:-
## - language support for messages
from CvPythonExtensions import *
import CvEventManager
import CvUtil
import BugUtil
import PyHelpers
import DH_Utils
# globals
gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
gi_HalfMaxX = -1
gi_AnimalUnitType = -1
#~ gi_ReconUnitType = -1
#~ gi_ShipUnitType = -1
gi_TechForBonus = -1 ## Tech when a subdued animal may become a resource instead
gi_PromoForSubdue = -1 ## Promotion that increases th base chance for subdue
gi_MessageColour = 44
gi_PromoDesert = -1
gi_PromoTundra = -1
ga_BadTerrain= None
gai_DefeatedToCaptured = None
gai_UnitToBonusRules = None
gai_UnitToFood = None
gai_UnitToHammers = None
gai_PromotionProbabilityChange = None
#~ gai_BuildingBonusRules = None
gb_OptionBuildingResourcePossible = True
gb_OptionFoodFromKills = True
gb_OptionResourcePossibleInsteadOfSubdue = True
def init():
## In this initialisation step we create a bunch of arrays to contain the information needed by the mod.
## First we define the "rules" using the TEXT values for everything making it easier to add or modify.
## Then we convert these text values to the intergers which are used in the events. This means we only do
## the conversion to integer once rather than on every event call. This should speed things up.
## In all cases invalid rules are reported then ignored for the rest of the game.
## The arraya are:-
## - PromotionProbabilityChange(promotion, chance change)
## the change to the probability of sucessfully "capturing" the animal unit.
## - SubdueRules(defeated unit, captured unit
## if you capture a "defeated unit" then you will get a "captured unit". Note resourse may be placed instead.
## - UnitToBonusRules(captured unit, bonus)
## a captured unit is converted to a bonus
## - KillFoodRules(kiled unit, food, hammers)
## a killed unit provides food and hammers to the nerest (player) city
BugUtil.debug("Subdue Animals INIT.")
global gai_DefeatedToCaptured, gai_UnitToBonusRules, gai_UnitToFood, gai_UnitToHammers
#~ global gi_AnimalUnitType, gi_ReconUnitType, gi_ShipUnitType, gi_TechForBonus, gai_PromotionProbabilityChange, gi_MessageColour
global gi_AnimalUnitType, gi_SeaAnimalUnitType, gi_PromoForSubdue, gi_TechForBonus, gai_PromotionProbabilityChange, gi_MessageColour
global gb_OptionFoodFromKills, gb_OptionResourcePossibleInsteadOfSubdue
global gb_OptionBuildingResourcePossible, ga_BadTerrain, gi_HalfMaxX
gi_HalfMaxX = CyMap().getGridWidth() /2
gb_OptionFoodFromKills = True
gb_OptionResourcePossibleInsteadOfSubdue = True
gi_AnimalUnitType = gc.getInfoTypeForString('UNITCOMBAT_ANIMAL')
gi_SeaAnimalUnitType = gc.getInfoTypeForString('UNITCOMBAT_SEA_ANIMAL')
gi_PromoForSubdue = gc.getInfoTypeForString('PROMOTION_HUNTER1')
ga_BadTerrain = [gc.getInfoTypeForString('TERRAIN_SNOW'), gc.getInfoTypeForString('TERRAIN_SALT_FLATS')]
gi_TechForBonus = gc.getInfoTypeForString('TECH_ANIMAL_HUSBANDRY')
if (gc.getInfoTypeForString('ERA_PREHISTORIC') > -1):
gi_TechForBonus = gc.getInfoTypeForString('TECH_DOG_BREEDING')
gi_MessageColour = gc.getInfoTypeForString("COLOR_YELLOW")
asPromotionProbabilityChange = [
['PROMOTION_WOODSMAN1', 2],
['PROMOTION_WOODSMAN2', 2],
['PROMOTION_WOODSMAN3', 2],
['PROMOTION_GUERILLA1', 2],
['PROMOTION_GUERILLA2', 2],
['PROMOTION_GUERILLA3', 2],
['PROMOTION_HUNTER1', 5],
['PROMOTION_HUNTER2', 5],
['PROMOTION_HUNTER3', 5]
]
# Convert these into integers for speed when used in game
gai_PromotionProbabilityChange = []
for i in range(asPromotionProbabilityChange.__len__()):
iPromotion = gc.getInfoTypeForString(asPromotionProbabilityChange[i][0])
BugUtil.debug("Promotion %s (%d) gives a probability of capture change of %d percent.", asPromotionProbabilityChange[i][0], iPromotion, asPromotionProbabilityChange[i][1])
if (iPromotion >= 0 ) and ( not (asPromotionProbabilityChange[i][1] == 0) ):
gai_PromotionProbabilityChange.append([iPromotion, asPromotionProbabilityChange[i][1]])
else:
BugUtil.warn("Promotion %s (%d) gives a probability of capture change of %d percent.. Contains an invalid value!", asPromotionProbabilityChange[i][0], iPromotion, asPromotionProbabilityChange[i][1])
## Defeated unit is subdued as captured unit or provides food and hammers
## [Defeated unit, captured unit, food, hammers]
asSubdueRules = [
['UNIT_AARDVARK', 'NONE', 3, 1, 1],
['UNIT_ANIMAL_JAGUAR', 'UNIT_SUBDUED_JAGUAR', 1, 1, 1],
['UNIT_BADGER', 'UNIT_SUBDUED_BADGER', 1, 1, 1],
['UNIT_BEAR', 'UNIT_SUBDUED_BEAR', 2, 2, 0],
['UNIT_BEAVER', 'UNIT_SUBDUED_BEAVER', 1, 1, 2],
['UNIT_BENGALTIGER', 'UNIT_SUBDUED_BENGALTIGER', 2, 1, 1],
['UNIT_BISON', 'UNIT_SUBDUED_BISON', 4, 2, 1],
['UNIT_BOAR', 'UNIT_SUBDUED_BOAR', 3, 1, 4],
['UNIT_BONGO', 'UNIT_SUBDUED_BONGO', 4, 2, 2],
['UNIT_BUFFALO', 'UNIT_SUBDUED_BUFFALO', 4, 2, 1],
['UNIT_CAMEL', 'UNIT_SUBDUED_CAMEL', 3, 1, 0],
['UNIT_CARIBOU', 'UNIT_SUBDUED_CARIBOU', 4, 2, 2],
['UNIT_CAVEBEAR', 'UNIT_SUBDUED_CAVEBEAR', 3, 2, 1],
['UNIT_CAVE_LION', 'UNIT_SUBDUED_CAVE_LION', 3, 2, 1],
['UNIT_CHEETAH', 'UNIT_SUBDUED_CHEETAH', 1, 1, 1],
['UNIT_COW', 'UNIT_SUBDUED_COW', 4, 2, 1],
['UNIT_DONKEY', 'UNIT_SUBDUED_DONKEY', 1, 1, 0],
['UNIT_DIREWOLF', 'UNIT_SUBDUED_DIREWOLF', 1, 2, 0],
['UNIT_ELEPHANT', 'UNIT_SUBDUED_ELEPHANT', 5, 2, 3],
['UNIT_GAZELLE', 'UNIT_SUBDUED_GAZELLE', 3, 2, 2],
['UNIT_GEMSBOK', 'UNIT_SUBDUED_GEMSBOK', 4, 2, 2],
['UNIT_GIRAFFE', 'UNIT_SUBDUED_GIRAFFE', 3, 1, 0],
['UNIT_GORILLA', 'UNIT_SUBDUED_GORILLA', 2, 1, 0],
['UNIT_GUANACO', 'UNIT_SUBDUED_GUANACO', 1, 1, 0],
['UNIT_HIPPO', 'UNIT_SUBDUED_HIPPO', 5, 2, 3],
['UNIT_HORSE', 'UNIT_SUBDUED_HORSE', 4, 1, 1],
['UNIT_HYENA', 'UNIT_SUBDUED_HYENA', 1, 1, 0],
['UNIT_IBEX', 'UNIT_SUBDUED_IBEX', 4, 2, 2],
['UNIT_KANGAROO_GREY', 'UNIT_SUBDUED_KANGAROO_GREY', 2, 1, 1],
['UNIT_KANGAROO_RED', 'UNIT_SUBDUED_KANGAROO_RED', 3, 1, 1],
['UNIT_KOALA', 'UNIT_SUBDUED_KOALA', 1, 1, 1],
['UNIT_LION', 'UNIT_SUBDUED_LION', 2, 1, 0],
['UNIT_LION_PACK', 'UNIT_SUBDUED_LION_PACK', 3, 2, 1],
['UNIT_MAMMOTH', 'UNIT_SUBDUED_MAMMOTH', 7, 3, 5],
['UNIT_MANDRILL', 'UNIT_SUBDUED_MANDRILL', 1, 1, 0],
['UNIT_MOOSE', 'UNIT_SUBDUED_MOOSE', 4, 2, 2],
['UNIT_MUSKOX', 'UNIT_SUBDUED_MUSKOX', 4, 2, 2],
['UNIT_OKAPI', 'UNIT_SUBDUED_OKAPI', 4, 2, 2],
['UNIT_ORANGUTAN', 'UNIT_SUBDUED_ORANGUTAN', 1, 1, 0],
['UNIT_PANDA_BEAR', 'UNIT_SUBDUED_PANDA_BEAR', 2, 1, 1],
['UNIT_PANTHER', 'UNIT_SUBDUED_PANTHER', 1, 1, 1],
['UNIT_POLARBEAR', 'UNIT_SUBDUED_POLARBEAR', 3, 2, 1],
['UNIT_RATEL', 'UNIT_SUBDUED_RATEL', 1, 1, 1],
['UNIT_RHINO', 'UNIT_SUBDUED_RHINO', 3, 3, 2],
['UNIT_SABRETOOTH','UNIT_SUBDUED_SABRETOOTH', 1, 2, 2],
['UNIT_SIBERIANTIGER','UNIT_SUBDUED_SIBERIANTIGER', 2, 1, 1],
['UNIT_STAG_DEER', 'UNIT_SUBDUED_STAG_DEER', 4, 2, 2],
['UNIT_SKUNK', 'UNIT_SUBDUED_SKUNK', 1, 1, 1],
['UNIT_TAPIR', 'UNIT_SUBDUED_TAPIR', 3, 1, 1],
['UNIT_TDEVIL', 'UNIT_SUBDUED_TDEVIL', 1, 1, 1],
['UNIT_WALLAROO', 'UNIT_SUBDUED_WALLAROO', 2, 1, 1],
['UNIT_WALLABY', 'UNIT_SUBDUED_WALLABY', 1, 1, 1],
['UNIT_WALRUS', 'UNIT_SUBDUED_WALRUS', 5, 2, 3],
['UNIT_WILDEBEEST', 'UNIT_SUBDUED_WILDEBEEST', 4, 2, 2],
['UNIT_WOLF', 'UNIT_SUBDUED_WOLF', 1, 1, 0],
['UNIT_WOLVERINE', 'UNIT_SUBDUED_WOLVERINE', 1, 1, 0],
['UNIT_ZEBRA', 'UNIT_SUBDUED_ZEBRA', 1, 1, 0],
['UNIT_COBRA', 'UNIT_SUBDUED_COBRA', 0, 1, 1],
['UNIT_GHARIAL', 'UNIT_SUBDUED_GHARIAL', 2, 1, 2],
['UNIT_IGUANA', 'UNIT_SUBDUED_IGUANA', 1, 1, 1],
['UNIT_KOMODO_DRAGON', 'UNIT_SUBDUED_KOMODO_DRAGON', 2, 1, 0],
['UNIT_MONITOR', 'UNIT_SUBDUED_MONITOR', 2, 1, 0],
['UNIT_RIVER_CROC_LARGE', 'UNIT_SUBDUED_RIVER_CROC_LARGE', 3, 1, 2],
['UNIT_RIVER_CROC_SMALL','UNIT_SUBDUED_RIVER_CROC_SMALL', 2, 1, 2],
['UNIT_TORTOISE', 'UNIT_SUBDUED_TORTOISE', 1, 1, 2],
['UNIT_TORTOISE2', 'UNIT_SUBDUED_TORTOISE2', 4, 3, 2],
['UNIT_CASSOWARY', 'UNIT_SUBDUED_CASSOWARY', 1, 1, 1],
['UNIT_DUCK', 'UNIT_SUBDUED_DUCK', 1, 0, 0],
['UNIT_HORNEDOWL', 'UNIT_SUBDUED_HORNEDOWL', 1, 0, 0],
['UNIT_PHEASANT', 'UNIT_SUBDUED_PHEASANT', 2, 0, 0],
['UNIT_EAGLE', 'UNIT_SUBDUED_EAGLE', 1, 0, 0],
['UNIT_EMU', 'UNIT_SUBDUED_EMU', 1, 1, 1],
['UNIT_HAWK', 'UNIT_SUBDUED_HAWK', 1, 0, 0],
['UNIT_OSTRICH', 'UNIT_SUBDUED_OSTRICH', 2, 1, 2],
['UNIT_PENGUIN', 'UNIT_SUBDUED_PENGUIN', 2, 0, 0],
['UNIT_ROCKHOPPER', 'UNIT_SUBDUED_ROCKHOPPER', 1, 0, 0],
['UNIT_MOA', 'UNIT_SUBDUED_MOA', 3, 2, 1],
['UNIT_RHEA', 'UNIT_SUBDUED_RHEA', 1, 1, 1],
['UNIT_VULTURE', 'UNIT_SUBDUED_VULTURE', 0, 1, 0],
['UNIT_SALTWATER_CROC_SMALL','UNIT_SUBDUED_SALTWATER_CROCS', 2, 1, 2],
['UNIT_SALTWATER_CROC_LARGE', 'UNIT_SUBDUED_SALTWATER_CROCL', 3, 1, 2],
['UNIT_GIANT_SQUID', 'UNIT_SUBDUED_GIANT_SQUID', 3, 1, 1],
['UNIT_SEATURTLE', 'UNIT_SUBDUED_SEATURTLE', 1, 1, 2],
['UNIT_WHALESHARK', 'UNIT_SUBDUED_WHALESHARK', 4, 1, 1],
['UNIT_GREATWHITE', 'UNIT_SUBDUED_GREATWHITE', 3, 1, 1],
['UNIT_HAMMERHEAD', 'UNIT_SUBDUED_HAMMERHEAD', 2, 1, 1],
['UNIT_SHARK', 'UNIT_SUBDUED_REEF_SHARK', 2, 1, 1],
['UNIT_ORCA', 'UNIT_SUBDUED_ORCA', 3, 1, 1],
['UNIT_NARWHAL', 'UNIT_SUBDUED_NARWHAL', 2, 1, 2],
['UNIT_MINKIE_WHALE', 'UNIT_SUBDUED_MINKIE_WHALE', 4, 2, 2],
['UNIT_HUMPBACK_WHALE', 'UNIT_SUBDUED_HUMPBACK_WHALE', 6, 3, 3],
['UNIT_BELUGA', 'UNIT_SUBDUED_BELUGA', 3, 1, 1],
['UNIT_COD', 'UNIT_SUBDUED_COD', 1, 0, 0],
['UNIT_CRAB', 'NONE', 1, 0, 0],
['UNIT_DUGONG', 'UNIT_SUBDUED_DUGONG', 2, 2, 1],
['UNIT_DOLPHIN', 'UNIT_SUBDUED_DOLPHIN', 2, 2, 1],
['UNIT_MACKEREL', 'UNIT_SUBDUED_MACKEREL', 1, 0, 0],
['UNIT_MANTA', 'UNIT_SUBDUED_MANTA', 2, 0, 0],
['UNIT_MARLIN', 'UNIT_SUBDUED_MARLIN', 2, 0, 0],
['UNIT_RAY', 'UNIT_SUBDUED_RAY', 1, 0, 0],
['UNIT_TUNA', 'UNIT_SUBDUED_TUNA', 1, 0, 0],
['UNIT_LEVIATHAN', 'NONE', 6, 4, 4]
]
# Convert these into integers for speed when used in game
BugUtil.debug("Subdue Animals capture definitions:-")
gai_DefeatedToCaptured = {}
gai_UnitToFood = {}
gai_UnitToHammers = {}
for i in range(asSubdueRules.__len__()):
iDefeatedUnit = gc.getInfoTypeForString(asSubdueRules[i][0])
iCapturedUnit = gc.getInfoTypeForString(asSubdueRules[i][1])
iFood = asSubdueRules[i][2]
iHammers = asSubdueRules[i][3]
iGold = asSubdueRules[i][4]
BugUtil.debug("Capture %s (%d) as %s (%d).", asSubdueRules[i][0], iDefeatedUnit, asSubdueRules[i][1], iCapturedUnit)
if (iDefeatedUnit >= 0 ):
if not (iDefeatedUnit in gai_DefeatedToCaptured.iteritems()):
if (iCapturedUnit >= 0):
gai_DefeatedToCaptured[iDefeatedUnit] = iCapturedUnit
## Add in an equivalent rule for the subdued version of the unit
gai_DefeatedToCaptured[iCapturedUnit] = iCapturedUnit
#add graphics?
#~ sUnitButton = getArtInfoUnit(iDefeatedUnit).getButton()
if (gb_OptionFoodFromKills):
BugUtil.debug(" - Kill gives %d food and %d hammers.", iFood, iHammers)
if (iFood > 0) or (iHammers > 0):
gai_UnitToFood[iDefeatedUnit] = iFood
gai_UnitToHammers[iDefeatedUnit] = iHammers
## add the rules for the subdued version of the unit
if not (iCapturedUnit in gai_UnitToFood.iteritems()):
gai_UnitToFood[iCapturedUnit] = iFood
gai_UnitToHammers[iCapturedUnit] = iHammers
else:
BugUtil.warn(" - Kill gives %d food and %d hammers. Contains an invalid value!", iFood, iHammers)
else:
BugUtil.warn("Capture %s (%d) as %s (%d). Contains duplicate defeated unit!", asSubdueRules[i][0], iDefeatedUnit, asSubdueRules[i][1], iCapturedUnit)
else:
BugUtil.warn("Capture %s (%d) as %s (%d). Contains an invalid unit!", asSubdueRules[i][0], iDefeatedUnit, asSubdueRules[i][1], iCapturedUnit)
## Subdued unit may become a bonus instead
gai_UnitToBonusRules = {}
if gb_OptionResourcePossibleInsteadOfSubdue:
as_UnitToBonusRules = {
'UNIT_ELEPHANT': 'BONUS_IVORY',
'UNIT_HORSE': 'BONUS_HORSE',
'UNIT_STAG_DEER': 'BONUS_DEER',
'UNIT_BISON': 'BONUS_BISON',
'UNIT_BOAR': 'BONUS_PIG',
'UNIT_COW': 'BONUS_COW',
'UNIT_BEAVER': 'BONUS_FUR',
'UNIT_CARIBOU': 'BONUS_DEER',
'UNIT_DUCK': 'BONUS_POULTRY',
'UNIT_TUNA': 'BONUS_FISH',
'UNIT_MARLIN': 'BONUS_FISH',
'UNIT_COD': 'BONUS_FISH',
'UNIT_MACKEREL': 'BONUS_FISH',
'UNIT_SUBDUED_MACKEREL': 'BONUS_FISH',
'UNIT_SUBDUED_COD': 'BONUS_FISH',
'UNIT_SUBDUED_MARLIN': 'BONUS_FISH',
'UNIT_SUBDUED_TUNA': 'BONUS_FISH',
'UNIT_SUBDUED_DUCK': 'BONUS_POULTRY',
'UNIT_SUBDUED_CARIBOU': 'BONUS_DEER',
'UNIT_SUBDUED_BEAVER': 'BONUS_FUR',
'UNIT_SUBDUED_ELEPHANT': 'BONUS_IVORY',
'UNIT_SUBDUED_HORSE': 'BONUS_HORSE',
'UNIT_SUBDUED_STAG_DEER': 'BONUS_DEER',
'UNIT_SUBDUED_BISON': 'BONUS_BISON',
'UNIT_SUBDUED_COW': 'BONUS_COW',
'UNIT_SUBDUED_BOAR': 'BONUS_PIG',
'UNIT_SUBDUED_MAMMOTH':'BONUS_MAMMOTH'
}
# Convert these into integers for speed when used in game
for sUnit, sBonus in as_UnitToBonusRules.iteritems():
iUnit = gc.getInfoTypeForString(sUnit)
iBonus = gc.getInfoTypeForString(sBonus)
if (iUnit >= 0 ) and (iBonus >= 0):
BugUtil.debug("Capture %s (%d) as bonus %s (%d).", sUnit, iUnit, sBonus, iBonus)
gai_UnitToBonusRules[iUnit] = iBonus
else:
BugUtil.warn("Capture %s (%d) as bonus %s (%d). Contains bad unit or bomus.", sUnit, iDefeatedUnit, sBonus, iBonus)
def onCombatResult(argsList):
'Combat Result'
## First we check that the loosing unit is an animal ie has an animal combat type. If not leave.
## Then calculate the chance that the winning unit will capture the defeated unit.
## Based on the unit type and promotions of the winning unit.
##
## If the animal is killed then food and hammers are returned to the nearest player city. Leave.
##
## If the player has the right tech then there is a chance that the captured animal will become a resource.
## If it dosent then it becomes a subdued animal.
BugUtil.debug("Subdue Animals - onCombatResult called.")
pWinner,pLoser = argsList
player = pWinner.getOwner()
pPlayer = gc.getPlayer(player)
team = pPlayer.getTeam()
winnerTeam = gc.getTeam(team)
iLoserType = pLoser.getUnitType()
## get out of this code as soon as possible if not applicable. ##
if not (pLoser.getUnitCombatType() == gi_AnimalUnitType):
BugUtil.debug("Subdue Animals - defeated unit was not an animal.")
return
bBarbarianAnimalAttack = False
if pLoser.isBarbarian() and pLoser.isMadeAttack() and pLoser.isAnimal():
bBarbarianAnimalAttack = True
sLoserUnitText = gc.getUnitInfo(iLoserType).getDescription()
BugUtil.debug("Subdue Animals - defeated unit was %s.", sLoserUnitText)
pPlot = pWinner.plot()
iWinnerPlotX = pWinner.plot().getX()
iWinnerPlotY = pWinner.plot().getY()
iLoserPlotX = pLoser.plot().getX()
iLoserPlotY = pLoser.plot().getY()
## Animal unit killed, captured or turned into a resource? ##
## Set the chance of sucessful capture based on unit type
## then adjust it based on the promotions the unit has.
if pWinner.isHasPromotion(gi_PromoForSubdue):
iChanceToCapture = 45
else:
iChanceToCapture = 10
for i in range(gai_PromotionProbabilityChange.__len__()):
if pWinner.isHasPromotion(gai_PromotionProbabilityChange[i][0]):
iChanceToCapture = iChanceToCapture + gai_PromotionProbabilityChange[i][1]
## Roll the dice and see if kill or subdue variant.
## If fail and option for kills produce food and hammers is true send the food and/or hammers to
## the nearest player city if one exists.
## If succeeds
## check to see if the player has the tech required to produce a resource instead of capture
## If yes roll dice
## if produce a resource
## produce a resource and leave
## otherwise
## capture a unit.
## is it possible to capture the unit?
## Find the replacement unit eg a lion is replaced by a subdued lion. ##
## If this animal has no replacement type then it is not caputred. ##
iCapturedUnit = -1
if iLoserType in gai_DefeatedToCaptured:
iCapturedUnit = gai_DefeatedToCaptured[iLoserType]
if (iCapturedUnit == -1) or (CyGame().getSorenRandNum(100, "subdueAimals") > iChanceToCapture):
## Animal unit killed - send food and hammers to nearest player city
iHammers = 0
iFood = 0
if iLoserType in gai_UnitToFood:
iFood = gai_UnitToFood[iLoserType]
if iLoserType in gai_UnitToFood:
iHammers = gai_UnitToHammers[iLoserType]
if ((iHammers + iFood) == 0):
## no food or hammers from this kill
return
iCity = DH_Utils.getNearestCity(player, pPlot,gi_HalfMaxX)
pClosestCity = pPlayer.getCity(iCity)
if (pClosestCity == None):
## Player has no cities
return
sFoodMessage = ''
sHammerMessage = ''
sAndMessage = ''
if (iHammers > 0):
pClosestCity.changeProduction(iHammers)
if (iHammers > 1):
sHammerMessage = BugUtil.getText("TXT_KEY_SUBDUED_MANY_HAMMERS",iHammers)
else:
sHammerMessage = BugUtil.getText("TXT_KEY_SUBDUED_ONE_HAMMER")
sReturnMessage = sHammerMessage
if (iFood > 0):
pClosestCity.changeFood(iFood)
if (iFood > 1):
sFoodMessage = BugUtil.getText("TXT_KEY_SUBDUED_MANY_FOOD",iFood)
else:
sFoodMessage = BugUtil.getText("TXT_KEY_SUBDUED_ONE_FOOD")
sReturnMessage = sFoodMessage
if (iFood > 0) and (iHammers > 0):
sReturnMessage = BugUtil.getText("TXT_KEY_SUBDUED_AND", (sFoodMessage, sHammerMessage))
sMessage = BugUtil.getText("TXT_KEY_SUBDUED_KILL_MESSAGE",(sLoserUnitText, sReturnMessage, pClosestCity.getName()))
BugUtil.debug("Subdue Animals - %s", sMessage)
#~ CyInterface().addMessage(player,false,15,sMessage,'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gi_MessageColour), iLoserPlotX, iLoserPlotY, True,True)
CyInterface().addMessage(player,false,15,sMessage,'',0,pLoser.getButton(),ColorTypes(gi_MessageColour), iLoserPlotX, iLoserPlotY, True,True)
return
# Animal bonus start
## If the player has the correct technology there is a chance that a resource will be placed
## instead of the unit being captured. Except on invalid plots.
## For land plots check that there is not the same resource next to this plot.
## For sea plots chack that there are no more than 1 of the same resource next to this plot.
pPlot = pLoser.plot()
if (pPlot.getBonusType(-1) == -1): ## No bonus on this plot
if iLoserType in gai_UnitToBonusRules: ## Loser can become a bonus
iBonus = gai_UnitToBonusRules[iLoserType]
if winnerTeam.isHasTech(gi_TechForBonus) and not ( pPlot.getTerrainType() in ga_BadTerrain):
iX = pPlot.getX()
iY = pPlot.getY()
iPlotIsWater = pPlot.isWater()
iCountSameResource = 0
for iXLoop in xrange(iX-1,iX+1,1):
for iYLoop in xrange(iY-1,iY+1,1):
if iX == iXLoop and iY == iYLoop:
continue
NewPlot = CyMap().plot(iXLoop,iYLoop)
if not (iPlotIsWater == NewPlot.isWater()): ## ignore plots not of the same domain type.
continue
if NewPlot.getBonusType(-1) == iBonus:
iCountSameResource = iCountSameResource + 1
if iCountSameResource == 0 or ( iCountSameResource ==1 and iPlotIsWater):
BugUtil.debug("Subdue Animals - Player has tech needed to create bonus. There are no problems with the location")
if (CyGame().getSorenRandNum(100, "subdueAimals") >= 80):
if iLoserType in gai_UnitToBonusRules:
iBonus = gai_UnitToBonusRules[iLoserType]
pPlot.setBonusType(iBonus)
sMessage = BugUtil.getText("TXT_KEY_SUBDUED_UNIT_TO_RESOURCE", (sLoserUnitText, gc.getBonusInfo(iBonus).getDescription()))
#~ CyInterface().addMessage(player,false,15,sMessage,'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gi_MessageColour), pPlot.getX(), pPlot.getY(), True,True)
CyInterface().addMessage(player,false,15,sMessage,'',0,pLoser.getButton(),ColorTypes(gi_MessageColour), iLoserPlotX, iLoserPlotY, True,True)
BugUtil.debug("Subdue Animals - %s", sMessage)
return
# Animal bonus end
iThisPlotX = iWinnerPlotX
iThisPlotY = iWinnerPlotY
if pWinner.isMadeAttack() or not bBarbarianAnimalAttack:
iThisPlotX = iLoserPlotX
iThisPlotY = iLoserPlotY
newUnit = pPlayer.initUnit(iCapturedUnit, iThisPlotX, iThisPlotY, UnitAITypes.NO_UNITAI, DirectionTypes.DIRECTION_NORTH)
newUnit.setDamage(75, False)
sMessage = BugUtil.getText("TXT_KEY_SUBDUED_ANIMAL", sLoserUnitText)
#~ CyInterface().addMessage(player,false,15,sMessage,'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gi_MessageColour), iThisPlotX, iThisPlotY, True,True)
CyInterface().addMessage(player,false,15,sMessage,'',0,pLoser.getButton(),ColorTypes(gi_MessageColour), iLoserPlotX, iLoserPlotY, True,True)
BugUtil.debug("Subdue Animals - %s", sMessage)