Raids

Gold/Elixir
Gold and Elixir can be stolen from three types of Resource Buildings: storages, mines/collectors and the Town Hall.
 * Storages: The percentage of Gold/Elixir that can be stolen from storages is 20% and is capped at 198,000. This means that if more than 990,000 is being held in storages, it is subject to the cap.
 * Mines/Collectors: The percentage of Gold/Elixir that can be stolen from mines/collectors is 50% and is capped only by the storage capacity of the mine/collector.
 * Town Hall: There is an additional 1,000 of each resource that can be stolen inside the Town Hall.

Therefore, calculated loot = (20% x stored resources, up to 198,000) + (50% x amount in mines/collectors) + 1,000. This means that the maximum calculated loot, for each resource, that can be stolen from 1 opponent (with maxed mines/collectors and full storages, and same Town Hall level) is: 198,000 + (7 x 75,000) + 1,000 = 724,000.

These figures are before the loot multiplier is applied. The loot multiplier is what is behind the loot "penalty" and the loot "bonus". The amount of available loot = calculated loot x loot multiplier. The loot multiplier $$\mathbb{M}$$ is determined as follows:
 * 5% for attacking someone with a Town Hall (TH) 4+ levels lower than the attacker's.
 * 25% for attacking someone with a TH 3 levels lower than the attacker's.
 * 50% for attacking someone with a TH 2 levels lower than the attacker's.
 * 90% for attacking someone with a TH 1 level lower than the attacker's.
 * 100% for attacking someone with a TH level equivalent to the attacker's.
 * 110% for attacking someone with a TH 1 level higher than the attacker's.
 * 150% for attacking someone with a TH 2 levels higher than the attacker's.
 * 200% for attacking someone with a TH 3+ levels higher than the attacker's.

The comprehensive formula for finding available loot $$L_{avail}$$ is as follows:

$$L_{avail} = \mathbb{M} \cdot ( min(0.2 \cdot L_{S},198000) + 0.5 \cdot L_{MC} ) + min(\mathbb{M} \cdot L_{TH}, 1000)$$

Where:
 * $$L_{S} = $$ total amount of loot in all storages
 * $$L_{MC} = $$ total amount of loot in all mines or collectors
 * $$L_{TH} = $$ total amount of loot in the Town Hall

NOTE: The 1,000 that the Town Hall stores is subject to the PENALTY but not the BONUS, as 1,000 of each resource is the most it can ever store.

Calculator:



The maximum theoretical Gold or Elixir loot is as follows:

$$L_{avail} = (200%) \cdot [ 198,000 + 0.5 \cdot (7 \cdot 150,000) ] + 1000 = 1,447,000$$

In practice this is almost impossible for someone to actually raid, though.

Dark Elixir
Dark Elixir Storages have 5% of their contents available for raiding and Dark Elixir Drills have 75% available for raiding. The cap for raiding from the storage is 2,000, while the drills are raidable according to (75% of uncollected DE) x (loot multiplier) or the maximum capacity of the drill, whichever is lower.

The comprehensive formula for finding Dark Elixir loot is as follows:

$$L_{avail} = \mathbb{M} \cdot min(0.05 \cdot L_{S},2000) + \sum_{i} min(\mathbb{M} \cdot 0.75 \cdot L_{D_i}, C_{D_i} )$$

Where:
 * $$L_{S} = $$ total amount of loot in the Dark Elixir Storage
 * $$L_{D_i} = $$ amount of loot in each Dark Elixir Drill
 * $$C_{D_i} = $$ maximum capacity of each Dark Elixir Drill

The maximum theoretical Dark Elixir loot is as follows:

$$L_{avail} = (200%) \cdot 2,000 + (1,600 + 1,600 + 1,600) = 8,800$$