Guide to event modding in BtS

#1: Only with SDK work. Probably not worth the hassle.

#2: You mean like for the forest fire event ;)?

PHP:
			<iNumPlotsRequired>1</iNumPlotsRequired>
			<bOwnPlot>1</bOwnPlot>
			<iPlotType>-1</iPlotType>
			<FeaturesRequired>
				<FeatureType>FEATURE_FOREST</FeatureType>
			</FeaturesRequired>

#3: Set bRecurring to 1. This will allow that the event can happen multiple times in a game (like e.g .the mine accident or the airliner crash).

#4: Doesn't work like that. The weights are combined, and then one event is selected is randomly out of them. Higher weight means then they have a higher chance of being selected.
 
ha true about the forest event.

I have some other questions

  • Is it better to have the Python "can do" in the trigger or the events?
  • What if I set unhealthiness to -1, what does it mean exactly? Unhealthiness of 1 and higher? Or unhealthiness of 1 and then healthier?
  • When you list the buildings in <BuildingClass>, do you also need to type a civilization only building? For example if I type BUILDINGCLASS_HARBOR, do I need the cothon for the Carthaginian?
  • I don't really understand the iNumBuildings / iNumBuildingsGlobal . For example I want to check if a city has built 2 out of 6 buildings. I list them in the BuildingClass, then what am I supposed to do? I tried different combination but still not working.
  • Last one is Python. I checked the Quest for the Elite Swordsman. I want that if my civic is Environmentalism, the trigger will not be triggered. The Civic tag only allows you to list one civic to trigger, so I put this in the Python
    Code:
    def canApplyForestFireIndustry(argsList):
    iEvent = argsList[0]
    kTriggeredData = argsList[1]
    player = gc.getPlayer(kTriggeredData.ePlayer)
    		
    iCivic = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_ENVIRONMENTALISM')
    	
    if not player.isCivic(iCivic):
    	return true
    	
    return false
 
Is it better to have the Python "can do" in the trigger or the events?

...er...no.
I think you're confusing something here.
You can independently check, if the trigger is valid, and if the event is valid.
You might want to have a trigger, which only appears under certain circumstances. Then you use the can do in the EventTriggerInfos.
But it could also be, that such a trigger has multiple events, and that some of them need further checking. Then you also need a can do check in the EventInfos.

What if I set unhealthiness to -1, what does it mean exactly? Unhealthiness of 1 and higher? Or unhealthiness of 1 and then healthier?

iUnhealthy = how many :yuck: a city needs to trigger this event.
If I set it to 1, the event might trigger if the city has 1 :yuck: (or more).
If I set it to 2, the event might trigger if the city has 2 :yuck:.
Not sure what will happen if you put in negative values. Then it will only happen if the city is near to becoming unhealthy...but that's just a guess.


When you list the buildings in <BuildingClass>, do you also need to type a civilization only building? For example if I type BUILDINGCLASS_HARBOR, do I need the cothon for the Carthaginian?

Yes, correct. UBs are checked if you type in the building class, no need to put them separately in there (...you also coud not).

I don't really understand the iNumBuildings / iNumBuildingsGlobal . For example I want to check if a city has built 2 out of 6 buildings. I list them in the BuildingClass, then what am I supposed to do? I tried different combination but still not working.

Doesn't work like this. This will check, if you have Y numbers of building X. iNumBuildingsGlobal should check, if also other civs have it (I think).

If you want to have situation 2 out of 6, then you'll have to do it via Python.

Last one is Python. I checked the Quest for the Elite Swordsman. I want that if my civic is Environmentalism, the trigger will not be triggered. The Civic tag only allows you to list one civic to trigger, so I put this in the Python
Code:
def canApplyForestFireIndustry(argsList):
iEvent = argsList[0]
kTriggeredData = argsList[1]
player = gc.getPlayer(kTriggeredData.ePlayer)
		
iCivic = CvUtil.findInfoTypeNum(gc.getCivicInfo,gc.getNumCivicInfos(),'CIVIC_ENVIRONMENTALISM')
	
if not player.isCivic(iCivic):
	return true
	
return false

Looks correct.
If it doesn't work, then you probably forgot to enable Python exceptions ^^.
 
Regards and congratulations for the great work, Solver.

I want to do that when a stack has 10 or more units, one is disbanding. But I have a problem with "<iNumUnitsGlobal>0</iNumUnitsGlobal>"

If I place -1, 0 or 1 always occurs, there are 10 units stacked or no.

If I place 100 never occurs, there are 10 units stacked or no

Do not know how.
Spoiler :
<EventTriggerInfo>
<Type>EVENTTRIGGER_ATTRITION</Type>
<WorldNewsTexts>
<Text>TXT_KEY_EVENTTRIGGER_ATTRITION</Text>
</WorldNewsTexts>
<TriggerTexts>
<TriggerText>
<Text>TXT_KEY_EVENT_TRIGGER_ATTRITION</Text>
<Era>NONE</Era>
</TriggerText>
</TriggerTexts>
<bSinglePlayer>0</bSinglePlayer>
<iPercentGamesActive>100</iPercentGamesActive>
<iWeight>-1</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>
<UnitClass>UNITCLASS_WARRIOR</UnitClass>
<UnitClass>UNITCLASS_SWORDSMAN</UnitClass>
<UnitClass>UNITCLASS_AXEMAN</UnitClass>
<UnitClass>UNITCLASS_ARCHER</UnitClass>
<UnitClass>UNITCLASS_CHARIOT</UnitClass>
<UnitClass>UNITCLASS_CATAPULT</UnitClass>
<UnitClass>UNITCLASS_SPEARMAN</UnitClass>
<UnitClass>UNITCLASS_HORSE_ARCHER</UnitClass>
</UnitsRequired>
<iNumUnits>10</iNumUnits>
<iNumUnitsGlobal>0</iNumUnitsGlobal>
<iUnitDamagedWeight>0</iUnitDamagedWeight>
<iUnitDistanceWeight>0</iUnitDistanceWeight>
<iUnitExperienceWeight>0</iUnitExperienceWeight>
<bUnitsOnPlot>1</bUnitsOnPlot>
<BuildingsRequired/>
<iNumBuildings>0</iNumBuildings>
<iNumBuildingsGlobal>0</iNumBuildingsGlobal>
<iNumPlotsRequired>1</iNumPlotsRequired>
<bOwnPlot>0</bOwnPlot>
<iPlotType>2</iPlotType>
<FeaturesRequired>
<FeatureType>FEATURE_FOREST</FeatureType>
<FeatureType>FEATURE_JUNGLE</FeatureType>
<FeatureType>FEATURE_OASIS</FeatureType>
<FeatureType>FEATURE_FLOOD_PLAINS</FeatureType>
</FeaturesRequired>
<TerrainsRequired>
<TerrainType>TERRAIN_TUNDRA</TerrainType>
<TerrainType>TERRAIN_PLAINS</TerrainType>
<TerrainType>TERRAIN_GRASS</TerrainType>
<TerrainType>TERRAIN_SNOW</TerrainType>
<TerrainType>TERRAIN_DESERT</TerrainType>
<TerrainType>TERRAIN_HILL</TerrainType>
</TerrainsRequired>
<ImprovementsRequired/>
<BonusesRequired/>
<RoutesRequired/>
<ReligionsRequired/>
<iNumReligions>0</iNumReligions>
<CorporationsRequired/>
<iNumCorporations>0</iNumCorporations>
<bPickReligion>0</bPickReligion>
<bStateReligion>0</bStateReligion>
<bHolyCity>0</bHolyCity>
<bPickCorporation>0</bPickCorporation>
<bHeadquarters>0</bHeadquarters>
<Events>
<Event>EVENT_ATTRITION</Event>
</Events>
<PrereqEvents/>
<bPrereqEventPlot>0</bPrereqEventPlot>
<OrPreReqs/>
<AndPreReqs/>
<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>1</bShowPlot>
<iCityFoodWeight>0</iCityFoodWeight>
<PythonCanDo/>
<PythonCanDoCity/>
<PythonCanDoUnit/>
<PythonCallback/>
</EventTriggerInfo>
 
Two questions:

1) The tag iConvertOwnCities : what happens if you put in a negative integer (-1)? Will it remove the triggered religion from your city if you chose iPickCity?

2) Does iHurryAnger duration need to be set with the iHappyTurns variable, or does it default to a permanent duration?
 
Hey, is there any way to have an event trigger have a condition for state religion being a certain religion? For example, can an event trigger have the condition of state religion must be hinduism or must be Islam?
 
Top Bottom