Getting Event to apply to all buildings, also those build after the event

Pir Lan Tota

Warlord
Joined
Jan 28, 2008
Messages
276
Location
Manchester
Ok, so I have an event that gives Christian Temples +2 Espionage after building the Shrine (turn after). Tested, works fine. Had 3 cities, all with the temple, all got the bonus.

However if I now build another Christian Temple, it doesnt get the bonus. Is there a way to permanently apply it to all Christian Temples, current and furture ones?

Code below:

<EventInfo>
<Type>EVENT_FOUNDING_CHRISTIAN</Type>
<Description>TXT_KEY_EVENT_FOUNDING_CHRISTIAN</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>
<iEspionagePoints>0</iEspionagePoints>
<bGoldenAge>0</bGoldenAge>
<iFreeUnitSupport>0</iFreeUnitSupport>
<iInflationMod>0</iInflationMod>
<iSpaceProductionMod>0</iSpaceProductionMod>
<Tech>NONE</Tech>
<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/>
<UnitName/>
<UnitCombatPromotions/>
<UnitClassPromotions/>
<BuildingClass>NONE</BuildingClass>
<iBuildingChange>0</iBuildingChange>
<BuildingExtraYields/>
<BuildingExtraCommerces>
<BuildingExtraCommerce>
<BuildingClass>BUILDINGCLASS_CHRISTIAN_TEMPLE</BuildingClass>
<CommerceType>COMMERCE_ESPIONAGE</CommerceType>
<iExtraCommerce>2</iExtraCommerce>
</BuildingExtraCommerce>
</BuildingExtraCommerces>
<BuildingExtraHappies/>
<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/>
<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/>
<iConvertOwnCities>0</iConvertOwnCities>
<iConvertOtherCities>0</iConvertOtherCities>
<iMaxNumReligions>-1</iMaxNumReligions>
<iOurAttitudeModifier>0</iOurAttitudeModifier>
<iAttitudeModifier>0</iAttitudeModifier>
<iTheirEnemyAttitudeModifier>0</iTheirEnemyAttitudeModifier>
<iPopulationChange>0</iPopulationChange>
<AdditionalEvents/>
<EventTimes/>
<ClearEvents/>
<PythonCallback/>
<PythonExpireCheck/>
<PythonCanDo/>
<PythonHelp/>
<Button>,Art/Interface/Buttons/Process/Blank.dds,Art/Interface/Buttons/Beyond_the_Sword_Atlas.dds,8,5</Button>
<iAIValue>1000</iAIValue>
</EventInfo>
 
Ok, so I have an event that gives Christian Temples +2 Espionage after building the Shrine (turn after). Tested, works fine. Had 3 cities, all with the temple, all got the bonus.

However if I now build another Christian Temple, it doesnt get the bonus. Is there a way to permanently apply it to all Christian Temples, current and furture ones?
I will start by asking a few questions to make 100% sure it ends up doing what you want it to do, because it's not 100% clear to me based on what you wrote.

You want +2:espionage:/turn on BUILDINGCLASS_CHRISTIAN_TEMPLE. The question is when you want this to trigger:
  1. when you build "the Shrine" (which is a wonder or ?)
  2. when you found Christianity
  3. when you own the Holy City


I think the correct solution would involve modding the DLL to get a new XML tag. However I suspect it would also be possible in python.

Solution 1:
add a building finished callback. If event active, then add +2:espionage:/turn.

Solution 2:
On newturn event, loop cities and adjust bonus or even just add to your pool.

I suspect solution 1 would be best, but precisely which one to pick depends on what you want for trigger conditions.


If the building should be +2:espionage:/turn when selecting for the build queue, then it requires a DLL modification. Sadly the "preview value" is what the AI look at when it decides which building to build. This mean without a DLL modification, the AI will not see the bonus and will set the value of the bonus to 0, even if it really wants to spy.
 
A possible simpler and just plain XML solution would be to have the Shrine give a Free Building that gives a +2:espionage: and have that building require the temple.

I have not tested that this works although I have done somethings similar. If it does work it means that your temples will also get the espionage if you capture the shrine from someone else. You would also loose the benefit if you loose the Shrine.
 
Thanks guys,

let me answer Nightinggale first:
when you build "the Shrine" (which is a wonder or ?) - Yea the wonder build by the Great Priest, e.g. Church of Nativity

when you found Christianity - Only when you build the Church

when you own the Holy City - Yup

Now, Dancing Hoskuld actually makes a great suggestion here, by adding a building to it, that does this, it will then apply to every city and flip when the holy city gets taken.

Simple, elegant, I like it :)

Quick question (will test if I get home tonight), new buildings dont need graphics right. As in I can just create a free building called Spanish Inquisition that gives +2 espionage points.

Cheers Guys!
 
Quick question (will test if I get home tonight), new buildings dont need graphics right. As in I can just create a free building called Spanish Inquisition that gives +2 espionage points.

Cheers Guys!

I usually reuse some art. I would define the new building with the same art define as the temple.
 
I remember this thread about no art for the building.
 
Now I fully understand the goal, hence the problem and the problem is gone. It's a job well done :lol:

I like the solution with an invisible building. It's simple and XML only, meaning no custom code to test for bugs. However it still has the problem that the temple "preview" will not have +2:espionage:/turn. The AI could also be an issue. It can predict the value from a free building class, but the free building comes from the shrine, not the temple, which mean it could have a hard time predicting the bonus from the temple itself. This aren't game breaking bugs, but more like glitches, which as I said earlier would require DLL coding to fix. I would argue they might not even be worth the time to fix even if we ignore the issue of coding skills required. It will not really matter to people, who are made aware of it, but the AI is a different story. However there is a good chance the AI will build temples for a religion where it has the holy city, which mean it's not a serious AI handicap.
 
Found another issue, bloody free building applies to every city, not the ones that have a Christian_Temple in it, unfortunately.

Oh well, more bug hunting :)
 
Granting the free building applies to every city, not just the selected ones with temples.
In that case, there is no point of the free building, since you might as well just let the shrine grants +2 espionage to all cities directly.

Python solution is doable but not advisable for someone with no prior experience. You need codes in many areas, such as onCityBuilt for new cities, onCityRazed when Wonder razed, onCityAcquired when Wonder changes hands.

Modifying the DLL to add a new tag is the cleaner solution, but it is worse than python for someone without experience, since you need additional tools to compile after coding.
 
How about adding python code, which runs once each turn. This code loops all cities and if they have both invisible building and temple, add +2:espionage: to the city owner. It's somewhat simple to code (once you know where to code it), but since it is a one time bonus each time, it will not show up as production. This mean with 5 temples, you would get +10, but the display for the combined production would still be +0.

Getting the display to work as intended would likely require DLL modifications because as platyping said, there are simply way too many conditions where python should be called to modify. With that high amount and spread of modifications, it's a design, which is very prone to bugs and I would never use it myself.

Oh I just had a new idea. Make two invisible buildings.
Building A: does nothing
Building B: +2:espionage:
The wonder adds building A to all cities.

On new turn loop, all cities are examined.
If the city has temple and building A, then add building B.
If the city lacks temple or A (or both), remove B.

This can lack one turn, meaning you build the wonder, then next turn you gain building B and then next turn you actually gain the production bonus. This lag can be countered by calling the same code on some other python callbacks, like adding building and onCityAcquired.

The good part about this setup is that while it could end up being as widely spread across the code as what platyping wrote about, a bug in this setup mean a change could affect production with a one turn delay and that is not a critical bug.

Maybe two invisible buildings aren't that needed, but it makes the code easier. Checking if the city has A is a quick way to tell if the player has the wonder. Building B had both the production and it is used as a bool to tell if the production is applied or not. This mean it is a way to add a new variable to the game and savegames without modding the DLL. I used to think you would have to mod the DLL to add more variables, but the core of this idea is to use the presence of an invisible building to store a bool.
 
Found another issue, bloody free building applies to every city, not the ones that have a Christian_Temple in it, unfortunately.

Oh well, more bug hunting :)

That is why you have the free building require the Christian Temple. Or is this requirement ignored in vanilla BtS and is something that got fixed in the RoM, RoM/AND and C2C line of mods?
 
Always been like that. If free building is lighthouse, it will even be granted to inland cities.

I actually already did the python way for one of my wonders long ago.
 
yea, even with Building required, it still bangs it in every city unfortunately.

Was trying to see if I could go the Apo Palace way, but that must be Python as well, as I cant see in the XML where it gives the bonus to religious buildings :(
 
Was trying to see if I could go the Apo Palace way, but that must be Python as well, as I cant see in the XML where it gives the bonus to religious buildings :(

Answered here (point 4).

Do you have a valid reason not to have read the 'Quick Modding Questions" thread on 8 February? :D
 
Back
Top Bottom