# GearCity Wiki

### Site Tools

gamemanual:gm_contracts

# Contracts Game Mechanics

The Game Mechanics section of the manual details the internal formula used in the game's calculations. This section of the manual uses pseudo-code and may not be 100% the same as the code in the game.

The Game Mechanics part of the manual is mainly designed to be a reference for the frequently asked question, “Why do I get this rating when I do X, Y, Z?!” Usually, this answer involves many different variables, which this section of the manual demonstrates.

The game mechanics section of the manual shows how the sausage gets made. So you really may want to avoid this portion of the manual if you enjoy the game.

# Variables

Name Description Name Description

# Fleet Contracts Specs

## Engine

### Displacement

```//Land/Army
EngineCC = (Random Number Between 0 And 5000) + 10000) * Engine_Type_EngineSize
//Maritime/Navy
EngineCC = (Random Number Between 0 And 10000) + 25000) * Engine_Type_EngineSize
//Aero
EngineCC = (Random Number Between 0 And 18000 + 12000) * Engine_Type_EngineSize```

### Unit Demand

```if(EngineCC > 20000)
EngineSizeUnitMod = 1000000 / EngineCC
else
EngineSizeUnitMod = (-0.123 * EngineCC) + 2500

if Land/Army
Units = ((govPopulation/100000) + EngineSizeUnitMod*0.2 +
Random Number Between 0 And EngineSizeUnitMod*0.8)) * govCalc + 1
else if Navy
Units = ((govPopulation/1000000) + EngineSizeUnitMod*0.2 +
Random Number Between 0 And EngineSizeUnitMod*0.8)) * govCalc + 1
else if Military Aero
Units = ((govPopulation/250000) + EngineSizeUnitMod*0.2 +
Random Number Between 0 And EngineSizeUnitMod*0.8)) * govCalc + 1
else if Civil Aero
Units = ((govPopulation/200000) + EngineSizeUnitMod*0.2 +
Random Number Between 0 And EngineSizeUnitMod*0.8)) + 1
else if Civil Maritime
Units = ((govPopulation/750000) + EngineSizeUnitMod*0.2 +
Random Number Between 0 And EngineSizeUnitMod*0.8))  + 1

Units = Units * Engine_Type_UnitNumbers

UnitsPerMonth = Units / ContractPeriod

if(UnitsPerMonth < 1)
UnitsPerMonth = 1```

### Fuel Consumption

```fuelRand = Random Number Between 0 And 3

if Land/Army
MPG = ((10 - (EngineCC/4000)) - fuelRand) * Engine_Type_FuelMOD * ex_1d002p_year99+3;
else if Navy
MPG =(( 10 - (EngineCC/12000)) - fuelRand)*Engine_Type_FuelMOD * ex_1d002p_year99+3;
else if Aero
MPG = ((10 - (EngineCC/3500)) - fuelRand) * Engine_Type_FuelMOD * ex_1d002p_year99+3;

if(MPG < 4 || MPG > 200)
MPG = -1;```

### Horse Power

```if Land/Army
HP = (Random Number Between 0 And (EngineCC/250)+((EngineCC/100)*ex_1d01p_year99)) * Engine_Type_HPMOD
else if Navy
HP =  (Random Number Between 0 And (EngineCC/600)+EngineCC/200) *ex_1d015p_year99 * Engine_Type_HPMOD
else if Aero
HP =  ((Random Number Between 0 And (EngineCC/250)+((EngineCC/70)*ex_1d005p_year99))) * Engine_Type_HPMOD
else if Civil Ships
HP =  (Random Number Between 0 And (EngineCC/500)+EngineCC/200) *ex_1d005p_year99 * Engine_Type_HPMOD```

### Torque

```if Land/Army
torque = (15 + Random Number Between 0 And EngineCC/450)+(EngineCC/300) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;
else if Navy
torque = (15 + Random Number Between 0 And EngineCC/370)+(EngineCC/500) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;
else if Aero
torque = (20 + Random Number Between 0 And EngineCC/300)+(EngineCC/200) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;```

### Torque

```if Land/Army
torque = (15 + Random Number Between 0 And EngineCC/450)+(EngineCC/300) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;
else if Navy
torque = (15 + Random Number Between 0 And EngineCC/370)+(EngineCC/500) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;
else if Aero
torque = (20 + Random Number Between 0 And EngineCC/300)+(EngineCC/200) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;```

### Torque

```if Land/Army
torque = (15 + Random Number Between 0 And EngineCC/450)+(EngineCC/300) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;
else if Navy
torque = (15 + Random Number Between 0 And EngineCC/370)+(EngineCC/500) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;
else if Aero
torque = (20 + Random Number Between 0 And EngineCC/300)+(EngineCC/200) ) * ex_1d008p_year99 * Engine_Type_torqueMOD;```

### Width

```if Land/Army
EngineWidth = (EngineCC/300 + 10) * Engine_Type_WidthMOD;
else if Navy
EngineWidth = (EngineCC/150 + 10)*Engine_Type_WidthMOD;
else if Aero
EngineWidth = (EngineCC/350 + 10)*Engine_Type_WidthMOD;```

### Length

```if Land/Army
EngineLength = (EngineCC / 300 + 12) * Engine_Type_LengthMOD;
else if Navy
EngineLength = (EngineCC / 150 + 12)*Engine_Type_LengthMOD;
else if Aero
EngineLength = (EngineCC / 200 + 12)*Engine_Type_LengthMOD;```

### Weight

```if Land/Army
Weight = (EngineCC / 11.5 + 100) * ex_1d008p_year99 * Engine_Type_WeightMOD;
else if Navy
Weight = (EngineCC / 5.5 + 500) * ex_1d008p_year99 * Engine_Type_WeightMOD;
else if Aero
Weight = (EngineCC / 10.0 + 50) * Engine_Type_WeightMOD;```

### Penalty, Unit Price, Signing Bonus

```if Units < 50
bonusPenality = (ex_1d025p_year99 *30000) * (50.0/(Units))

if Land/Army
Penalty =   (ex_1d025p_year99 * EngineCC/50) * Units + 1 + bonusPenality;
else if Military Navy
Penalty =   (ex_1d025p_year99 * EngineCC/10) * Units + 1 + bonusPenality;
else if Military Aero
Penalty =   (ex_1d025p_year99 * EngineCC/30) * Units + 1 + bonusPenality;
else if Civilian Aero
Penalty =  (ex_1d025p_year99 * EngineCC/80) * Units + 1 + bonusPenality;
else if Civilian Ships
Penalty =   (ex_1d025p_year99 * EngineCC/80) * Units + 1+bonusPenality;

if(Random Number Between 0 And 1 = 1 )
{
basePrice = 0

if Easy Difficulty
basePrice = 175;
else if Normal Difficulty
basePrice = 75

if Land/Army
{
UnitCosts = ((((105 +basePrice) * ex_1d025p_year99) +
Random Number Between 0 And (130 + basePrice/1.25) * ex_1d02p_year99)) +
EngineCC/200 + 1 + (bonusPenality/10))

Penalty = ((UnitCosts + EngineCC/200) /2.0) * Units + 1 + bonusPenality
}
else if Military Navy
{
UnitCosts = ((((305 + basePrice) * ex_1d025p_year99) +
Random Number Between 0 And (200 +basePrice/1.25) * ex_1d02p_year99)) +
EngineCC/50 + 1+(bonusPenality/10))

Penalty = ((UnitCosts + EngineCC/50)/0.5) * Units + 1 + bonusPenality
}
else if Military Aero
{
UnitCosts = ((((205  + basePrice) * ex_1d025p_year99) +
Random Number Between 0 And (230 +basePrice/1.25) * ex_1d02p_year99)) +
EngineCC/100 + 1 + (bonusPenality/10))

Penalty = ((UnitCosts+EngineCC/100)/1.5) * Units + 1 + bonusPenality
}
else if Civilian Aero
{
UnitCosts = ((((130 + basePrice) * ex_1d025p_year99) +
Random Number Between 0 And (155 +basePrice/1.25) * ex_1d02p_year99)) +
EngineCC/150 + 1 + (bonusPenality/10))

Penalty = ((UnitCosts+EngineCC/150)/2.0) * Units + 1 + bonusPenality
}
else if Civilian Ships
{
UnitCosts = ((((255  + basePrice) * ex_1d025p_year99) +
Random Number Between 0 And (200 + basePrice/1.25) * ex_1d02p_year99)) +
EngineCC/100 + 1+(bonusPenality/10))

Penalty = ((UnitCosts + EngineCC/100)/2.0) * Units + 1 + bonusPenality
}

if(Units > 1000)
UnitCosts = (UnitCosts * 0.75) + (UnitCosts * 0.25 * (1000.0/(1000.0 + Units)))
else
UnitCosts = (UnitCosts * 0.875)

UnitCosts = UnitCosts * contractUnitPriceMod;
UnitCosts = UnitCosts * Engine_Type_unitPrice;

SigningBonus = UnitCosts / (Random Number Between 0 And 10) + 10) * Units

SigningBonus = SigningBonus * contractUnitPriceMod
SigningBonus = SigningBonus * Engine_Type_unitPrice

Penalty = Penalty + SigningBonus * Random Number Between 0 and 1.0 + 3.0

}```

## Vehicles

### Units

```Units = (govPopulation * (0.002 + (0.0025 * Absolute Value of(govStatus*3) ))) * Type_Popularity + 1

Units = Units * CarContractType_unitNumbers

if(warContract)
Units = Units * 5```

### Displacement

`EngineCC = (Random Number Between 0 And (500) + 1000) * Wealth`

### Horse Power

```if Military Contract
HP = (Random Number Between 0 And (10)+(5 * ex_1d008p_year99)) * wealth * CarContractType_HPMOD
else if Civilian Contract
HP = (Random Number Between 0 And (15)+10) * ex_1d008p_year99 * wealth * CarContractType_HPMOD```

### Fuel Consumption

```if(Military Contract)
MPG = (14 - (wealth * 2)+ Random Number Between 0 And (4)) * CarContractType_FuelMOD + 3;
else if(Civilian Contract)
MPG = (20 - (wealth *1.75)+ Random Number Between 0 And (4)) * CarContractType_FuelMOD + 3;

if(MPG < 4 OR MPG > 200)
No fuel economy limit```

### Cargo

```if(Military Contract)
CargoReq = 200 + (Random Number Between 0 And (200) + 200) * (cargoType * 1.2) * CarContractType_CargoMOD
else if(Civilian Contract)
CargoReq = 200 + (Random Number Between 0 And (200) + 150) * (cargoType * 1.2) * CarContractType_CargoMOD```

### Torque

`torque =  (25 + (EngineCC/100)) * ex_1d005p_year99 * CarContractType_torqueMOD`

### Weight

`Weight = (500 + (CargoReq /  50) + Random Number Between 0 And (300)) * ex_1d008p_year99 * CarContractType_WeightMOD`

### Top Speed

```if( Year < 2021 )
topSpeed = ( (20 + ((year-1899)/3.5)) + Random Number Between 0 And (15 + ((year-1899)/2)) )* ex_1d005p_year99 * CarContractType_TopSpeedMOD
else
topSpeed =  (40 + Random Number Between 0 And (80)) * ex_1d005p_year99 * CarContractType_TopSpeedMOD```

### Unit Price, Penalty, Signing Bonus

```basePrice = 0

if Difficulty is Easy
basePrice = 175
else if Difficulty Normal
basePrice = 75

if(Military Contract)
{
UnitCosts = (((350 + basePrice) * ex_1d02p_year99) +
Random Number Between 0 And ((50 + basePrice/1.25) *
ex_1d02p_year99)) * (Wealth * 0.8 + 1)
}
else if(Civilian Contract)
{
UnitCosts = (((250  + basePrice) * ex_1d02p_year99) +
Random Number Between 0 And ((100 + basePrice/1.25) *
ex_1d02p_year99)) * (Wealth * 0.7 + 1)
}

if(UnitCosts > 1000)
UnitCosts = (UnitCosts * 0.75) + (UnitCosts * 0.25 * (1000.0/(1000.0 + Units)))
else
UnitCosts = (UnitCosts * 0.875)

UnitCosts = UnitCosts * contractUnitPriceMod
UnitCosts = UnitCosts * CarContractType_unitPrice

if(UnitCosts < 450)
UnitCosts = 450

SigningBonus = UnitCosts/(Random Number Between 0 And (10) + 10)  * Units

Penalty = Penalty + SigningBonus * RandomNumber->randDblExc(1.0) + 0.5

Penalty = Penalty + ((ex_1d02p_year99 * EngineCC/50) * Units) + 1

SigningBonus = SigningBonus * contractUnitPriceMod
SigningBonus = SigningBonus * CarContractType_unitPrice```

# Generate Racing Contracts

## Vehicles

Racing series restrictions define displacement, fuel, induction, cylinder, vehicle types, etc.

### Signing Bonus, Penalties, Unit Costs

```SigningBonus =  ((2000*ex_1d03p_year99)+(5000*RacingSeries_Funding_Value*ex_1d06p_year99)) *
(Random Number Between (0 And 1.0)+0.5)

Penalty = SigningBonus * (Random Number Between (0 And 3.0)+2.0)

if Difficulty = Easy
UnitCosts = (3000*ex_1d025p_year99) * (RacingSeries_Funding_Value/5.0 +1)
else if Difficulty = Normal
UnitCosts = (2000*ex_1d025p_year99) * (RacingSeries_Funding_Value/6.0 +1)
else if Difficulty = Hard or Nightmare
UnitCosts = (1000*ex_1d025p_year99) * (RacingSeries_Funding_Value/7.0 +1)```

### Units

`Units = ((RacingSeries_Races) * RacingSeries_Funding_Value) + 10;`

### Minimum HP

`MinHP = (100+(2*(year-1900)))`

### Lateral G

`Lateral_G =  1 + (0.0005 * (year-1900))`

### Top Speed

`Top_Speed = 100 + (2 * (year-1900))`

## Engines

Displacement, fuel, induction, and cylinder types defined by racing series restrictions.

### Signing Bonus, Penalties, Unit Costs

```SigningBonus =  ((1000*ex_1d03p_year99)+(2500*RacingSeries_Funding_Value*ex_1d06p_year99)) *
(Random Number Between (0 And 1.0)+0.5)

Penalty = SigningBonus * (Random Number Between (0 And 3.0)+2.0)

if Difficulty = Easy
UnitCosts = (3000*ex_1d02p_year99) * (RacingSeries_Funding_Value/5.0 + 1)
else if Difficulty = Normal
UnitCosts = (2500*ex_1d02p_year99) * (RacingSeries_Funding_Value/6.0 + 1)
else if Difficulty = Hard or Nightmare
UnitCosts = (1500*ex_1d02p_year99) * (RacingSeries_Funding_Value/7.0 + 1)```

### Units

`Units = ((RacingSeries_Races * 3.0) * RacingSeries_Funding_Value) + 5;`

### Minimum HP

`Min_HP =  (100+(2*(year-1900)));`

# Contract Winner Selection

(awardFleetContracts)

# Contract Renewal

renewContractRequests