adaptive trait

tipwong

Chieftain
Joined
Mar 3, 2008
Messages
58
How to mod to make human can choose two traits in every 100 turns instead of one? also can i change it to for example can choose traits for every 50 turns?
 
More questions: I have checked the terrain xml file and find that the hill have no defense bonus(idefense is 0), but why in the game there is 25% defense bonus? How to have more animals or barbarian spawn for the entire game? Where are the xml files that determine these values?
 
How to mod to make human can choose two traits in every 100 turns instead of one? also can i change it to for example can choose traits for every 50 turns?
Adapting the Adaptive trait is a lot harder than it should be.
C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\python/CvEventManager.py
Code:
	def onBeginPlayerTurn(self, argsList):

[skipping irrelevant code]

		if pPlayer.hasTrait(gc.getInfoTypeForString('TRAIT_ADAPTIVE')):
			iCycle = 100
			if CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_QUICK'):
				iCycle = 75
			if CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_EPIC'):
				iCycle = 150
			if CyGame().getGameSpeedType() == gc.getInfoTypeForString('GAMESPEED_MARATHON'):
				iCycle = 300
			for i in range(10):
				if (i * iCycle) - 5 == iGameTurn:
					iEvent = CvUtil.findInfoTypeNum(gc.getEventTriggerInfo, gc.getNumEventTriggerInfos(),'EVENTTRIGGER_TRAIT_ADAPTIVE')
					triggerData = pPlayer.initTriggeredData(iEvent, true, -1, -1, -1, iPlayer, -1, -1, -1, -1, -1)

That is what determines how often to trigger the event to let you change your trait. As you can see, it happens every 100 turns on standard speed but at different rates at other speeds. You can easily make the event happen twice as often by taking the numbers after iCycle = and cutting them in half. This is the easy part. Allowing more trait selections is more difficult.


The popup that gives you the choice to switch traits is handled here.

C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\XML\Events\CIV4EventTriggerInfos.xml
Code:
		<EventTriggerInfo>
			<Type>EVENTTRIGGER_TRAIT_ADAPTIVE</Type>
			<WorldNewsTexts>
				<Text></Text>
			</WorldNewsTexts>
			<TriggerTexts>
				<TriggerText>
					<Text>TXT_KEY_EVENTTRIGGER_TRAIT_ADAPTIVE</Text>
					<Era>NONE</Era>
				</TriggerText>
			</TriggerTexts>
			<bSinglePlayer>0</bSinglePlayer>
			<iPercentGamesActive>100</iPercentGamesActive>
			<iWeight>0</iWeight>
			<bProbabilityUnitMultiply>0</bProbabilityUnitMultiply>
			<bProbabilityBuildingMultiply>0</bProbabilityBuildingMultiply>
			<Civic>NONE</Civic>
			<iMinTreasury>0</iMinTreasury>
			<iMinPopulation>0</iMinPopulation>
			<iMaxPopulation>0</iMaxPopulation>
			<iMinMapLandmass>0</iMinMapLandmass>
			<iMinOurLandmass>0</iMinOurLandmass>
			<iMaxOurLandmass>-1</iMaxOurLandmass>
			<MinDifficulty>NONE</MinDifficulty>
			<iAngry>0</iAngry>
			<iUnhealthy>0</iUnhealthy>
			<UnitsRequired>
			</UnitsRequired>
			<iNumUnits>0</iNumUnits>
			<iNumUnitsGlobal>0</iNumUnitsGlobal>
			<iUnitDamagedWeight>0</iUnitDamagedWeight>
			<iUnitDistanceWeight>0</iUnitDistanceWeight>
			<iUnitExperienceWeight>0</iUnitExperienceWeight>
			<bUnitsOnPlot>0</bUnitsOnPlot>
			<BuildingsRequired>
			</BuildingsRequired>
			<iNumBuildings>0</iNumBuildings>
			<iNumBuildingsGlobal>0</iNumBuildingsGlobal>
			<iNumPlotsRequired>0</iNumPlotsRequired>
			<bOwnPlot>0</bOwnPlot>
			<iPlotType>-1</iPlotType>
			<FeaturesRequired>
			</FeaturesRequired>
			<TerrainsRequired>
			</TerrainsRequired>
			<ImprovementsRequired>
			</ImprovementsRequired>
			<BonusesRequired>
			</BonusesRequired>
			<RoutesRequired>
			</RoutesRequired>
			<ReligionsRequired>
			</ReligionsRequired>
			<iNumReligions>0</iNumReligions>
			<CorporationsRequired>
			</CorporationsRequired>
			<iNumCorporations>0</iNumCorporations>
			<bPickReligion>0</bPickReligion>
			<bStateReligion>0</bStateReligion>
			<bHolyCity>0</bHolyCity>
			<bPickCorporation>0</bPickCorporation>
			<bHeadquarters>0</bHeadquarters>
			<Events>[B]
				<Event>EVENT_TRAIT_AGGRESSIVE</Event>[/B]
				<Event>EVENT_TRAIT_ARCANE</Event>
				<Event>EVENT_TRAIT_CHARISMATIC</Event>
				<Event>EVENT_TRAIT_CREATIVE</Event>
				<Event>EVENT_TRAIT_EXPANSIVE</Event>
				<Event>EVENT_TRAIT_FINANCIAL</Event>
				<Event>EVENT_TRAIT_INDUSTRIOUS</Event>
				<Event>EVENT_TRAIT_ORGANIZED</Event>
				<Event>EVENT_TRAIT_PHILOSOPHICAL</Event>
				<Event>EVENT_TRAIT_RAIDERS</Event>
				<Event>EVENT_TRAIT_SPIRITUAL</Event>
			</Events>
			<PrereqEvents>
			</PrereqEvents>
			<bPrereqEventPlot>0</bPrereqEventPlot>
			<OrPreReqs>
			</OrPreReqs>
			<AndPreReqs>
			</AndPreReqs>
			<ObsoleteTechs>
			</ObsoleteTechs>
			<bRecurring>1</bRecurring>
			<bTeam>0</bTeam>
			<bGlobal>0</bGlobal>
			<bPickPlayer>0</bPickPlayer>
			<bOtherPlayerWar>0</bOtherPlayerWar>
			<bOtherPlayerHasReligion>0</bOtherPlayerHasReligion>
			<bOtherPlayerHasOtherReligion>0</bOtherPlayerHasOtherReligion>
			<bOtherPlayerAI>0</bOtherPlayerAI>
			<iOtherPlayerShareBorders>0</iOtherPlayerShareBorders>
			<OtherPlayerHasTech>NONE</OtherPlayerHasTech>
			<bPickCity>0</bPickCity>
			<bPickOtherPlayerCity>0</bPickOtherPlayerCity>
			<bShowPlot>0</bShowPlot>
			<iCityFoodWeight>0</iCityFoodWeight>
			<PythonCanDo></PythonCanDo>
			<PythonCanDoCity></PythonCanDoCity>
			<PythonCanDoUnit></PythonCanDoUnit>
			<PythonCallback></PythonCallback>
			<iPrereqCrime>0</iPrereqCrime>
			<iPrereqGlobalCounter>0</iPrereqGlobalCounter>
			<PrereqAlignment>NONE</PrereqAlignment>
			<PrereqCivilizationPleased>NONE</PrereqCivilizationPleased>
			<PrereqLeader>NONE</PrereqLeader>[B]
			<PrereqTrait>TRAIT_ADAPTIVE</PrereqTrait>[/B]
		</EventTriggerInfo>

I'll only show the rest of the code for the Aggressive trait option, as all the other traits are handled the same.

This is what gives you the ability to select a trait:
C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\XML\Events\CIV4EventTriggerInfos.xml
Code:
        <EventInfo>
            <Type>EVENT_TRAIT_AGGRESSIVE</Type>
            <Description>TXT_KEY_EVENT_TRAIT_AGGRESSIVE</Description>
            <LocalInfoText></LocalInfoText>
            <WorldNewsTexts>
            </WorldNewsTexts>
            <OtherPlayerPopup></OtherPlayerPopup>
            <QuestFailText></QuestFailText>
            <bQuest>0</bQuest>
            <bGlobal>0</bGlobal>
            <bTeam>0</bTeam>
            <bPickCity>0</bPickCity>
            <bPickOtherPlayerCity>0</bPickOtherPlayerCity>
            <bDeclareWar>0</bDeclareWar>
            <iGold>0</iGold>
            <bGoldToPlayer>0</bGoldToPlayer>
            <iRandomGold>0</iRandomGold>
            <iCulture>0</iCulture>
            <iEspionagePoints>0</iEspionagePoints>
            <bGoldenAge>0</bGoldenAge>
            <iFreeUnitSupport>0</iFreeUnitSupport>
            <iInflationMod>0</iInflationMod>
            <iSpaceProductionMod>0</iSpaceProductionMod>
            <Tech>NONE</Tech>
            <TechFlavors>
                <TechFlavor>
                    <FlavorType>FLAVOR_MILITARY</FlavorType>
                    <iFlavor>1</iFlavor>
                </TechFlavor>
            </TechFlavors>
            <iTechPercent>0</iTechPercent>
            <iTechCostPercent>0</iTechCostPercent>
            <iTechMinTurnsLeft>0</iTechMinTurnsLeft>
            <PrereqTech>NONE</PrereqTech>
            <UnitClass>NONE</UnitClass>
            <iNumFreeUnits>0</iNumFreeUnits>
            <bDisbandUnit>0</bDisbandUnit>
            <iUnitExperience>0</iUnitExperience>
            <iUnitImmobileTurns>0</iUnitImmobileTurns>
            <UnitPromotion></UnitPromotion>
            <UnitName></UnitName>
            <UnitCombatPromotions>
            </UnitCombatPromotions>
            <UnitClassPromotions>
            </UnitClassPromotions>
            <BuildingClass>NONE</BuildingClass>
            <iBuildingChange>0</iBuildingChange>
            <BuildingExtraYields>
            </BuildingExtraYields>
            <BuildingExtraCommerces>
            </BuildingExtraCommerces>
            <BuildingExtraHappies>
            </BuildingExtraHappies>
            <BuildingExtraHealths>
            </BuildingExtraHealths>
            <iHappy>0</iHappy>
            <iHealth>0</iHealth>
            <iHurryAnger>0</iHurryAnger>
            <iHappyTurns>0</iHappyTurns>
            <iRevoltTurns>0</iRevoltTurns>
            <iMinPillage>0</iMinPillage>
            <iMaxPillage>0</iMaxPillage>
            <iFood>0</iFood>
            <iFoodPercent>0</iFoodPercent>
            <FreeSpecialistCounts>
            </FreeSpecialistCounts>
            <FeatureType>NONE</FeatureType>
            <iFeatureChange>0</iFeatureChange>
            <ImprovementType>NONE</ImprovementType>
            <iImprovementChange>0</iImprovementChange>
            <BonusType>NONE</BonusType>
            <iBonusChange>0</iBonusChange>
            <RouteType>NONE</RouteType>
            <iRouteChange>0</iRouteChange>
            <BonusRevealed>NONE</BonusRevealed>
            <BonusGift>NONE</BonusGift>
            <PlotExtraYields>
            </PlotExtraYields>
            <iConvertOwnCities>0</iConvertOwnCities>
            <iConvertOtherCities>0</iConvertOtherCities>
            <iMaxNumReligions>-1</iMaxNumReligions>
            <iOurAttitudeModifier>0</iOurAttitudeModifier>
            <iAttitudeModifier>0</iAttitudeModifier>
            <iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
            <iPopulationChange>0</iPopulationChange>
            <AdditionalEvents>
            </AdditionalEvents>
            <EventTimes>
            </EventTimes>
            <ClearEvents>
            </ClearEvents>
            <PythonCallback>doTraitAggressive</PythonCallback>
            <PythonExpireCheck></PythonExpireCheck>
            <PythonCanDo>canApplyTraitAggressive</PythonCanDo>
            <PythonHelp></PythonHelp>
            <Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
            <iAIValue>1000</iAIValue>
            <iCrime>0</iCrime>
            <iGlobalCounter>0</iGlobalCounter>
            <PrereqAlignment>NONE</PrereqAlignment>
            <PrereqBonus>NONE</PrereqBonus>
            <PrereqCivilization>NONE</PrereqCivilization>
            <PrereqReligion>NONE</PrereqReligion>
            <PrereqStateReligion>NONE</PrereqStateReligion>
        </EventInfo>
The real work is done in python.

C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\python\entrypoints\CvRandomEventInterface.py
Code:
def canApplyTraitAggressive(argsList):
	iEvent = argsList[0]
	kTriggeredData = argsList[1]
	pPlayer = gc.getPlayer(kTriggeredData.ePlayer)[B]
	if gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getPermanentTrait() == gc.getInfoTypeForString('TRAIT_AGGRESSIVE'):[/B]
		return False
	return True

def doTraitAggressive(argsList):
	iEvent = argsList[0]
	kTriggeredData = argsList[1]
	iPlayer = kTriggeredData.ePlayer
	pPlayer = gc.getPlayer(iPlayer)[B]
	for iTrait in range(gc.getNumTraitInfos()):
		if pPlayer.hasTrait(iTrait):
			if (gc.getTraitInfo(iTrait).isSelectable()):
				if gc.getLeaderHeadInfo(pPlayer.getLeaderType()).getPermanentTrait() != iTrait:
					pPlayer.setHasTrait(iTrait,False)[/B]
	pPlayer.setHasTrait(gc.getInfoTypeForString('TRAIT_AGGRESSIVE'),True)

It makes the option unavailable if the trait you would select is your permanent trait, and it deletes all of your traits except adaptive and your permanent trait before granting a new trait.

Your permanent trait is defined here:

C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\XML\Civilizations/CIV4LeaderheadInfos.xml
Code:
        <LeaderHeadInfo>
            <Type>LEADER_VARN</Type>
[skipping irrelevant code]
            <Traits>[B]
                 <Trait>
                    <TraitType>TRAIT_ADAPTIVE</TraitType>
                    <bTrait>1</bTrait>
                 </Trait>[/B]
                 <Trait>
                    <TraitType>TRAIT_CREATIVE</TraitType>
                    <bTrait>1</bTrait>
                 </Trait>
                 <Trait>
                    <TraitType>TRAIT_SPIRITUAL</TraitType>
                    <bTrait>1</bTrait>
                 </Trait>
            </Traits>

[skipping irrelevant code]

            <bAltarVictory>1</bAltarVictory>
            <bReligionVictory>1</bReligionVictory>
            <iAIPatrolGroupMage>100</iAIPatrolGroupMage>
            <iAIPatrolGroupSize>100</iAIPatrolGroupSize>
            <iAIValueDefense>100</iAIValueDefense>
            <iAIValueMage>100</iAIValueMage>
            <iAttitudeBadBonus>2</iAttitudeBadBonus>
            <iEconomyTechValue>130</iEconomyTechValue>
            <iFavoriteEarlyMilTech>TECH_BRONZE_WORKING</iFavoriteEarlyMilTech>
            <iFavoriteEarlyReligion>RELIGION_RUNES_OF_KILMORPH</iFavoriteEarlyReligion>
            <iFavoriteEarlyTech1>TECH_HONOR</iFavoriteEarlyTech1>
            <iFavoriteEarlyWonder>BUILDINGCLASS_TOWER_OF_EYES</iFavoriteEarlyWonder>
            <iFavoriteLateWonder>BUILDINGCLASS_CELESTIAL_COMPASS</iFavoriteLateWonder>
            <iSomniumAggressiveness>40</iSomniumAggressiveness>
            <Alignment>ALIGNMENT_GOOD</Alignment>
            <FavoriteTech>TECH_HONOR</FavoriteTech>
            <FavoriteUnitCombat>UNITCOMBAT_DISCIPLE</FavoriteUnitCombat>
            <FavoriteWonder>BUILDING_TOWER_OF_EYES</FavoriteWonder>
          [B]  <PermanentTrait>TRAIT_SPIRITUAL</PermanentTrait>[/B]

[skipping irrelevant code]
        </LeaderHeadInfo>
C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\XML\Civilizations\CIV4TraitInfos.xml
Code:
		<TraitInfo>
			<Type>TRAIT_AGGRESSIVE</Type>
			<Description>TXT_KEY_TRAIT_AGGRESSIVE</Description>
			<ShortDescription>TXT_KEY_TRAIT_AGGRESSIVE_SHORT</ShortDescription>
			<Help/>
			<iHealth>0</iHealth>
			<iHappiness>0</iHappiness>
			<iMaxAnarchy>-1</iMaxAnarchy>
			<iUpkeepModifier>0</iUpkeepModifier>
			<iLevelExperienceModifier>0</iLevelExperienceModifier>
			<iGreatPeopleRateModifier>0</iGreatPeopleRateModifier>
			<iGreatGeneralRateModifier>0</iGreatGeneralRateModifier>
			<iDomesticGreatGeneralRateModifier>0</iDomesticGreatGeneralRateModifier>
			<iMaxGlobalBuildingProductionModifier>0</iMaxGlobalBuildingProductionModifier>
			<iMaxTeamBuildingProductionModifier>0</iMaxTeamBuildingProductionModifier>
			<iMaxPlayerBuildingProductionModifier>0</iMaxPlayerBuildingProductionModifier>
			<bAdaptive>0</bAdaptive>
			<bAgnostic>0</bAgnostic>
			<bAssimilation>0</bAssimilation>
			<bBarbarianAlly>0</bBarbarianAlly>
			<bIgnoreFood>0</bIgnoreFood>
			<bInsane>0</bInsane>[B]
			<bSelectable>1</bSelectable>[/B]
			<bSprawling>0</bSprawling>
			<iFreeXPFromCombat>0</iFreeXPFromCombat>
			<iMaxCities>-1</iMaxCities>
			<iPillagingGold>0</iPillagingGold>
			<iStartingGold>0</iStartingGold>
			<iSummonDuration>0</iSummonDuration>
			<iUpgradeCostModifier>0</iUpgradeCostModifier>
			<ExtraYieldThresholds/>
			<TradeYieldModifiers/>
			<CommerceChanges/>
			<CommerceModifiers/>
			<FreePromotions>
				<FreePromotion>
					<PromotionType>PROMOTION_COMBAT1</PromotionType>
					<bFreePromotion>1</bFreePromotion>
				</FreePromotion>
			</FreePromotions>
			<FreePromotionUnitCombats>
				<FreePromotionUnitCombat>
					<UnitCombatType>UNITCOMBAT_ADEPT</UnitCombatType>
					<bFreePromotionUnitCombat>1</bFreePromotionUnitCombat>
				</FreePromotionUnitCombat>
				<FreePromotionUnitCombat>
					<UnitCombatType>UNITCOMBAT_ARCHER</UnitCombatType>
					<bFreePromotionUnitCombat>1</bFreePromotionUnitCombat>
				</FreePromotionUnitCombat>
				<FreePromotionUnitCombat>
					<UnitCombatType>UNITCOMBAT_DISCIPLE</UnitCombatType>
					<bFreePromotionUnitCombat>1</bFreePromotionUnitCombat>
				</FreePromotionUnitCombat>
				<FreePromotionUnitCombat>
					<UnitCombatType>UNITCOMBAT_MELEE</UnitCombatType>
					<bFreePromotionUnitCombat>1</bFreePromotionUnitCombat>
				</FreePromotionUnitCombat>
				<FreePromotionUnitCombat>
					<UnitCombatType>UNITCOMBAT_MOUNTED</UnitCombatType>
					<bFreePromotionUnitCombat>1</bFreePromotionUnitCombat>
				</FreePromotionUnitCombat>
				<FreePromotionUnitCombat>
					<UnitCombatType>UNITCOMBAT_RECON</UnitCombatType>
					<bFreePromotionUnitCombat>1</bFreePromotionUnitCombat>
				</FreePromotionUnitCombat>
			</FreePromotionUnitCombats>
		</TraitInfo>
I believe that if (gc.getTraitInfo(iTrait).isSelectable()): simply tells whether the trait has the bSelectable tag, and that this tag does not really do anything. It is just a way to prevent this event (or the similar one for the Insane trait) from remove traits civ traits, Adaptable, Insane, etc.



If you want to allow the choice of 2 traits, I think you'll have to change the adaptive trait event trigger so that it gives a choice between any combination of 2 traits rather than only one. I think this means changing 11 events to 55. The def canApplyTrait[insert trait names here](argsList): calls would have to return false if either trait is the permanent trait, and the def doTrait[insert trait names here](argsList): would add 2 traits after eliminating all non-permanent selectable traits.


Well, now that I think of it, I guess there are a few other options. You could try make it so that the python code that triggers the event is what removes your non-permanent traits rather than the doTrait____ calls, and then set it up so that that python call that adds the trait counts how many traits you have total and then triggers the event again if you do not have enough.



More questions: I have checked the terrain xml file and find that the hill have no defense bonus(idefense is 0), but why in the game there is 25% defense bonus? How to have more animals or barbarian spawn for the entire game? Where are the xml files that determine these values?

The hill entry in CIV4TerrainInfos.xml does practically nothing. Firaxis originally intended to handle hills, peaks, oceans, and costs in much the same way as the other terrain types, but ended up going for a hardcoded mechanic in the game engine. If I recall correctly, even deleting hills, peaks, oceans, and coasts from the file will not stop them from showing up in the game (although there might be a few complications if you do so.)

I'm not sure if there is something granting hills a defense bonus in general, but I think the bonus actually applies only to certain units. In C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\XML\Units\CIV4UnitInfos.xml there is a <iHillsDefense> tag (right under the <iHillsAttack> tag). This is what gives Archers their 25% defense bonus on hills.

There is also a <iHillsDefense> tag in C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\XML\Units\CIV4PromotionInfos.xml, which is what makes the Guerilla promotions provide extra defense on hills.



I'm not really an expert on animal spawning.

I do know that for an animal to be able to spawn it must have a <TerrainNative> or <FeatureNative> tag in its unit defines so the game knows where to put it.
Code:
            <TerrainNatives>
                <TerrainNative>
                    <TerrainType>TERRAIN_SNOW</TerrainType>
                    <bTerrainNative>1</bTerrainNative>
                </TerrainNative>
            </TerrainNatives>
            <FeatureNatives>
                <FeatureNative>
                    <FeatureType>FEATURE_FOREST</FeatureType>
                    <bFeatureNative>1</bFeatureNative>
                </FeatureNative>
                <FeatureNative>
                    <FeatureType>FEATURE_FOREST_ANCIENT</FeatureType>
                    <bFeatureNative>1</bFeatureNative>
                </FeatureNative>
            </FeatureNatives>

I believe that you can increase the rate of spawning of both animals and other barbarians by reducing this number in C:\Program Files (x86)\Firaxis Games\Sid Meier's Civilization 4\Beyond the Sword\Mods\Fall from Heaven 2\Assets\XML\GlobalDefinesAlt.xml

Code:
    <Define>
        <DefineName>TILES_PER_SPAWN</DefineName>
        <iDefineIntVal>6</iDefineIntVal>
    </Define>

Having more barbarians units, including animals, already present reduced the change of further random spawns. I believe that things like bear dens spawning bears can actually reduce the chance of tigers and gorillas spawning. It is handled on a per area basis though, so bears in a polar region might not matter so much to spawns in the tropics.
 
Back
Top Bottom