__Factories__

__Capacity and utilization__

Each factory produces a certain quantity of the respective goods per hour (capacity). The more goods are picked up, the higher the utilization (= quantity picked up / capacity). A higher utilization leads to longer waiting times. The utilization is limited to 300%. It is calculated once an hour.

__Growth__

If a factory is permanently well utilized, it grows. The growth is (utilization - 50%)/10 per hour. Once 100% is reached, the factory grows to the next level. Investments further promote the growth of the operation (invest_growth/1000 per investment, only up to 99%). F.e. if the invest_growth is currently 4, one investment will grow the farm by 0.4%.

The new capacity is: Capacity (Level) = Capacity (Level-1) + Capacity (Level 1) * ((factory_growth_basic + factory_growth_dynamic * Level) / 100)

The warehouse size for input goods grows by const_factories -> growthPerLevel.

__Delivery bonus and consumption__

Unlike cities, the delivery bonus for incoming goods depends only on the type of goods and the stock level and not on the distance. For each type of goods there is a minimum and a maximum bonus. These values are stored in the database under const_resources.

The actual bonus is calculated as follows: Minimum price + (1 - stock level/stock size)*(maximum price - minimum price).

__Investments__

Any player who has a factory connected to his rail network can invest in it. On the one hand, investments contribute to the growth of the factories (invest_growth/1000 per investment, only up to 99%), on the other hand, they shorten the waiting time of the players concerned. If a player or a company has invested more than 50% of the total amount, the waiting time is additionally halved.

The cost of an investment increases with each additional investment made by a player.

The cost of an investment is calculated from:

* base value = (investPerLevel)+(investPerLevel*0.2*operating level)

* Price = Base Value*Investment No.

The basic value is the value of the factory type entered under investPerLevel.

The price is always rounded to 1000s of digits.

If the farm rises, all previous investments are reset to 10% of the previous sum! Players must therefore invest again to gain an advantage! Small residual values are deleted.

__Prestige__

When the factory levels up, the investors receive a reward in the form of prestige. The money sum of the investments is used for this. Under const_factories, a new column 'prestige' is created as a basic value per factory type. The top investor receives prestige:

Basic value + (0.03 * basic value * (current operating level - 1)).

The value is always rounded to the nearest 10.

For example, with a base value of 100, a company with level 10 would award 130 (127, rounded to 130) prestige to the top investor. The maximum for this is 500 prestige for the top investor.

The second investor gets investment_prestige_factor (currently 80%) of the prestige of player 1; the third investment_prestige_factor of player 2 and so on. In case of an exact tie, the player who had invested the higher amount first gets the preference. The minimum is always 2 prestige if you have made at least one investment.

If the top investor has made >50% of all investments, there is an extra bonus of (base value / 4).

__Wating time__

The waiting time occurs only during loading, unloading is immediate. It depends on the following factors:

- Utilization: Higher utilization leads to higher waiting time:
The waiting time is multiplied by the utilization. (For example, if the load is 65%, the waiting time is multiplied by 0.65).

- Stock level of input goods (not for raw material factories): Low stock levels of input goods increase the waiting time:
The current stock level (in %) for the input good with the current lowest stock level (if there are multiple input goods) is used for the calculation (La).

The normal waiting time is multiplied by (factory_storage_wait_factor^((100-La) / 100)) and added to the previous time.

Hereby the waiting time grows, the higher the demand of a good is, and one should try to reach at least an average stock level, and to have a balanced distribution in case of several incoming goods.

- Investments:
The reduction in waiting time due to investments is divided into a weighted sum of the absolute number of investments and the relative share of all players. For this calculation, the proportion of all previous investments is needed.

'''A1''' = (log((1 + (share of player + share of company / 2)), invest_relative_factor)

The share of the player or the association is the relative share of the investments in the total investments (absolute number of investments). The value would reach a maximum value of about 0.6 at 100% investments.

To the total number of investments always 50 are added. Thus, one can never reach a value of 100%, and the first investments do not have such a strong effect.

'''A2''' = min((log((1 + (absolute number of investments of the player)), invest_number_factor)),0.4)

The value would reach its maximum of 0.4 at 26 investments.

waiting_time_new = waiting time - (waiting time * (A1 + A2))

**Bonus**If an association holds a share of >50% of the investments of a factory, the waiting time is additionally reduced by another 50%. Here, not the number of investments, but the amount of money is calculated. This is done after the normal calculation of the waiting time reduction. If a player without an association holds a share of 50%, the bonus also applies to him.

- Workers: There are personalities that reduce the waiting time by a certain percentage.
- Chaining: If a player of an association delivers goods to a factory without picking them up, while another player of the company only picks up goods, a chaining occurs. Chaining increases the delivery bonus for the delivering player and decreases the waiting time for the collecting player. The more players participate, the greater the advantage.
Bonus delivery premium (incoming goods) = (chain_base^(-delivery quantity of goods on this day (company)/pickup quantity on this day (company)))/chain_divisor (value range 0 - 0.5 -> 0% - 50%)

Factor waiting time = chain_wait_summand + chain_wait_factor*bonus delivery bonus (value range 0.67 - 1)

Bonus waiting time = 1 - factor waiting time (value range 0 - -33%)

- Noob protection (First 2 days): The calculated waiting time is multiplied by noob_wait_reduction.

__Warehouses/Ports__

In warehouses/ports all already unlocked goods can be picked up and delivered. However, a train cannot deliver and pick up the same goods in a timetable.

__Capacity__

Basic capacity: capacity_warehouse, 5,000 t/h

__Utilization__

To calculate the utilization, we add up the picked up tons of all goods in the warehouse and divide it by the capacity. The maximum is 300% (as for factories). The utilization is recalculated once per hour.

__Investments__

Investments work in the same way as for factories. The waiting time advantage applies to all goods. investperlevel_storage, default: 100,000

__Growth__

The warehouse size is 5000*level of warehouse t. -> growthperlevel_warehouse

__Prestige for investments__

The same formula as for factories applies here as well.

The basic value is 150 PP. -> prestige_warehouse

There is no prestige for deliveries.

__Bonus__

The bonus is calculated in the same way as for cities. Since there will be significantly more cities than warehouses, the bonuses in warehouses should generally be higher than in the city. An additional parameter in the database (factor_warehouse, default 1.5) is therefore needed.

The delivery bonus depends on the type of goods, the distance of the closest factory of this goods to the warehouse (compared to the average of all warehouses) and the stock level.

ABW(ware) = Distance(ware) / Average distance(ware)

The respective min and max price of the commodity (from const_resources) is multiplied by ABW and factor_warehouse.

Bonus = minimum price + (1 - stock level/stock size)*(maximum price - minimum price)

__Waiting time__

- The calculation of the waiting time is similar to that of the factories with inbound goods.
- The basic waiting time is warehouse_base_waiting_time (default: 120).
- Utilization: waiting time is multiplied by utilization
- Stock level of goods: Same formula as for factories, factory_storage_wait_factor is replaced by warehouse_storage_wait_factor (default: 5).
- Investments: Same as for factories.
- Workers: Same as for factories.
- Chaining: Chaining is also possible for warehouses. Here, however, no differentiation is made according to the goods, but only a comparison is made of how many tons the association has delivered to and collected from the warehouse in total. Premium and waiting time bonuses are then calculated in the same way as for normal chaining.
- Noob protection: As for factories