This trick was used extensively in my coding experience with Europa Universalis 3. There was no channel to give a player gold for conquering a province, as an example, so events had to be coded. It got quite complicated just to effect simple things.
Here is the event Miracle at the Walls (1st choice, +1

for Walls) from Civilization 4/Beyond The Sword/Assets/XML/Events/CIV4EventInfos.xml
Notice how it gives you <BuildingExtraCommerce> in the text key of COMMERCE_GOLD. This isn't what you want, since you don't want ExtraCommerce, because that's only what coin can be converted into. You want extra yields, which would be raw coin.
The section immediately before <BuildingExtraCommerce> is <BuildingExtraYields>. Yields is the term for food, hammers, and commerce. The Warships quest option #2 gives a raw commerce boost to Harbors in the form of:
Code:
<BuildingExtraYields>
<BuildingExtraYield>
<BuildingClass>BUILDINGCLASS_HARBOR</BuildingClass>
<YieldType>YIELD_COMMERCE</YieldType>
<iExtraYield>2</iExtraYield>
</BuildingExtraYield>
</BuildingExtraYields>
so we need to add the yield of YIELD_COMMERCE to BUILDINGCLASS_WALLS with some kind of event that fires for all BUILDINGCLASS_WALLS.
If you go back to the Miracle at the Wall, you notice two flags called <bQuest> and <bGlobal>. If the flag <bQuest> is boolean 1, then the event pops up as the first part of a quest (You must construct 7 Triremes). If boolean 0, then it's merely a regular event. The flag <bGlobal>, if set to boolean 1, makes the change apply to everything forever and always. Thus, if you select the second option for the Warships quest, all BUILDINGCLASS_HARBOR will have 2 YIELD_COMMERCE whether already built or built in the future.
We also need to set <bPickCity> to boolean 0, so that it applies to all cities.
So I would code an event based on Miracle at the Walls. Added or changed content is Green, removed content is Red.
You'll notice I changed the TXT_KEYs to create new ones... this isn't strictly necessary, but you can add some text in the files Civilization 4/Beyond The Sword/Assets/XML/Text/CIV4GameText_Events_BTS.xml, copying the syntax for a similar event and matching the TXT_KEYs used here.
This is all well and good, but now we are missing something to trigger the event. Here's the relevant lines from Miracle at the Walls inside of CIV4EventTriggersInfos.xml:
As
isenchine pointed out, we need to set <iPercentGamesActive> to value 100, and <iWeight> to value -1. Additionally, we need to rewrite this event so that it is global and requires the Great Wall wonder instead of merely Walls. So, again, <bPickCity> should be set to boolean 0, as should <bShowPlot> (moves view to event), because there isn't a city to pick.
The second thing we can do - or not do - is remove the technology of Rifling from the obsolete section. You may want to keep it in.
The <Events> section needs to be modified to reflect the tag of our event, EVENT_GREAT_WALL.
<bPickReligion> and <bStateReligion> need to both be set to boolean 0, as Miracle at the Walls is dependent on your religion, but the Great Wall event should not be.
The last thing we need to do is change the scope of <BuildingsRequired> to the Great Wall. The proper TXT_KEY is BUILDINGCLASS_GREAT_WALL, found in Assets/XML/Buildings/CIV4BuildingClassInfos.xml. Additionally, we need to change the <iNumBuildingsRequired> to value 0, and <iNumBuildingsRequiredGlobal> to value 1. This makes the scope not care where the building is, merely that it is. That section of code should be modified to read:
Code:
<BuildingsRequired>
<BuildingClass>BUILDINGCLASS_GREAT_WALL</BuildingClass>
</BuildingsRequired>
<iNumBuildings>0</iNumBuildings>
<iNumBuildingsGlobal>1</iNumBuildingsGlobal>
Thus, the final event should read like this:
That should be it. The TXT_KEY entries can be made in Assets/XML/Text/CIV4GameText_Events_BTS.xml if you want them to be. Otherwise, you'll get TXT_KEY_EVENT_GREAT_WALL showing.
I've never coded an event for Civilization IV, so I don't know if this will work correctly.