Skills you must learn/have to do this:
- Playing Freeciv
- Change a rule set (for testing)
- Running Freeciv auto games
- Compile the Freeciv source code
- Get the source code of Freeciv trunk from SVN
- A little bit of C coding
- Create a patch
In Freeciv 2.6 it is possible to create a rule set that has a building that makes a city immune to spy actions like poison, steal a tech and establish an embassy. (In 2.5 and below it is only possible to protect a city against the incite spy action) This is done by editing the action enabler(s) (new concept in Freeciv 2.6) of the spy action you wish the building to block.
The Freeciv AI makes some decisions, like what building to build in a city, based on utility. That is a fancy way of saying that it calculates a number to represent how much it wants a particular building and use that number when deciding what to build next. Support for considering action immunity was just added to the evaluation of buildings.
Your patch will adjust the values representing how bad the AI think it is that one of its cities could become a target of the spy actions poison city, sabotage a random building (/the production), sabotage a specific building (or the production), steal a random tech, steal a specific tech, establish an embassy and investigate the city. The value of incite city may need adjustment too. You can do this in the function action_target_neg_util() in the file ai/default/aicity.c. The goal of adjusting ("balancing") them is to make the AI play better.
Your patch should be for the current trunk branch of Freeciv. When this is done post your patch to patch #4623.
For some actions it is natural to make the value depend on knowledge about the city it self. The city is given in the parameter pcity. You can get a lot of information from it. (Want to know what techs its owner has? Get the owner from the city and get his list of known techs!) It may also be a good idea to consider other rules/settings like diplchance. (The badness of incite use diplchance)
You will have to test your changes to know your new values actually are better. Run auto games so you won't have to wait for human players to move. Make sure you have loaded the ruleset you modified before starting to test. Make sure you are running the version of Freeciv you just modified. You don't have to install Freeciv again each time you make a change. The script fcser allows you to run the Freeciv server from the folder where you compiled it. The script fcgui allows you to start a client the same way.
To test you changes you will have to modify a rule set. I recommend starting with a copy of the classic ruleset. Action enablers live in the ruleset file game.ruleset. Buildings live in the ruleset file buildings.ruleset. The classic ruleset live in data/classic. To make a building in the target city block an action you must first find all action enablers that enable it. (Classic currently only have one one action enabler for each action) Then find the target_reqs requirement vector. If it don't have one add one. Add the building as a requirement and set present to FALSE.
How to create a patch, get Freeciv trunk from SVN and compile Freeciv is documented online. You can find good introductions to C for the programming skill set you already have by using Google. Try to remember reading your patch before sending it to make sure that test data like ruleset modifications wasn't accidentally included.
Edited 5th June 2015: Freeciv 2.6 isn't trunk any more. Make it clear that trunk, curretnly 3.0, is the main target.