Skip to content

Commit

Permalink
Create version 0.2.0
Browse files Browse the repository at this point in the history
  • Loading branch information
cit1zen committed Oct 3, 2022
1 parent a561118 commit 206abaf
Show file tree
Hide file tree
Showing 15 changed files with 772 additions and 156 deletions.
66 changes: 66 additions & 0 deletions AlcoholDistilleryExplosion.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
include("core/SOVIETInstructions.txt");
include("core/Math.txt");
include("core/Explosion.txt");
include("disasters/AlcoholDistilleryExplosion.txt");


defineVariable(int, _random_value);
defineVariable(int, _building_count);
defineVariable(int, _building_index);
defineArray(int[200], _valid_buildings);
defineVariable(int, _valid_buildings_max_size);
defineVariable(int, _valid_buildings_current_size);
defineVariable(Building, _building);
defineVariable(Resources, _building_actual);
defineVariable(Resources, _building_capacity);
defineVariable(Resources, _building_production);


defineFunction(main, void)
{
InitConstants();

_valid_buildings_max_size = 200;
_valid_buildings_current_size = 0;

Building_GetNumberOfBuildings(_building_count);
_building_index = 0;
while (_building_index < _building_count) {
// Get data
_building.GetDataByIndex(_building_index);
_building_actual.GetFromBuilding(_building_index);
_building_capacity.GetCapacityFromBuilding(_building_index);
_building_production.GetProductionFromBuilding(_building_index);
if (CheckIfValidDistilleryExplosion(
_building,
_building_actual,
_building_capacity,
_building_production
)
) {
if (_valid_buildings_current_size < _valid_buildings_max_size) {
_valid_buildings[_valid_buildings_current_size] = _building_index;
_valid_buildings_current_size = _valid_buildings_current_size + 1;
}
else () {
Random(_random_value);
_valid_buildings[_random_value % 100] = _building_index;
}
}
_building_index = _building_index + 1;
}

// Check if we found anything
if (_valid_buildings_current_size < 1) {
end();
}

// Choose one of the buildings as an epicentre of explosion
Random(_random_value);
_building_index = _valid_buildings[_random_value % _valid_buildings_current_size];

SimulateDistilleryExplosion(
_building_index
);
end();
}
53 changes: 52 additions & 1 deletion FuelTankExplosion.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,60 @@ include("core/Explosion.txt");
include("disasters/FuelTankExplosion.txt");


defineVariable(int, _random_value);
defineVariable(int, _building_count);
defineVariable(int, _building_index);
defineArray(int[200], _valid_buildings);
defineVariable(int, _valid_buildings_max_size);
defineVariable(int, _valid_buildings_current_size);
defineVariable(Building, _building);
defineVariable(Resources, _building_actual);
defineVariable(Resources, _building_capacity);


defineFunction(main, void)
{
InitConstants();
FuelTankExplosion_Simulate();

_valid_buildings_max_size = 200;
_valid_buildings_current_size = 0;

Building_GetNumberOfBuildings(_building_count);
_building_index = 0;
while (_building_index < _building_count) {
// Get data
_building.GetDataByIndex(_building_index);
_building_actual.GetFromBuilding(_building_index);
_building_capacity.GetCapacityFromBuilding(_building_index);
if (CheckIfValidForFuelTankExplosion(
_building,
_building_actual,
_building_capacity
)
) {
if (_valid_buildings_current_size < _valid_buildings_max_size) {
_valid_buildings[_valid_buildings_current_size] = _building_index;
_valid_buildings_current_size = _valid_buildings_current_size + 1;
}
else () {
Random(_random_value);
_valid_buildings[_random_value % 100] = _building_index;
}
}
_building_index = _building_index + 1;
}

// Check if we found anything
if (_valid_buildings_current_size < 1) {
end();
}

// Choose one of the buildings as an epicentre of explosion
Random(_random_value);
_building_index = _valid_buildings[_random_value % _valid_buildings_current_size];

SimulateFuelTankExplosion(
_building_index
);
end();
}
63 changes: 63 additions & 0 deletions GrainSiloExplosion.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
include("core/SOVIETInstructions.txt");
include("core/Math.txt");
include("core/Explosion.txt");
include("disasters/GrainSiloExplosion.txt");


defineVariable(int, _random_value);
defineVariable(int, _building_count);
defineVariable(int, _building_index);
defineArray(int[200], _valid_buildings);
defineVariable(int, _valid_buildings_max_size);
defineVariable(int, _valid_buildings_current_size);
defineVariable(Building, _building);
defineVariable(Resources, _building_actual);
defineVariable(Resources, _building_capacity);


defineFunction(main, void)
{
InitConstants();

_valid_buildings_max_size = 200;
_valid_buildings_current_size = 0;

Building_GetNumberOfBuildings(_building_count);
_building_index = 0;
while (_building_index < _building_count) {
// Get data
_building.GetDataByIndex(_building_index);
_building_actual.GetFromBuilding(_building_index);
_building_capacity.GetCapacityFromBuilding(_building_index);
if (CheckIfValidForGrainSiloExplosion(
_building,
_building_actual,
_building_capacity
)
) {
if (_valid_buildings_current_size < _valid_buildings_max_size) {
_valid_buildings[_valid_buildings_current_size] = _building_index;
_valid_buildings_current_size = _valid_buildings_current_size + 1;
}
else () {
Random(_random_value);
_valid_buildings[_random_value % 100] = _building_index;
}
}
_building_index = _building_index + 1;
}

// Check if we found anything
if (_valid_buildings_current_size < 1) {
end();
}

// Choose one of the buildings as an epicentre of explosion
Random(_random_value);
_building_index = _valid_buildings[_random_value % _valid_buildings_current_size];

SimulateGrainSiloExplosion(
_building_index
);
end();
}
154 changes: 147 additions & 7 deletions Main.txt
Original file line number Diff line number Diff line change
@@ -1,24 +1,164 @@
include("core/SOVIETInstructions.txt");
include("core/Math.txt");
include("core/Explosion.txt");
include("disasters/AlcoholDistilleryExplosion.txt");
include("disasters/FuelTankExplosion.txt");
include("disasters/GrainSiloExplosion.txt");
include("disasters/RefineryExplosion.txt");


defineVariable(int, RANDOM_VALUE);
defineVariable(int, REFINERY_EXPLOSION);
defineVariable(int, DISTILLERY_EXPLOSION);
defineVariable(int, FUEL_TANK_EXPLOSION);
defineVariable(int, GRAIN_SILO_EXPLOSION);
defineVariable(int, CHEMICAL_PLANT_EXPLOSION);
defineVariable(int, GAS_STATION_EXPLOSION);

defineVariable(int, _random_value);
defineVariable(int, _building_count);
defineVariable(int, _building_index);
defineVariable(int, _array_index);
defineArray(int[200], _valid_buildings);
defineArray(int[200], _valid_buildings_disaster_types);
defineVariable(int, _valid_buildings_max_size);
defineVariable(int, _valid_buildings_current_size);
defineVariable(Building, _building);
defineVariable(Resources, _building_actual);
defineVariable(Resources, _building_capacity);
defineVariable(Resources, _building_production);
defineVariable(int, _choosed_building_index);


defineFunction(main, void)
{
InitConstants();
Script_SetContinuous(1);

// Roll a dice on fuel tank explosion
Random(RANDOM_VALUE);
RANDOM_VALUE = RANDOM_VALUE % 20;
if (RANDOM_VALUE < 1) {
FuelTankExplosion_Simulate();
REFINERY_EXPLOSION = 0;
DISTILLERY_EXPLOSION = 1;
FUEL_TANK_EXPLOSION = 2;
GRAIN_SILO_EXPLOSION = 3;
// TODO
CHEMICAL_PLANT_EXPLOSION = 4;
// TODO
GAS_STATION_EXPLOSION = 5;

_valid_buildings_max_size = 200;

// Roll a dice if any disaster will happen
Random(_random_value);
_random_value = _random_value % 20;
if (_random_value > 1) {
Script_Sleep(60.0);
end();
}

Building_GetNumberOfBuildings(_building_count);
_building_index = 0;
_valid_buildings_current_size = 0;
while (_building_index < _building_count) {
// Get data
_building.GetDataByIndex(_building_index);
_building_actual.GetFromBuilding(_building_index);
_building_capacity.GetCapacityFromBuilding(_building_index);
_building_production.GetProductionFromBuilding(_building_index);
// Check if building can be a victim of a disaster
if (CheckIfValidRefineryExplosion(
_building,
_building_actual,
_building_capacity,
_building_production
)
) {
if (_valid_buildings_current_size < _valid_buildings_max_size) {
_valid_buildings[_valid_buildings_current_size] = _building_index;
_valid_buildings_disaster_types[_valid_buildings_current_size] = REFINERY_EXPLOSION;
_valid_buildings_current_size = _valid_buildings_current_size + 1;
}
else () {
Random(_random_value);
_valid_buildings[_random_value % _valid_buildings_max_size] = _building_index;
_valid_buildings_disaster_types[_random_value % _valid_buildings_max_size] = REFINERY_EXPLOSION;
}
}
elseif (CheckIfValidDistilleryExplosion(
_building,
_building_actual,
_building_capacity,
_building_production
)
) {
if (_valid_buildings_current_size < _valid_buildings_max_size) {
_valid_buildings[_valid_buildings_current_size] = _building_index;
_valid_buildings_disaster_types[_valid_buildings_current_size] = DISTILLERY_EXPLOSION;
_valid_buildings_current_size = _valid_buildings_current_size + 1;
}
else () {
Random(_random_value);
_valid_buildings[_random_value % _valid_buildings_max_size] = _building_index;
_valid_buildings_disaster_types[_random_value % _valid_buildings_max_size] = DISTILLERY_EXPLOSION;
}
}
elseif (CheckIfValidForFuelTankExplosion(
_building,
_building_actual,
_building_capacity
)
) {
if (_valid_buildings_current_size < _valid_buildings_max_size) {
_valid_buildings[_valid_buildings_current_size] = _building_index;
_valid_buildings_disaster_types[_valid_buildings_current_size] = FUEL_TANK_EXPLOSION;
_valid_buildings_current_size = _valid_buildings_current_size + 1;
}
else () {
Random(_random_value);
_valid_buildings[_random_value % _valid_buildings_max_size] = _building_index;
_valid_buildings_disaster_types[_random_value % _valid_buildings_max_size] = FUEL_TANK_EXPLOSION;
}
}
elseif (CheckIfValidForGrainSiloExplosion(
_building,
_building_actual,
_building_capacity
)
) {
if (_valid_buildings_current_size < _valid_buildings_max_size) {
_valid_buildings[_valid_buildings_current_size] = _building_index;
_valid_buildings_disaster_types[_valid_buildings_current_size] = GRAIN_SILO_EXPLOSION;
_valid_buildings_current_size = _valid_buildings_current_size + 1;
}
else () {
Random(_random_value);
_valid_buildings[_random_value % _valid_buildings_max_size] = _building_index;
_valid_buildings_disaster_types[_random_value % _valid_buildings_max_size] = GRAIN_SILO_EXPLOSION;
}
}
_building_index = _building_index + 1;
}

// Check if we found any valid buildings
if (_valid_buildings_current_size < 1) {
Script_Sleep(60.0);
end();
}
Script_Sleep(60.0);

// Choose a building and start an appropriate disaster
Random(_random_value);
_array_index = _random_value % _valid_buildings_current_size;
_choosed_building_index = _valid_buildings[_array_index];
if (_valid_buildings_disaster_types[_array_index] < (REFINERY_EXPLOSION + 1)) {
SimulateRefineryExplosion(_choosed_building_index);
}
elseif (_valid_buildings_disaster_types[_array_index] < (DISTILLERY_EXPLOSION + 1)) {
SimulateDistilleryExplosion(_choosed_building_index);
}
elseif (_valid_buildings_disaster_types[_array_index] < (FUEL_TANK_EXPLOSION + 1)) {
SimulateFuelTankExplosion(_choosed_building_index);
}
elseif (_valid_buildings_disaster_types[_array_index] < (GRAIN_SILO_EXPLOSION + 1)) {
SimulateGrainSiloExplosion(_choosed_building_index);
}

Script_Sleep(60.0);
end();
}
16 changes: 15 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,11 @@ The script makes the game harder by adding disasters and industrial accidents wi

Disasters added by the mod:
* Oil and oil products tank explosions caused by vapors.
* Fuel refinery explosions.
* Grain silo explosions.
* Alcohol distillery explosions.

Possible future disasters:
* Refinery explosion.
* Chemical plant leaks and explosions.
* Coal mine explosions caused by methane.

Expand All @@ -18,6 +20,18 @@ Possible future disasters:

If an oil or fuel tank is full of vapors (less than 80% of the capacity), there is a chance that a fuel tank will explode and will set itself and buildings in the vicinity on fire.

### Grain Silo Explosion

Grain silos and warehouses storing grain can explode thanks to grain particles in the air.

### Alcohol Distillery Explosion

Ethanol vapors can cause fires in the distilleries.

### Refinery

Refineries can explode thanks to all the chemicals and oil products.

## Contributors

* [Nyxyx](https://steamcommunity.com/profiles/76561198042251829)
Expand Down
Loading

0 comments on commit 206abaf

Please sign in to comment.