mechaerik
Tuturuu!
Yeah, that wouldn't really work well. As it stands, this is just a simple 1 file python modcomp, and most people would like it better that way, rather than more complicated SDK.
## mechaerik War Prize ModComp
Civ IV BTS ... I think.
Me. Can you put the lines?I managed to convert the mod for RevolutionDCM. If anyone is interested let me know...
## War Prizes
from CvPythonExtensions import *
import CvUtil
import PyHelpers
import CvAdvisorUtils
import CvTechChooser
import BugCore
import BugUtil
import CvEventInterface
gc = CyGlobalContext()
localText = CyTranslator()
PyPlayer = PyHelpers.PyPlayer
PyInfo = PyHelpers.PyInfo
PyCity = PyHelpers.PyCity
PyGame = PyHelpers.PyGame
class WarPrizesEvent:
def __init__(self, eventMgr):
self.eventMgr = eventMgr
eventMgr.addEventHandler("combatResult", self.onCombatResult)
def onCombatResult(self, argsList):
'Combat Result'
pWinner,pLoser = argsList
playerX = PyPlayer(pWinner.getOwner())
unitX = PyInfo.UnitInfo(pWinner.getUnitType())
playerY = PyPlayer(pLoser.getOwner())
unitY = PyInfo.UnitInfo(pLoser.getUnitType())
## mechaerik War Prize ModComp START##
pPlayer = gc.getPlayer(pWinner.getOwner())
pPlayerLoser = gc.getPlayer(pLoser.getOwner())
if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")):
if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
if CyGame().getSorenRandNum(100, "Bob") <= 25:
iUnit = pLoser.getUnitType()
newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
newUnit.finishMoves()
newUnit.setDamage(50, pWinner.getOwner())
if (pPlayer.isHuman()):
CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("TXT_KEY_WEHAVECAPTUREDSOMETHING",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_BLUE")), pWinner.getX(), pWinner.getY(), True,True)
elif (pPlayerLoser.isHuman()):
CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("TXT_KEY_WEHAVELOSTSOMETHING",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)
## War Prize Modcomp END##
<?xml version="1.0" encoding="ISO-8859-1" ?>
<mod id="WarPrizes"
name="WarPrizes"
module="WarPrizes"
author="-"
version="-"
date="-"
url="-">
<events module="WarPrizes" class="WarPrizesEvent"/>
<gameutils/>
</mod>
Here is the mod adopted for BUG 4.4 installed as standalone. I removed the barbarian if statement, so now barbarians will capture your ships:
Spoiler :
WarPrizes.py:
PHP:## War Prizes from CvPythonExtensions import * import CvUtil import PyHelpers import CvAdvisorUtils import CvTechChooser import BugCore import BugUtil import CvEventInterface gc = CyGlobalContext() localText = CyTranslator() PyPlayer = PyHelpers.PyPlayer PyInfo = PyHelpers.PyInfo PyCity = PyHelpers.PyCity PyGame = PyHelpers.PyGame class WarPrizesEvent: def __init__(self, eventMgr): self.eventMgr = eventMgr eventMgr.addEventHandler("combatResult", self.onCombatResult) def onCombatResult(self, argsList): 'Combat Result' pWinner,pLoser = argsList playerX = PyPlayer(pWinner.getOwner()) unitX = PyInfo.UnitInfo(pWinner.getUnitType()) playerY = PyPlayer(pLoser.getOwner()) unitY = PyInfo.UnitInfo(pLoser.getUnitType()) ## mechaerik War Prize ModComp START## pPlayer = gc.getPlayer(pWinner.getOwner()) pPlayerLoser = gc.getPlayer(pLoser.getOwner()) if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")): if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")): if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")): if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")): if CyGame().getSorenRandNum(100, "Bob") <= 25: iUnit = pLoser.getUnitType() newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION) newUnit.finishMoves() newUnit.setDamage(50, pWinner.getOwner()) if (pPlayer.isHuman()): CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("TXT_KEY_WEHAVECAPTUREDSOMETHING",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_BLUE")), pWinner.getX(), pWinner.getY(), True,True) elif (pPlayerLoser.isHuman()): CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("TXT_KEY_WEHAVELOSTSOMETHING",()),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True) ## War Prize Modcomp END##
War Prizes.xml:
PHP:<?xml version="1.0" encoding="ISO-8859-1" ?> <mod id="WarPrizes" name="WarPrizes" module="WarPrizes" author="-" version="-" date="-" url="-"> <events module="WarPrizes" class="WarPrizesEvent"/> <gameutils/> </mod>
if (unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_SIEGE") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_RECON") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_HELICOPTER") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_NAVAL") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_AIR") or unitX.getUnitCombatType() != gc.getInfoTypeForString("UNITCOMBAT_BIOLOGICAL")):
if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SIEGE")):
if CyGame().getSorenRandNum(100, "") <= 15:
iUnit = pLoser.getUnitType()
newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
newUnit.finishMoves()
newUnit.setDamage(50, pWinner.getOwner())
if (pPlayer.isHuman()):
CyInterface().addMessage(pWinner.getOwner(),false,20,CyTranslator().getText("TXT_KEY_MISC_WARPRIZES_SUCCESS",(pLoser.getName(),)),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_BLUE")), pWinner.getX(), pWinner.getY(), True,True)
elif (pPlayerLoser.isHuman()):
CyInterface().addMessage(pLoser.getOwner(),false,20,CyTranslator().getText("TXT_KEY_MISC_WARPRIZES_FAILURE",(pLoser.getName(),)),'',0,'Art/Interface/Buttons/General/warning_popup.dds',ColorTypes(gc.getInfoTypeForString("COLOR_RED")), pLoser.getX(), pLoser.getY(), True,True)
What would I need to change to make the event text display the unit type that is captured? I thought it was just Unit.getname() put after the text in eventmanager.py, but that didn't work. Then I tried changing the civilopedia text to %s3_unit (or something), but that didn't work either.
Not sure if you still need this, but I managed to get it to display the type of unit correctly for my SETI Program wonder.
unitX = PyInfo.UnitInfo(Unit.getUnitType())
Then unitX.getDescription() is the code u need to stuff into the text code
In fact, this method is used commonly in the default BTS eventmanager.
Look at onCombatResult for example
pPlayer = gc.getPlayer(pWinner.getOwner())
pPlayerLoser = gc.getPlayer(pLoser.getOwner())
if not (gc.getPlayer(pWinner.getOwner()).isBarbarian()):
if (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_MELEE")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_GUN")) or (unitX.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_ARCHER")):
if (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_NAVAL")) or (unitY.getUnitCombatType() == gc.getInfoTypeForString("UNITCOMBAT_SIEGE")):
if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
if not (unitY.getUnitClassType() == gc.getInfoTypeForString("UNITCLASS_PRIVATEER")):
if CyGame().getSorenRandNum(100, "Bob") <= 25:
iUnit = pLoser.getUnitType()
newUnit = pPlayer.initUnit(pLoser.getUnitType(), pWinner.getX(), pWinner.getY(), UnitAITypes.NO_UNITAI, DirectionTypes.NO_DIRECTION)
newUnit.finishMoves()
newUnit.setDamage(50, pWinner.getOwner())