Spy

Overview
A spy is a special, non-combat unit, that can perform espionage missions in enemy territory. See Espionage for more details.

Effects

 * Can perform Espionage missions.

Espionage
Espionage allows towns to designate certain residents as spies by training a Spy Unit item and giving it to a player. When a resident is a spy, he will have the ability to perform missions when inside another town's borders. Each mission has a chance to succeed and fail. These chances are effected by the presence of enemy spies online and greatly influenced by the proximity of enemy spies and scout towers. When a spy mission is performed a countdown begins in which the spy must remain inside the enemy town's borders. As the spy mission progresses the spy's 'exposure' increases. If the spy's exposure reaches certain percentages, different countermeasures are deployed against the spy. Once completed, the money for the mission will be taken from the town's treasury and the success or failure of the mission will be logged to that spy unit, which can later be dropped as a mission report book.

Spy Exposure
A spy's exposure always starts at 0 and doesn't increase until the mission starts. Once the mission starts the spy receives 0.1% exposure per-second. If there are other players nearby when the spy is performing the mission(within 30 blocks) the exposure is increased by an additional 0.2% per player nearby. If the spy is in range of a scout tower the spy will receive another 0.5% of exposure per second per scout tower. Each mission has a duration, the longer the mission the more exposure a spy will gain while attempting to do the mission. As the exposure level increases, the following counter measures start to take place.

Exposure Level Countermeasures
Exposure Level	Countermeasure

Mission Chances
The Mission's success chances are also effected by the number of players online in the enemy civilization. Each mission has a requirement for the amount of players online called 'intel' the more intel required for a mission, the more players need to be online to get the maximum success change. The success rate of the mission is reduced by the % of residents online to intel. For example, if a mission's intel is 20, and there are 10 people online. That mission's success chance is lowered by 50%. If there is nobody online the chances of success are 0! (This example may no longer work with the new equation) Equation: Success Rate = BaseMissionSuccessRate*MIN((Residents Online/Intel Required), 1.0)

Mission Intel Levels
Mission	Intel (aka players online)

Building Spies
Spies like other units are produced at the Barracks. Once the spy has been built, add the spies unit item to your inventory and you will be presented with an array of "mission books" Each book is a different mission which can be performed while you're in enemy territory. To perform the mission, make sure you have the required amount of coins in the town's treasury, then select the book and right click. Once the mission begins your exposure will be indicated by the XP bar.

Mission Duration
The length of a mission greatly effects your ability to perform it, since each second that ticks by increases your exposure. When your exposure gets too high the town being spied on might be able to kill you or drive you out of their borders, effectively preventing you from performing a mission. Below is a table detailing the length of missions. Remember that you must stay within the town's borders and stay alive in order to successfully complete your mission. In addition some missions require you to be within range of a specific target. You must also be within the correct range of the target when the mission countdown ends.

Mission Reports
Every time a spy performs a mission, the time, date, mission, results, and who performed the mission is logged on the server. When a player has a spy unit and dies, a written book is generated containing a log of all of the spy missions that spy unit has performed. By killing spies, towns can verify that they have been spied upon and can take the appropriate diplomatic action.

Other Units

 * Settler