pepper2000
King
- Joined
- Apr 14, 2013
- Messages
- 899
Hi all,
I'm looking for some help on adding units that have special effects, e.g. settlers that can only settle on particular terrains. Here's an example of a unit that can only settle in cislunar space.
It works fine when I run normally, but when I turn C2C on debug mode, I get the error message noted below. I am not able to click any of the buttons to see what the debugger has to say. Does anyone know about this? I also recognize that no units currently in the game have this sort of embedded python code.
Otherwise, what would be the proper way to do what I am trying to do? I am looking for a general solution that would allow me to insert any custom python code both for when the mission can be executed and for the outcome, because I have a variety of other things like the Lunar Rover landing, planetary probes, etc.
Just to add more context, the isPossible function seems to work all right even in debug mode. I am able to move the Cislunar Settler around, and the settle icon appears and disappears depending on whether the unit is over the right terrain. It's only when I click the button to settle that I get a problem.
My best guess as to the cause of the problem is that when I try to execute the unit's command, an extra call to makePythonObject() is triggered in CvOutcome.cpp, which causes the assert (CvDLLPythonIFaceBase.h, line 86) to fail. But I'm in over my head on this one.
I'm looking for some help on adding units that have special effects, e.g. settlers that can only settle on particular terrains. Here's an example of a unit that can only settle in cislunar space.
Spoiler :
Code:
<!-- New settler units-->
<UnitInfo>
<Class>UNITCLASS_CISLUNARSETTLER</Class>
<Type>UNIT_CISLUNARSETTLER</Type>
<Capture>UNITCLASS_CAPTIVE_CIVILIAN</Capture>
<Combat>UNITCOMBAT_SETTLER</Combat>
<SubCombatTypes>
<SubCombatType>UNITCOMBAT_EARLY_SPACESHIP</SubCombatType>
<SubCombatType>UNITCOMBAT_CIVILIAN</SubCombatType>
<SubCombatType>UNITCOMBAT_SPECIES_HUMAN</SubCombatType>
<SubCombatType>UNITCOMBAT_MOTILITY_PILOTING</SubCombatType>
<SubCombatType>UNITCOMBAT_QUALITY_INFERIOR</SubCombatType>
<SubCombatType>UNITCOMBAT_GROUP_SOLO</SubCombatType>
<SubCombatType>UNITCOMBAT_SIZE_HUGE</SubCombatType>
<SubCombatType>UNITCOMBAT_HEALS_AS_PEOPLE</SubCombatType>
<SubCombatType>UNITCOMBAT_HEALS_AS_SPACECRAFT</SubCombatType>
</SubCombatTypes>
<Domain>DOMAIN_LAND</Domain>
<MapCategoryTypes>
<MapCategoryType>MAPCATEGORY_EARTH</MapCategoryType>
<MapCategoryType>MAPCATEGORY_SPACE</MapCategoryType>
</MapCategoryTypes>
<DefaultUnitAI>UNITAI_SETTLE</DefaultUnitAI>
<Description>TXT_KEY_UNIT_CISLUNARSETTLER</Description>
<ExtraHoverText>TXT_KEY_UNIT_CISLUNARSETTLER_HOVER</ExtraHoverText>
<Help>TXT_KEY_UNIT_CISLUNARSETTLER_HOVER</Help>
<Civilopedia>TXT_KEY_UNIT_SETTLER_PEDIA</Civilopedia>
<Strategy>TXT_KEY_UNIT_SETTLER_STRATEGY</Strategy>
<Advisor>ADVISOR_GROWTH</Advisor>
<bCanMoveAllTerrain>1</bCanMoveAllTerrain>
<bCanMoveImpassable>1</bCanMoveImpassable>
<bFood>1</bFood>
<UnitAIs>
<UnitAI>
<UnitAIType>UNITAI_SETTLE</UnitAIType>
<bUnitAI>1</bUnitAI>
</UnitAI>
</UnitAIs>
<PrereqBuilding>BUILDING_COMMERCIAL_SPACEPORT</PrereqBuilding>
<PrereqTech>TECH_SPACE_COLONIES</PrereqTech>
<ProductionTraits>
<ProductionTrait>
<ProductionTraitType>TRAIT_IMPERIALIST</ProductionTraitType>
<iProductionTrait>50</iProductionTrait>
</ProductionTrait>
</ProductionTraits>
<iCost>4850</iCost>
<iAdvancedStartCost>100</iAdvancedStartCost>
<iMinAreaSize>-1</iMinAreaSize>
<iMoves>24</iMoves>
<iNukeRange>-1</iNukeRange>
<iExtraCost>10</iExtraCost>
<iAsset>1</iAsset>
<UnitMeshGroups>
<iGroupSize>1</iGroupSize>
<fMaxSpeed>1.75</fMaxSpeed>
<fPadTime>1</fPadTime>
<iMeleeWaveSize>1</iMeleeWaveSize>
<iRangedWaveSize>0</iRangedWaveSize>
<UnitMeshGroup>
<iRequired>1</iRequired>
<EarlyArtDefineTag>ART_DEF_UNIT_SPACECRAFT_SETTLER</EarlyArtDefineTag>
</UnitMeshGroup>
</UnitMeshGroups>
<FormationType>FORMATION_TYPE_DEFAULT</FormationType>
<Actions>
<Action>
<MissionType>MISSION_PLANET_LAND</MissionType>
<iCost>
<Adapt>
<ID>ADAPT_DEFAULT</ID>
<Constant>0</Constant>
</Adapt>
</iCost>
<ActionOutcomes>
<Outcome>
<OutcomeType>OUTCOME_UPGRADE_TO_PLANET_SETTLER</OutcomeType>
<iChance>100</iChance>
<PythonName>BuildCityCislunar</PythonName>
<Python>
from CvPythonExtensions import CyGlobalContext
def isPossible(unit,plot):
gc = CyGlobalContext()
if not gc.getActivePlayer().canFound(plot.getX(),plot.getY()):
return False
valid_terrain_strings = ['SPACE']
valid_terrains = [gc.getInfoTypeForString('TERRAIN_'+t) for t in valid_terrain_strings]
return plot.getTerrainType() in valid_terrains
def doOutcome(unit,plot,eDefPlayer, eDefUnitType):
gc = CyGlobalContext()
gc.getActivePlayer().found(plot.getX(),plot.getY())
def getDisplay(unit,plot):
return u"Build a city on this plot."
def getAIValue(unit, plot):
return 1
</Python>
</Outcome>
</ActionOutcomes>
</Action>
</Actions>
</UnitInfo>
It works fine when I run normally, but when I turn C2C on debug mode, I get the error message noted below. I am not able to click any of the buttons to see what the debugger has to say. Does anyone know about this? I also recognize that no units currently in the game have this sort of embedded python code.
Otherwise, what would be the proper way to do what I am trying to do? I am looking for a general solution that would allow me to insert any custom python code both for when the mission can be executed and for the outcome, because I have a variety of other things like the Lunar Rover landing, planetary probes, etc.
Just to add more context, the isPossible function seems to work all right even in debug mode. I am able to move the Cislunar Settler around, and the settle icon appears and disappears depending on whether the unit is over the right terrain. It's only when I click the button to settle that I get a problem.
My best guess as to the cause of the problem is that when I try to execute the unit's command, an extra call to makePythonObject() is triggered in CvOutcome.cpp, which causes the assert (CvDLLPythonIFaceBase.h, line 86) to fail. But I'm in over my head on this one.
Attachments
Last edited: