Events, Events, Events

Androrc the Orc

Emperor
Joined
Apr 19, 2004
Messages
1,621
Location
Vienna, Austria
I have managed to make events work only at certain dates in the game (thus making historical events possible), but I have one problem. It seems that they won't work on scenarios. Any idea on how to fix this?

EDIT: Oh nevermind, I found out the problem; I was using the first tutorial event and it wouldn't fire because it required me to have no population and no owned land and in the scenario I started with cities.
 
Are your events in releasable state?

That is to say, do you have enough events you could release an "Events Mod" for Colonization?
 
Now professions can require events too (Regulars are a profession in my personal Civ4Col):



That makes possible inventions like those of Paradox's Victoria. While not the same as having an actual Tech Tree, in my opinion it's better than no way to represent technology advancement at all.

I should release a mod in the following days with the modifications I've done.
 
Hi Androrc,

Any news on the progress of your events? I have been scripting quite a number of colonization events myself for The Authentic Colonization (TAC) over on the http://www.civforum.de boards. Would be interesting to see what you have added.
 
I have made only a few events, but I have coded in a good chunk event effects and triggers (for example, making events only trigger between set start and end dates). Most can be seen in Spread of Imperialism, but the latest of them aren't added there.

I have taken a look at your mod previously and found it to be quite well-done. If you need any help with making specific event triggers or effects, let me know.
 
Thanks for the offer!

I have added a number of my own triggers as well, e.g. for historic events. I also added a number of generic functions for triggers that can be used by our other team members who do not want to mess around with python, e.g.:

  • hasSilverBonus
  • hasFurBonus
  • hasCottonBonus
  • hasSugarBonus
  • hasTobaccoBonus
  • hasIronBonus
  • hasMineralsBonus
  • hasTimberBonus
  • hasFoodBonus
  • hasNoBonus
  • hasAllBuildings (all buildings listed in the trigger must be available in a city, nut just one of them)


All of them can be used by simply adding to the PythonCanDo section, e.g.
PHP:
<PythonCanDo>hasSilverBonus</PythonCanDo>

For the events I have added a lot of functionality to deal with COL features that are not available in CIV events, e.g. father point rewards, dealing with goods (clothes, tools, whatever), changing Europa sell prices, taxes, etc.

To support these, we have added 4 generic XML parameters to the event. Below is an example, which can be used to give 300 political father points as a reward (this is part of our "finding a lost tribe of Amazons" event).

Spoiler :

PHP:
		<EventInfo>
			<Type>EVENT_LOST_TRIBE_1</Type>
			<Description>TXT_KEY_EVENT_LOST_TRIBE_1</Description>
			<LocalInfoText/>
			<WorldNewsTexts/>
			<OtherPlayerPopup/>
			<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>
			<UnitClass>NONE</UnitClass>
			<iNumFreeUnits>0</iNumFreeUnits>
			<bDisbandUnit>0</bDisbandUnit>
			<iUnitExperience>5</iUnitExperience>
			<iUnitImmobileTurns>0</iUnitImmobileTurns>
			<UnitPromotion/>
			<UnitName/>
			<UnitCombatPromotions/>
			<UnitClassPromotions/>
			<BuildingClass>NONE</BuildingClass>
			<iBuildingChange>0</iBuildingChange>
			<BuildingExtraYields/>
			<iRevoltTurns>0</iRevoltTurns>
			<iMinPillage>0</iMinPillage>
			<iMaxPillage>0</iMaxPillage>
			<iFood>0</iFood>
			<iFoodPercent>0</iFoodPercent>
			<FeatureType>NONE</FeatureType>
			<iFeatureChange>0</iFeatureChange>
			<ImprovementType/>
			<iImprovementChange>0</iImprovementChange>
			<RouteType>NONE</RouteType>
			<iRouteChange>0</iRouteChange>
			<BonusRevealed>NONE</BonusRevealed>
			<PlotExtraYields/>
			<iOurAttitudeModifier>0</iOurAttitudeModifier>
			<iAttitudeModifier>0</iAttitudeModifier>
			<iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
			<iPopulationChange>0</iPopulationChange>
			<AdditionalEvents/>
			<EventTimes/>
			<ClearEvents/>
			<PythonCallback>ChangeFatherPoints</PythonCallback>
			<PythonExpireCheck/>
			<PythonCanDo/>
			<PythonHelp>getHelpChangeFatherPoints</PythonHelp>
			<Button>,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
			<iAIValue>1000</iAIValue>
			<!-- TAC Generic Event Parameters: 
			Parameter1 = Type of Father Points:
				-1 = Not used
				0= EXPLORATION
				1= RELIGION
				2= TRADE
				3= MILITARY
				4= POLITICAL
			Parameter2 = Father point change: Example 100 is equivalent to finding a goody hut
			Parameter3 = not used
			Parameter4 = not used-->
			<iGenericParameter1>4</iGenericParameter1>
			<iGenericParameter2>300</iGenericParameter2>
			<iGenericParameter3>0</iGenericParameter3>
			<iGenericParameter4>0</iGenericParameter4>
		</EventInfo>
 
Sounds good :)

I have added the following triggers:

<Civilization> - will only trigger for a specific civilization
<Father> - will only trigger if has a specific founding father
<iMinYear> - will only trigger if the game year is equal to or greater than the value given
<iMaxYear> - will only trigger if the game year is less than or equal to the value given
<iPlotX> - if trigger for a city or a plot, will trigger only for a plot with this X value
<iPlotY> - if trigger for a city or a plot, will trigger only for a plot with this Y value

And the following effects:

<Inherit> - will acquire all cities owned by the specified civilization
<ChangeYieldRateModifiers> - changes the yield rate modifier of yields

There are others, but they relate to specific systems and as such wouldn't work without porting those systems as well.
 
Thanks for the offer!

I have added a number of my own triggers as well, e.g. for historic events. I also added a number of generic functions for triggers that can be used by our other team members who do not want to mess around with python, e.g.:

  • hasSilverBonus
  • hasFurBonus
  • hasCottonBonus
  • hasSugarBonus
  • hasTobaccoBonus
  • hasIronBonus
  • hasMineralsBonus
  • hasTimberBonus
  • hasFoodBonus
  • hasNoBonus
  • hasAllBuildings (all buildings listed in the trigger must be available in a city, nut just one of them)


All of them can be used by simply adding to the PythonCanDo section, e.g.
PHP:
<PythonCanDo>hasSilverBonus</PythonCanDo>

For the events I have added a lot of functionality to deal with COL features that are not available in CIV events, e.g. father point rewards, dealing with goods (clothes, tools, whatever), changing Europa sell prices, taxes, etc.

To support these, we have added 4 generic XML parameters to the event. Below is an example, which can be used to give 300 political father points as a reward (this is part of our "finding a lost tribe of Amazons" event).

Spoiler :

PHP:
		<EventInfo>
			<Type>EVENT_LOST_TRIBE_1</Type>
			<Description>TXT_KEY_EVENT_LOST_TRIBE_1</Description>
			<LocalInfoText/>
			<WorldNewsTexts/>
			<OtherPlayerPopup/>
			<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>
			<UnitClass>NONE</UnitClass>
			<iNumFreeUnits>0</iNumFreeUnits>
			<bDisbandUnit>0</bDisbandUnit>
			<iUnitExperience>5</iUnitExperience>
			<iUnitImmobileTurns>0</iUnitImmobileTurns>
			<UnitPromotion/>
			<UnitName/>
			<UnitCombatPromotions/>
			<UnitClassPromotions/>
			<BuildingClass>NONE</BuildingClass>
			<iBuildingChange>0</iBuildingChange>
			<BuildingExtraYields/>
			<iRevoltTurns>0</iRevoltTurns>
			<iMinPillage>0</iMinPillage>
			<iMaxPillage>0</iMaxPillage>
			<iFood>0</iFood>
			<iFoodPercent>0</iFoodPercent>
			<FeatureType>NONE</FeatureType>
			<iFeatureChange>0</iFeatureChange>
			<ImprovementType/>
			<iImprovementChange>0</iImprovementChange>
			<RouteType>NONE</RouteType>
			<iRouteChange>0</iRouteChange>
			<BonusRevealed>NONE</BonusRevealed>
			<PlotExtraYields/>
			<iOurAttitudeModifier>0</iOurAttitudeModifier>
			<iAttitudeModifier>0</iAttitudeModifier>
			<iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
			<iPopulationChange>0</iPopulationChange>
			<AdditionalEvents/>
			<EventTimes/>
			<ClearEvents/>
			<PythonCallback>ChangeFatherPoints</PythonCallback>
			<PythonExpireCheck/>
			<PythonCanDo/>
			<PythonHelp>getHelpChangeFatherPoints</PythonHelp>
			<Button>,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
			<iAIValue>1000</iAIValue>
			<!-- TAC Generic Event Parameters: 
			Parameter1 = Type of Father Points:
				-1 = Not used
				0= EXPLORATION
				1= RELIGION
				2= TRADE
				3= MILITARY
				4= POLITICAL
			Parameter2 = Father point change: Example 100 is equivalent to finding a goody hut
			Parameter3 = not used
			Parameter4 = not used-->
			<iGenericParameter1>4</iGenericParameter1>
			<iGenericParameter2>300</iGenericParameter2>
			<iGenericParameter3>0</iGenericParameter3>
			<iGenericParameter4>0</iGenericParameter4>
		</EventInfo>

Hi Ronnar!

This events are included in the TAC 203.

  • Line 1728: <PythonCanDo>hasNoBonus</PythonCanDo>
    Line 1945: <PythonCanDo>hasSilverBonus</PythonCanDo>
    Line 2311: <PythonCanDo>hasFoodBonus</PythonCanDo>
    Line 2387: <PythonCanDo>hasFoodBonus</PythonCanDo>
Could you, please, give some comments about these events:
  • hasFurBonus
    [*]hasCottonBonus
  • hasSugarBonus
  • hasTobaccoBonus
  • hasIronBonus
  • hasMineralsBonus
  • hasTimberBonus
How do you plan to use them and at which conditions? Thank you in advance.
 
Hi Ronnar!

This events are included in the TAC 203.

Could you, please, give some comments about these events:
  • hasFurBonus
  • hasCottonBonus
  • hasSugarBonus
  • hasTobaccoBonus
  • hasIronBonus
  • hasMineralsBonus
  • hasTimberBonus
How do you plan to use them and at which conditions? Thank you in advance.

Hi KJ,

The functions are only checking if the chosen plot for an event has a certain bonus. Unfortunately that functionality is not available directly in the event trigger xml for COL.

If the plot has no bonus or not the correct bonus, the function will return false and the event will not trigger.

At the moment we do not use them all for events. A possible use could be that a native entering a plot with a tobacco bonus has a certain chance to teach an untrained tobacco planter working this plot so he becomes an expert unit.

Or that a special cotton type was found on plot x, which now has a better yield.

The possibilities are endless ... :)

But I do not want to abuse Androrcs thread for a discussion about colonization events in TAC. Feel free to ask more about it in our thread http://www.civforum.de/showthread.php?t=67209 (Sorry, posts are all in German as you know. But feel free to post English questions there.)
 
Hm, those features sound great Ronnar.. I'd be very interested to add some Events to my mod using this.

For the events I have added a lot of functionality to deal with COL features that are not available in CIV events, e.g. father point rewards, dealing with goods (clothes, tools, whatever), changing Europa sell prices, taxes, etc.

To support these, we have added 4 generic XML parameters to the event. Below is an example, which can be used to give 300 political father points as a reward (this is part of our "finding a lost tribe of Amazons" event).
Those sound like some useful additions - would the code enabling those new tags be relatively easy to merge to an existing mod? I'd guess the PythonCanDo ones wouldn't require a DLL change at all.

One cool additional feature would be triggers that happen only if your relation with a given civ (especially with your parent "King" civ) was above or below a certain threshold. This could allow for punitive events if your relation with your King drops too low, and allow for Kings to issue quest events e.g. demanding delivery of a certain amount of goods, where your performance influences your relations with them - that kind of thing would be perfect for Kailric's proposed Medieval mod. Could things like that be possible using a python event trigger?

BTW, is there something that prevents Events from firing for Native civs? I made an event for my mod to give Alien (Native) players a free Saucer unit (triggered by using a Civic that all native civs have), but it's not triggering in the game and I'm not sure why; I'll attach the code for it here.:confused:
 
Hm, those features sound great Ronnar.. I'd be very interested to add some Events to my mod using this.


Those sound like some useful additions - would the code enabling those new tags be relatively easy to merge to an existing mod? I'd guess the PythonCanDo ones wouldn't require a DLL change at all.
If you want to use the generic XML parameters, they do require a DLL change. If you are ok with putting the values in Python code, then it does not require a DLL change. But then each event needs it's own python code. Not a big issue, but not very flexible and hard to understand for someone else trying to edit your events.

I do not know how hard it is to merge it into your DLL, as I am only messing with python scripts and do not touch the DLL code. It should be documented in the DLL sources in the next release of our TAC mod (should be released within the next month).

The Python functions itself are very simple. The biggest part is reading the generic parameters e.g. for the father point type and amount.

Here is an example for giving father points of a certain type and adjusting it to the speed and difficulty of the game. Of course there is a second function creating the correct help text for the event mouse over.

Spoiler :

PHP:
def ChangeFatherPoints(argsList):
	eEvent = argsList[0]
	event = gc.getEventInfo(eEvent)
	kTriggeredData = argsList[1]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	team = gc.getTeam(player.getTeam())
	if event.getGenericParameter(1)!=-1:
		Handicap = gc.getHandicapInfo(CyGame().getHandicapType())
		Speed = gc.getGameSpeedInfo(CyGame().getGameSpeedType())
		FatherPointChange = event.getGenericParameter(2)*Speed.getFatherPercent()/100*Handicap.getFatherPercent()/100
		team.changeFatherPoints(event.getGenericParameter(1), FatherPointChange)

One cool additional feature would be triggers that happen only if your relation with a given civ (especially with your parent "King" civ) was above or below a certain threshold. This could allow for punitive events if your relation with your King drops too low, and allow for Kings to issue quest events e.g. demanding delivery of a certain amount of goods, where your performance influences your relations with them - that kind of thing would be perfect for Kailric's proposed Medieval mod. Could things like that be possible using a python event trigger?
That would be quite easy. Pick the king of the player that triggered the event and check the attitude. Put both into the <PythonCanDo> part of the event trigger XML.

Example code, which triggers an event if the king's attitude towards the chosen player is 0 (ATTITUDE_FURIOUS).
Spoiler :

PHP:
def canTriggerKingQuest(argsList):
	ePlayer = argsList[1]
	player = gc.getPlayer(ePlayer)
	king = gc.getPlayer(player.getParent())
	
	if not player.isPlayable():
		return false
	if not king.isEurope():
		return false
	if king.AI_getAttitude(ePlayer) <> 0:
		return false
	return true

I have not tested this code, but this or something similar should work.

Delivering goods is something I did for an event, but I have chosen an easy way: As soon as a city has at least the requested amount in stock, the event pops-up and asks if you want to give the goods to the king in exchange for e.g. a Europe price increase for this good or a tax decrease. You would add such a check to the PythonCanDo of the Event, not the trigger.

Example: (replace -event.getGenericParameter(1) with the amount of goods that the king requested). For a quest that should trigger 100% of the time, you would have to loop through all cities of the player instead of just checking the trigger city as I do in my example below.
Spoiler :

PHP:
def CanDoFestivity2(argsList):
	eEvent = argsList[0]
	event = gc.getEventInfo(eEvent)
	kTriggeredData = argsList[1]
	iYield = gc.getInfoTypeForString("YIELD_CIGARS")
	player = gc.getPlayer(kTriggeredData.ePlayer)
	city = player.getCity(kTriggeredData.iCityId)
	if city.getYieldStored(iYield) <= -event.getGenericParameter(1) :
		return false
	return true


BTW, is there something that prevents Events from firing for Native civs? I made an event for my mod to give Alien (Native) players a free Saucer unit (triggered by using a Civic that all native civs have), but it's not triggering in the game and I'm not sure why; I'll attach the code for it here.:confused:

Sorry, I did not have the time to check your code, but usually events can be triggered for natives. We had to exclude natives in our mod for some events because it didn't make sense for some of them to trigger for natives. Try your event with something simple like giving them 10 gold instead of a free flying saucer to see if the trigger works correct.
 
Thanks for your help Ronnar. I got the alien Saucer event to work (just had to reset MaxPopulation to -1 on the trigger) which makes playing the natives much more interesting. I'll try making some punitive king events using your trigger. Is it possible to adjust the king's attitude using python like below?
king.AI_getAttitude(ePlayer) = king.AI_getAttitude(ePlayer) + 1

You're right, its probably simplest to use Python functions to avoid changing DLL. I'm interested to look at the events you've made, would you mind uploading your python file when you get done? Another thing I'd like to find out is to check if the player has a certain Civic using a pythoncando function for one of the Event choices (currently there's only a civic xml tag for eventtriggers). That would allow techs from the techtree modcomp to unlock various choices for triggered events.
 
I'm interested to look at the events you've made, would you mind uploading your python file when you get done?

A new version of the TAC mod was released last week, which includes some of the events we created. The source codes also include the changes we made to the DLL to allow for the generic parameters for the events XML.

You can find the download links here (sorry, German only):
http://www.civforum.de/showpost.php?p=3714242&postcount=1423

Most events are not or only in some parts translated, but I am sure you will find out what they do from the XML+python code.

There are also two quests included (First to discover Pacific Ocean, First to found X cities without access to ocean).
 
Is it possible to adjust the king's attitude using python like below?
king.AI_getAttitude(ePlayer) = king.AI_getAttitude(ePlayer) + 1

Python functions starting with get and is only read information, they can never be used to write data back. You need to look for functions with set or change if you want to do this.

The below code can be used to change the relation to the king by +1. it will change the king's attitude towards the player by +1 as well as the other way round (player's attitude vs. king)

Code:
	eEvent = argsList[0]
	kTriggeredData = argsList[1]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	eking = player.getParent()
	king = gc.getPlayer(eking)
	player.AI_changeAttitudeExtra(eking, 1)
	king.AI_changeAttitudeExtra(kTriggeredData.ePlayer, 1)

If you do that, remember to specify a python help function that gives the player some information what the event is doing:

Code:
def getHelpEventXXX(argsList):
	eEvent = argsList[0]
	kTriggeredData = argsList[1]
	player = gc.getPlayer(kTriggeredData.ePlayer)
	eking = player.getParent()
	king = gc.getPlayer(eking)
	szHelp = localText.getText("TXT_KEY_EVENT_RELATION_KING_INCREASE", (1, king.getCivilizationAdjectiveKey()))
	return szHelp

Of course you have to create the correct XML text entry :
Code:
		<Tag>TXT_KEY_EVENT_RELATION_KING_INCREASE</Tag>
		<English>[ICON_BULLET]Relations to %s2_civ_adjective king are improved by [COLOR_POSITIVE_TEXT]%D1[COLOR_REVERT]</English>
 
Top Bottom